diff options
Diffstat (limited to 'src')
322 files changed, 30236 insertions, 24160 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index bfb875ac..af2db52f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -48,8 +48,7 @@ nobase_dist_proto_DATA = google/protobuf/descriptor.proto \ google/protobuf/timestamp.proto \ google/protobuf/type.proto \ google/protobuf/wrappers.proto \ - google/protobuf/compiler/plugin.proto \ - google/protobuf/compiler/profile.proto + google/protobuf/compiler/plugin.proto # Not sure why these don't get cleaned automatically. clean-local: @@ -72,7 +71,6 @@ nobase_include_HEADERS = \ google/protobuf/stubs/atomicops_internals_arm64_gcc.h \ google/protobuf/stubs/atomicops_internals_arm_gcc.h \ google/protobuf/stubs/atomicops_internals_arm_qnx.h \ - google/protobuf/stubs/atomicops_internals_atomicword_compat.h \ google/protobuf/stubs/atomicops_internals_generic_c11_atomic.h \ google/protobuf/stubs/atomicops_internals_generic_gcc.h \ google/protobuf/stubs/atomicops_internals_mips_gcc.h \ @@ -104,6 +102,7 @@ nobase_include_HEADERS = \ google/protobuf/api.pb.h \ google/protobuf/any.h \ google/protobuf/arena.h \ + google/protobuf/arena_impl.h \ google/protobuf/arenastring.h \ google/protobuf/descriptor_database.h \ google/protobuf/descriptor.h \ @@ -119,6 +118,7 @@ nobase_include_HEADERS = \ google/protobuf/generated_message_table_driven.h \ google/protobuf/generated_message_util.h \ google/protobuf/has_bits.h \ + google/protobuf/implicit_weak_message.h \ google/protobuf/map_entry.h \ google/protobuf/map_entry_lite.h \ google/protobuf/map_field.h \ @@ -158,7 +158,6 @@ nobase_include_HEADERS = \ google/protobuf/compiler/parser.h \ google/protobuf/compiler/plugin.h \ google/protobuf/compiler/plugin.pb.h \ - google/protobuf/compiler/profile.pb.h \ google/protobuf/compiler/cpp/cpp_generator.h \ google/protobuf/compiler/csharp/csharp_generator.h \ google/protobuf/compiler/csharp/csharp_names.h \ @@ -184,7 +183,7 @@ nobase_include_HEADERS = \ lib_LTLIBRARIES = libprotobuf-lite.la libprotobuf.la libprotoc.la libprotobuf_lite_la_LIBADD = $(PTHREAD_LIBS) -libprotobuf_lite_la_LDFLAGS = -version-info 13:0:0 -export-dynamic -no-undefined +libprotobuf_lite_la_LDFLAGS = -version-info 15:1:0 -export-dynamic -no-undefined if HAVE_LD_VERSION_SCRIPT libprotobuf_lite_la_LDFLAGS += -Wl,--version-script=$(srcdir)/libprotobuf-lite.map EXTRA_libprotobuf_lite_la_DEPENDENCIES = libprotobuf-lite.map @@ -198,6 +197,8 @@ libprotobuf_lite_la_SOURCES = \ google/protobuf/stubs/hash.h \ google/protobuf/stubs/int128.cc \ google/protobuf/stubs/int128.h \ + google/protobuf/stubs/io_win32.cc \ + google/protobuf/stubs/io_win32.h \ google/protobuf/stubs/map_util.h \ google/protobuf/stubs/mathutil.h \ google/protobuf/stubs/once.cc \ @@ -220,6 +221,9 @@ libprotobuf_lite_la_SOURCES = \ google/protobuf/arenastring.cc \ google/protobuf/extension_set.cc \ google/protobuf/generated_message_util.cc \ + google/protobuf/generated_message_table_driven_lite.h \ + google/protobuf/generated_message_table_driven_lite.cc \ + google/protobuf/implicit_weak_message.cc \ google/protobuf/message_lite.cc \ google/protobuf/repeated_field.cc \ google/protobuf/wire_format_lite.cc \ @@ -229,7 +233,7 @@ libprotobuf_lite_la_SOURCES = \ google/protobuf/io/zero_copy_stream_impl_lite.cc libprotobuf_la_LIBADD = $(PTHREAD_LIBS) -libprotobuf_la_LDFLAGS = -version-info 13:0:0 -export-dynamic -no-undefined +libprotobuf_la_LDFLAGS = -version-info 15:1:0 -export-dynamic -no-undefined if HAVE_LD_VERSION_SCRIPT libprotobuf_la_LDFLAGS += -Wl,--version-script=$(srcdir)/libprotobuf.map EXTRA_libprotobuf_la_DEPENDENCIES = libprotobuf.map @@ -250,6 +254,8 @@ libprotobuf_la_SOURCES = \ google/protobuf/extension_set_heavy.cc \ google/protobuf/field_mask.pb.cc \ google/protobuf/generated_message_reflection.cc \ + google/protobuf/generated_message_table_driven_lite.h \ + google/protobuf/generated_message_table_driven.cc \ google/protobuf/map_field.cc \ google/protobuf/message.cc \ google/protobuf/reflection_internal.h \ @@ -318,7 +324,7 @@ libprotobuf_la_SOURCES = \ nodist_libprotobuf_la_SOURCES = $(nodist_libprotobuf_lite_la_SOURCES) libprotoc_la_LIBADD = $(PTHREAD_LIBS) libprotobuf.la -libprotoc_la_LDFLAGS = -version-info 13:0:0 -export-dynamic -no-undefined +libprotoc_la_LDFLAGS = -version-info 15:1:0 -export-dynamic -no-undefined if HAVE_LD_VERSION_SCRIPT libprotoc_la_LDFLAGS += -Wl,--version-script=$(srcdir)/libprotoc.map EXTRA_libprotoc_la_DEPENDENCIES = libprotoc.map @@ -328,7 +334,6 @@ libprotoc_la_SOURCES = \ google/protobuf/compiler/command_line_interface.cc \ google/protobuf/compiler/plugin.cc \ google/protobuf/compiler/plugin.pb.cc \ - google/protobuf/compiler/profile.pb.cc \ google/protobuf/compiler/subprocess.cc \ google/protobuf/compiler/subprocess.h \ google/protobuf/compiler/zip_writer.cc \ @@ -352,7 +357,10 @@ libprotoc_la_SOURCES = \ google/protobuf/compiler/cpp/cpp_message.h \ google/protobuf/compiler/cpp/cpp_message_field.cc \ google/protobuf/compiler/cpp/cpp_message_field.h \ + google/protobuf/compiler/cpp/cpp_message_layout_helper.h \ google/protobuf/compiler/cpp/cpp_options.h \ + google/protobuf/compiler/cpp/cpp_padding_optimizer.cc \ + google/protobuf/compiler/cpp/cpp_padding_optimizer.h \ google/protobuf/compiler/cpp/cpp_primitive_field.cc \ google/protobuf/compiler/cpp/cpp_primitive_field.h \ google/protobuf/compiler/cpp/cpp_service.cc \ @@ -519,6 +527,7 @@ js_well_known_types_sources = \ google/protobuf/compiler/js/well_known_types/timestamp.js # We have to cd to $(srcdir) so that out-of-tree builds work properly. google/protobuf/compiler/js/well_known_types_embed.cc: js_embed$(EXEEXT) $(js_well_known_types_sources) + mkdir -p `dirname $@` && \ oldpwd=`pwd` && cd $(srcdir) && \ $$oldpwd/js_embed$(EXEEXT) $(js_well_known_types_sources) > $$oldpwd/$@ @@ -557,8 +566,8 @@ protoc_inputs = \ google/protobuf/unittest_preserve_unknown_enum.proto \ google/protobuf/unittest.proto \ google/protobuf/unittest_proto3_arena.proto \ - google/protobuf/unittest_proto3_arena_lite.proto \ - google/protobuf/unittest_proto3_lite.proto \ + google/protobuf/unittest_proto3_arena_lite.proto \ + google/protobuf/unittest_proto3_lite.proto \ google/protobuf/unittest_well_known_types.proto \ google/protobuf/util/internal/testdata/anys.proto \ google/protobuf/util/internal/testdata/books.proto \ @@ -579,6 +588,9 @@ EXTRA_DIST = \ $(protoc_inputs) \ $(js_well_known_types_sources) \ solaris/libstdc++.la \ + google/protobuf/unittest_proto3.proto \ + google/protobuf/test_messages_proto3.proto \ + google/protobuf/test_messages_proto2.proto \ google/protobuf/io/gzip_stream.h \ google/protobuf/io/gzip_stream_unittest.sh \ google/protobuf/testdata/golden_message \ @@ -677,10 +689,10 @@ protoc_outputs = \ google/protobuf/unittest_preserve_unknown_enum.pb.h \ google/protobuf/unittest_proto3_arena.pb.cc \ google/protobuf/unittest_proto3_arena.pb.h \ - google/protobuf/unittest_proto3_arena_lite.pb.cc \ - google/protobuf/unittest_proto3_arena_lite.pb.h \ - google/protobuf/unittest_proto3_lite.pb.cc \ - google/protobuf/unittest_proto3_lite.pb.h \ + google/protobuf/unittest_proto3_arena_lite.pb.cc \ + google/protobuf/unittest_proto3_arena_lite.pb.h \ + google/protobuf/unittest_proto3_lite.pb.cc \ + google/protobuf/unittest_proto3_lite.pb.h \ google/protobuf/unittest_well_known_types.pb.cc \ google/protobuf/unittest_well_known_types.pb.h \ google/protobuf/util/internal/testdata/anys.pb.cc \ @@ -710,8 +722,6 @@ protoc_outputs = \ google/protobuf/util/message_differencer_unittest.pb.cc \ google/protobuf/util/message_differencer_unittest.pb.h -BUILT_SOURCES = $(protoc_outputs) google/protobuf/compiler/js/well_known_types_embed.cc - if USE_EXTERNAL_PROTOC unittest_proto_middleman: $(protoc_inputs) @@ -761,6 +771,7 @@ protobuf_test_SOURCES = \ google/protobuf/stubs/bytestream_unittest.cc \ google/protobuf/stubs/common_unittest.cc \ google/protobuf/stubs/int128_unittest.cc \ + google/protobuf/stubs/io_win32_unittest.cc \ google/protobuf/stubs/once_unittest.cc \ google/protobuf/stubs/statusor_test.cc \ google/protobuf/stubs/status_test.cc \ @@ -786,8 +797,8 @@ protobuf_test_SOURCES = \ google/protobuf/no_field_presence_test.cc \ google/protobuf/preserve_unknown_enum_test.cc \ google/protobuf/proto3_arena_unittest.cc \ - google/protobuf/proto3_arena_lite_unittest.cc \ - google/protobuf/proto3_lite_unittest.cc \ + google/protobuf/proto3_arena_lite_unittest.cc \ + google/protobuf/proto3_lite_unittest.cc \ google/protobuf/reflection_ops_unittest.cc \ google/protobuf/repeated_field_reflection_unittest.cc \ google/protobuf/repeated_field_unittest.cc \ @@ -799,12 +810,15 @@ protobuf_test_SOURCES = \ google/protobuf/io/printer_unittest.cc \ google/protobuf/io/tokenizer_unittest.cc \ google/protobuf/io/zero_copy_stream_unittest.cc \ + google/protobuf/compiler/annotation_test_util.h \ + google/protobuf/compiler/annotation_test_util.cc \ google/protobuf/compiler/command_line_interface_unittest.cc \ google/protobuf/compiler/importer_unittest.cc \ google/protobuf/compiler/mock_code_generator.cc \ google/protobuf/compiler/mock_code_generator.h \ google/protobuf/compiler/parser_unittest.cc \ google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc \ + google/protobuf/compiler/cpp/cpp_move_unittest.cc \ google/protobuf/compiler/cpp/cpp_unittest.h \ google/protobuf/compiler/cpp/cpp_unittest.cc \ google/protobuf/compiler/cpp/cpp_plugin_unittest.cc \ @@ -830,9 +844,8 @@ protobuf_test_SOURCES = \ google/protobuf/util/time_util_test.cc \ google/protobuf/util/type_resolver_util_test.cc \ $(COMMON_TEST_SOURCES) - - nodist_protobuf_test_SOURCES = $(protoc_outputs) +$(am_protobuf_test_OBJECTS): unittest_proto_middleman # Run cpp_unittest again with PROTOBUF_TEST_NO_DESCRIPTORS defined. protobuf_lazy_descriptor_test_LDADD = $(PTHREAD_LIBS) libprotobuf.la \ @@ -848,6 +861,7 @@ protobuf_lazy_descriptor_test_SOURCES = \ google/protobuf/compiler/cpp/cpp_unittest.cc \ $(COMMON_TEST_SOURCES) nodist_protobuf_lazy_descriptor_test_SOURCES = $(protoc_outputs) +$(am_protobuf_lazy_descriptor_test_OBJECTS): unittest_proto_middleman COMMON_LITE_TEST_SOURCES = \ google/protobuf/arena_test_util.cc \ @@ -872,6 +886,7 @@ protobuf_lite_test_SOURCES = \ google/protobuf/lite_unittest.cc \ $(COMMON_LITE_TEST_SOURCES) nodist_protobuf_lite_test_SOURCES = $(protoc_lite_outputs) +$(am_protobuf_lite_test_OBJECTS): unittest_proto_middleman # lite_arena_unittest depends on gtest because teboring@ found that without # gtest when building the test internally our memory sanitizer doesn't detect @@ -887,6 +902,7 @@ protobuf_lite_arena_test_SOURCES = \ google/protobuf/lite_arena_unittest.cc \ $(COMMON_LITE_TEST_SOURCES) nodist_protobuf_lite_arena_test_SOURCES = $(protoc_lite_outputs) +$(am_protobuf_lite_arena_test_OBJECTS): unittest_proto_middleman # Test plugin binary. test_plugin_LDADD = $(PTHREAD_LIBS) libprotobuf.la libprotoc.la \ @@ -916,15 +932,11 @@ no_warning_test.cc: echo "#include <$${FILE}>" >> no_warning_test.cc; \ fi \ done - echo "#include <gtest/gtest.h>" >> no_warning_test.cc - echo "TEST(NoWarningTest, Empty) {}" >> no_warning_test.cc + echo "int main(int, char**) { return 0; }" >> no_warning_test.cc -no_warning_test_LDADD = $(PTHREAD_LIBS) libprotobuf.la \ - ../gmock/gtest/lib/libgtest.la \ - ../gmock/gtest/lib/libgtest_main.la -no_warning_test_CPPFLAGS = -I$(srcdir)/../gmock/gtest/include +no_warning_test_LDADD = $(PTHREAD_LIBS) libprotobuf.la libprotoc.la no_warning_test_CXXFLAGS = $(PTHREAD_CFLAGS) $(PTHREAD_DEF) $(ZLIB_DEF) \ - -Wall -Werror + -Wall -Wextra -Werror -Wno-unused-parameter nodist_no_warning_test_SOURCES = no_warning_test.cc $(protoc_outputs) TESTS = protobuf-test protobuf-lazy-descriptor-test protobuf-lite-test \ diff --git a/src/README.md b/src/README.md index c9362ee2..3ae23fa6 100644 --- a/src/README.md +++ b/src/README.md @@ -184,6 +184,16 @@ In the downloads section, download the zip file protoc-$VERSION-win32.zip. It contains the protoc binary as well as public proto files of protobuf library. +Protobuf and its dependencies can be installed directly by using `vcpkg`: + + >vcpkg install protobuf protobuf:x64-windows + +If zlib support is desired, you'll also need to install the zlib feature: + + >vcpkg install protobuf[zlib] protobuf[zlib]:x64-windows + +See https://github.com/Microsoft/vcpkg for more information. + To build from source using Microsoft Visual C++, see [cmake/README.md](../cmake/README.md). To build from source using Cygwin or MinGW, follow the Unix installation diff --git a/src/google/protobuf/any.pb.cc b/src/google/protobuf/any.pb.cc index 6c80aaa2..4335e467 100644 --- a/src/google/protobuf/any.pb.cc +++ b/src/google/protobuf/any.pb.cc @@ -1,7 +1,6 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/protobuf/any.proto -#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION #include <google/protobuf/any.pb.h> #include <algorithm> @@ -15,56 +14,61 @@ #include <google/protobuf/generated_message_reflection.h> #include <google/protobuf/reflection_ops.h> #include <google/protobuf/wire_format.h> +// This is a temporary google only hack +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS +#include "third_party/protobuf/version.h" +#endif // @@protoc_insertion_point(includes) - namespace google { namespace protobuf { -class AnyDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Any> { +class AnyDefaultTypeInternal { + public: + ::google::protobuf::internal::ExplicitlyConstructed<Any> + _instance; } _Any_default_instance_; - +} // namespace protobuf +} // namespace google namespace protobuf_google_2fprotobuf_2fany_2eproto { +void InitDefaultsAnyImpl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); +#else + ::google::protobuf::internal::InitProtobufDefaults(); +#endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + { + void* ptr = &::google::protobuf::_Any_default_instance_; + new (ptr) ::google::protobuf::Any(); + ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); + } + ::google::protobuf::Any::InitAsDefaultInstance(); +} -namespace { +void InitDefaultsAny() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsAnyImpl); +} ::google::protobuf::Metadata file_level_metadata[1]; -} // namespace - -PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::ParseTableField - const TableStruct::entries[] = { - {0, 0, 0, ::google::protobuf::internal::kInvalidMask, 0, 0}, -}; - -PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::AuxillaryParseTableField - const TableStruct::aux[] = { - ::google::protobuf::internal::AuxillaryParseTableField(), -}; -PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::ParseTable const - TableStruct::schema[] = { - { NULL, NULL, 0, -1, -1, false }, -}; - -const ::google::protobuf::uint32 TableStruct::offsets[] = { +const ::google::protobuf::uint32 TableStruct::offsets[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { ~0u, // no _has_bits_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Any, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Any, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Any, type_url_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Any, value_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Any, type_url_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Any, value_), }; - -static const ::google::protobuf::internal::MigrationSchema schemas[] = { - { 0, -1, sizeof(Any)}, +static const ::google::protobuf::internal::MigrationSchema schemas[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { + { 0, -1, sizeof(::google::protobuf::Any)}, }; static ::google::protobuf::Message const * const file_default_instances[] = { - reinterpret_cast<const ::google::protobuf::Message*>(&_Any_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_Any_default_instance_), }; -namespace { - void protobuf_AssignDescriptors() { AddDescriptors(); ::google::protobuf::MessageFactory* factory = NULL; @@ -78,33 +82,15 @@ void protobuf_AssignDescriptorsOnce() { ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors); } -void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; +void protobuf_RegisterTypes(const ::std::string&) GOOGLE_PROTOBUF_ATTRIBUTE_COLD; void protobuf_RegisterTypes(const ::std::string&) { protobuf_AssignDescriptorsOnce(); ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 1); } -} // namespace - -void TableStruct::Shutdown() { - _Any_default_instance_.Shutdown(); - delete file_level_metadata[0].reflection; -} - -void TableStruct::InitDefaultsImpl() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - ::google::protobuf::internal::InitProtobufDefaults(); - _Any_default_instance_.DefaultConstruct(); -} - -void InitDefaults() { - static GOOGLE_PROTOBUF_DECLARE_ONCE(once); - ::google::protobuf::GoogleOnceInit(&once, &TableStruct::InitDefaultsImpl); -} void AddDescriptorsImpl() { InitDefaults(); - static const char descriptor[] = { + static const char descriptor[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { "\n\031google/protobuf/any.proto\022\017google.prot" "obuf\"&\n\003Any\022\020\n\010type_url\030\001 \001(\t\022\r\n\005value\030\002" " \001(\014Bo\n\023com.google.protobufB\010AnyProtoP\001Z" @@ -116,25 +102,26 @@ void AddDescriptorsImpl() { descriptor, 205); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/any.proto", &protobuf_RegisterTypes); - ::google::protobuf::internal::OnShutdown(&TableStruct::Shutdown); } void AddDescriptors() { static GOOGLE_PROTOBUF_DECLARE_ONCE(once); ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl); } -// Force AddDescriptors() to be called at static initialization time. +// Force AddDescriptors() to be called at dynamic initialization time. struct StaticDescriptorInitializer { StaticDescriptorInitializer() { AddDescriptors(); } } static_descriptor_initializer; - } // namespace protobuf_google_2fprotobuf_2fany_2eproto - +namespace google { +namespace protobuf { // =================================================================== +void Any::InitAsDefaultInstance() { +} void Any::PackFrom(const ::google::protobuf::Message& message) { _any_metadata_.PackFrom(message); } @@ -156,7 +143,7 @@ const int Any::kValueFieldNumber; Any::Any() : ::google::protobuf::Message(), _internal_metadata_(NULL), _any_metadata_(&type_url_, &value_) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { - protobuf_google_2fprotobuf_2fany_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fany_2eproto::InitDefaultsAny(); } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Any) @@ -200,27 +187,25 @@ void Any::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* Any::descriptor() { - protobuf_google_2fprotobuf_2fany_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fany_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; + ::protobuf_google_2fprotobuf_2fany_2eproto::protobuf_AssignDescriptorsOnce(); + return ::protobuf_google_2fprotobuf_2fany_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const Any& Any::default_instance() { - protobuf_google_2fprotobuf_2fany_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fany_2eproto::InitDefaultsAny(); return *internal_default_instance(); } -Any* Any::New(::google::protobuf::Arena* arena) const { - Any* n = new Any; - if (arena != NULL) { - arena->Own(n); - } - return n; -} void Any::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.Any) + ::google::protobuf::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + type_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + _internal_metadata_.Clear(); } bool Any::MergePartialFromCodedStream( @@ -236,11 +221,11 @@ bool Any::MergePartialFromCodedStream( // string type_url = 1; case 1: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(10u)) { + static_cast< ::google::protobuf::uint8>(10u /* 10 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_type_url())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( - this->type_url().data(), this->type_url().length(), + this->type_url().data(), static_cast<int>(this->type_url().length()), ::google::protobuf::internal::WireFormatLite::PARSE, "google.protobuf.Any.type_url")); } else { @@ -252,7 +237,7 @@ bool Any::MergePartialFromCodedStream( // bytes value = 2; case 2: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(18u)) { + static_cast< ::google::protobuf::uint8>(18u /* 18 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadBytes( input, this->mutable_value())); } else { @@ -263,12 +248,11 @@ bool Any::MergePartialFromCodedStream( default: { handle_unusual: - if (tag == 0 || - ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + if (tag == 0) { goto success; } - DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag)); + DO_(::google::protobuf::internal::WireFormat::SkipField( + input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } @@ -291,7 +275,7 @@ void Any::SerializeWithCachedSizes( // string type_url = 1; if (this->type_url().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( - this->type_url().data(), this->type_url().length(), + this->type_url().data(), static_cast<int>(this->type_url().length()), ::google::protobuf::internal::WireFormatLite::SERIALIZE, "google.protobuf.Any.type_url"); ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( @@ -304,11 +288,16 @@ void Any::SerializeWithCachedSizes( 2, this->value(), output); } + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + ::google::protobuf::internal::WireFormat::SerializeUnknownFields( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), output); + } // @@protoc_insertion_point(serialize_end:google.protobuf.Any) } ::google::protobuf::uint8* Any::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Any) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -316,7 +305,7 @@ void Any::SerializeWithCachedSizes( // string type_url = 1; if (this->type_url().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( - this->type_url().data(), this->type_url().length(), + this->type_url().data(), static_cast<int>(this->type_url().length()), ::google::protobuf::internal::WireFormatLite::SERIALIZE, "google.protobuf.Any.type_url"); target = @@ -331,6 +320,10 @@ void Any::SerializeWithCachedSizes( 2, this->value(), target); } + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), target); + } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Any) return target; } @@ -339,6 +332,11 @@ size_t Any::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Any) size_t total_size = 0; + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance())); + } // string type_url = 1; if (this->type_url().size() > 0) { total_size += 1 + @@ -415,129 +413,27 @@ void Any::Swap(Any* other) { InternalSwap(other); } void Any::InternalSwap(Any* other) { + using std::swap; type_url_.Swap(&other->type_url_); value_.Swap(&other->value_); - std::swap(_cached_size_, other->_cached_size_); + _internal_metadata_.Swap(&other->_internal_metadata_); + swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata Any::GetMetadata() const { protobuf_google_2fprotobuf_2fany_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fany_2eproto::file_level_metadata[kIndexInFileMessages]; + return ::protobuf_google_2fprotobuf_2fany_2eproto::file_level_metadata[kIndexInFileMessages]; } -#if PROTOBUF_INLINE_NOT_IN_HEADERS -// Any - -// string type_url = 1; -void Any::clear_type_url() { - type_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -const ::std::string& Any::type_url() const { - // @@protoc_insertion_point(field_get:google.protobuf.Any.type_url) - return type_url_.GetNoArena(); -} -void Any::set_type_url(const ::std::string& value) { - - type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.Any.type_url) -} -#if LANG_CXX11 -void Any::set_type_url(::std::string&& value) { - - type_url_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Any.type_url) -} -#endif -void Any::set_type_url(const char* value) { - GOOGLE_DCHECK(value != NULL); - - 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) { - - type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.Any.type_url) -} -::std::string* Any::mutable_type_url() { - - // @@protoc_insertion_point(field_mutable:google.protobuf.Any.type_url) - return type_url_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -::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) { - if (type_url != NULL) { - - } else { - - } - type_url_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), type_url); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.Any.type_url) -} - -// bytes value = 2; -void Any::clear_value() { - value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -const ::std::string& Any::value() const { - // @@protoc_insertion_point(field_get:google.protobuf.Any.value) - return value_.GetNoArena(); -} -void Any::set_value(const ::std::string& value) { - - value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.Any.value) -} -#if LANG_CXX11 -void Any::set_value(::std::string&& value) { - - value_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Any.value) -} -#endif -void Any::set_value(const char* value) { - GOOGLE_DCHECK(value != NULL); - - 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) { - - value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.Any.value) -} -::std::string* Any::mutable_value() { - - // @@protoc_insertion_point(field_mutable:google.protobuf.Any.value) - return value_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -::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) { - if (value != NULL) { - - } else { - - } - value_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.Any.value) -} - -#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // @@protoc_insertion_point(namespace_scope) - +} // namespace protobuf +} // namespace google +namespace google { +namespace protobuf { +template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::Any* Arena::Create< ::google::protobuf::Any >(Arena* arena) { + return Arena::CreateInternal< ::google::protobuf::Any >(arena); +} } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/any.pb.h b/src/google/protobuf/any.pb.h index bc05fb35..14c21a8f 100644 --- a/src/google/protobuf/any.pb.h +++ b/src/google/protobuf/any.pb.h @@ -1,19 +1,19 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/protobuf/any.proto -#ifndef PROTOBUF_google_2fprotobuf_2fany_2eproto__INCLUDED -#define PROTOBUF_google_2fprotobuf_2fany_2eproto__INCLUDED +#ifndef PROTOBUF_google_2fprotobuf_2fany_2eproto_INCLUDED +#define PROTOBUF_google_2fprotobuf_2fany_2eproto_INCLUDED #include <string> #include <google/protobuf/stubs/common.h> -#if GOOGLE_PROTOBUF_VERSION < 3003000 +#if GOOGLE_PROTOBUF_VERSION < 3005000 #error This file was generated by a newer version of protoc which is #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3003000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION +#if 3005001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. @@ -31,30 +31,38 @@ #include <google/protobuf/unknown_field_set.h> #include <google/protobuf/any.h> // @@protoc_insertion_point(includes) -namespace google { -namespace protobuf { -class Any; -class AnyDefaultTypeInternal; -LIBPROTOBUF_EXPORT extern AnyDefaultTypeInternal _Any_default_instance_; -} // namespace protobuf -} // namespace google - -namespace google { -namespace protobuf { namespace protobuf_google_2fprotobuf_2fany_2eproto { -// Internal implementation detail -- do not call these. +// Internal implementation detail -- do not use these members. struct LIBPROTOBUF_EXPORT TableStruct { static const ::google::protobuf::internal::ParseTableField entries[]; static const ::google::protobuf::internal::AuxillaryParseTableField aux[]; - static const ::google::protobuf::internal::ParseTable schema[]; + static const ::google::protobuf::internal::ParseTable schema[1]; + static const ::google::protobuf::internal::FieldMetadata field_metadata[]; + static const ::google::protobuf::internal::SerializationTable serialization_table[]; static const ::google::protobuf::uint32 offsets[]; - static void InitDefaultsImpl(); - static void Shutdown(); }; void LIBPROTOBUF_EXPORT AddDescriptors(); -void LIBPROTOBUF_EXPORT InitDefaults(); +void LIBPROTOBUF_EXPORT InitDefaultsAnyImpl(); +void LIBPROTOBUF_EXPORT InitDefaultsAny(); +inline void LIBPROTOBUF_EXPORT InitDefaults() { + InitDefaultsAny(); +} } // namespace protobuf_google_2fprotobuf_2fany_2eproto +namespace google { +namespace protobuf { +class Any; +class AnyDefaultTypeInternal; +LIBPROTOBUF_EXPORT extern AnyDefaultTypeInternal _Any_default_instance_; +} // namespace protobuf +} // namespace google +namespace google { +namespace protobuf { +template<> LIBPROTOBUF_EXPORT ::google::protobuf::Any* Arena::Create< ::google::protobuf::Any>(Arena*); +} // namespace protobuf +} // namespace google +namespace google { +namespace protobuf { // =================================================================== @@ -69,10 +77,25 @@ class LIBPROTOBUF_EXPORT Any : public ::google::protobuf::Message /* @@protoc_in CopyFrom(from); return *this; } + #if LANG_CXX11 + Any(Any&& from) noexcept + : Any() { + *this = ::std::move(from); + } + inline Any& operator=(Any&& from) noexcept { + if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + #endif static const ::google::protobuf::Descriptor* descriptor(); static const Any& default_instance(); + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY static inline const Any* internal_default_instance() { return reinterpret_cast<const Any*>( &_Any_default_instance_); @@ -91,12 +114,19 @@ class LIBPROTOBUF_EXPORT Any : public ::google::protobuf::Message /* @@protoc_in } void Swap(Any* other); + friend void swap(Any& a, Any& b) { + a.Swap(&b); + } // implements Message ---------------------------------------------- - inline Any* New() const PROTOBUF_FINAL { return New(NULL); } + inline Any* New() const PROTOBUF_FINAL { + return ::google::protobuf::Arena::Create<Any>(NULL); + } - Any* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + Any* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL { + return ::google::protobuf::Arena::Create<Any>(arena); + } void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const Any& from); @@ -168,14 +198,18 @@ class LIBPROTOBUF_EXPORT Any : public ::google::protobuf::Message /* @@protoc_in ::google::protobuf::internal::ArenaStringPtr value_; mutable int _cached_size_; ::google::protobuf::internal::AnyMetadata _any_metadata_; - friend struct protobuf_google_2fprotobuf_2fany_2eproto::TableStruct; + friend struct ::protobuf_google_2fprotobuf_2fany_2eproto::TableStruct; + friend void ::protobuf_google_2fprotobuf_2fany_2eproto::InitDefaultsAnyImpl(); }; // =================================================================== // =================================================================== -#if !PROTOBUF_INLINE_NOT_IN_HEADERS +#ifdef __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif // __GNUC__ // Any // string type_url = 1; @@ -284,14 +318,15 @@ inline void Any::set_allocated_value(::std::string* value) { // @@protoc_insertion_point(field_set_allocated:google.protobuf.Any.value) } -#endif // !PROTOBUF_INLINE_NOT_IN_HEADERS +#ifdef __GNUC__ + #pragma GCC diagnostic pop +#endif // __GNUC__ // @@protoc_insertion_point(namespace_scope) - } // namespace protobuf } // namespace google // @@protoc_insertion_point(global_scope) -#endif // PROTOBUF_google_2fprotobuf_2fany_2eproto__INCLUDED +#endif // PROTOBUF_google_2fprotobuf_2fany_2eproto_INCLUDED diff --git a/src/google/protobuf/any.proto b/src/google/protobuf/any.proto index 9bd3f50a..49329425 100644 --- a/src/google/protobuf/any.proto +++ b/src/google/protobuf/any.proto @@ -74,6 +74,16 @@ option objc_class_prefix = "GPB"; // any.Unpack(foo) // ... // +// Example 4: Pack and unpack a message in Go +// +// foo := &pb.Foo{...} +// any, err := ptypes.MarshalAny(foo) +// ... +// foo := &pb.Foo{} +// if err := ptypes.UnmarshalAny(any, foo); err != nil { +// ... +// } +// // The pack methods provided by protobuf library will by default use // 'type.googleapis.com/full.type.name' as the type URL and the unpack // methods only use the fully qualified type name after the last '/' @@ -110,17 +120,18 @@ option objc_class_prefix = "GPB"; // } // message Any { - // A URL/resource name whose content describes the type of the - // serialized protocol buffer message. + // A URL/resource name that uniquely identifies the type of the serialized + // protocol buffer message. The last segment of the URL's path must represent + // the fully qualified name of the type (as in + // `path/google.protobuf.Duration`). The name should be in a canonical form + // (e.g., leading "." is not accepted). // - // For URLs which use the scheme `http`, `https`, or no scheme, the - // following restrictions and interpretations apply: + // In practice, teams usually precompile into the binary all types that they + // expect it to use in the context of Any. However, for URLs which use the + // scheme `http`, `https`, or no scheme, one can optionally set up a type + // server that maps type URLs to message definitions as follows: // // * If no scheme is provided, `https` is assumed. - // * The last segment of the URL's path must represent the fully - // qualified name of the type (as in `path/google.protobuf.Duration`). - // The name should be in a canonical form (e.g., leading "." is - // not accepted). // * An HTTP GET on the URL must yield a [google.protobuf.Type][] // value in binary format, or produce an error. // * Applications are allowed to cache lookup results based on the @@ -129,6 +140,10 @@ message Any { // on changes to types. (Use versioned type names to manage // breaking changes.) // + // Note: this functionality is not currently available in the official + // protobuf release, and it is not used for type URLs beginning with + // type.googleapis.com. + // // Schemes other than `http`, `https` (or the empty scheme) might be // used with implementation specific semantics. // diff --git a/src/google/protobuf/api.pb.cc b/src/google/protobuf/api.pb.cc index 94c6685f..b0354551 100644 --- a/src/google/protobuf/api.pb.cc +++ b/src/google/protobuf/api.pb.cc @@ -1,7 +1,6 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/protobuf/api.proto -#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION #include <google/protobuf/api.pb.h> #include <algorithm> @@ -15,90 +14,146 @@ #include <google/protobuf/generated_message_reflection.h> #include <google/protobuf/reflection_ops.h> #include <google/protobuf/wire_format.h> +// This is a temporary google only hack +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS +#include "third_party/protobuf/version.h" +#endif // @@protoc_insertion_point(includes) - namespace google { namespace protobuf { -class ApiDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Api> { +class ApiDefaultTypeInternal { + public: + ::google::protobuf::internal::ExplicitlyConstructed<Api> + _instance; } _Api_default_instance_; -class MethodDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Method> { +class MethodDefaultTypeInternal { + public: + ::google::protobuf::internal::ExplicitlyConstructed<Method> + _instance; } _Method_default_instance_; -class MixinDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Mixin> { +class MixinDefaultTypeInternal { + public: + ::google::protobuf::internal::ExplicitlyConstructed<Mixin> + _instance; } _Mixin_default_instance_; - +} // namespace protobuf +} // namespace google namespace protobuf_google_2fprotobuf_2fapi_2eproto { +void InitDefaultsApiImpl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); +#else + ::google::protobuf::internal::InitProtobufDefaults(); +#endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + protobuf_google_2fprotobuf_2fapi_2eproto::InitDefaultsMethod(); + protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaultsOption(); + protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto::InitDefaultsSourceContext(); + protobuf_google_2fprotobuf_2fapi_2eproto::InitDefaultsMixin(); + { + void* ptr = &::google::protobuf::_Api_default_instance_; + new (ptr) ::google::protobuf::Api(); + ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); + } + ::google::protobuf::Api::InitAsDefaultInstance(); +} -namespace { +void InitDefaultsApi() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsApiImpl); +} -::google::protobuf::Metadata file_level_metadata[3]; +void InitDefaultsMethodImpl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); +#else + ::google::protobuf::internal::InitProtobufDefaults(); +#endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaultsOption(); + { + void* ptr = &::google::protobuf::_Method_default_instance_; + new (ptr) ::google::protobuf::Method(); + ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); + } + ::google::protobuf::Method::InitAsDefaultInstance(); +} -} // namespace +void InitDefaultsMethod() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsMethodImpl); +} -PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::ParseTableField - const TableStruct::entries[] = { - {0, 0, 0, ::google::protobuf::internal::kInvalidMask, 0, 0}, -}; +void InitDefaultsMixinImpl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; -PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::AuxillaryParseTableField - const TableStruct::aux[] = { - ::google::protobuf::internal::AuxillaryParseTableField(), -}; -PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::ParseTable const - TableStruct::schema[] = { - { NULL, NULL, 0, -1, -1, false }, - { NULL, NULL, 0, -1, -1, false }, - { NULL, NULL, 0, -1, -1, false }, -}; +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); +#else + ::google::protobuf::internal::InitProtobufDefaults(); +#endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + { + void* ptr = &::google::protobuf::_Mixin_default_instance_; + new (ptr) ::google::protobuf::Mixin(); + ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); + } + ::google::protobuf::Mixin::InitAsDefaultInstance(); +} + +void InitDefaultsMixin() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsMixinImpl); +} + +::google::protobuf::Metadata file_level_metadata[3]; -const ::google::protobuf::uint32 TableStruct::offsets[] = { +const ::google::protobuf::uint32 TableStruct::offsets[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { ~0u, // no _has_bits_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Api, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, name_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, methods_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, options_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, version_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, source_context_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, mixins_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, syntax_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Api, name_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Api, methods_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Api, options_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Api, version_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Api, source_context_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Api, mixins_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Api, syntax_), ~0u, // no _has_bits_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Method, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, name_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, request_type_url_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, request_streaming_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, response_type_url_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, response_streaming_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, options_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, syntax_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Method, name_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Method, request_type_url_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Method, request_streaming_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Method, response_type_url_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Method, response_streaming_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Method, options_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Method, syntax_), ~0u, // no _has_bits_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Mixin, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Mixin, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Mixin, name_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Mixin, root_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Mixin, name_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Mixin, root_), }; - -static const ::google::protobuf::internal::MigrationSchema schemas[] = { - { 0, -1, sizeof(Api)}, - { 12, -1, sizeof(Method)}, - { 24, -1, sizeof(Mixin)}, +static const ::google::protobuf::internal::MigrationSchema schemas[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { + { 0, -1, sizeof(::google::protobuf::Api)}, + { 12, -1, sizeof(::google::protobuf::Method)}, + { 24, -1, sizeof(::google::protobuf::Mixin)}, }; static ::google::protobuf::Message const * const file_default_instances[] = { - reinterpret_cast<const ::google::protobuf::Message*>(&_Api_default_instance_), - reinterpret_cast<const ::google::protobuf::Message*>(&_Method_default_instance_), - reinterpret_cast<const ::google::protobuf::Message*>(&_Mixin_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_Api_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_Method_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_Mixin_default_instance_), }; -namespace { - void protobuf_AssignDescriptors() { AddDescriptors(); ::google::protobuf::MessageFactory* factory = NULL; @@ -112,43 +167,15 @@ void protobuf_AssignDescriptorsOnce() { ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors); } -void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; +void protobuf_RegisterTypes(const ::std::string&) GOOGLE_PROTOBUF_ATTRIBUTE_COLD; void protobuf_RegisterTypes(const ::std::string&) { protobuf_AssignDescriptorsOnce(); ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 3); } -} // namespace - -void TableStruct::Shutdown() { - _Api_default_instance_.Shutdown(); - delete file_level_metadata[0].reflection; - _Method_default_instance_.Shutdown(); - delete file_level_metadata[1].reflection; - _Mixin_default_instance_.Shutdown(); - delete file_level_metadata[2].reflection; -} - -void TableStruct::InitDefaultsImpl() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - ::google::protobuf::internal::InitProtobufDefaults(); - ::google::protobuf::protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto::InitDefaults(); - ::google::protobuf::protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaults(); - _Api_default_instance_.DefaultConstruct(); - _Method_default_instance_.DefaultConstruct(); - _Mixin_default_instance_.DefaultConstruct(); - _Api_default_instance_.get_mutable()->source_context_ = const_cast< ::google::protobuf::SourceContext*>( - ::google::protobuf::SourceContext::internal_default_instance()); -} - -void InitDefaults() { - static GOOGLE_PROTOBUF_DECLARE_ONCE(once); - ::google::protobuf::GoogleOnceInit(&once, &TableStruct::InitDefaultsImpl); -} void AddDescriptorsImpl() { InitDefaults(); - static const char descriptor[] = { + static const char descriptor[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { "\n\031google/protobuf/api.proto\022\017google.prot" "obuf\032$google/protobuf/source_context.pro" "to\032\032google/protobuf/type.proto\"\201\002\n\003Api\022\014" @@ -173,27 +200,39 @@ void AddDescriptorsImpl() { descriptor, 750); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/api.proto", &protobuf_RegisterTypes); - ::google::protobuf::protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto::AddDescriptors(); - ::google::protobuf::protobuf_google_2fprotobuf_2ftype_2eproto::AddDescriptors(); - ::google::protobuf::internal::OnShutdown(&TableStruct::Shutdown); + ::protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto::AddDescriptors(); + ::protobuf_google_2fprotobuf_2ftype_2eproto::AddDescriptors(); } void AddDescriptors() { static GOOGLE_PROTOBUF_DECLARE_ONCE(once); ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl); } -// Force AddDescriptors() to be called at static initialization time. +// Force AddDescriptors() to be called at dynamic initialization time. struct StaticDescriptorInitializer { StaticDescriptorInitializer() { AddDescriptors(); } } static_descriptor_initializer; - } // namespace protobuf_google_2fprotobuf_2fapi_2eproto - +namespace google { +namespace protobuf { // =================================================================== +void Api::InitAsDefaultInstance() { + ::google::protobuf::_Api_default_instance_._instance.get_mutable()->source_context_ = const_cast< ::google::protobuf::SourceContext*>( + ::google::protobuf::SourceContext::internal_default_instance()); +} +void Api::clear_options() { + options_.Clear(); +} +void Api::clear_source_context() { + if (GetArenaNoVirtual() == NULL && source_context_ != NULL) { + delete source_context_; + } + source_context_ = NULL; +} #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int Api::kNameFieldNumber; const int Api::kMethodsFieldNumber; @@ -207,7 +246,7 @@ const int Api::kSyntaxFieldNumber; Api::Api() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { - protobuf_google_2fprotobuf_2fapi_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fapi_2eproto::InitDefaultsApi(); } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Api) @@ -240,8 +279,9 @@ Api::Api(const Api& from) void Api::SharedCtor() { name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); version_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - ::memset(&source_context_, 0, reinterpret_cast<char*>(&syntax_) - - reinterpret_cast<char*>(&source_context_) + sizeof(syntax_)); + ::memset(&source_context_, 0, static_cast<size_t>( + reinterpret_cast<char*>(&syntax_) - + reinterpret_cast<char*>(&source_context_)) + sizeof(syntax_)); _cached_size_ = 0; } @@ -253,9 +293,7 @@ Api::~Api() { void Api::SharedDtor() { name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); version_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != internal_default_instance()) { - delete source_context_; - } + if (this != internal_default_instance()) delete source_context_; } void Api::SetCachedSize(int size) const { @@ -264,25 +302,22 @@ void Api::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* Api::descriptor() { - protobuf_google_2fprotobuf_2fapi_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fapi_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; + ::protobuf_google_2fprotobuf_2fapi_2eproto::protobuf_AssignDescriptorsOnce(); + return ::protobuf_google_2fprotobuf_2fapi_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const Api& Api::default_instance() { - protobuf_google_2fprotobuf_2fapi_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fapi_2eproto::InitDefaultsApi(); return *internal_default_instance(); } -Api* Api::New(::google::protobuf::Arena* arena) const { - Api* n = new Api; - if (arena != NULL) { - arena->Own(n); - } - return n; -} void Api::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.Api) + ::google::protobuf::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + methods_.Clear(); options_.Clear(); mixins_.Clear(); @@ -293,6 +328,7 @@ void Api::Clear() { } source_context_ = NULL; syntax_ = 0; + _internal_metadata_.Clear(); } bool Api::MergePartialFromCodedStream( @@ -308,11 +344,11 @@ bool Api::MergePartialFromCodedStream( // string name = 1; case 1: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(10u)) { + static_cast< ::google::protobuf::uint8>(10u /* 10 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( - this->name().data(), this->name().length(), + this->name().data(), static_cast<int>(this->name().length()), ::google::protobuf::internal::WireFormatLite::PARSE, "google.protobuf.Api.name")); } else { @@ -324,8 +360,8 @@ bool Api::MergePartialFromCodedStream( // repeated .google.protobuf.Method methods = 2; case 2: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(18u)) { - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + static_cast< ::google::protobuf::uint8>(18u /* 18 & 0xFF */)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, add_methods())); } else { goto handle_unusual; @@ -336,8 +372,8 @@ bool Api::MergePartialFromCodedStream( // repeated .google.protobuf.Option options = 3; case 3: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(26u)) { - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + static_cast< ::google::protobuf::uint8>(26u /* 26 & 0xFF */)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, add_options())); } else { goto handle_unusual; @@ -348,11 +384,11 @@ bool Api::MergePartialFromCodedStream( // string version = 4; case 4: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(34u)) { + static_cast< ::google::protobuf::uint8>(34u /* 34 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_version())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( - this->version().data(), this->version().length(), + this->version().data(), static_cast<int>(this->version().length()), ::google::protobuf::internal::WireFormatLite::PARSE, "google.protobuf.Api.version")); } else { @@ -364,8 +400,8 @@ bool Api::MergePartialFromCodedStream( // .google.protobuf.SourceContext source_context = 5; case 5: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(42u)) { - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + static_cast< ::google::protobuf::uint8>(42u /* 42 & 0xFF */)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, mutable_source_context())); } else { goto handle_unusual; @@ -376,8 +412,8 @@ bool Api::MergePartialFromCodedStream( // repeated .google.protobuf.Mixin mixins = 6; case 6: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(50u)) { - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + static_cast< ::google::protobuf::uint8>(50u /* 50 & 0xFF */)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, add_mixins())); } else { goto handle_unusual; @@ -388,7 +424,7 @@ bool Api::MergePartialFromCodedStream( // .google.protobuf.Syntax syntax = 7; case 7: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(56u)) { + static_cast< ::google::protobuf::uint8>(56u /* 56 & 0xFF */)) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -402,12 +438,11 @@ bool Api::MergePartialFromCodedStream( default: { handle_unusual: - if (tag == 0 || - ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + if (tag == 0) { goto success; } - DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag)); + DO_(::google::protobuf::internal::WireFormat::SkipField( + input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } @@ -430,7 +465,7 @@ void Api::SerializeWithCachedSizes( // string name = 1; if (this->name().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( - this->name().data(), this->name().length(), + this->name().data(), static_cast<int>(this->name().length()), ::google::protobuf::internal::WireFormatLite::SERIALIZE, "google.protobuf.Api.name"); ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( @@ -438,21 +473,27 @@ void Api::SerializeWithCachedSizes( } // repeated .google.protobuf.Method methods = 2; - for (unsigned int i = 0, n = this->methods_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->methods_size()); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 2, this->methods(i), output); + 2, + this->methods(static_cast<int>(i)), + output); } // repeated .google.protobuf.Option options = 3; - for (unsigned int i = 0, n = this->options_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->options_size()); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 3, this->options(i), output); + 3, + this->options(static_cast<int>(i)), + output); } // string version = 4; if (this->version().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( - this->version().data(), this->version().length(), + this->version().data(), static_cast<int>(this->version().length()), ::google::protobuf::internal::WireFormatLite::SERIALIZE, "google.protobuf.Api.version"); ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( @@ -462,13 +503,16 @@ void Api::SerializeWithCachedSizes( // .google.protobuf.SourceContext source_context = 5; if (this->has_source_context()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 5, *this->source_context_, output); + 5, *source_context_, output); } // repeated .google.protobuf.Mixin mixins = 6; - for (unsigned int i = 0, n = this->mixins_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->mixins_size()); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 6, this->mixins(i), output); + 6, + this->mixins(static_cast<int>(i)), + output); } // .google.protobuf.Syntax syntax = 7; @@ -477,11 +521,16 @@ void Api::SerializeWithCachedSizes( 7, this->syntax(), output); } + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + ::google::protobuf::internal::WireFormat::SerializeUnknownFields( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), output); + } // @@protoc_insertion_point(serialize_end:google.protobuf.Api) } ::google::protobuf::uint8* Api::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Api) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -489,7 +538,7 @@ void Api::SerializeWithCachedSizes( // string name = 1; if (this->name().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( - this->name().data(), this->name().length(), + this->name().data(), static_cast<int>(this->name().length()), ::google::protobuf::internal::WireFormatLite::SERIALIZE, "google.protobuf.Api.name"); target = @@ -498,23 +547,25 @@ void Api::SerializeWithCachedSizes( } // repeated .google.protobuf.Method methods = 2; - for (unsigned int i = 0, n = this->methods_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->methods_size()); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: - InternalWriteMessageNoVirtualToArray( - 2, this->methods(i), deterministic, target); + InternalWriteMessageToArray( + 2, this->methods(static_cast<int>(i)), deterministic, target); } // repeated .google.protobuf.Option options = 3; - for (unsigned int i = 0, n = this->options_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->options_size()); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: - InternalWriteMessageNoVirtualToArray( - 3, this->options(i), deterministic, target); + InternalWriteMessageToArray( + 3, this->options(static_cast<int>(i)), deterministic, target); } // string version = 4; if (this->version().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( - this->version().data(), this->version().length(), + this->version().data(), static_cast<int>(this->version().length()), ::google::protobuf::internal::WireFormatLite::SERIALIZE, "google.protobuf.Api.version"); target = @@ -525,15 +576,16 @@ void Api::SerializeWithCachedSizes( // .google.protobuf.SourceContext source_context = 5; if (this->has_source_context()) { target = ::google::protobuf::internal::WireFormatLite:: - InternalWriteMessageNoVirtualToArray( - 5, *this->source_context_, deterministic, target); + InternalWriteMessageToArray( + 5, *source_context_, deterministic, target); } // repeated .google.protobuf.Mixin mixins = 6; - for (unsigned int i = 0, n = this->mixins_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->mixins_size()); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: - InternalWriteMessageNoVirtualToArray( - 6, this->mixins(i), deterministic, target); + InternalWriteMessageToArray( + 6, this->mixins(static_cast<int>(i)), deterministic, target); } // .google.protobuf.Syntax syntax = 7; @@ -542,6 +594,10 @@ void Api::SerializeWithCachedSizes( 7, this->syntax(), target); } + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), target); + } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Api) return target; } @@ -550,36 +606,41 @@ size_t Api::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Api) size_t total_size = 0; + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance())); + } // repeated .google.protobuf.Method methods = 2; { - unsigned int count = this->methods_size(); + unsigned int count = static_cast<unsigned int>(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)); + ::google::protobuf::internal::WireFormatLite::MessageSize( + this->methods(static_cast<int>(i))); } } // repeated .google.protobuf.Option options = 3; { - unsigned int count = this->options_size(); + unsigned int count = static_cast<unsigned int>(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)); + ::google::protobuf::internal::WireFormatLite::MessageSize( + this->options(static_cast<int>(i))); } } // repeated .google.protobuf.Mixin mixins = 6; { - unsigned int count = this->mixins_size(); + unsigned int count = static_cast<unsigned int>(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)); + ::google::protobuf::internal::WireFormatLite::MessageSize( + this->mixins(static_cast<int>(i))); } } @@ -600,8 +661,8 @@ size_t Api::ByteSizeLong() const { // .google.protobuf.SourceContext source_context = 5; if (this->has_source_context()) { total_size += 1 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - *this->source_context_); + ::google::protobuf::internal::WireFormatLite::MessageSize( + *source_context_); } // .google.protobuf.Syntax syntax = 7; @@ -681,277 +742,31 @@ void Api::Swap(Api* other) { InternalSwap(other); } void Api::InternalSwap(Api* other) { - methods_.InternalSwap(&other->methods_); - options_.InternalSwap(&other->options_); - mixins_.InternalSwap(&other->mixins_); + using std::swap; + CastToBase(&methods_)->InternalSwap(CastToBase(&other->methods_)); + CastToBase(&options_)->InternalSwap(CastToBase(&other->options_)); + CastToBase(&mixins_)->InternalSwap(CastToBase(&other->mixins_)); name_.Swap(&other->name_); version_.Swap(&other->version_); - std::swap(source_context_, other->source_context_); - std::swap(syntax_, other->syntax_); - std::swap(_cached_size_, other->_cached_size_); + swap(source_context_, other->source_context_); + swap(syntax_, other->syntax_); + _internal_metadata_.Swap(&other->_internal_metadata_); + swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata Api::GetMetadata() const { protobuf_google_2fprotobuf_2fapi_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fapi_2eproto::file_level_metadata[kIndexInFileMessages]; + return ::protobuf_google_2fprotobuf_2fapi_2eproto::file_level_metadata[kIndexInFileMessages]; } -#if PROTOBUF_INLINE_NOT_IN_HEADERS -// Api - -// string name = 1; -void Api::clear_name() { - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -const ::std::string& Api::name() const { - // @@protoc_insertion_point(field_get:google.protobuf.Api.name) - return name_.GetNoArena(); -} -void Api::set_name(const ::std::string& value) { - - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.Api.name) -} -#if LANG_CXX11 -void Api::set_name(::std::string&& value) { - - name_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Api.name) -} -#endif -void Api::set_name(const char* value) { - GOOGLE_DCHECK(value != NULL); - - 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) { - - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.Api.name) -} -::std::string* Api::mutable_name() { - - // @@protoc_insertion_point(field_mutable:google.protobuf.Api.name) - return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -::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) { - if (name != NULL) { - - } else { - - } - name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.Api.name) -} -// repeated .google.protobuf.Method methods = 2; -int Api::methods_size() const { - return methods_.size(); -} -void Api::clear_methods() { - methods_.Clear(); -} -const ::google::protobuf::Method& Api::methods(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.Api.methods) - return methods_.Get(index); -} -::google::protobuf::Method* Api::mutable_methods(int index) { - // @@protoc_insertion_point(field_mutable:google.protobuf.Api.methods) - return methods_.Mutable(index); -} -::google::protobuf::Method* Api::add_methods() { - // @@protoc_insertion_point(field_add:google.protobuf.Api.methods) - return methods_.Add(); -} -::google::protobuf::RepeatedPtrField< ::google::protobuf::Method >* -Api::mutable_methods() { - // @@protoc_insertion_point(field_mutable_list:google.protobuf.Api.methods) - return &methods_; -} -const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Method >& -Api::methods() const { - // @@protoc_insertion_point(field_list:google.protobuf.Api.methods) - return methods_; -} +// =================================================================== -// repeated .google.protobuf.Option options = 3; -int Api::options_size() const { - return options_.size(); +void Method::InitAsDefaultInstance() { } -void Api::clear_options() { +void Method::clear_options() { options_.Clear(); } -const ::google::protobuf::Option& Api::options(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.Api.options) - return options_.Get(index); -} -::google::protobuf::Option* Api::mutable_options(int index) { - // @@protoc_insertion_point(field_mutable:google.protobuf.Api.options) - return options_.Mutable(index); -} -::google::protobuf::Option* Api::add_options() { - // @@protoc_insertion_point(field_add:google.protobuf.Api.options) - return options_.Add(); -} -::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >* -Api::mutable_options() { - // @@protoc_insertion_point(field_mutable_list:google.protobuf.Api.options) - return &options_; -} -const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >& -Api::options() const { - // @@protoc_insertion_point(field_list:google.protobuf.Api.options) - return options_; -} - -// string version = 4; -void Api::clear_version() { - version_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -const ::std::string& Api::version() const { - // @@protoc_insertion_point(field_get:google.protobuf.Api.version) - return version_.GetNoArena(); -} -void Api::set_version(const ::std::string& value) { - - version_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.Api.version) -} -#if LANG_CXX11 -void Api::set_version(::std::string&& value) { - - version_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Api.version) -} -#endif -void Api::set_version(const char* value) { - GOOGLE_DCHECK(value != NULL); - - 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) { - - version_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.Api.version) -} -::std::string* Api::mutable_version() { - - // @@protoc_insertion_point(field_mutable:google.protobuf.Api.version) - return version_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -::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) { - if (version != NULL) { - - } else { - - } - version_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), version); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.Api.version) -} - -// .google.protobuf.SourceContext source_context = 5; -bool Api::has_source_context() const { - return this != internal_default_instance() && source_context_ != NULL; -} -void Api::clear_source_context() { - if (GetArenaNoVirtual() == NULL && source_context_ != NULL) delete source_context_; - source_context_ = NULL; -} -const ::google::protobuf::SourceContext& Api::source_context() const { - // @@protoc_insertion_point(field_get:google.protobuf.Api.source_context) - return source_context_ != NULL ? *source_context_ - : *::google::protobuf::SourceContext::internal_default_instance(); -} -::google::protobuf::SourceContext* Api::mutable_source_context() { - - if (source_context_ == NULL) { - source_context_ = new ::google::protobuf::SourceContext; - } - // @@protoc_insertion_point(field_mutable:google.protobuf.Api.source_context) - return source_context_; -} -::google::protobuf::SourceContext* Api::release_source_context() { - // @@protoc_insertion_point(field_release:google.protobuf.Api.source_context) - - ::google::protobuf::SourceContext* temp = source_context_; - source_context_ = NULL; - return temp; -} -void Api::set_allocated_source_context(::google::protobuf::SourceContext* source_context) { - delete source_context_; - source_context_ = source_context; - if (source_context) { - - } else { - - } - // @@protoc_insertion_point(field_set_allocated:google.protobuf.Api.source_context) -} - -// repeated .google.protobuf.Mixin mixins = 6; -int Api::mixins_size() const { - return mixins_.size(); -} -void Api::clear_mixins() { - mixins_.Clear(); -} -const ::google::protobuf::Mixin& Api::mixins(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.Api.mixins) - return mixins_.Get(index); -} -::google::protobuf::Mixin* Api::mutable_mixins(int index) { - // @@protoc_insertion_point(field_mutable:google.protobuf.Api.mixins) - return mixins_.Mutable(index); -} -::google::protobuf::Mixin* Api::add_mixins() { - // @@protoc_insertion_point(field_add:google.protobuf.Api.mixins) - return mixins_.Add(); -} -::google::protobuf::RepeatedPtrField< ::google::protobuf::Mixin >* -Api::mutable_mixins() { - // @@protoc_insertion_point(field_mutable_list:google.protobuf.Api.mixins) - return &mixins_; -} -const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Mixin >& -Api::mixins() const { - // @@protoc_insertion_point(field_list:google.protobuf.Api.mixins) - return mixins_; -} - -// .google.protobuf.Syntax syntax = 7; -void Api::clear_syntax() { - syntax_ = 0; -} -::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) { - - syntax_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.Api.syntax) -} - -#endif // PROTOBUF_INLINE_NOT_IN_HEADERS - -// =================================================================== - #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int Method::kNameFieldNumber; const int Method::kRequestTypeUrlFieldNumber; @@ -965,7 +780,7 @@ const int Method::kSyntaxFieldNumber; Method::Method() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { - protobuf_google_2fprotobuf_2fapi_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fapi_2eproto::InitDefaultsMethod(); } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Method) @@ -989,8 +804,8 @@ Method::Method(const Method& from) response_type_url_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.response_type_url_); } ::memcpy(&request_streaming_, &from.request_streaming_, - reinterpret_cast<char*>(&syntax_) - - reinterpret_cast<char*>(&request_streaming_) + sizeof(syntax_)); + static_cast<size_t>(reinterpret_cast<char*>(&syntax_) - + reinterpret_cast<char*>(&request_streaming_)) + sizeof(syntax_)); // @@protoc_insertion_point(copy_constructor:google.protobuf.Method) } @@ -998,8 +813,9 @@ void Method::SharedCtor() { name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); request_type_url_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); response_type_url_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - ::memset(&request_streaming_, 0, reinterpret_cast<char*>(&syntax_) - - reinterpret_cast<char*>(&request_streaming_) + sizeof(syntax_)); + ::memset(&request_streaming_, 0, static_cast<size_t>( + reinterpret_cast<char*>(&syntax_) - + reinterpret_cast<char*>(&request_streaming_)) + sizeof(syntax_)); _cached_size_ = 0; } @@ -1020,31 +836,30 @@ void Method::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* Method::descriptor() { - protobuf_google_2fprotobuf_2fapi_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fapi_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; + ::protobuf_google_2fprotobuf_2fapi_2eproto::protobuf_AssignDescriptorsOnce(); + return ::protobuf_google_2fprotobuf_2fapi_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const Method& Method::default_instance() { - protobuf_google_2fprotobuf_2fapi_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fapi_2eproto::InitDefaultsMethod(); return *internal_default_instance(); } -Method* Method::New(::google::protobuf::Arena* arena) const { - Method* n = new Method; - if (arena != NULL) { - arena->Own(n); - } - return n; -} void Method::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.Method) + ::google::protobuf::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + options_.Clear(); name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); request_type_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); response_type_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - ::memset(&request_streaming_, 0, reinterpret_cast<char*>(&syntax_) - - reinterpret_cast<char*>(&request_streaming_) + sizeof(syntax_)); + ::memset(&request_streaming_, 0, static_cast<size_t>( + reinterpret_cast<char*>(&syntax_) - + reinterpret_cast<char*>(&request_streaming_)) + sizeof(syntax_)); + _internal_metadata_.Clear(); } bool Method::MergePartialFromCodedStream( @@ -1060,11 +875,11 @@ bool Method::MergePartialFromCodedStream( // string name = 1; case 1: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(10u)) { + static_cast< ::google::protobuf::uint8>(10u /* 10 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( - this->name().data(), this->name().length(), + this->name().data(), static_cast<int>(this->name().length()), ::google::protobuf::internal::WireFormatLite::PARSE, "google.protobuf.Method.name")); } else { @@ -1076,11 +891,11 @@ bool Method::MergePartialFromCodedStream( // string request_type_url = 2; case 2: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(18u)) { + static_cast< ::google::protobuf::uint8>(18u /* 18 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_request_type_url())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( - this->request_type_url().data(), this->request_type_url().length(), + this->request_type_url().data(), static_cast<int>(this->request_type_url().length()), ::google::protobuf::internal::WireFormatLite::PARSE, "google.protobuf.Method.request_type_url")); } else { @@ -1092,7 +907,7 @@ bool Method::MergePartialFromCodedStream( // bool request_streaming = 3; case 3: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(24u)) { + static_cast< ::google::protobuf::uint8>(24u /* 24 & 0xFF */)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -1106,11 +921,11 @@ bool Method::MergePartialFromCodedStream( // string response_type_url = 4; case 4: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(34u)) { + static_cast< ::google::protobuf::uint8>(34u /* 34 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_response_type_url())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( - this->response_type_url().data(), this->response_type_url().length(), + this->response_type_url().data(), static_cast<int>(this->response_type_url().length()), ::google::protobuf::internal::WireFormatLite::PARSE, "google.protobuf.Method.response_type_url")); } else { @@ -1122,7 +937,7 @@ bool Method::MergePartialFromCodedStream( // bool response_streaming = 5; case 5: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(40u)) { + static_cast< ::google::protobuf::uint8>(40u /* 40 & 0xFF */)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -1136,8 +951,8 @@ bool Method::MergePartialFromCodedStream( // repeated .google.protobuf.Option options = 6; case 6: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(50u)) { - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + static_cast< ::google::protobuf::uint8>(50u /* 50 & 0xFF */)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, add_options())); } else { goto handle_unusual; @@ -1148,7 +963,7 @@ bool Method::MergePartialFromCodedStream( // .google.protobuf.Syntax syntax = 7; case 7: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(56u)) { + static_cast< ::google::protobuf::uint8>(56u /* 56 & 0xFF */)) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -1162,12 +977,11 @@ bool Method::MergePartialFromCodedStream( default: { handle_unusual: - if (tag == 0 || - ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + if (tag == 0) { goto success; } - DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag)); + DO_(::google::protobuf::internal::WireFormat::SkipField( + input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } @@ -1190,7 +1004,7 @@ void Method::SerializeWithCachedSizes( // string name = 1; if (this->name().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( - this->name().data(), this->name().length(), + this->name().data(), static_cast<int>(this->name().length()), ::google::protobuf::internal::WireFormatLite::SERIALIZE, "google.protobuf.Method.name"); ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( @@ -1200,7 +1014,7 @@ void Method::SerializeWithCachedSizes( // string request_type_url = 2; if (this->request_type_url().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( - this->request_type_url().data(), this->request_type_url().length(), + this->request_type_url().data(), static_cast<int>(this->request_type_url().length()), ::google::protobuf::internal::WireFormatLite::SERIALIZE, "google.protobuf.Method.request_type_url"); ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( @@ -1215,7 +1029,7 @@ void Method::SerializeWithCachedSizes( // string response_type_url = 4; if (this->response_type_url().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( - this->response_type_url().data(), this->response_type_url().length(), + this->response_type_url().data(), static_cast<int>(this->response_type_url().length()), ::google::protobuf::internal::WireFormatLite::SERIALIZE, "google.protobuf.Method.response_type_url"); ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( @@ -1228,9 +1042,12 @@ void Method::SerializeWithCachedSizes( } // repeated .google.protobuf.Option options = 6; - for (unsigned int i = 0, n = this->options_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->options_size()); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 6, this->options(i), output); + 6, + this->options(static_cast<int>(i)), + output); } // .google.protobuf.Syntax syntax = 7; @@ -1239,11 +1056,16 @@ void Method::SerializeWithCachedSizes( 7, this->syntax(), output); } + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + ::google::protobuf::internal::WireFormat::SerializeUnknownFields( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), output); + } // @@protoc_insertion_point(serialize_end:google.protobuf.Method) } ::google::protobuf::uint8* Method::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Method) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -1251,7 +1073,7 @@ void Method::SerializeWithCachedSizes( // string name = 1; if (this->name().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( - this->name().data(), this->name().length(), + this->name().data(), static_cast<int>(this->name().length()), ::google::protobuf::internal::WireFormatLite::SERIALIZE, "google.protobuf.Method.name"); target = @@ -1262,7 +1084,7 @@ void Method::SerializeWithCachedSizes( // string request_type_url = 2; if (this->request_type_url().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( - this->request_type_url().data(), this->request_type_url().length(), + this->request_type_url().data(), static_cast<int>(this->request_type_url().length()), ::google::protobuf::internal::WireFormatLite::SERIALIZE, "google.protobuf.Method.request_type_url"); target = @@ -1278,7 +1100,7 @@ void Method::SerializeWithCachedSizes( // string response_type_url = 4; if (this->response_type_url().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( - this->response_type_url().data(), this->response_type_url().length(), + this->response_type_url().data(), static_cast<int>(this->response_type_url().length()), ::google::protobuf::internal::WireFormatLite::SERIALIZE, "google.protobuf.Method.response_type_url"); target = @@ -1292,10 +1114,11 @@ void Method::SerializeWithCachedSizes( } // repeated .google.protobuf.Option options = 6; - for (unsigned int i = 0, n = this->options_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->options_size()); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: - InternalWriteMessageNoVirtualToArray( - 6, this->options(i), deterministic, target); + InternalWriteMessageToArray( + 6, this->options(static_cast<int>(i)), deterministic, target); } // .google.protobuf.Syntax syntax = 7; @@ -1304,6 +1127,10 @@ void Method::SerializeWithCachedSizes( 7, this->syntax(), target); } + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), target); + } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Method) return target; } @@ -1312,14 +1139,19 @@ size_t Method::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Method) size_t total_size = 0; + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance())); + } // repeated .google.protobuf.Option options = 6; { - unsigned int count = this->options_size(); + unsigned int count = static_cast<unsigned int>(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)); + ::google::protobuf::internal::WireFormatLite::MessageSize( + this->options(static_cast<int>(i))); } } @@ -1436,259 +1268,28 @@ void Method::Swap(Method* other) { InternalSwap(other); } void Method::InternalSwap(Method* other) { - options_.InternalSwap(&other->options_); + using std::swap; + CastToBase(&options_)->InternalSwap(CastToBase(&other->options_)); name_.Swap(&other->name_); request_type_url_.Swap(&other->request_type_url_); response_type_url_.Swap(&other->response_type_url_); - std::swap(request_streaming_, other->request_streaming_); - std::swap(response_streaming_, other->response_streaming_); - std::swap(syntax_, other->syntax_); - std::swap(_cached_size_, other->_cached_size_); + swap(request_streaming_, other->request_streaming_); + swap(response_streaming_, other->response_streaming_); + swap(syntax_, other->syntax_); + _internal_metadata_.Swap(&other->_internal_metadata_); + swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata Method::GetMetadata() const { protobuf_google_2fprotobuf_2fapi_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fapi_2eproto::file_level_metadata[kIndexInFileMessages]; + return ::protobuf_google_2fprotobuf_2fapi_2eproto::file_level_metadata[kIndexInFileMessages]; } -#if PROTOBUF_INLINE_NOT_IN_HEADERS -// Method - -// string name = 1; -void Method::clear_name() { - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -const ::std::string& Method::name() const { - // @@protoc_insertion_point(field_get:google.protobuf.Method.name) - return name_.GetNoArena(); -} -void Method::set_name(const ::std::string& value) { - - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.Method.name) -} -#if LANG_CXX11 -void Method::set_name(::std::string&& value) { - - name_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Method.name) -} -#endif -void Method::set_name(const char* value) { - GOOGLE_DCHECK(value != NULL); - - 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) { - - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.Method.name) -} -::std::string* Method::mutable_name() { - - // @@protoc_insertion_point(field_mutable:google.protobuf.Method.name) - return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -::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) { - if (name != NULL) { - - } else { - - } - name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.Method.name) -} - -// string request_type_url = 2; -void Method::clear_request_type_url() { - request_type_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -const ::std::string& Method::request_type_url() const { - // @@protoc_insertion_point(field_get:google.protobuf.Method.request_type_url) - return request_type_url_.GetNoArena(); -} -void Method::set_request_type_url(const ::std::string& value) { - - request_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.Method.request_type_url) -} -#if LANG_CXX11 -void Method::set_request_type_url(::std::string&& value) { - - request_type_url_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Method.request_type_url) -} -#endif -void Method::set_request_type_url(const char* value) { - GOOGLE_DCHECK(value != NULL); - - 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) { - - request_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.Method.request_type_url) -} -::std::string* Method::mutable_request_type_url() { - - // @@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() { - // @@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) { - if (request_type_url != NULL) { - - } else { - - } - request_type_url_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), request_type_url); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.Method.request_type_url) -} - -// bool request_streaming = 3; -void Method::clear_request_streaming() { - request_streaming_ = false; -} -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) { - - request_streaming_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.Method.request_streaming) -} - -// string response_type_url = 4; -void Method::clear_response_type_url() { - response_type_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -const ::std::string& Method::response_type_url() const { - // @@protoc_insertion_point(field_get:google.protobuf.Method.response_type_url) - return response_type_url_.GetNoArena(); -} -void Method::set_response_type_url(const ::std::string& value) { - - response_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.Method.response_type_url) -} -#if LANG_CXX11 -void Method::set_response_type_url(::std::string&& value) { - - response_type_url_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Method.response_type_url) -} -#endif -void Method::set_response_type_url(const char* value) { - GOOGLE_DCHECK(value != NULL); - - 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) { - - response_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.Method.response_type_url) -} -::std::string* Method::mutable_response_type_url() { - - // @@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() { - // @@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) { - if (response_type_url != NULL) { - - } else { - - } - response_type_url_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), response_type_url); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.Method.response_type_url) -} - -// bool response_streaming = 5; -void Method::clear_response_streaming() { - response_streaming_ = false; -} -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) { - - response_streaming_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.Method.response_streaming) -} - -// repeated .google.protobuf.Option options = 6; -int Method::options_size() const { - return options_.size(); -} -void Method::clear_options() { - options_.Clear(); -} -const ::google::protobuf::Option& Method::options(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.Method.options) - return options_.Get(index); -} -::google::protobuf::Option* Method::mutable_options(int index) { - // @@protoc_insertion_point(field_mutable:google.protobuf.Method.options) - return options_.Mutable(index); -} -::google::protobuf::Option* Method::add_options() { - // @@protoc_insertion_point(field_add:google.protobuf.Method.options) - return options_.Add(); -} -::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >* -Method::mutable_options() { - // @@protoc_insertion_point(field_mutable_list:google.protobuf.Method.options) - return &options_; -} -const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >& -Method::options() const { - // @@protoc_insertion_point(field_list:google.protobuf.Method.options) - return options_; -} - -// .google.protobuf.Syntax syntax = 7; -void Method::clear_syntax() { - syntax_ = 0; -} -::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) { - - syntax_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.Method.syntax) -} - -#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== +void Mixin::InitAsDefaultInstance() { +} #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int Mixin::kNameFieldNumber; const int Mixin::kRootFieldNumber; @@ -1697,7 +1298,7 @@ const int Mixin::kRootFieldNumber; Mixin::Mixin() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { - protobuf_google_2fprotobuf_2fapi_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fapi_2eproto::InitDefaultsMixin(); } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Mixin) @@ -1740,27 +1341,25 @@ void Mixin::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* Mixin::descriptor() { - protobuf_google_2fprotobuf_2fapi_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fapi_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; + ::protobuf_google_2fprotobuf_2fapi_2eproto::protobuf_AssignDescriptorsOnce(); + return ::protobuf_google_2fprotobuf_2fapi_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const Mixin& Mixin::default_instance() { - protobuf_google_2fprotobuf_2fapi_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fapi_2eproto::InitDefaultsMixin(); return *internal_default_instance(); } -Mixin* Mixin::New(::google::protobuf::Arena* arena) const { - Mixin* n = new Mixin; - if (arena != NULL) { - arena->Own(n); - } - return n; -} void Mixin::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.Mixin) + ::google::protobuf::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); root_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + _internal_metadata_.Clear(); } bool Mixin::MergePartialFromCodedStream( @@ -1776,11 +1375,11 @@ bool Mixin::MergePartialFromCodedStream( // string name = 1; case 1: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(10u)) { + static_cast< ::google::protobuf::uint8>(10u /* 10 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( - this->name().data(), this->name().length(), + this->name().data(), static_cast<int>(this->name().length()), ::google::protobuf::internal::WireFormatLite::PARSE, "google.protobuf.Mixin.name")); } else { @@ -1792,11 +1391,11 @@ bool Mixin::MergePartialFromCodedStream( // string root = 2; case 2: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(18u)) { + static_cast< ::google::protobuf::uint8>(18u /* 18 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_root())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( - this->root().data(), this->root().length(), + this->root().data(), static_cast<int>(this->root().length()), ::google::protobuf::internal::WireFormatLite::PARSE, "google.protobuf.Mixin.root")); } else { @@ -1807,12 +1406,11 @@ bool Mixin::MergePartialFromCodedStream( default: { handle_unusual: - if (tag == 0 || - ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + if (tag == 0) { goto success; } - DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag)); + DO_(::google::protobuf::internal::WireFormat::SkipField( + input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } @@ -1835,7 +1433,7 @@ void Mixin::SerializeWithCachedSizes( // string name = 1; if (this->name().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( - this->name().data(), this->name().length(), + this->name().data(), static_cast<int>(this->name().length()), ::google::protobuf::internal::WireFormatLite::SERIALIZE, "google.protobuf.Mixin.name"); ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( @@ -1845,18 +1443,23 @@ void Mixin::SerializeWithCachedSizes( // string root = 2; if (this->root().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( - this->root().data(), this->root().length(), + this->root().data(), static_cast<int>(this->root().length()), ::google::protobuf::internal::WireFormatLite::SERIALIZE, "google.protobuf.Mixin.root"); ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( 2, this->root(), output); } + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + ::google::protobuf::internal::WireFormat::SerializeUnknownFields( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), output); + } // @@protoc_insertion_point(serialize_end:google.protobuf.Mixin) } ::google::protobuf::uint8* Mixin::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Mixin) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -1864,7 +1467,7 @@ void Mixin::SerializeWithCachedSizes( // string name = 1; if (this->name().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( - this->name().data(), this->name().length(), + this->name().data(), static_cast<int>(this->name().length()), ::google::protobuf::internal::WireFormatLite::SERIALIZE, "google.protobuf.Mixin.name"); target = @@ -1875,7 +1478,7 @@ void Mixin::SerializeWithCachedSizes( // string root = 2; if (this->root().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( - this->root().data(), this->root().length(), + this->root().data(), static_cast<int>(this->root().length()), ::google::protobuf::internal::WireFormatLite::SERIALIZE, "google.protobuf.Mixin.root"); target = @@ -1883,6 +1486,10 @@ void Mixin::SerializeWithCachedSizes( 2, this->root(), target); } + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), target); + } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Mixin) return target; } @@ -1891,6 +1498,11 @@ size_t Mixin::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Mixin) size_t total_size = 0; + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance())); + } // string name = 1; if (this->name().size() > 0) { total_size += 1 + @@ -1967,129 +1579,33 @@ void Mixin::Swap(Mixin* other) { InternalSwap(other); } void Mixin::InternalSwap(Mixin* other) { + using std::swap; name_.Swap(&other->name_); root_.Swap(&other->root_); - std::swap(_cached_size_, other->_cached_size_); + _internal_metadata_.Swap(&other->_internal_metadata_); + swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata Mixin::GetMetadata() const { protobuf_google_2fprotobuf_2fapi_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fapi_2eproto::file_level_metadata[kIndexInFileMessages]; + return ::protobuf_google_2fprotobuf_2fapi_2eproto::file_level_metadata[kIndexInFileMessages]; } -#if PROTOBUF_INLINE_NOT_IN_HEADERS -// Mixin -// string name = 1; -void Mixin::clear_name() { - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -const ::std::string& Mixin::name() const { - // @@protoc_insertion_point(field_get:google.protobuf.Mixin.name) - return name_.GetNoArena(); -} -void Mixin::set_name(const ::std::string& value) { - - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.Mixin.name) -} -#if LANG_CXX11 -void Mixin::set_name(::std::string&& value) { - - name_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Mixin.name) -} -#endif -void Mixin::set_name(const char* value) { - GOOGLE_DCHECK(value != NULL); - - 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) { - - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.Mixin.name) -} -::std::string* Mixin::mutable_name() { - - // @@protoc_insertion_point(field_mutable:google.protobuf.Mixin.name) - return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -::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) { - if (name != NULL) { - - } else { - - } - name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.Mixin.name) -} - -// string root = 2; -void Mixin::clear_root() { - root_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -const ::std::string& Mixin::root() const { - // @@protoc_insertion_point(field_get:google.protobuf.Mixin.root) - return root_.GetNoArena(); -} -void Mixin::set_root(const ::std::string& value) { - - root_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.Mixin.root) +// @@protoc_insertion_point(namespace_scope) +} // namespace protobuf +} // namespace google +namespace google { +namespace protobuf { +template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::Api* Arena::Create< ::google::protobuf::Api >(Arena* arena) { + return Arena::CreateInternal< ::google::protobuf::Api >(arena); } -#if LANG_CXX11 -void Mixin::set_root(::std::string&& value) { - - root_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Mixin.root) +template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::Method* Arena::Create< ::google::protobuf::Method >(Arena* arena) { + return Arena::CreateInternal< ::google::protobuf::Method >(arena); } -#endif -void Mixin::set_root(const char* value) { - GOOGLE_DCHECK(value != NULL); - - 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) { - - root_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.Mixin.root) -} -::std::string* Mixin::mutable_root() { - - // @@protoc_insertion_point(field_mutable:google.protobuf.Mixin.root) - return root_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -::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) { - if (root != NULL) { - - } else { - - } - root_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), root); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.Mixin.root) +template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::Mixin* Arena::Create< ::google::protobuf::Mixin >(Arena* arena) { + return Arena::CreateInternal< ::google::protobuf::Mixin >(arena); } - -#endif // PROTOBUF_INLINE_NOT_IN_HEADERS - -// @@protoc_insertion_point(namespace_scope) - } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/api.pb.h b/src/google/protobuf/api.pb.h index 108c63a4..648aa308 100644 --- a/src/google/protobuf/api.pb.h +++ b/src/google/protobuf/api.pb.h @@ -1,19 +1,19 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/protobuf/api.proto -#ifndef PROTOBUF_google_2fprotobuf_2fapi_2eproto__INCLUDED -#define PROTOBUF_google_2fprotobuf_2fapi_2eproto__INCLUDED +#ifndef PROTOBUF_google_2fprotobuf_2fapi_2eproto_INCLUDED +#define PROTOBUF_google_2fprotobuf_2fapi_2eproto_INCLUDED #include <string> #include <google/protobuf/stubs/common.h> -#if GOOGLE_PROTOBUF_VERSION < 3003000 +#if GOOGLE_PROTOBUF_VERSION < 3005000 #error This file was generated by a newer version of protoc which is #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3003000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION +#if 3005001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. @@ -32,54 +32,52 @@ #include <google/protobuf/source_context.pb.h> #include <google/protobuf/type.pb.h> // @@protoc_insertion_point(includes) + +namespace protobuf_google_2fprotobuf_2fapi_2eproto { +// Internal implementation detail -- do not use these members. +struct LIBPROTOBUF_EXPORT TableStruct { + static const ::google::protobuf::internal::ParseTableField entries[]; + static const ::google::protobuf::internal::AuxillaryParseTableField aux[]; + static const ::google::protobuf::internal::ParseTable schema[3]; + static const ::google::protobuf::internal::FieldMetadata field_metadata[]; + static const ::google::protobuf::internal::SerializationTable serialization_table[]; + static const ::google::protobuf::uint32 offsets[]; +}; +void LIBPROTOBUF_EXPORT AddDescriptors(); +void LIBPROTOBUF_EXPORT InitDefaultsApiImpl(); +void LIBPROTOBUF_EXPORT InitDefaultsApi(); +void LIBPROTOBUF_EXPORT InitDefaultsMethodImpl(); +void LIBPROTOBUF_EXPORT InitDefaultsMethod(); +void LIBPROTOBUF_EXPORT InitDefaultsMixinImpl(); +void LIBPROTOBUF_EXPORT InitDefaultsMixin(); +inline void LIBPROTOBUF_EXPORT InitDefaults() { + InitDefaultsApi(); + InitDefaultsMethod(); + InitDefaultsMixin(); +} +} // namespace protobuf_google_2fprotobuf_2fapi_2eproto namespace google { namespace protobuf { class Api; class ApiDefaultTypeInternal; LIBPROTOBUF_EXPORT extern ApiDefaultTypeInternal _Api_default_instance_; -class Enum; -class EnumDefaultTypeInternal; -LIBPROTOBUF_EXPORT extern EnumDefaultTypeInternal _Enum_default_instance_; -class EnumValue; -class EnumValueDefaultTypeInternal; -LIBPROTOBUF_EXPORT extern EnumValueDefaultTypeInternal _EnumValue_default_instance_; -class Field; -class FieldDefaultTypeInternal; -LIBPROTOBUF_EXPORT extern FieldDefaultTypeInternal _Field_default_instance_; class Method; class MethodDefaultTypeInternal; LIBPROTOBUF_EXPORT extern MethodDefaultTypeInternal _Method_default_instance_; class Mixin; class MixinDefaultTypeInternal; LIBPROTOBUF_EXPORT extern MixinDefaultTypeInternal _Mixin_default_instance_; -class Option; -class OptionDefaultTypeInternal; -LIBPROTOBUF_EXPORT extern OptionDefaultTypeInternal _Option_default_instance_; -class SourceContext; -class SourceContextDefaultTypeInternal; -LIBPROTOBUF_EXPORT extern SourceContextDefaultTypeInternal _SourceContext_default_instance_; -class Type; -class TypeDefaultTypeInternal; -LIBPROTOBUF_EXPORT extern TypeDefaultTypeInternal _Type_default_instance_; } // namespace protobuf } // namespace google - namespace google { namespace protobuf { - -namespace protobuf_google_2fprotobuf_2fapi_2eproto { -// Internal implementation detail -- do not call these. -struct LIBPROTOBUF_EXPORT TableStruct { - static const ::google::protobuf::internal::ParseTableField entries[]; - static const ::google::protobuf::internal::AuxillaryParseTableField aux[]; - static const ::google::protobuf::internal::ParseTable schema[]; - static const ::google::protobuf::uint32 offsets[]; - static void InitDefaultsImpl(); - static void Shutdown(); -}; -void LIBPROTOBUF_EXPORT AddDescriptors(); -void LIBPROTOBUF_EXPORT InitDefaults(); -} // namespace protobuf_google_2fprotobuf_2fapi_2eproto +template<> LIBPROTOBUF_EXPORT ::google::protobuf::Api* Arena::Create< ::google::protobuf::Api>(Arena*); +template<> LIBPROTOBUF_EXPORT ::google::protobuf::Method* Arena::Create< ::google::protobuf::Method>(Arena*); +template<> LIBPROTOBUF_EXPORT ::google::protobuf::Mixin* Arena::Create< ::google::protobuf::Mixin>(Arena*); +} // namespace protobuf +} // namespace google +namespace google { +namespace protobuf { // =================================================================== @@ -94,10 +92,25 @@ class LIBPROTOBUF_EXPORT Api : public ::google::protobuf::Message /* @@protoc_in CopyFrom(from); return *this; } + #if LANG_CXX11 + Api(Api&& from) noexcept + : Api() { + *this = ::std::move(from); + } + inline Api& operator=(Api&& from) noexcept { + if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + #endif static const ::google::protobuf::Descriptor* descriptor(); static const Api& default_instance(); + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY static inline const Api* internal_default_instance() { return reinterpret_cast<const Api*>( &_Api_default_instance_); @@ -106,12 +119,19 @@ class LIBPROTOBUF_EXPORT Api : public ::google::protobuf::Message /* @@protoc_in 0; void Swap(Api* other); + friend void swap(Api& a, Api& b) { + a.Swap(&b); + } // implements Message ---------------------------------------------- - inline Api* New() const PROTOBUF_FINAL { return New(NULL); } + inline Api* New() const PROTOBUF_FINAL { + return ::google::protobuf::Arena::Create<Api>(NULL); + } - Api* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + Api* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL { + return ::google::protobuf::Arena::Create<Api>(arena); + } void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const Api& from); @@ -151,11 +171,11 @@ class LIBPROTOBUF_EXPORT Api : public ::google::protobuf::Message /* @@protoc_in int methods_size() const; void clear_methods(); static const int kMethodsFieldNumber = 2; - const ::google::protobuf::Method& methods(int index) const; ::google::protobuf::Method* mutable_methods(int index); - ::google::protobuf::Method* add_methods(); ::google::protobuf::RepeatedPtrField< ::google::protobuf::Method >* mutable_methods(); + const ::google::protobuf::Method& methods(int index) const; + ::google::protobuf::Method* add_methods(); const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Method >& methods() const; @@ -163,11 +183,11 @@ class LIBPROTOBUF_EXPORT Api : public ::google::protobuf::Message /* @@protoc_in int options_size() const; void clear_options(); static const int kOptionsFieldNumber = 3; - const ::google::protobuf::Option& options(int index) const; ::google::protobuf::Option* mutable_options(int index); - ::google::protobuf::Option* add_options(); ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >* mutable_options(); + const ::google::protobuf::Option& options(int index) const; + ::google::protobuf::Option* add_options(); const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >& options() const; @@ -175,11 +195,11 @@ class LIBPROTOBUF_EXPORT Api : public ::google::protobuf::Message /* @@protoc_in int mixins_size() const; void clear_mixins(); static const int kMixinsFieldNumber = 6; - const ::google::protobuf::Mixin& mixins(int index) const; ::google::protobuf::Mixin* mutable_mixins(int index); - ::google::protobuf::Mixin* add_mixins(); ::google::protobuf::RepeatedPtrField< ::google::protobuf::Mixin >* mutable_mixins(); + const ::google::protobuf::Mixin& mixins(int index) const; + ::google::protobuf::Mixin* add_mixins(); const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Mixin >& mixins() const; @@ -216,8 +236,8 @@ class LIBPROTOBUF_EXPORT Api : public ::google::protobuf::Message /* @@protoc_in void clear_source_context(); static const int kSourceContextFieldNumber = 5; const ::google::protobuf::SourceContext& source_context() const; - ::google::protobuf::SourceContext* mutable_source_context(); ::google::protobuf::SourceContext* release_source_context(); + ::google::protobuf::SourceContext* mutable_source_context(); void set_allocated_source_context(::google::protobuf::SourceContext* source_context); // .google.protobuf.Syntax syntax = 7; @@ -238,7 +258,8 @@ class LIBPROTOBUF_EXPORT Api : public ::google::protobuf::Message /* @@protoc_in ::google::protobuf::SourceContext* source_context_; int syntax_; mutable int _cached_size_; - friend struct protobuf_google_2fprotobuf_2fapi_2eproto::TableStruct; + friend struct ::protobuf_google_2fprotobuf_2fapi_2eproto::TableStruct; + friend void ::protobuf_google_2fprotobuf_2fapi_2eproto::InitDefaultsApiImpl(); }; // ------------------------------------------------------------------- @@ -253,10 +274,25 @@ class LIBPROTOBUF_EXPORT Method : public ::google::protobuf::Message /* @@protoc CopyFrom(from); return *this; } + #if LANG_CXX11 + Method(Method&& from) noexcept + : Method() { + *this = ::std::move(from); + } + inline Method& operator=(Method&& from) noexcept { + if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + #endif static const ::google::protobuf::Descriptor* descriptor(); static const Method& default_instance(); + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY static inline const Method* internal_default_instance() { return reinterpret_cast<const Method*>( &_Method_default_instance_); @@ -265,12 +301,19 @@ class LIBPROTOBUF_EXPORT Method : public ::google::protobuf::Message /* @@protoc 1; void Swap(Method* other); + friend void swap(Method& a, Method& b) { + a.Swap(&b); + } // implements Message ---------------------------------------------- - inline Method* New() const PROTOBUF_FINAL { return New(NULL); } + inline Method* New() const PROTOBUF_FINAL { + return ::google::protobuf::Arena::Create<Method>(NULL); + } - Method* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + Method* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL { + return ::google::protobuf::Arena::Create<Method>(arena); + } void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const Method& from); @@ -310,11 +353,11 @@ class LIBPROTOBUF_EXPORT Method : public ::google::protobuf::Message /* @@protoc int options_size() const; void clear_options(); static const int kOptionsFieldNumber = 6; - const ::google::protobuf::Option& options(int index) const; ::google::protobuf::Option* mutable_options(int index); - ::google::protobuf::Option* add_options(); ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >* mutable_options(); + const ::google::protobuf::Option& options(int index) const; + ::google::protobuf::Option* add_options(); const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >& options() const; @@ -390,7 +433,8 @@ class LIBPROTOBUF_EXPORT Method : public ::google::protobuf::Message /* @@protoc bool response_streaming_; int syntax_; mutable int _cached_size_; - friend struct protobuf_google_2fprotobuf_2fapi_2eproto::TableStruct; + friend struct ::protobuf_google_2fprotobuf_2fapi_2eproto::TableStruct; + friend void ::protobuf_google_2fprotobuf_2fapi_2eproto::InitDefaultsMethodImpl(); }; // ------------------------------------------------------------------- @@ -405,10 +449,25 @@ class LIBPROTOBUF_EXPORT Mixin : public ::google::protobuf::Message /* @@protoc_ CopyFrom(from); return *this; } + #if LANG_CXX11 + Mixin(Mixin&& from) noexcept + : Mixin() { + *this = ::std::move(from); + } + inline Mixin& operator=(Mixin&& from) noexcept { + if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + #endif static const ::google::protobuf::Descriptor* descriptor(); static const Mixin& default_instance(); + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY static inline const Mixin* internal_default_instance() { return reinterpret_cast<const Mixin*>( &_Mixin_default_instance_); @@ -417,12 +476,19 @@ class LIBPROTOBUF_EXPORT Mixin : public ::google::protobuf::Message /* @@protoc_ 2; void Swap(Mixin* other); + friend void swap(Mixin& a, Mixin& b) { + a.Swap(&b); + } // implements Message ---------------------------------------------- - inline Mixin* New() const PROTOBUF_FINAL { return New(NULL); } + inline Mixin* New() const PROTOBUF_FINAL { + return ::google::protobuf::Arena::Create<Mixin>(NULL); + } - Mixin* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + Mixin* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL { + return ::google::protobuf::Arena::Create<Mixin>(arena); + } void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const Mixin& from); @@ -493,14 +559,18 @@ class LIBPROTOBUF_EXPORT Mixin : public ::google::protobuf::Message /* @@protoc_ ::google::protobuf::internal::ArenaStringPtr name_; ::google::protobuf::internal::ArenaStringPtr root_; mutable int _cached_size_; - friend struct protobuf_google_2fprotobuf_2fapi_2eproto::TableStruct; + friend struct ::protobuf_google_2fprotobuf_2fapi_2eproto::TableStruct; + friend void ::protobuf_google_2fprotobuf_2fapi_2eproto::InitDefaultsMixinImpl(); }; // =================================================================== // =================================================================== -#if !PROTOBUF_INLINE_NOT_IN_HEADERS +#ifdef __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif // __GNUC__ // Api // string name = 1; @@ -563,23 +633,23 @@ inline int Api::methods_size() const { inline void Api::clear_methods() { methods_.Clear(); } -inline const ::google::protobuf::Method& Api::methods(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.Api.methods) - return methods_.Get(index); -} inline ::google::protobuf::Method* Api::mutable_methods(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.Api.methods) return methods_.Mutable(index); } -inline ::google::protobuf::Method* Api::add_methods() { - // @@protoc_insertion_point(field_add:google.protobuf.Api.methods) - return methods_.Add(); -} inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::Method >* Api::mutable_methods() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.Api.methods) return &methods_; } +inline const ::google::protobuf::Method& Api::methods(int index) const { + // @@protoc_insertion_point(field_get:google.protobuf.Api.methods) + return methods_.Get(index); +} +inline ::google::protobuf::Method* Api::add_methods() { + // @@protoc_insertion_point(field_add:google.protobuf.Api.methods) + return methods_.Add(); +} inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Method >& Api::methods() const { // @@protoc_insertion_point(field_list:google.protobuf.Api.methods) @@ -590,26 +660,23 @@ Api::methods() const { inline int Api::options_size() const { return options_.size(); } -inline void Api::clear_options() { - options_.Clear(); -} -inline const ::google::protobuf::Option& Api::options(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.Api.options) - return options_.Get(index); -} inline ::google::protobuf::Option* Api::mutable_options(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.Api.options) return options_.Mutable(index); } -inline ::google::protobuf::Option* Api::add_options() { - // @@protoc_insertion_point(field_add:google.protobuf.Api.options) - return options_.Add(); -} inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >* Api::mutable_options() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.Api.options) return &options_; } +inline const ::google::protobuf::Option& Api::options(int index) const { + // @@protoc_insertion_point(field_get:google.protobuf.Api.options) + return options_.Get(index); +} +inline ::google::protobuf::Option* Api::add_options() { + // @@protoc_insertion_point(field_add:google.protobuf.Api.options) + return options_.Add(); +} inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >& Api::options() const { // @@protoc_insertion_point(field_list:google.protobuf.Api.options) @@ -673,22 +740,11 @@ inline void Api::set_allocated_version(::std::string* version) { inline bool Api::has_source_context() const { return this != internal_default_instance() && source_context_ != NULL; } -inline void Api::clear_source_context() { - if (GetArenaNoVirtual() == NULL && source_context_ != NULL) delete source_context_; - source_context_ = NULL; -} inline const ::google::protobuf::SourceContext& Api::source_context() const { + const ::google::protobuf::SourceContext* p = source_context_; // @@protoc_insertion_point(field_get:google.protobuf.Api.source_context) - return source_context_ != NULL ? *source_context_ - : *::google::protobuf::SourceContext::internal_default_instance(); -} -inline ::google::protobuf::SourceContext* Api::mutable_source_context() { - - if (source_context_ == NULL) { - source_context_ = new ::google::protobuf::SourceContext; - } - // @@protoc_insertion_point(field_mutable:google.protobuf.Api.source_context) - return source_context_; + return p != NULL ? *p : *reinterpret_cast<const ::google::protobuf::SourceContext*>( + &::google::protobuf::_SourceContext_default_instance_); } inline ::google::protobuf::SourceContext* Api::release_source_context() { // @@protoc_insertion_point(field_release:google.protobuf.Api.source_context) @@ -697,14 +753,31 @@ inline ::google::protobuf::SourceContext* Api::release_source_context() { source_context_ = NULL; return temp; } +inline ::google::protobuf::SourceContext* Api::mutable_source_context() { + + if (source_context_ == NULL) { + source_context_ = ::google::protobuf::Arena::Create< ::google::protobuf::SourceContext >( + GetArenaNoVirtual()); + } + // @@protoc_insertion_point(field_mutable:google.protobuf.Api.source_context) + return source_context_; +} inline void Api::set_allocated_source_context(::google::protobuf::SourceContext* source_context) { - delete source_context_; - source_context_ = source_context; + ::google::protobuf::Arena* message_arena = GetArenaNoVirtual(); + if (message_arena == NULL) { + delete reinterpret_cast< ::google::protobuf::MessageLite*>(source_context_); + } if (source_context) { + ::google::protobuf::Arena* submessage_arena = NULL; + if (message_arena != submessage_arena) { + source_context = ::google::protobuf::internal::GetOwnedMessage( + message_arena, source_context, submessage_arena); + } } else { } + source_context_ = source_context; // @@protoc_insertion_point(field_set_allocated:google.protobuf.Api.source_context) } @@ -715,23 +788,23 @@ inline int Api::mixins_size() const { inline void Api::clear_mixins() { mixins_.Clear(); } -inline const ::google::protobuf::Mixin& Api::mixins(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.Api.mixins) - return mixins_.Get(index); -} inline ::google::protobuf::Mixin* Api::mutable_mixins(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.Api.mixins) return mixins_.Mutable(index); } -inline ::google::protobuf::Mixin* Api::add_mixins() { - // @@protoc_insertion_point(field_add:google.protobuf.Api.mixins) - return mixins_.Add(); -} inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::Mixin >* Api::mutable_mixins() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.Api.mixins) return &mixins_; } +inline const ::google::protobuf::Mixin& Api::mixins(int index) const { + // @@protoc_insertion_point(field_get:google.protobuf.Api.mixins) + return mixins_.Get(index); +} +inline ::google::protobuf::Mixin* Api::add_mixins() { + // @@protoc_insertion_point(field_add:google.protobuf.Api.mixins) + return mixins_.Add(); +} inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Mixin >& Api::mixins() const { // @@protoc_insertion_point(field_list:google.protobuf.Api.mixins) @@ -947,26 +1020,23 @@ inline void Method::set_response_streaming(bool value) { inline int Method::options_size() const { return options_.size(); } -inline void Method::clear_options() { - options_.Clear(); -} -inline const ::google::protobuf::Option& Method::options(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.Method.options) - return options_.Get(index); -} inline ::google::protobuf::Option* Method::mutable_options(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.Method.options) return options_.Mutable(index); } -inline ::google::protobuf::Option* Method::add_options() { - // @@protoc_insertion_point(field_add:google.protobuf.Method.options) - return options_.Add(); -} inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >* Method::mutable_options() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.Method.options) return &options_; } +inline const ::google::protobuf::Option& Method::options(int index) const { + // @@protoc_insertion_point(field_get:google.protobuf.Method.options) + return options_.Get(index); +} +inline ::google::protobuf::Option* Method::add_options() { + // @@protoc_insertion_point(field_add:google.protobuf.Method.options) + return options_.Add(); +} inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >& Method::options() const { // @@protoc_insertion_point(field_list:google.protobuf.Method.options) @@ -1097,7 +1167,9 @@ inline void Mixin::set_allocated_root(::std::string* root) { // @@protoc_insertion_point(field_set_allocated:google.protobuf.Mixin.root) } -#endif // !PROTOBUF_INLINE_NOT_IN_HEADERS +#ifdef __GNUC__ + #pragma GCC diagnostic pop +#endif // __GNUC__ // ------------------------------------------------------------------- // ------------------------------------------------------------------- @@ -1105,10 +1177,9 @@ inline void Mixin::set_allocated_root(::std::string* root) { // @@protoc_insertion_point(namespace_scope) - } // namespace protobuf } // namespace google // @@protoc_insertion_point(global_scope) -#endif // PROTOBUF_google_2fprotobuf_2fapi_2eproto__INCLUDED +#endif // PROTOBUF_google_2fprotobuf_2fapi_2eproto_INCLUDED diff --git a/src/google/protobuf/api.proto b/src/google/protobuf/api.proto index 7c30e8b7..f37ee2fa 100644 --- a/src/google/protobuf/api.proto +++ b/src/google/protobuf/api.proto @@ -42,26 +42,33 @@ option java_multiple_files = true; option objc_class_prefix = "GPB"; option go_package = "google.golang.org/genproto/protobuf/api;api"; -// Api is a light-weight descriptor for a protocol buffer service. +// Api is a light-weight descriptor for an API Interface. +// +// Interfaces are also described as "protocol buffer services" in some contexts, +// such as by the "service" keyword in a .proto file, but they are different +// from API Services, which represent a concrete implementation of an interface +// as opposed to simply a description of methods and bindings. They are also +// sometimes simply referred to as "APIs" in other contexts, such as the name of +// this message itself. See https://cloud.google.com/apis/design/glossary for +// detailed terminology. message Api { - // The fully qualified name of this api, including package name - // followed by the api's simple name. + // The fully qualified name of this interface, including package name + // followed by the interface's simple name. string name = 1; - // The methods of this api, in unspecified order. + // The methods of this interface, in unspecified order. repeated Method methods = 2; - // Any metadata attached to the API. + // Any metadata attached to the interface. repeated Option options = 3; - // A version string for this api. If specified, must have the form - // `major-version.minor-version`, as in `1.10`. If the minor version - // is omitted, it defaults to zero. If the entire version field is - // empty, the major version is derived from the package name, as - // outlined below. If the field is not empty, the version in the - // package name will be verified to be consistent with what is - // provided here. + // A version string for this interface. If specified, must have the form + // `major-version.minor-version`, as in `1.10`. If the minor version is + // omitted, it defaults to zero. If the entire version field is empty, the + // major version is derived from the package name, as outlined below. If the + // field is not empty, the version in the package name will be verified to be + // consistent with what is provided here. // // The versioning schema uses [semantic // versioning](http://semver.org) where the major version number @@ -71,10 +78,10 @@ message Api { // chosen based on the product plan. // // The major version is also reflected in the package name of the - // API, which must end in `v<major-version>`, as in + // interface, which must end in `v<major-version>`, as in // `google.feature.v1`. For major versions 0 and 1, the suffix can // be omitted. Zero major versions must only be used for - // experimental, none-GA apis. + // experimental, non-GA interfaces. // // string version = 4; @@ -83,14 +90,14 @@ message Api { // message. SourceContext source_context = 5; - // Included APIs. See [Mixin][]. + // Included interfaces. See [Mixin][]. repeated Mixin mixins = 6; // The source syntax of the service. Syntax syntax = 7; } -// Method represents a method of an api. +// Method represents a method of an API interface. message Method { // The simple name of this method. @@ -115,9 +122,9 @@ message Method { Syntax syntax = 7; } -// Declares an API to be included in this API. The including API must -// redeclare all the methods from the included API, but documentation -// and options are inherited as follows: +// Declares an API Interface to be included in this interface. The including +// interface must redeclare all the methods from the included interface, but +// documentation and options are inherited as follows: // // - If after comment and whitespace stripping, the documentation // string of the redeclared method is empty, it will be inherited @@ -129,7 +136,8 @@ message Method { // // - If an http annotation is inherited, the path pattern will be // modified as follows. Any version prefix will be replaced by the -// version of the including API plus the [root][] path if specified. +// version of the including interface plus the [root][] path if +// specified. // // Example of a simple mixin: // @@ -193,7 +201,7 @@ message Method { // ... // } message Mixin { - // The fully qualified name of the API which is included. + // The fully qualified name of the interface which is included. string name = 1; // If non-empty specifies a path under which inherited HTTP paths diff --git a/src/google/protobuf/arena.cc b/src/google/protobuf/arena.cc index 16cf8951..e53d7219 100755 --- a/src/google/protobuf/arena.cc +++ b/src/google/protobuf/arena.cc @@ -38,277 +38,382 @@ #include <sanitizer/asan_interface.h> #endif // ADDRESS_SANITIZER +#include <google/protobuf/stubs/port.h> + namespace google { +static const size_t kMinCleanupListElements = 8; +static const size_t kMaxCleanupListElements = 64; // 1kB on 64-bit. + namespace protobuf { +namespace internal { -google::protobuf::internal::SequenceNumber Arena::lifecycle_id_generator_; +google::protobuf::internal::SequenceNumber ArenaImpl::lifecycle_id_generator_; #if defined(GOOGLE_PROTOBUF_NO_THREADLOCAL) -Arena::ThreadCache& Arena::thread_cache() { +ArenaImpl::ThreadCache& ArenaImpl::thread_cache() { static internal::ThreadLocalStorage<ThreadCache>* thread_cache_ = new internal::ThreadLocalStorage<ThreadCache>(); return *thread_cache_->Get(); } #elif defined(PROTOBUF_USE_DLLS) -Arena::ThreadCache& Arena::thread_cache() { +ArenaImpl::ThreadCache& ArenaImpl::thread_cache() { static GOOGLE_THREAD_LOCAL ThreadCache thread_cache_ = { -1, NULL }; return thread_cache_; } #else -GOOGLE_THREAD_LOCAL Arena::ThreadCache Arena::thread_cache_ = { -1, NULL }; +GOOGLE_THREAD_LOCAL ArenaImpl::ThreadCache ArenaImpl::thread_cache_ = {-1, NULL}; #endif -void Arena::Init() { +void ArenaImpl::Init() { lifecycle_id_ = lifecycle_id_generator_.GetNext(); - blocks_ = 0; - hint_ = 0; - space_allocated_ = 0; - owns_first_block_ = true; - cleanup_list_ = 0; - - if (options_.initial_block != NULL && options_.initial_block_size > 0) { - GOOGLE_CHECK_GE(options_.initial_block_size, sizeof(Block)) - << ": Initial block size too small for header."; - - // Add first unowned block to list. - Block* first_block = reinterpret_cast<Block*>(options_.initial_block); - first_block->size = options_.initial_block_size; - first_block->pos = kHeaderSize; - first_block->next = NULL; - // Thread which calls Init() owns the first block. This allows the - // single-threaded case to allocate on the first block without taking any - // locks. - first_block->owner = &thread_cache(); - SetThreadCacheBlock(first_block); - AddBlockInternal(first_block); - owns_first_block_ = false; - } + google::protobuf::internal::NoBarrier_Store(&hint_, 0); + google::protobuf::internal::NoBarrier_Store(&threads_, 0); - // Call the initialization hook - if (options_.on_arena_init != NULL) { - hooks_cookie_ = options_.on_arena_init(this); + if (initial_block_) { + // Thread which calls Init() owns the first block. This allows the + // single-threaded case to allocate on the first block without having to + // perform atomic operations. + new (initial_block_) Block(options_.initial_block_size, NULL); + SerialArena* serial = + SerialArena::New(initial_block_, &thread_cache(), this); + serial->set_next(NULL); + google::protobuf::internal::NoBarrier_Store(&threads_, + reinterpret_cast<google::protobuf::internal::AtomicWord>(serial)); + google::protobuf::internal::NoBarrier_Store(&space_allocated_, + options_.initial_block_size); + CacheSerialArena(serial); } else { - hooks_cookie_ = NULL; + google::protobuf::internal::NoBarrier_Store(&space_allocated_, 0); } } -Arena::~Arena() { - uint64 space_allocated = ResetInternal(); - - // Call the destruction hook - if (options_.on_arena_destruction != NULL) { - options_.on_arena_destruction(this, hooks_cookie_, space_allocated); - } -} - -uint64 Arena::Reset() { - // Invalidate any ThreadCaches pointing to any blocks we just destroyed. - lifecycle_id_ = lifecycle_id_generator_.GetNext(); - return ResetInternal(); +ArenaImpl::~ArenaImpl() { + // Have to do this in a first pass, because some of the destructors might + // refer to memory in other blocks. + CleanupList(); + FreeBlocks(); } -uint64 Arena::ResetInternal() { +uint64 ArenaImpl::Reset() { + // Have to do this in a first pass, because some of the destructors might + // refer to memory in other blocks. CleanupList(); uint64 space_allocated = FreeBlocks(); - - // Call the reset hook - if (options_.on_arena_reset != NULL) { - options_.on_arena_reset(this, hooks_cookie_, space_allocated); - } + Init(); return space_allocated; } -Arena::Block* Arena::NewBlock(void* me, Block* my_last_block, size_t n, - size_t start_block_size, size_t max_block_size) { +ArenaImpl::Block* ArenaImpl::NewBlock(Block* last_block, size_t min_bytes) { size_t size; - if (my_last_block != NULL) { + if (last_block) { // Double the current block size, up to a limit. - size = 2 * (my_last_block->size); - if (size > max_block_size) size = max_block_size; + size = std::min(2 * last_block->size(), options_.max_block_size); } else { - size = start_block_size; + size = options_.start_block_size; } - // Verify that n + kHeaderSize won't overflow. - GOOGLE_CHECK_LE(n, std::numeric_limits<size_t>::max() - kHeaderSize); - size = std::max(size, kHeaderSize + n); - - Block* b = reinterpret_cast<Block*>(options_.block_alloc(size)); - b->pos = kHeaderSize + n; - b->size = size; - b->owner = me; -#ifdef ADDRESS_SANITIZER - // Poison the rest of the block for ASAN. It was unpoisoned by the underlying - // malloc but it's not yet usable until we return it as part of an allocation. - ASAN_POISON_MEMORY_REGION( - reinterpret_cast<char*>(b) + b->pos, b->size - b->pos); -#endif // ADDRESS_SANITIZER + // Verify that min_bytes + kBlockHeaderSize won't overflow. + GOOGLE_CHECK_LE(min_bytes, std::numeric_limits<size_t>::max() - kBlockHeaderSize); + size = std::max(size, kBlockHeaderSize + min_bytes); + + void* mem = options_.block_alloc(size); + Block* b = new (mem) Block(size, last_block); + google::protobuf::internal::NoBarrier_AtomicIncrement(&space_allocated_, size); return b; } -void Arena::AddBlock(Block* b) { - MutexLock l(&blocks_lock_); - AddBlockInternal(b); +ArenaImpl::Block::Block(size_t size, Block* next) + : next_(next), pos_(kBlockHeaderSize), size_(size) {} + +GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE +void ArenaImpl::SerialArena::AddCleanupFallback(void* elem, + void (*cleanup)(void*)) { + size_t size = cleanup_ ? cleanup_->size * 2 : kMinCleanupListElements; + size = std::min(size, kMaxCleanupListElements); + size_t bytes = internal::AlignUpTo8(CleanupChunk::SizeOf(size)); + CleanupChunk* list = reinterpret_cast<CleanupChunk*>(AllocateAligned(bytes)); + list->next = cleanup_; + list->size = size; + + cleanup_ = list; + cleanup_ptr_ = &list->nodes[0]; + cleanup_limit_ = &list->nodes[size]; + + AddCleanup(elem, cleanup); +} + +void* ArenaImpl::AllocateAligned(size_t n) { + SerialArena* arena; + if (GOOGLE_PREDICT_TRUE(GetSerialArenaFast(&arena))) { + return arena->AllocateAligned(n); + } else { + return AllocateAlignedFallback(n); + } } -void Arena::AddBlockInternal(Block* b) { - b->next = reinterpret_cast<Block*>(google::protobuf::internal::NoBarrier_Load(&blocks_)); - google::protobuf::internal::Release_Store(&blocks_, reinterpret_cast<google::protobuf::internal::AtomicWord>(b)); - if (b->avail() != 0) { - // Direct future allocations to this block. - google::protobuf::internal::Release_Store(&hint_, reinterpret_cast<google::protobuf::internal::AtomicWord>(b)); +void* ArenaImpl::AllocateAlignedAndAddCleanup(size_t n, + void (*cleanup)(void*)) { + SerialArena* arena; + if (GOOGLE_PREDICT_TRUE(GetSerialArenaFast(&arena))) { + return arena->AllocateAlignedAndAddCleanup(n, cleanup); + } else { + return AllocateAlignedAndAddCleanupFallback(n, cleanup); } - space_allocated_ += b->size; } -void Arena::AddListNode(void* elem, void (*cleanup)(void*)) { - Node* node = reinterpret_cast<Node*>(AllocateAligned(sizeof(Node))); - node->elem = elem; - node->cleanup = cleanup; - node->next = reinterpret_cast<Node*>( - google::protobuf::internal::NoBarrier_AtomicExchange(&cleanup_list_, - reinterpret_cast<google::protobuf::internal::AtomicWord>(node))); +void ArenaImpl::AddCleanup(void* elem, void (*cleanup)(void*)) { + SerialArena* arena; + if (GOOGLE_PREDICT_TRUE(GetSerialArenaFast(&arena))) { + arena->AddCleanup(elem, cleanup); + } else { + return AddCleanupFallback(elem, cleanup); + } } -void* Arena::AllocateAligned(const std::type_info* allocated, size_t n) { - // Align n to next multiple of 8 (from Hacker's Delight, Chapter 3.) - n = (n + 7) & -8; +GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE +void* ArenaImpl::AllocateAlignedFallback(size_t n) { + return GetSerialArena()->AllocateAligned(n); +} - // Monitor allocation if needed. - if (GOOGLE_PREDICT_FALSE(hooks_cookie_ != NULL) && - options_.on_arena_allocation != NULL) { - options_.on_arena_allocation(allocated, n, hooks_cookie_); - } +GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE +void* ArenaImpl::AllocateAlignedAndAddCleanupFallback(size_t n, + void (*cleanup)(void*)) { + return GetSerialArena()->AllocateAlignedAndAddCleanup(n, cleanup); +} + +GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE +void ArenaImpl::AddCleanupFallback(void* elem, void (*cleanup)(void*)) { + GetSerialArena()->AddCleanup(elem, cleanup); +} +inline GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE +bool ArenaImpl::GetSerialArenaFast(ArenaImpl::SerialArena** arena) { // If this thread already owns a block in this arena then try to use that. // This fast path optimizes the case where multiple threads allocate from the // same arena. - if (thread_cache().last_lifecycle_id_seen == lifecycle_id_ && - thread_cache().last_block_used_ != NULL) { - if (thread_cache().last_block_used_->avail() < n) { - return SlowAlloc(n); - } - return AllocFromBlock(thread_cache().last_block_used_, n); + ThreadCache* tc = &thread_cache(); + if (GOOGLE_PREDICT_TRUE(tc->last_lifecycle_id_seen == lifecycle_id_)) { + *arena = tc->last_serial_arena; + return true; + } + + // Check whether we own the last accessed SerialArena on this arena. This + // fast path optimizes the case where a single thread uses multiple arenas. + SerialArena* serial = + reinterpret_cast<SerialArena*>(google::protobuf::internal::Acquire_Load(&hint_)); + if (GOOGLE_PREDICT_TRUE(serial != NULL && serial->owner() == tc)) { + *arena = serial; + return true; } - // Check whether we own the last accessed block on this arena. - // This fast path optimizes the case where a single thread uses multiple - // arenas. - void* me = &thread_cache(); - Block* b = reinterpret_cast<Block*>(google::protobuf::internal::Acquire_Load(&hint_)); - if (!b || b->owner != me || b->avail() < n) { - return SlowAlloc(n); + return false; +} + +ArenaImpl::SerialArena* ArenaImpl::GetSerialArena() { + SerialArena* arena; + if (GOOGLE_PREDICT_TRUE(GetSerialArenaFast(&arena))) { + return arena; + } else { + return GetSerialArenaFallback(&thread_cache()); } - return AllocFromBlock(b, n); } -void* Arena::AllocFromBlock(Block* b, size_t n) { - size_t p = b->pos; - b->pos = p + n; +GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE +void* ArenaImpl::SerialArena::AllocateAlignedFallback(size_t n) { + // Sync back to current's pos. + head_->set_pos(head_->size() - (limit_ - ptr_)); + + head_ = arena_->NewBlock(head_, n); + ptr_ = head_->Pointer(head_->pos()); + limit_ = head_->Pointer(head_->size()); + #ifdef ADDRESS_SANITIZER - ASAN_UNPOISON_MEMORY_REGION(reinterpret_cast<char*>(b) + p, n); + ASAN_POISON_MEMORY_REGION(ptr_, limit_ - ptr_); #endif // ADDRESS_SANITIZER - return reinterpret_cast<char*>(b) + p; -} -void* Arena::SlowAlloc(size_t n) { - void* me = &thread_cache(); - Block* b = FindBlock(me); // Find block owned by me. - // See if allocation fits in my latest block. - if (b != NULL && b->avail() >= n) { - SetThreadCacheBlock(b); - google::protobuf::internal::NoBarrier_Store(&hint_, reinterpret_cast<google::protobuf::internal::AtomicWord>(b)); - return AllocFromBlock(b, n); - } - b = NewBlock(me, b, n, options_.start_block_size, options_.max_block_size); - AddBlock(b); - SetThreadCacheBlock(b); - return reinterpret_cast<char*>(b) + kHeaderSize; + return AllocateAligned(n); } -uint64 Arena::SpaceAllocated() const { - MutexLock l(&blocks_lock_); - return space_allocated_; +uint64 ArenaImpl::SpaceAllocated() const { + return google::protobuf::internal::NoBarrier_Load(&space_allocated_); } -uint64 Arena::SpaceUsed() const { +uint64 ArenaImpl::SpaceUsed() const { + SerialArena* serial = + reinterpret_cast<SerialArena*>(google::protobuf::internal::Acquire_Load(&threads_)); uint64 space_used = 0; - Block* b = reinterpret_cast<Block*>(google::protobuf::internal::NoBarrier_Load(&blocks_)); - while (b != NULL) { - space_used += (b->pos - kHeaderSize); - b = b->next; + for ( ; serial; serial = serial->next()) { + space_used += serial->SpaceUsed(); + } + return space_used; +} + +uint64 ArenaImpl::SerialArena::SpaceUsed() const { + // Get current block's size from ptr_ (since we can't trust head_->pos(). + uint64 space_used = ptr_ - head_->Pointer(kBlockHeaderSize); + // Get subsequent block size from b->pos(). + for (Block* b = head_->next(); b; b = b->next()) { + space_used += (b->pos() - kBlockHeaderSize); } + // Remove the overhead of the SerialArena itself. + space_used -= kSerialArenaSize; return space_used; } -std::pair<uint64, uint64> Arena::SpaceAllocatedAndUsed() const { - return std::make_pair(SpaceAllocated(), SpaceUsed()); +uint64 ArenaImpl::FreeBlocks() { + uint64 space_allocated = 0; + // By omitting an Acquire barrier we ensure that any user code that doesn't + // properly synchronize Reset() or the destructor will throw a TSAN warning. + SerialArena* serial = + reinterpret_cast<SerialArena*>(google::protobuf::internal::NoBarrier_Load(&threads_)); + + while (serial) { + // This is inside a block we are freeing, so we need to read it now. + SerialArena* next = serial->next(); + space_allocated += ArenaImpl::SerialArena::Free(serial, initial_block_, + options_.block_dealloc); + // serial is dead now. + serial = next; + } + + return space_allocated; } -uint64 Arena::FreeBlocks() { +uint64 ArenaImpl::SerialArena::Free(ArenaImpl::SerialArena* serial, + Block* initial_block, + void (*block_dealloc)(void*, size_t)) { uint64 space_allocated = 0; - Block* b = reinterpret_cast<Block*>(google::protobuf::internal::NoBarrier_Load(&blocks_)); - Block* first_block = NULL; - while (b != NULL) { - space_allocated += (b->size); - Block* next = b->next; - if (next != NULL) { -#ifdef ADDRESS_SANITIZER - // This memory was provided by the underlying allocator as unpoisoned, so - // return it in an unpoisoned state. - ASAN_UNPOISON_MEMORY_REGION(reinterpret_cast<char*>(b), b->size); -#endif // ADDRESS_SANITIZER - options_.block_dealloc(b, b->size); - } else { - if (owns_first_block_) { + + // We have to be careful in this function, since we will be freeing the Block + // that contains this SerialArena. Be careful about accessing |serial|. + + for (Block* b = serial->head_; b; ) { + // This is inside the block we are freeing, so we need to read it now. + Block* next_block = b->next(); + space_allocated += (b->size()); + #ifdef ADDRESS_SANITIZER - // This memory was provided by the underlying allocator as unpoisoned, - // so return it in an unpoisoned state. - ASAN_UNPOISON_MEMORY_REGION(reinterpret_cast<char*>(b), b->size); + // This memory was provided by the underlying allocator as unpoisoned, so + // return it in an unpoisoned state. + ASAN_UNPOISON_MEMORY_REGION(b->Pointer(0), b->size()); #endif // ADDRESS_SANITIZER - options_.block_dealloc(b, b->size); - } else { - // User passed in the first block, skip free'ing the memory. - first_block = b; - } + + if (b != initial_block) { + block_dealloc(b, b->size()); } - b = next; - } - blocks_ = 0; - hint_ = 0; - space_allocated_ = 0; - if (!owns_first_block_) { - // Make the first block that was passed in through ArenaOptions - // available for reuse. - first_block->pos = kHeaderSize; - // Thread which calls Reset() owns the first block. This allows the - // single-threaded case to allocate on the first block without taking any - // locks. - first_block->owner = &thread_cache(); - SetThreadCacheBlock(first_block); - AddBlockInternal(first_block); + + b = next_block; } + return space_allocated; } -void Arena::CleanupList() { - Node* head = - reinterpret_cast<Node*>(google::protobuf::internal::NoBarrier_Load(&cleanup_list_)); - while (head != NULL) { - head->cleanup(head->elem); - head = head->next; +void ArenaImpl::CleanupList() { + // By omitting an Acquire barrier we ensure that any user code that doesn't + // properly synchronize Reset() or the destructor will throw a TSAN warning. + SerialArena* serial = + reinterpret_cast<SerialArena*>(google::protobuf::internal::NoBarrier_Load(&threads_)); + + for ( ; serial; serial = serial->next()) { + serial->CleanupList(); } - cleanup_list_ = 0; } -Arena::Block* Arena::FindBlock(void* me) { - // TODO(sanjay): We might want to keep a separate list with one - // entry per thread. - Block* b = reinterpret_cast<Block*>(google::protobuf::internal::Acquire_Load(&blocks_)); - while (b != NULL && b->owner != me) { - b = b->next; +void ArenaImpl::SerialArena::CleanupList() { + if (cleanup_ != NULL) { + CleanupListFallback(); + } +} + +void ArenaImpl::SerialArena::CleanupListFallback() { + // Cleanup newest chunk: ptrs give us length. + size_t n = cleanup_ptr_ - &cleanup_->nodes[0]; + CleanupNode* node = cleanup_ptr_; + for (size_t i = 0; i < n; i++) { + --node; + node->cleanup(node->elem); + } + + // Cleanup older chunks, which are known to be full. + CleanupChunk* list = cleanup_->next; + while (list) { + size_t n = list->size; + CleanupNode* node = &list->nodes[list->size]; + for (size_t i = 0; i < n; i++) { + --node; + node->cleanup(node->elem); + } + list = list->next; + } +} + +ArenaImpl::SerialArena* ArenaImpl::SerialArena::New(Block* b, void* owner, + ArenaImpl* arena) { + GOOGLE_DCHECK_EQ(b->pos(), kBlockHeaderSize); // Should be a fresh block + GOOGLE_DCHECK_LE(kBlockHeaderSize + kSerialArenaSize, b->size()); + SerialArena* serial = + reinterpret_cast<SerialArena*>(b->Pointer(kBlockHeaderSize)); + b->set_pos(kBlockHeaderSize + kSerialArenaSize); + serial->arena_ = arena; + serial->owner_ = owner; + serial->head_ = b; + serial->ptr_ = b->Pointer(b->pos()); + serial->limit_ = b->Pointer(b->size()); + serial->cleanup_ = NULL; + serial->cleanup_ptr_ = NULL; + serial->cleanup_limit_ = NULL; + return serial; +} + +GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE +ArenaImpl::SerialArena* ArenaImpl::GetSerialArenaFallback(void* me) { + // Look for this SerialArena in our linked list. + SerialArena* serial = + reinterpret_cast<SerialArena*>(google::protobuf::internal::Acquire_Load(&threads_)); + for ( ; serial; serial = serial->next()) { + if (serial->owner() == me) { + break; + } + } + + if (!serial) { + // This thread doesn't have any SerialArena, which also means it doesn't + // have any blocks yet. So we'll allocate its first block now. + Block* b = NewBlock(NULL, kSerialArenaSize); + serial = SerialArena::New(b, me, this); + + google::protobuf::internal::AtomicWord head; + do { + head = google::protobuf::internal::NoBarrier_Load(&threads_); + serial->set_next(reinterpret_cast<SerialArena*>(head)); + } while (google::protobuf::internal::Release_CompareAndSwap( + &threads_, head, reinterpret_cast<google::protobuf::internal::AtomicWord>(serial)) != head); + } + + CacheSerialArena(serial); + return serial; +} + +} // namespace internal + +void Arena::CallDestructorHooks() { + uint64 space_allocated = impl_.SpaceAllocated(); + // Call the reset hook + if (on_arena_reset_ != NULL) { + on_arena_reset_(this, hooks_cookie_, space_allocated); + } + + // Call the destruction hook + if (on_arena_destruction_ != NULL) { + on_arena_destruction_(this, hooks_cookie_, space_allocated); + } +} + +void Arena::OnArenaAllocation(const std::type_info* allocated_type, + size_t n) const { + if (on_arena_allocation_ != NULL) { + on_arena_allocation_(allocated_type, n, hooks_cookie_); } - return b; } } // namespace protobuf diff --git a/src/google/protobuf/arena.h b/src/google/protobuf/arena.h index 0ffc6004..f3cdedac 100644 --- a/src/google/protobuf/arena.h +++ b/src/google/protobuf/arena.h @@ -37,7 +37,7 @@ #ifdef max #undef max // Visual Studio defines this macro #endif -#if __cplusplus >= 201103L +#if LANG_CXX11 #include <google/protobuf/stubs/type_traits.h> #endif #if defined(_MSC_VER) && !_HAS_EXCEPTIONS @@ -51,22 +51,32 @@ using type_info = ::type_info; #include <typeinfo> #endif -#include <google/protobuf/stubs/atomic_sequence_num.h> -#include <google/protobuf/stubs/atomicops.h> -#include <google/protobuf/stubs/common.h> -#include <google/protobuf/stubs/logging.h> -#include <google/protobuf/stubs/mutex.h> -#include <google/protobuf/stubs/type_traits.h> - +#include <google/protobuf/arena_impl.h> +#include <google/protobuf/stubs/port.h> namespace google { namespace protobuf { +struct ArenaOptions; +} // namespace protobuf + +namespace quality_webanswers { + +void TempPrivateWorkAround(::google::protobuf::ArenaOptions* arena_options); + +} // namespace quality_webanswers + +namespace protobuf { +namespace arena_metrics { + +void EnableArenaMetrics(::google::protobuf::ArenaOptions* options); + +} // namespace arena_metrics class Arena; // defined below class Message; // message.h namespace internal { -class ArenaString; // arenastring.h +struct ArenaStringPtr; // arenastring.h class LazyField; // lazy_field.h template<typename Type> @@ -123,6 +133,19 @@ struct ArenaOptions { // calls free. void (*block_dealloc)(void*, size_t); + ArenaOptions() + : start_block_size(kDefaultStartBlockSize), + max_block_size(kDefaultMaxBlockSize), + initial_block(NULL), + initial_block_size(0), + block_alloc(&::operator new), + block_dealloc(&internal::arena_free), + on_arena_init(NULL), + on_arena_reset(NULL), + on_arena_destruction(NULL), + on_arena_allocation(NULL) {} + + private: // Hooks for adding external functionality such as user-specific metrics // collection, specific debugging abilities, etc. // Init hook may return a pointer to a cookie to be stored in the arena. @@ -144,23 +167,15 @@ struct ArenaOptions { void (*on_arena_allocation)(const std::type_info* allocated_type, uint64 alloc_size, void* cookie); - ArenaOptions() - : start_block_size(kDefaultStartBlockSize), - max_block_size(kDefaultMaxBlockSize), - initial_block(NULL), - initial_block_size(0), - block_alloc(&::operator new), - block_dealloc(&internal::arena_free), - on_arena_init(NULL), - on_arena_reset(NULL), - on_arena_destruction(NULL), - on_arena_allocation(NULL) {} - - private: // Constants define default starting block size and max block size for // arena allocator behavior -- see descriptions above. static const size_t kDefaultStartBlockSize = 256; static const size_t kDefaultMaxBlockSize = 8192; + + friend void ::google::protobuf::arena_metrics::EnableArenaMetrics(ArenaOptions*); + friend void quality_webanswers::TempPrivateWorkAround(ArenaOptions*); + friend class Arena; + friend class ArenaOptionsTestFriend; }; // Support for non-RTTI environments. (The metrics hooks API uses type @@ -225,21 +240,40 @@ class LIBPROTOBUF_EXPORT Arena { public: // Arena constructor taking custom options. See ArenaOptions below for // descriptions of the options available. - explicit Arena(const ArenaOptions& options) : options_(options) { - Init(); + explicit Arena(const ArenaOptions& options) : impl_(options) { + Init(options); } + // Block overhead. Use this as a guide for how much to over-allocate the + // initial block if you want an allocation of size N to fit inside it. + // + // WARNING: if you allocate multiple objects, it is difficult to guarantee + // that a series of allocations will fit in the initial block, especially if + // Arena changes its alignment guarantees in the future! + static const size_t kBlockOverhead = internal::ArenaImpl::kBlockHeaderSize + + internal::ArenaImpl::kSerialArenaSize; + // Default constructor with sensible default options, tuned for average // use-cases. - Arena() { - Init(); + Arena() : impl_(ArenaOptions()) { Init(ArenaOptions()); } + + ~Arena() { + if (hooks_cookie_) { + CallDestructorHooks(); + } } - // Destructor deletes all owned heap allocated objects, and destructs objects - // that have non-trivial destructors, except for proto2 message objects whose - // destructors can be skipped. Also, frees all blocks except the initial block - // if it was passed in. - ~Arena(); + void Init(const ArenaOptions& options) { + on_arena_allocation_ = options.on_arena_allocation; + on_arena_reset_ = options.on_arena_reset; + on_arena_destruction_ = options.on_arena_destruction; + // Call the initialization hook + if (options.on_arena_init != NULL) { + hooks_cookie_ = options.on_arena_init(this); + } else { + hooks_cookie_ = NULL; + } + } // API to create proto2 message objects on the arena. If the arena passed in // is NULL, then a heap allocated object is returned. Type T must be a message @@ -251,40 +285,69 @@ class LIBPROTOBUF_EXPORT Arena { // // This function also accepts any type T that satisfies the arena message // allocation protocol, documented above. - template <typename T> GOOGLE_ATTRIBUTE_ALWAYS_INLINE +#if LANG_CXX11 + template <typename T, typename... Args> + GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE static T* CreateMessage( + ::google::protobuf::Arena* arena, Args&&... args) { + static_assert( + InternalHelper<T>::is_arena_constructable::value, + "CreateMessage can only construct types that are ArenaConstructable"); + if (arena == NULL) { + return new T(NULL, std::forward<Args>(args)...); + } else { + return arena->CreateMessageInternal<T>(std::forward<Args>(args)...); + } + } +#endif + + template <typename T> GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE static T* CreateMessage(::google::protobuf::Arena* arena) { +#if LANG_CXX11 + static_assert( + InternalHelper<T>::is_arena_constructable::value, + "CreateMessage can only construct types that are ArenaConstructable"); +#endif if (arena == NULL) { return new T; } else { - return arena->CreateMessageInternal<T>(static_cast<T*>(0)); + return arena->CreateMessageInternal<T>(); } } // One-argument form of CreateMessage. This is useful for constructing objects // that implement the arena message construction protocol described above but // take additional constructor arguments. - template <typename T, typename Arg> GOOGLE_ATTRIBUTE_ALWAYS_INLINE + template <typename T, typename Arg> GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE static T* CreateMessage(::google::protobuf::Arena* arena, const Arg& arg) { +#if LANG_CXX11 + static_assert( + InternalHelper<T>::is_arena_constructable::value, + "CreateMessage can only construct types that are ArenaConstructable"); +#endif if (arena == NULL) { return new T(NULL, arg); } else { - return arena->CreateMessageInternal<T>(static_cast<T*>(0), - arg); + return arena->CreateMessageInternal<T>(arg); } } // Two-argument form of CreateMessage. This is useful for constructing objects // that implement the arena message construction protocol described above but // take additional constructor arguments. - template <typename T, typename Arg1, typename Arg2> GOOGLE_ATTRIBUTE_ALWAYS_INLINE + template <typename T, typename Arg1, typename Arg2> + GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE static T* CreateMessage(::google::protobuf::Arena* arena, const Arg1& arg1, const Arg2& arg2) { +#if LANG_CXX11 + static_assert( + InternalHelper<T>::is_arena_constructable::value, + "CreateMessage can only construct types that are ArenaConstructable"); +#endif if (arena == NULL) { return new T(NULL, arg1, arg2); } else { - return arena->CreateMessageInternal<T>(static_cast<T*>(0), - arg1, arg2); + return arena->CreateMessageInternal<T>(arg1, arg2); } } @@ -304,7 +367,8 @@ class LIBPROTOBUF_EXPORT Arena { // if the object were allocated on the heap (except that the underlying memory // is obtained from the arena). #if LANG_CXX11 - template <typename T, typename... Args> GOOGLE_ATTRIBUTE_ALWAYS_INLINE + template <typename T, typename... Args> + GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE static T* Create(::google::protobuf::Arena* arena, Args&&... args) { if (arena == NULL) { return new T(std::forward<Args>(args)...); @@ -314,7 +378,8 @@ class LIBPROTOBUF_EXPORT Arena { } } #endif - template <typename T> GOOGLE_ATTRIBUTE_ALWAYS_INLINE + + template <typename T> GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE static T* Create(::google::protobuf::Arena* arena) { if (arena == NULL) { return new T(); @@ -324,7 +389,7 @@ class LIBPROTOBUF_EXPORT Arena { } // Version of the above with one constructor argument for the created object. - template <typename T, typename Arg> GOOGLE_ATTRIBUTE_ALWAYS_INLINE + template <typename T, typename Arg> GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE static T* Create(::google::protobuf::Arena* arena, const Arg& arg) { if (arena == NULL) { return new T(arg); @@ -335,7 +400,8 @@ class LIBPROTOBUF_EXPORT Arena { } // Version of the above with two constructor arguments for the created object. - template <typename T, typename Arg1, typename Arg2> GOOGLE_ATTRIBUTE_ALWAYS_INLINE + template <typename T, typename Arg1, typename Arg2> + GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE static T* Create(::google::protobuf::Arena* arena, const Arg1& arg1, const Arg2& arg2) { if (arena == NULL) { return new T(arg1, arg2); @@ -348,9 +414,11 @@ class LIBPROTOBUF_EXPORT Arena { // Version of the above with three constructor arguments for the created // object. template <typename T, typename Arg1, typename Arg2, typename Arg3> - GOOGLE_ATTRIBUTE_ALWAYS_INLINE static T* Create(::google::protobuf::Arena* arena, - const Arg1& arg1, const Arg2& arg2, - const Arg3& arg3) { + GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE + static T* Create(::google::protobuf::Arena* arena, + const Arg1& arg1, + const Arg2& arg2, + const Arg3& arg3) { if (arena == NULL) { return new T(arg1, arg2, arg3); } else { @@ -363,9 +431,10 @@ class LIBPROTOBUF_EXPORT Arena { // object. template <typename T, typename Arg1, typename Arg2, typename Arg3, typename Arg4> - GOOGLE_ATTRIBUTE_ALWAYS_INLINE static T* Create(::google::protobuf::Arena* arena, - const Arg1& arg1, const Arg2& arg2, - const Arg3& arg3, const Arg4& arg4) { + GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE + static T* Create(::google::protobuf::Arena* arena, + const Arg1& arg1, const Arg2& arg2, + const Arg3& arg3, const Arg4& arg4) { if (arena == NULL) { return new T(arg1, arg2, arg3, arg4); } else { @@ -378,10 +447,11 @@ class LIBPROTOBUF_EXPORT Arena { // object. template <typename T, typename Arg1, typename Arg2, typename Arg3, typename Arg4, typename Arg5> - GOOGLE_ATTRIBUTE_ALWAYS_INLINE static T* Create(::google::protobuf::Arena* arena, - const Arg1& arg1, const Arg2& arg2, - const Arg3& arg3, const Arg4& arg4, - const Arg5& arg5) { + GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE + static T* Create(::google::protobuf::Arena* arena, + const Arg1& arg1, const Arg2& arg2, + const Arg3& arg3, const Arg4& arg4, + const Arg5& arg5) { if (arena == NULL) { return new T(arg1, arg2, arg3, arg4, arg5); } else { @@ -394,10 +464,11 @@ class LIBPROTOBUF_EXPORT Arena { // object. template <typename T, typename Arg1, typename Arg2, typename Arg3, typename Arg4, typename Arg5, typename Arg6> - GOOGLE_ATTRIBUTE_ALWAYS_INLINE static T* Create(::google::protobuf::Arena* arena, - const Arg1& arg1, const Arg2& arg2, - const Arg3& arg3, const Arg4& arg4, - const Arg5& arg5, const Arg6& arg6) { + GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE + static T* Create(::google::protobuf::Arena* arena, + const Arg1& arg1, const Arg2& arg2, + const Arg3& arg3, const Arg4& arg4, + const Arg5& arg5, const Arg6& arg6) { if (arena == NULL) { return new T(arg1, arg2, arg3, arg4, arg5, arg6); } else { @@ -410,11 +481,12 @@ class LIBPROTOBUF_EXPORT Arena { // object. template <typename T, typename Arg1, typename Arg2, typename Arg3, typename Arg4, typename Arg5, typename Arg6, typename Arg7> - GOOGLE_ATTRIBUTE_ALWAYS_INLINE static T* Create(::google::protobuf::Arena* arena, - const Arg1& arg1, const Arg2& arg2, - const Arg3& arg3, const Arg4& arg4, - const Arg5& arg5, const Arg6& arg6, - const Arg7& arg7) { + GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE + static T* Create(::google::protobuf::Arena* arena, + const Arg1& arg1, const Arg2& arg2, + const Arg3& arg3, const Arg4& arg4, + const Arg5& arg5, const Arg6& arg6, + const Arg7& arg7) { if (arena == NULL) { return new T(arg1, arg2, arg3, arg4, arg5, arg6, arg7); } else { @@ -428,11 +500,12 @@ class LIBPROTOBUF_EXPORT Arena { template <typename T, typename Arg1, typename Arg2, typename Arg3, typename Arg4, typename Arg5, typename Arg6, typename Arg7, typename Arg8> - GOOGLE_ATTRIBUTE_ALWAYS_INLINE static T* Create(::google::protobuf::Arena* arena, - const Arg1& arg1, const Arg2& arg2, - const Arg3& arg3, const Arg4& arg4, - const Arg5& arg5, const Arg6& arg6, - const Arg7& arg7, const Arg8& arg8) { + GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE + static T* Create(::google::protobuf::Arena* arena, + const Arg1& arg1, const Arg2& arg2, + const Arg3& arg3, const Arg4& arg4, + const Arg5& arg5, const Arg6& arg6, + const Arg7& arg7, const Arg8& arg8) { if (arena == NULL) { return new T(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); } else { @@ -448,7 +521,7 @@ class LIBPROTOBUF_EXPORT Arena { // To ensure safe uses, this function checks at compile time // (when compiled as C++11) that T is trivially default-constructible and // trivially destructible. - template <typename T> GOOGLE_ATTRIBUTE_ALWAYS_INLINE + template <typename T> GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE static T* CreateArray(::google::protobuf::Arena* arena, size_t num_elements) { GOOGLE_CHECK_LE(num_elements, std::numeric_limits<size_t>::max() / sizeof(T)) @@ -463,28 +536,37 @@ class LIBPROTOBUF_EXPORT Arena { // Returns the total space allocated by the arena, which is the sum of the // sizes of the underlying blocks. This method is relatively fast; a counter // is kept as blocks are allocated. - uint64 SpaceAllocated() const; + uint64 SpaceAllocated() const { return impl_.SpaceAllocated(); } // Returns the total space used by the arena. Similar to SpaceAllocated but // does not include free space and block overhead. The total space returned // may not include space used by other threads executing concurrently with // the call to this method. - GOOGLE_ATTRIBUTE_NOINLINE uint64 SpaceUsed() const; + uint64 SpaceUsed() const { return impl_.SpaceUsed(); } // DEPRECATED. Please use SpaceAllocated() and SpaceUsed(). // // Combines SpaceAllocated and SpaceUsed. Returns a pair of // <space_allocated, space_used>. - GOOGLE_ATTRIBUTE_NOINLINE std::pair<uint64, uint64> SpaceAllocatedAndUsed() const; + PROTOBUF_RUNTIME_DEPRECATED("Please use SpaceAllocated() and SpaceUsed()") + std::pair<uint64, uint64> SpaceAllocatedAndUsed() const { + return std::make_pair(SpaceAllocated(), SpaceUsed()); + } // Frees all storage allocated by this arena after calling destructors // registered with OwnDestructor() and freeing objects registered with Own(). // Any objects allocated on this arena are unusable after this call. It also // returns the total space used by the arena which is the sums of the sizes // of the allocated blocks. This method is not thread-safe. - GOOGLE_ATTRIBUTE_NOINLINE uint64 Reset(); + GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE uint64 Reset() { + // Call the reset hook + if (on_arena_reset_ != NULL) { + on_arena_reset_(this, hooks_cookie_, impl_.SpaceAllocated()); + } + return impl_.Reset(); + } // Adds |object| to a list of heap-allocated objects to be freed with |delete| // when the arena is destroyed or reset. - template <typename T> GOOGLE_ATTRIBUTE_NOINLINE + template <typename T> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE void Own(T* object) { OwnInternal(object, google::protobuf::internal::is_convertible<T*, ::google::protobuf::Message*>()); } @@ -494,10 +576,10 @@ class LIBPROTOBUF_EXPORT Arena { // that it does not free the underlying memory with |delete|; hence, it is // normally only used for objects that are placement-newed into // arena-allocated memory. - template <typename T> GOOGLE_ATTRIBUTE_NOINLINE + template <typename T> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE void OwnDestructor(T* object) { if (object != NULL) { - AddListNode(object, &internal::arena_destruct_object<T>); + impl_.AddCleanup(object, &internal::arena_destruct_object<T>); } } @@ -505,30 +587,70 @@ class LIBPROTOBUF_EXPORT Arena { // will be manually called when the arena is destroyed or reset. This differs // from OwnDestructor() in that any member function may be specified, not only // the class destructor. - GOOGLE_ATTRIBUTE_NOINLINE void OwnCustomDestructor(void* object, - void (*destruct)(void*)) { - AddListNode(object, destruct); + GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE void OwnCustomDestructor( + void* object, void (*destruct)(void*)) { + impl_.AddCleanup(object, destruct); } // Retrieves the arena associated with |value| if |value| is an arena-capable // message, or NULL otherwise. This differs from value->GetArena() in that the // latter is a virtual call, while this method is a templated call that // resolves at compile-time. - template<typename T> GOOGLE_ATTRIBUTE_ALWAYS_INLINE + template<typename T> GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE static ::google::protobuf::Arena* GetArena(const T* value) { - return GetArenaInternal(value, static_cast<T*>(0)); + return GetArenaInternal(value, is_arena_constructable<T>()); } - private: - struct InternalIsArenaConstructableHelper { + template <typename T> + class InternalHelper { + template <typename U> + static char DestructorSkippable(const typename U::DestructorSkippable_*); + template <typename U> + static double DestructorSkippable(...); + + typedef google::protobuf::internal::integral_constant< + bool, sizeof(DestructorSkippable<T>(static_cast<const T*>(0))) == + sizeof(char) || + google::protobuf::internal::has_trivial_destructor<T>::value> + is_destructor_skippable; + template<typename U> static char ArenaConstructable( const typename U::InternalArenaConstructable_*); template<typename U> static double ArenaConstructable(...); + + typedef google::protobuf::internal::integral_constant<bool, sizeof(ArenaConstructable<T>( + static_cast<const T*>(0))) == + sizeof(char)> + is_arena_constructable; + +#if LANG_CXX11 + template <typename... Args> + static T* Construct(void* ptr, Args&&... args) { + return new (ptr) T(std::forward<Args>(args)...); + } +#else + template <typename Arg1> + static T* Construct(void* ptr, const Arg1& arg1) { + return new (ptr) T(arg1); + } + template <typename Arg1, typename Arg2> + static T* Construct(void* ptr, const Arg1& arg1, const Arg2& arg2) { + return new (ptr) T(arg1, arg2); + } + template <typename Arg1, typename Arg2, typename Arg3> + static T* Construct(void* ptr, const Arg1& arg1, + const Arg2& arg2, const Arg3& arg3) { + return new (ptr) T(arg1, arg2, arg3); + } +#endif // LANG_CXX11 + + static Arena* GetArena(const T* p) { return p->GetArenaNoVirtual(); } + + friend class Arena; }; - public: // Helper typetrait that indicates support for arenas in a type T at compile // time. This is public only to allow construction of higher-level templated // utilities. is_arena_constructable<T>::value is true if the message type T @@ -537,278 +659,225 @@ class LIBPROTOBUF_EXPORT Arena { // This is inside Arena because only Arena has the friend relationships // necessary to see the underlying generated code traits. template <typename T> - struct is_arena_constructable - : public google::protobuf::internal::integral_constant< - bool, sizeof(InternalIsArenaConstructableHelper::ArenaConstructable< - const T>(static_cast<const T*>(0))) == sizeof(char)> { - }; + struct is_arena_constructable : InternalHelper<T>::is_arena_constructable {}; private: - // Blocks are variable length malloc-ed objects. The following structure - // describes the common header for all blocks. - struct Block { - void* owner; // &ThreadCache of thread that owns this block, or - // &this->owner if not yet owned by a thread. - Block* next; // Next block in arena (may have different owner) - // ((char*) &block) + pos is next available byte. It is always - // aligned at a multiple of 8 bytes. - size_t pos; - size_t size; // total size of the block. - GOOGLE_ATTRIBUTE_ALWAYS_INLINE size_t avail() const { return size - pos; } - // data follows - }; - - template<typename Type> friend class ::google::protobuf::internal::GenericTypeHandler; - friend class MockArena; // For unit-testing. - friend class internal::ArenaString; // For AllocateAligned. - friend class internal::LazyField; // For CreateMaybeMessage. - - struct ThreadCache { - // The ThreadCache is considered valid as long as this matches the - // lifecycle_id of the arena being used. - int64 last_lifecycle_id_seen; - Block* last_block_used_; - }; - - static const size_t kHeaderSize = sizeof(Block); - static google::protobuf::internal::SequenceNumber lifecycle_id_generator_; -#if defined(GOOGLE_PROTOBUF_NO_THREADLOCAL) - // Android ndk does not support GOOGLE_THREAD_LOCAL keyword so we use a custom thread - // local storage class we implemented. - // iOS also does not support the GOOGLE_THREAD_LOCAL keyword. - static ThreadCache& thread_cache(); -#elif defined(PROTOBUF_USE_DLLS) - // Thread local variables cannot be exposed through DLL interface but we can - // wrap them in static functions. - static ThreadCache& thread_cache(); -#else - static GOOGLE_THREAD_LOCAL ThreadCache thread_cache_; - static ThreadCache& thread_cache() { return thread_cache_; } + template <typename T> GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE + static T* CreateMessageInternal(::google::protobuf::Arena* arena) { +#if LANG_CXX11 + static_assert( + InternalHelper<T>::is_arena_constructable::value, + "CreateMessage can only construct types that are ArenaConstructable"); #endif - - // SFINAE for skipping addition to delete list for a message type when created - // with CreateMessage. This is mainly to skip proto2/proto1 message objects - // with cc_enable_arenas=true from being part of the delete list. Also, note, - // compiler will optimize out the branch in CreateInternal<T>. - template<typename T> - static inline bool SkipDeleteList(typename T::DestructorSkippable_*) { - return true; + if (arena == NULL) { + return new T; + } else { + return arena->CreateMessageInternal<T>(); + } } - // For message objects that don't have the DestructorSkippable_ trait, we - // always add to the delete list. - template<typename T> - static inline bool SkipDeleteList(...) { - return google::protobuf::internal::has_trivial_destructor<T>::value; + template <typename T> GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE + static T* CreateInternal(::google::protobuf::Arena* arena) { + if (arena == NULL) { + return new T(); + } else { + return arena->CreateInternal<T>(google::protobuf::internal::has_trivial_destructor<T>::value); + } } - private: - struct InternalIsDestructorSkippableHelper { - template<typename U> - static char DestructorSkippable( - const typename U::DestructorSkippable_*); - template<typename U> - static double DestructorSkippable(...); - }; + void CallDestructorHooks(); + void OnArenaAllocation(const std::type_info* allocated_type, size_t n) const; + inline void AllocHook(const std::type_info* allocated_type, size_t n) const { + if (GOOGLE_PREDICT_FALSE(hooks_cookie_ != NULL)) { + OnArenaAllocation(allocated_type, n); + } + } - public: - // Helper typetrait that indicates whether the desctructor of type T should be - // called when arena is destroyed at compile time. This is only to allow - // construction of higher-level templated utilities. - // is_destructor_skippable<T>::value is true if the destructor of the message - // type T should not be called when arena is destroyed or false otherwise. - // This is inside Arena because only Arena has the friend relationships - // necessary to see the underlying generated code traits. - template<typename T> - struct is_destructor_skippable - : public google::protobuf::internal::integral_constant< - bool, - sizeof(InternalIsDestructorSkippableHelper::DestructorSkippable< - const T>(static_cast<const T*>(0))) == sizeof(char) || - google::protobuf::internal::has_trivial_destructor<T>::value> {}; + // Allocate and also optionally call on_arena_allocation callback with the + // allocated type info when the hooks are in place in ArenaOptions and + // the cookie is not null. + template<typename T> GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE + void* AllocateInternal(bool skip_explicit_ownership) { + const size_t n = internal::AlignUpTo8(sizeof(T)); + AllocHook(RTTI_TYPE_ID(T), n); + // Monitor allocation if needed. + if (skip_explicit_ownership) { + return impl_.AllocateAligned(n); + } else { + return impl_.AllocateAlignedAndAddCleanup( + n, &internal::arena_destruct_object<T>); + } + } - private: // CreateMessage<T> requires that T supports arenas, but this private method // works whether or not T supports arenas. These are not exposed to user code // as it can cause confusing API usages, and end up having double free in // user code. These are used only internally from LazyField and Repeated // fields, since they are designed to work in all mode combinations. - template<typename Msg> GOOGLE_ATTRIBUTE_ALWAYS_INLINE - static Msg* CreateMaybeMessage( - Arena* arena, typename Msg::InternalArenaConstructable_*) { - return CreateMessage<Msg>(arena); + template <typename Msg> GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE + static Msg* CreateMaybeMessage(Arena* arena, google::protobuf::internal::true_type) { + return CreateMessageInternal<Msg>(arena); + } + + template <typename T> GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE + static T* CreateMaybeMessage(Arena* arena, google::protobuf::internal::false_type) { + return CreateInternal<T>(arena); } - template<typename T> GOOGLE_ATTRIBUTE_ALWAYS_INLINE - static T* CreateMaybeMessage(Arena* arena, ...) { - return Create<T>(arena); + template <typename T> GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE + static T* CreateMaybeMessage(Arena* arena) { + return CreateMaybeMessage<T>(arena, is_arena_constructable<T>()); } // Just allocate the required size for the given type assuming the // type has a trivial constructor. - template<typename T> GOOGLE_ATTRIBUTE_ALWAYS_INLINE + template<typename T> GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE T* CreateInternalRawArray(size_t num_elements) { GOOGLE_CHECK_LE(num_elements, std::numeric_limits<size_t>::max() / sizeof(T)) << "Requested size is too large to fit into size_t."; - return static_cast<T*>( - AllocateAligned(RTTI_TYPE_ID(T), sizeof(T) * num_elements)); + const size_t n = internal::AlignUpTo8(sizeof(T) * num_elements); + // Monitor allocation if needed. + AllocHook(RTTI_TYPE_ID(T), n); + return static_cast<T*>(impl_.AllocateAligned(n)); } #if LANG_CXX11 - template <typename T, typename... Args> GOOGLE_ATTRIBUTE_ALWAYS_INLINE + template <typename T, typename... Args> + GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE T* CreateInternal(bool skip_explicit_ownership, Args&&... args) { - T* t = new (AllocateAligned(RTTI_TYPE_ID(T), sizeof(T))) + return new (AllocateInternal<T>(skip_explicit_ownership)) T(std::forward<Args>(args)...); - if (!skip_explicit_ownership) { - AddListNode(t, &internal::arena_destruct_object<T>); - } - return t; } -#endif - template <typename T> GOOGLE_ATTRIBUTE_ALWAYS_INLINE +#else + template <typename T> GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE T* CreateInternal(bool skip_explicit_ownership) { - T* t = new (AllocateAligned(RTTI_TYPE_ID(T), sizeof(T))) T(); - if (!skip_explicit_ownership) { - AddListNode(t, &internal::arena_destruct_object<T>); - } - return t; + return new (AllocateInternal<T>(skip_explicit_ownership)) T(); } - template <typename T, typename Arg> GOOGLE_ATTRIBUTE_ALWAYS_INLINE + template <typename T, typename Arg> GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE T* CreateInternal(bool skip_explicit_ownership, const Arg& arg) { - T* t = new (AllocateAligned(RTTI_TYPE_ID(T), sizeof(T))) T(arg); - if (!skip_explicit_ownership) { - AddListNode(t, &internal::arena_destruct_object<T>); - } - return t; + return new (AllocateInternal<T>(skip_explicit_ownership)) T(arg); } - template <typename T, typename Arg1, typename Arg2> GOOGLE_ATTRIBUTE_ALWAYS_INLINE - T* CreateInternal( - bool skip_explicit_ownership, const Arg1& arg1, const Arg2& arg2) { - T* t = new (AllocateAligned(RTTI_TYPE_ID(T), sizeof(T))) T(arg1, arg2); - if (!skip_explicit_ownership) { - AddListNode(t, &internal::arena_destruct_object<T>); - } - return t; + template <typename T, typename Arg1, typename Arg2> + GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE + T* CreateInternal(bool skip_explicit_ownership, + const Arg1& arg1, + const Arg2& arg2) { + return new (AllocateInternal<T>(skip_explicit_ownership)) T(arg1, arg2); } template <typename T, typename Arg1, typename Arg2, typename Arg3> - GOOGLE_ATTRIBUTE_ALWAYS_INLINE T* CreateInternal(bool skip_explicit_ownership, - const Arg1& arg1, - const Arg2& arg2, - const Arg3& arg3) { - T* t = new (AllocateAligned(RTTI_TYPE_ID(T), sizeof(T))) + GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE + T* CreateInternal(bool skip_explicit_ownership, + const Arg1& arg1, + const Arg2& arg2, + const Arg3& arg3) { + return new (AllocateInternal<T>(skip_explicit_ownership)) T(arg1, arg2, arg3); - if (!skip_explicit_ownership) { - AddListNode(t, &internal::arena_destruct_object<T>); - } - return t; } template <typename T, typename Arg1, typename Arg2, typename Arg3, typename Arg4> - GOOGLE_ATTRIBUTE_ALWAYS_INLINE T* CreateInternal(bool skip_explicit_ownership, - const Arg1& arg1, - const Arg2& arg2, - const Arg3& arg3, - const Arg4& arg4) { - T* t = new (AllocateAligned(RTTI_TYPE_ID(T), sizeof(T))) + GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE + T* CreateInternal(bool skip_explicit_ownership, + const Arg1& arg1, + const Arg2& arg2, + const Arg3& arg3, + const Arg4& arg4) { + return new (AllocateInternal<T>(skip_explicit_ownership)) T(arg1, arg2, arg3, arg4); - if (!skip_explicit_ownership) { - AddListNode(t, &internal::arena_destruct_object<T>); - } - return t; } template <typename T, typename Arg1, typename Arg2, typename Arg3, typename Arg4, typename Arg5> - GOOGLE_ATTRIBUTE_ALWAYS_INLINE T* CreateInternal(bool skip_explicit_ownership, - const Arg1& arg1, - const Arg2& arg2, - const Arg3& arg3, - const Arg4& arg4, - const Arg5& arg5) { - T* t = new (AllocateAligned(RTTI_TYPE_ID(T), sizeof(T))) + GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE + T* CreateInternal(bool skip_explicit_ownership, + const Arg1& arg1, + const Arg2& arg2, + const Arg3& arg3, + const Arg4& arg4, + const Arg5& arg5) { + return new (AllocateInternal<T>(skip_explicit_ownership)) T(arg1, arg2, arg3, arg4, arg5); - if (!skip_explicit_ownership) { - AddListNode(t, &internal::arena_destruct_object<T>); - } - return t; } template <typename T, typename Arg1, typename Arg2, typename Arg3, typename Arg4, typename Arg5, typename Arg6> - GOOGLE_ATTRIBUTE_ALWAYS_INLINE T* CreateInternal(bool skip_explicit_ownership, - const Arg1& arg1, - const Arg2& arg2, - const Arg3& arg3, - const Arg4& arg4, - const Arg5& arg5, - const Arg6& arg6) { - T* t = new (AllocateAligned(RTTI_TYPE_ID(T), sizeof(T))) + GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE + T* CreateInternal(bool skip_explicit_ownership, + const Arg1& arg1, + const Arg2& arg2, + const Arg3& arg3, + const Arg4& arg4, + const Arg5& arg5, + const Arg6& arg6) { + return new (AllocateInternal<T>(skip_explicit_ownership)) T(arg1, arg2, arg3, arg4, arg5, arg6); - if (!skip_explicit_ownership) { - AddListNode(t, &internal::arena_destruct_object<T>); - } - return t; } template <typename T, typename Arg1, typename Arg2, typename Arg3, typename Arg4, typename Arg5, typename Arg6, typename Arg7> - GOOGLE_ATTRIBUTE_ALWAYS_INLINE T* CreateInternal(bool skip_explicit_ownership, - const Arg1& arg1, - const Arg2& arg2, - const Arg3& arg3, - const Arg4& arg4, - const Arg5& arg5, - const Arg6& arg6, - const Arg7& arg7) { - T* t = new (AllocateAligned(RTTI_TYPE_ID(T), sizeof(T))) + GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE + T* CreateInternal(bool skip_explicit_ownership, + const Arg1& arg1, + const Arg2& arg2, + const Arg3& arg3, + const Arg4& arg4, + const Arg5& arg5, + const Arg6& arg6, + const Arg7& arg7) { + return new (AllocateInternal<T>(skip_explicit_ownership)) T(arg1, arg2, arg3, arg4, arg5, arg6, arg7); - if (!skip_explicit_ownership) { - AddListNode(t, &internal::arena_destruct_object<T>); - } - return t; } template <typename T, typename Arg1, typename Arg2, typename Arg3, typename Arg4, typename Arg5, typename Arg6, typename Arg7, typename Arg8> - GOOGLE_ATTRIBUTE_ALWAYS_INLINE T* CreateInternal(bool skip_explicit_ownership, - const Arg1& arg1, - const Arg2& arg2, - const Arg3& arg3, - const Arg4& arg4, - const Arg5& arg5, - const Arg6& arg6, - const Arg7& arg7, - const Arg8& arg8) { - T* t = new (AllocateAligned(RTTI_TYPE_ID(T), sizeof(T))) + GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE + T* CreateInternal(bool skip_explicit_ownership, + const Arg1& arg1, + const Arg2& arg2, + const Arg3& arg3, + const Arg4& arg4, + const Arg5& arg5, + const Arg6& arg6, + const Arg7& arg7, + const Arg8& arg8) { + return new (AllocateInternal<T>(skip_explicit_ownership)) T(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); - if (!skip_explicit_ownership) { - AddListNode(t, &internal::arena_destruct_object<T>); - } - return t; } - - template <typename T> GOOGLE_ATTRIBUTE_ALWAYS_INLINE - T* CreateMessageInternal(typename T::InternalArenaConstructable_*) { - return CreateInternal<T>(SkipDeleteList<T>(static_cast<T*>(0)), this); +#endif +#if LANG_CXX11 + template <typename T, typename... Args> + GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE T* CreateMessageInternal( + Args&&... args) { + return InternalHelper<T>::Construct( + AllocateInternal<T>(InternalHelper<T>::is_destructor_skippable::value), + this, std::forward<Args>(args)...); + } +#endif + template <typename T> + GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE T* CreateMessageInternal() { + return InternalHelper<T>::Construct( + AllocateInternal<T>(InternalHelper<T>::is_destructor_skippable::value), + this); } - template <typename T, typename Arg> GOOGLE_ATTRIBUTE_ALWAYS_INLINE - T* CreateMessageInternal(typename T::InternalArenaConstructable_*, - const Arg& arg) { - return CreateInternal<T>(SkipDeleteList<T>(static_cast<T*>(0)), this, arg); + template <typename T, typename Arg> GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE + T* CreateMessageInternal(const Arg& arg) { + return InternalHelper<T>::Construct( + AllocateInternal<T>(InternalHelper<T>::is_destructor_skippable::value), + this, arg); } - template <typename T, typename Arg1, typename Arg2> GOOGLE_ATTRIBUTE_ALWAYS_INLINE - T* CreateMessageInternal(typename T::InternalArenaConstructable_*, - const Arg1& arg1, const Arg2& arg2) { - return CreateInternal<T>(SkipDeleteList<T>(static_cast<T*>(0)), this, arg1, - arg2); + template <typename T, typename Arg1, typename Arg2> + GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE + T* CreateMessageInternal(const Arg1& arg1, const Arg2& arg2) { + return InternalHelper<T>::Construct( + AllocateInternal<T>(InternalHelper<T>::is_destructor_skippable::value), + this, arg1, arg2); } // CreateInArenaStorage is used to implement map field. Without it, @@ -818,14 +887,15 @@ class LIBPROTOBUF_EXPORT Arena { static void CreateInArenaStorage(T* ptr, Arena* arena) { CreateInArenaStorageInternal(ptr, arena, typename is_arena_constructable<T>::type()); - RegisterDestructorInternal(ptr, arena, - typename is_destructor_skippable<T>::type()); + RegisterDestructorInternal( + ptr, arena, + typename InternalHelper<T>::is_destructor_skippable::type()); } template <typename T> static void CreateInArenaStorageInternal( T* ptr, Arena* arena, google::protobuf::internal::true_type) { - new (ptr) T(arena); + InternalHelper<T>::Construct(ptr, arena); } template <typename T> static void CreateInArenaStorageInternal( @@ -847,103 +917,59 @@ class LIBPROTOBUF_EXPORT Arena { // is a subtype of ::google::protobuf::Message and 'false_type' otherwise. Collapsing // all template instantiations to one for generic Message reduces code size, // using the virtual destructor instead. - template<typename T> GOOGLE_ATTRIBUTE_ALWAYS_INLINE + template<typename T> GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE void OwnInternal(T* object, google::protobuf::internal::true_type) { if (object != NULL) { - AddListNode(object, &internal::arena_delete_object< ::google::protobuf::Message >); + impl_.AddCleanup(object, + &internal::arena_delete_object< ::google::protobuf::Message>); } } - template<typename T> GOOGLE_ATTRIBUTE_ALWAYS_INLINE + template<typename T> GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE void OwnInternal(T* object, google::protobuf::internal::false_type) { if (object != NULL) { - AddListNode(object, &internal::arena_delete_object<T>); + impl_.AddCleanup(object, &internal::arena_delete_object<T>); } } // Implementation for GetArena(). Only message objects with // InternalArenaConstructable_ tags can be associated with an arena, and such // objects must implement a GetArenaNoVirtual() method. - template<typename T> GOOGLE_ATTRIBUTE_ALWAYS_INLINE + template <typename T> GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE static ::google::protobuf::Arena* GetArenaInternal( - const T* value, typename T::InternalArenaConstructable_*) { - return value->GetArenaNoVirtual(); + const T* value, google::protobuf::internal::true_type) { + return InternalHelper<T>::GetArena(value); } - template<typename T> GOOGLE_ATTRIBUTE_ALWAYS_INLINE - static ::google::protobuf::Arena* GetArenaInternal(const T* /* value */, ...) { + template <typename T> + GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE + static ::google::protobuf::Arena* GetArenaInternal( + const T* /* value */, google::protobuf::internal::false_type) { return NULL; } - // Allocate and also optionally call on_arena_allocation callback with the - // allocated type info when the hooks are in place in ArenaOptions and - // the cookie is not null. - void* AllocateAligned(const std::type_info* allocated, size_t n); - - // Allocate an internal allocation, avoiding optional typed monitoring. - GOOGLE_ATTRIBUTE_ALWAYS_INLINE void* AllocateAligned(size_t n) { - return AllocateAligned(NULL, n); - } - - void Init(); - - // Free all blocks and return the total space used which is the sums of sizes - // of the all the allocated blocks. - uint64 FreeBlocks(); - - // Add object pointer and cleanup function pointer to the list. - // TODO(rohananil, cfallin): We could pass in a sub-arena into this method - // to avoid polluting blocks of this arena with list nodes. This would help in - // mixed mode (where many protobufs have cc_enable_arenas=false), and is an - // alternative to a chunked linked-list, but with extra overhead of *next. - void AddListNode(void* elem, void (*cleanup)(void*)); - // Delete or Destruct all objects owned by the arena. - void CleanupList(); - uint64 ResetInternal(); - - inline void SetThreadCacheBlock(Block* block) { - thread_cache().last_block_used_ = block; - thread_cache().last_lifecycle_id_seen = lifecycle_id_; + // For friends of arena. + void* AllocateAligned(size_t n) { + AllocHook(NULL, n); + return impl_.AllocateAligned(internal::AlignUpTo8(n)); } - int64 lifecycle_id_; // Unique for each arena. Changes on Reset(). + internal::ArenaImpl impl_; - google::protobuf::internal::AtomicWord blocks_; // Head of linked list of all allocated blocks - google::protobuf::internal::AtomicWord hint_; // Fast thread-local block access - uint64 space_allocated_; // Sum of sizes of all allocated blocks. - - // Node contains the ptr of the object to be cleaned up and the associated - // cleanup function ptr. - struct Node { - void* elem; // Pointer to the object to be cleaned up. - void (*cleanup)(void*); // Function pointer to the destructor or deleter. - Node* next; // Next node in the list. - }; - - google::protobuf::internal::AtomicWord cleanup_list_; // Head of a linked list of nodes containing object - // ptrs and cleanup methods. - - bool owns_first_block_; // Indicates that arena owns the first block - mutable Mutex blocks_lock_; - - void AddBlock(Block* b); - // Access must be synchronized, either by blocks_lock_ or by being called from - // Init()/Reset(). - void AddBlockInternal(Block* b); - void* SlowAlloc(size_t n); - Block* FindBlock(void* me); - Block* NewBlock(void* me, Block* my_last_block, size_t n, - size_t start_block_size, size_t max_block_size); - static void* AllocFromBlock(Block* b, size_t n); - template <typename Key, typename T> - friend class Map; + void (*on_arena_allocation_)(const std::type_info* allocated_type, + uint64 alloc_size, void* cookie); + void (*on_arena_reset_)(Arena* arena, void* cookie, uint64 space_used); + void (*on_arena_destruction_)(Arena* arena, void* cookie, uint64 space_used); // The arena may save a cookie it receives from the external on_init hook // and then use it when calling the on_reset and on_destruction hooks. void* hooks_cookie_; - ArenaOptions options_; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Arena); + template <typename Type> + friend class ::google::protobuf::internal::GenericTypeHandler; + friend struct internal::ArenaStringPtr; // For AllocateAligned. + friend class internal::LazyField; // For CreateMaybeMessage. + template <typename Key, typename T> + friend class Map; }; // Defined above for supporting environments without RTTI. diff --git a/src/google/protobuf/arena_impl.h b/src/google/protobuf/arena_impl.h new file mode 100644 index 00000000..439b0969 --- /dev/null +++ b/src/google/protobuf/arena_impl.h @@ -0,0 +1,318 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// This file defines an Arena allocator for better allocation performance. + +#ifndef GOOGLE_PROTOBUF_ARENA_IMPL_H__ +#define GOOGLE_PROTOBUF_ARENA_IMPL_H__ + +#include <limits> + +#include <google/protobuf/stubs/atomic_sequence_num.h> +#include <google/protobuf/stubs/atomicops.h> +#include <google/protobuf/stubs/common.h> +#include <google/protobuf/stubs/logging.h> +#include <google/protobuf/stubs/mutex.h> + +#include <google/protobuf/stubs/port.h> + +#ifdef ADDRESS_SANITIZER +#include <sanitizer/asan_interface.h> +#endif // ADDRESS_SANITIZER + +namespace google { + +namespace protobuf { +namespace internal { + +inline size_t AlignUpTo8(size_t n) { + // Align n to next multiple of 8 (from Hacker's Delight, Chapter 3.) + return (n + 7) & -8; +} + +// This class provides the core Arena memory allocation library. Different +// implementations only need to implement the public interface below. +// Arena is not a template type as that would only be useful if all protos +// in turn would be templates, which will/cannot happen. However separating +// the memory allocation part from the cruft of the API users expect we can +// use #ifdef the select the best implementation based on hardware / OS. +class LIBPROTOBUF_EXPORT ArenaImpl { + public: + struct Options { + size_t start_block_size; + size_t max_block_size; + char* initial_block; + size_t initial_block_size; + void* (*block_alloc)(size_t); + void (*block_dealloc)(void*, size_t); + + template <typename O> + explicit Options(const O& options) + : start_block_size(options.start_block_size), + max_block_size(options.max_block_size), + initial_block(options.initial_block), + initial_block_size(options.initial_block_size), + block_alloc(options.block_alloc), + block_dealloc(options.block_dealloc) {} + }; + + template <typename O> + explicit ArenaImpl(const O& options) : options_(options) { + if (options_.initial_block != NULL && options_.initial_block_size > 0) { + GOOGLE_CHECK_GE(options_.initial_block_size, sizeof(Block)) + << ": Initial block size too small for header."; + initial_block_ = reinterpret_cast<Block*>(options_.initial_block); + } else { + initial_block_ = NULL; + } + + Init(); + } + + // Destructor deletes all owned heap allocated objects, and destructs objects + // that have non-trivial destructors, except for proto2 message objects whose + // destructors can be skipped. Also, frees all blocks except the initial block + // if it was passed in. + ~ArenaImpl(); + + uint64 Reset(); + + uint64 SpaceAllocated() const; + uint64 SpaceUsed() const; + + void* AllocateAligned(size_t n); + + void* AllocateAlignedAndAddCleanup(size_t n, void (*cleanup)(void*)); + + // Add object pointer and cleanup function pointer to the list. + void AddCleanup(void* elem, void (*cleanup)(void*)); + + private: + void* AllocateAlignedFallback(size_t n); + void* AllocateAlignedAndAddCleanupFallback(size_t n, void (*cleanup)(void*)); + void AddCleanupFallback(void* elem, void (*cleanup)(void*)); + + // Node contains the ptr of the object to be cleaned up and the associated + // cleanup function ptr. + struct CleanupNode { + void* elem; // Pointer to the object to be cleaned up. + void (*cleanup)(void*); // Function pointer to the destructor or deleter. + }; + + // Cleanup uses a chunked linked list, to reduce pointer chasing. + struct CleanupChunk { + static size_t SizeOf(size_t i) { + return sizeof(CleanupChunk) + (sizeof(CleanupNode) * (i - 1)); + } + size_t size; // Total elements in the list. + CleanupChunk* next; // Next node in the list. + CleanupNode nodes[1]; // True length is |size|. + }; + + class Block; + + // A thread-unsafe Arena that can only be used within its owning thread. + class LIBPROTOBUF_EXPORT SerialArena { + public: + // The allocate/free methods here are a little strange, since SerialArena is + // allocated inside a Block which it also manages. This is to avoid doing + // an extra allocation for the SerialArena itself. + + // Creates a new SerialArena inside Block* and returns it. + static SerialArena* New(Block* b, void* owner, ArenaImpl* arena); + + // Destroys this SerialArena, freeing all blocks with the given dealloc + // function, except any block equal to |initial_block|. + static uint64 Free(SerialArena* serial, Block* initial_block, + void (*block_dealloc)(void*, size_t)); + + void CleanupList(); + uint64 SpaceUsed() const; + + void* AllocateAligned(size_t n) { + GOOGLE_DCHECK_EQ(internal::AlignUpTo8(n), n); // Must be already aligned. + GOOGLE_DCHECK_GE(limit_, ptr_); + if (GOOGLE_PREDICT_FALSE(static_cast<size_t>(limit_ - ptr_) < n)) { + return AllocateAlignedFallback(n); + } + void* ret = ptr_; + ptr_ += n; +#ifdef ADDRESS_SANITIZER + ASAN_UNPOISON_MEMORY_REGION(ret, n); +#endif // ADDRESS_SANITIZER + return ret; + } + + void AddCleanup(void* elem, void (*cleanup)(void*)) { + if (GOOGLE_PREDICT_FALSE(cleanup_ptr_ == cleanup_limit_)) { + AddCleanupFallback(elem, cleanup); + return; + } + cleanup_ptr_->elem = elem; + cleanup_ptr_->cleanup = cleanup; + cleanup_ptr_++; + } + + void* AllocateAlignedAndAddCleanup(size_t n, void (*cleanup)(void*)) { + void* ret = AllocateAligned(n); + AddCleanup(ret, cleanup); + return ret; + } + + void* owner() const { return owner_; } + SerialArena* next() const { return next_; } + void set_next(SerialArena* next) { next_ = next; } + + private: + void* AllocateAlignedFallback(size_t n); + void AddCleanupFallback(void* elem, void (*cleanup)(void*)); + void CleanupListFallback(); + + ArenaImpl* arena_; // Containing arena. + void* owner_; // &ThreadCache of this thread; + Block* head_; // Head of linked list of blocks. + CleanupChunk* cleanup_; // Head of cleanup list. + SerialArena* next_; // Next SerialArena in this linked list. + + // Next pointer to allocate from. Always 8-byte aligned. Points inside + // head_ (and head_->pos will always be non-canonical). We keep these + // here to reduce indirection. + char* ptr_; + char* limit_; + + // Next CleanupList members to append to. These point inside cleanup_. + CleanupNode* cleanup_ptr_; + CleanupNode* cleanup_limit_; + }; + + // Blocks are variable length malloc-ed objects. The following structure + // describes the common header for all blocks. + class LIBPROTOBUF_EXPORT Block { + public: + Block(size_t size, Block* next); + + char* Pointer(size_t n) { + GOOGLE_DCHECK(n <= size_); + return reinterpret_cast<char*>(this) + n; + } + + Block* next() const { return next_; } + size_t pos() const { return pos_; } + size_t size() const { return size_; } + void set_pos(size_t pos) { pos_ = pos; } + + private: + Block* next_; // Next block for this thread. + size_t pos_; + size_t size_; + // data follows + }; + + struct ThreadCache { +#if defined(GOOGLE_PROTOBUF_NO_THREADLOCAL) + // If we are using the ThreadLocalStorage class to store the ThreadCache, + // then the ThreadCache's default constructor has to be responsible for + // initializing it. + ThreadCache() : last_lifecycle_id_seen(-1), last_serial_arena(NULL) {} +#endif + + // The ThreadCache is considered valid as long as this matches the + // lifecycle_id of the arena being used. + int64 last_lifecycle_id_seen; + SerialArena* last_serial_arena; + }; + static google::protobuf::internal::SequenceNumber lifecycle_id_generator_; +#if defined(GOOGLE_PROTOBUF_NO_THREADLOCAL) + // Android ndk does not support GOOGLE_THREAD_LOCAL keyword so we use a custom thread + // local storage class we implemented. + // iOS also does not support the GOOGLE_THREAD_LOCAL keyword. + static ThreadCache& thread_cache(); +#elif defined(PROTOBUF_USE_DLLS) + // Thread local variables cannot be exposed through DLL interface but we can + // wrap them in static functions. + static ThreadCache& thread_cache(); +#else + static GOOGLE_THREAD_LOCAL ThreadCache thread_cache_; + static ThreadCache& thread_cache() { return thread_cache_; } +#endif + + void Init(); + + // Free all blocks and return the total space used which is the sums of sizes + // of the all the allocated blocks. + uint64 FreeBlocks(); + // Delete or Destruct all objects owned by the arena. + void CleanupList(); + + inline void CacheSerialArena(SerialArena* serial) { + thread_cache().last_serial_arena = serial; + thread_cache().last_lifecycle_id_seen = lifecycle_id_; + // TODO(haberman): evaluate whether we would gain efficiency by getting rid + // of hint_. It's the only write we do to ArenaImpl in the allocation path, + // which will dirty the cache line. + google::protobuf::internal::Release_Store(&hint_, reinterpret_cast<google::protobuf::internal::AtomicWord>(serial)); + } + + google::protobuf::internal::AtomicWord threads_; // Pointer to a linked list of SerialArena. + google::protobuf::internal::AtomicWord hint_; // Fast thread-local block access + google::protobuf::internal::AtomicWord space_allocated_; // Sum of sizes of all allocated blocks. + + Block *initial_block_; // If non-NULL, points to the block that came from + // user data. + + Block* NewBlock(Block* last_block, size_t min_bytes); + + SerialArena* GetSerialArena(); + bool GetSerialArenaFast(SerialArena** arena); + SerialArena* GetSerialArenaFallback(void* me); + int64 lifecycle_id_; // Unique for each arena. Changes on Reset(). + + Options options_; + + GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ArenaImpl); + + public: + // kBlockHeaderSize is sizeof(Block), aligned up to the nearest multiple of 8 + // to protect the invariant that pos is always at a multiple of 8. + static const size_t kBlockHeaderSize = (sizeof(Block) + 7) & -8; + static const size_t kSerialArenaSize = (sizeof(SerialArena) + 7) & -8; +#if LANG_CXX11 + static_assert(kBlockHeaderSize % 8 == 0, + "kBlockHeaderSize must be a multiple of 8."); + static_assert(kSerialArenaSize % 8 == 0, + "kSerialArenaSize must be a multiple of 8."); +#endif +}; + +} // namespace internal +} // namespace protobuf + +} // namespace google +#endif // GOOGLE_PROTOBUF_ARENA_IMPL_H__ diff --git a/src/google/protobuf/arena_unittest.cc b/src/google/protobuf/arena_unittest.cc index 6172cade..71e28b0c 100644 --- a/src/google/protobuf/arena_unittest.cc +++ b/src/google/protobuf/arena_unittest.cc @@ -67,7 +67,6 @@ using protobuf_unittest::TestOneof2; using protobuf_unittest::TestEmptyMessage; namespace protobuf { -namespace { class Notifier { public: @@ -270,7 +269,7 @@ TEST(ArenaTest, InitialBlockTooSmall) { // Construct a small (64 byte) initial block of memory to be used by the // arena allocator; then, allocate an object which will not fit in the // initial block. - std::vector<char> arena_block(64); + std::vector<char> arena_block(96); ArenaOptions options; options.initial_block = &arena_block[0]; options.initial_block_size = arena_block.size(); @@ -1299,12 +1298,12 @@ TEST(ArenaTest, SpaceAllocated_and_Used) { options.initial_block_size = 0; Arena arena_3(options); EXPECT_EQ(0, arena_3.SpaceUsed()); - ::google::protobuf::Arena::CreateArray<char>(&arena_3, 190); + ::google::protobuf::Arena::CreateArray<char>(&arena_3, 160); EXPECT_EQ(256, arena_3.SpaceAllocated()); - EXPECT_EQ(Align8(190), arena_3.SpaceUsed()); + EXPECT_EQ(Align8(160), arena_3.SpaceUsed()); ::google::protobuf::Arena::CreateArray<char>(&arena_3, 70); EXPECT_EQ(256 + 512, arena_3.SpaceAllocated()); - EXPECT_EQ(Align8(190) + Align8(70), arena_3.SpaceUsed()); + EXPECT_EQ(Align8(160) + Align8(70), arena_3.SpaceUsed()); EXPECT_EQ(256 + 512, arena_3.Reset()); } @@ -1347,6 +1346,13 @@ TEST(ArenaTest, GetArenaShouldReturnNullForNonArenaAllocatedMessages) { EXPECT_EQ(NULL, Arena::GetArena(const_pointer_to_message)); } +TEST(ArenaTest, AddCleanup) { + ::google::protobuf::Arena arena; + for (int i = 0; i < 100; i++) { + arena.Own(new int); + } +} + TEST(ArenaTest, UnsafeSetAllocatedOnArena) { ::google::protobuf::Arena arena; TestAllTypes* message = Arena::CreateMessage<TestAllTypes>(&arena); @@ -1405,13 +1411,20 @@ uint32 ArenaHooksTestUtil::num_reset = 0; uint32 ArenaHooksTestUtil::num_destruct = 0; const int ArenaHooksTestUtil::kCookieValue; +class ArenaOptionsTestFriend { + public: + static void Set(::google::protobuf::ArenaOptions* options) { + options->on_arena_init = ArenaHooksTestUtil::on_init; + options->on_arena_allocation = ArenaHooksTestUtil::on_allocation; + options->on_arena_reset = ArenaHooksTestUtil::on_reset; + options->on_arena_destruction = ArenaHooksTestUtil::on_destruction; + } +}; + // Test the hooks are correctly called and that the cookie is passed. TEST(ArenaTest, ArenaHooksSanity) { ::google::protobuf::ArenaOptions options; - options.on_arena_init = ArenaHooksTestUtil::on_init; - options.on_arena_allocation = ArenaHooksTestUtil::on_allocation; - options.on_arena_reset = ArenaHooksTestUtil::on_reset; - options.on_arena_destruction = ArenaHooksTestUtil::on_destruction; + ArenaOptionsTestFriend::Set(&options); // Scope for defining the arena { @@ -1433,6 +1446,5 @@ TEST(ArenaTest, ArenaHooksSanity) { } -} // namespace } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/arenastring.h b/src/google/protobuf/arenastring.h index 63fd00e5..2b108616 100755 --- a/src/google/protobuf/arenastring.h +++ b/src/google/protobuf/arenastring.h @@ -33,12 +33,11 @@ #include <string> -#include <google/protobuf/stubs/logging.h> +#include <google/protobuf/arena.h> #include <google/protobuf/stubs/common.h> #include <google/protobuf/stubs/fastmem.h> -#include <google/protobuf/arena.h> - - +#include <google/protobuf/stubs/logging.h> +#include <google/protobuf/stubs/port.h> // This is the implementation of arena string fields written for the open-source // release. The ArenaStringPtr struct below is an internal implementation class @@ -52,6 +51,18 @@ namespace google { namespace protobuf { namespace internal { +template <typename T> +class TaggedPtr { + public: + void Set(T* p) { ptr_ = reinterpret_cast<uintptr_t>(p); } + T* Get() const { return reinterpret_cast<T*>(ptr_); } + + bool IsNull() { return ptr_ == 0; } + + private: + uintptr_t ptr_; +}; + struct LIBPROTOBUF_EXPORT ArenaStringPtr { inline void Set(const ::std::string* default_value, const ::std::string& value, ::google::protobuf::Arena* arena) { @@ -62,6 +73,12 @@ struct LIBPROTOBUF_EXPORT ArenaStringPtr { } } + inline void SetLite(const ::std::string* default_value, + const ::std::string& value, + ::google::protobuf::Arena* arena) { + Set(default_value, value, arena); + } + // Basic accessors. inline const ::std::string& Get() const { return *ptr_; } @@ -84,8 +101,9 @@ struct LIBPROTOBUF_EXPORT ArenaStringPtr { } ::std::string* released = NULL; if (arena != NULL) { - // ptr_ is owned by the arena -- we need to return a copy. - released = new ::std::string(*ptr_); + // ptr_ is owned by the arena. + released = new ::std::string; + released->swap(*ptr_); } else { released = ptr_; } @@ -143,7 +161,7 @@ struct LIBPROTOBUF_EXPORT ArenaStringPtr { // Swaps internal pointers. Arena-safety semantics: this is guarded by the // logic in Swap()/UnsafeArenaSwap() at the message level, so this method is // 'unsafe' if called directly. - GOOGLE_ATTRIBUTE_ALWAYS_INLINE void Swap(ArenaStringPtr* other) { + GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE void Swap(ArenaStringPtr* other) { std::swap(ptr_, other->ptr_); } @@ -288,18 +306,27 @@ struct LIBPROTOBUF_EXPORT ArenaStringPtr { return ptr_ == default_value; } + // Internal accessors!!!! + void UnsafeSetTaggedPointer(TaggedPtr< ::std::string> value) { + ptr_ = value.Get(); + } + // Generated code only! An optimization, in certain cases the generated + // code is certain we can obtain a string with no default checks and + // tag tests. + ::std::string* UnsafeMutablePointer() { return ptr_; } + private: ::std::string* ptr_; - GOOGLE_ATTRIBUTE_NOINLINE void CreateInstance(::google::protobuf::Arena* arena, - const ::std::string* initial_value) { + GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE + void CreateInstance(::google::protobuf::Arena* arena, + const ::std::string* initial_value) { GOOGLE_DCHECK(initial_value != NULL); - ptr_ = new ::std::string(*initial_value); - if (arena != NULL) { - arena->Own(ptr_); - } + // uses "new ::std::string" when arena is nullptr + ptr_ = Arena::Create< ::std::string >(arena, *initial_value); } - GOOGLE_ATTRIBUTE_NOINLINE void CreateInstanceNoArena(const ::std::string* initial_value) { + GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE + void CreateInstanceNoArena(const ::std::string* initial_value) { GOOGLE_DCHECK(initial_value != NULL); ptr_ = new ::std::string(*initial_value); } diff --git a/src/google/protobuf/arenastring_unittest.cc b/src/google/protobuf/arenastring_unittest.cc index e5afe42d..d5d995a6 100644 --- a/src/google/protobuf/arenastring_unittest.cc +++ b/src/google/protobuf/arenastring_unittest.cc @@ -32,19 +32,23 @@ #include <google/protobuf/arenastring.h> -#include <string> +#include <algorithm> +#include <cstdlib> #include <memory> #ifndef _SHARED_PTR_H #include <google/protobuf/stubs/shared_ptr.h> #endif -#include <cstdlib> +#include <string> +#include <vector> #include <google/protobuf/stubs/logging.h> #include <google/protobuf/stubs/common.h> #include <gtest/gtest.h> +#include <google/protobuf/io/coded_stream.h> +#include <google/protobuf/io/zero_copy_stream_impl.h> + namespace google { -using google::protobuf::internal::ArenaString; using google::protobuf::internal::ArenaStringPtr; namespace protobuf { @@ -87,7 +91,35 @@ TEST(ArenaStringPtrTest, ArenaStringPtrOnArena) { EXPECT_EQ(string("default"), field.Get()); field.Set(&default_value, WrapString("Test short"), &arena); EXPECT_EQ(string("Test short"), field.Get()); - field.Set(&default_value, WrapString("Test long long long long value"), &arena); + field.Set(&default_value, WrapString("Test long long long long value"), + &arena); + EXPECT_EQ(string("Test long long long long value"), field.Get()); + field.Set(&default_value, string(""), &arena); + field.Destroy(&default_value, &arena); + + ArenaStringPtr field2; + field2.UnsafeSetDefault(&default_value); + ::std::string* mut = field2.Mutable(&default_value, &arena); + EXPECT_EQ(mut, field2.Mutable(&default_value, &arena)); + EXPECT_EQ(mut, &field2.Get()); + EXPECT_NE(&default_value, mut); + EXPECT_EQ(string("default"), *mut); + *mut = "Test long long long long value"; // ensure string allocates storage + EXPECT_EQ(string("Test long long long long value"), field2.Get()); + field2.Destroy(&default_value, &arena); +} + +TEST(ArenaStringPtrTest, ArenaStringPtrOnArenaNoSSO) { + google::protobuf::Arena arena; + ArenaStringPtr field; + ::std::string default_value = "default"; + field.UnsafeSetDefault(&default_value); + EXPECT_EQ(string("default"), field.Get()); + + // Avoid triggering the SSO optimization by setting the string to something + // larger than the internal buffer. + field.Set(&default_value, WrapString("Test long long long long value"), + &arena); EXPECT_EQ(string("Test long long long long value"), field.Get()); field.Set(&default_value, string(""), &arena); field.Destroy(&default_value, &arena); @@ -104,5 +136,6 @@ TEST(ArenaStringPtrTest, ArenaStringPtrOnArena) { field2.Destroy(&default_value, &arena); } + } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/compiler/annotation_test_util.cc b/src/google/protobuf/compiler/annotation_test_util.cc new file mode 100644 index 00000000..cc8534cc --- /dev/null +++ b/src/google/protobuf/compiler/annotation_test_util.cc @@ -0,0 +1,169 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include <google/protobuf/compiler/annotation_test_util.h> + +#include <memory> +#ifndef _SHARED_PTR_H +#include <google/protobuf/stubs/shared_ptr.h> +#endif +#include <google/protobuf/compiler/code_generator.h> +#include <google/protobuf/compiler/command_line_interface.h> +#include <google/protobuf/io/printer.h> +#include <google/protobuf/io/zero_copy_stream.h> +#include <google/protobuf/io/zero_copy_stream_impl_lite.h> +#include <google/protobuf/descriptor.pb.h> + +#include <google/protobuf/testing/file.h> +#include <google/protobuf/testing/file.h> +#include <google/protobuf/testing/googletest.h> +#include <gtest/gtest.h> + +namespace google { +namespace protobuf { +namespace compiler { +namespace annotation_test_util { +namespace { + +// A CodeGenerator that captures the FileDescriptor it's passed as a +// FileDescriptorProto. +class DescriptorCapturingGenerator : public CodeGenerator { + public: + // Does not own file; file must outlive the Generator. + explicit DescriptorCapturingGenerator(FileDescriptorProto* file) + : file_(file) {} + + virtual bool Generate(const FileDescriptor* file, const string& parameter, + GeneratorContext* context, string* error) const { + file->CopyTo(file_); + return true; + } + + private: + FileDescriptorProto* file_; +}; +} // namespace + +void AddFile(const string& filename, const string& data) { + GOOGLE_CHECK_OK(File::SetContents(TestTempDir() + "/" + filename, data, + true)); +} + +bool RunProtoCompiler(const string& filename, + const string& plugin_specific_args, + CommandLineInterface* cli, FileDescriptorProto* file) { + cli->SetInputsAreProtoPathRelative(true); + + DescriptorCapturingGenerator capturing_generator(file); + cli->RegisterGenerator("--capture_out", &capturing_generator, ""); + + string proto_path = "-I" + TestTempDir(); + string capture_out = "--capture_out=" + TestTempDir(); + + const char* argv[] = {"protoc", proto_path.c_str(), + plugin_specific_args.c_str(), capture_out.c_str(), + filename.c_str()}; + + return cli->Run(5, argv) == 0; +} + +bool DecodeMetadata(const string& path, GeneratedCodeInfo* info) { + string data; + GOOGLE_CHECK_OK(File::GetContents(path, &data, true)); + io::ArrayInputStream input(data.data(), data.size()); + return info->ParseFromZeroCopyStream(&input); +} + +void FindAnnotationsOnPath( + const GeneratedCodeInfo& info, const string& source_file, + const std::vector<int>& path, + std::vector<const GeneratedCodeInfo::Annotation*>* annotations) { + for (int i = 0; i < info.annotation_size(); ++i) { + const GeneratedCodeInfo::Annotation* annotation = &info.annotation(i); + if (annotation->source_file() != source_file || + annotation->path_size() != path.size()) { + continue; + } + int node = 0; + for (; node < path.size(); ++node) { + if (annotation->path(node) != path[node]) { + break; + } + } + if (node == path.size()) { + annotations->push_back(annotation); + } + } +} + +const GeneratedCodeInfo::Annotation* FindAnnotationOnPath( + const GeneratedCodeInfo& info, const string& source_file, + const std::vector<int>& path) { + std::vector<const GeneratedCodeInfo::Annotation*> annotations; + FindAnnotationsOnPath(info, source_file, path, &annotations); + if (annotations.empty()) { + return NULL; + } + return annotations[0]; +} + +bool AtLeastOneAnnotationMatchesSubstring( + const string& file_content, + const std::vector<const GeneratedCodeInfo::Annotation*>& annotations, + const string& expected_text) { + for (std::vector<const GeneratedCodeInfo::Annotation*>::const_iterator + i = annotations.begin(), + e = annotations.end(); + i != e; ++i) { + const GeneratedCodeInfo::Annotation* annotation = *i; + uint32 begin = annotation->begin(); + uint32 end = annotation->end(); + if (end < begin || end > file_content.size()) { + return false; + } + if (file_content.substr(begin, end - begin) == expected_text) { + return true; + } + } + return false; +} + +bool AnnotationMatchesSubstring(const string& file_content, + const GeneratedCodeInfo::Annotation* annotation, + const string& expected_text) { + std::vector<const GeneratedCodeInfo::Annotation*> annotations; + annotations.push_back(annotation); + return AtLeastOneAnnotationMatchesSubstring(file_content, annotations, + expected_text); +} +} // namespace annotation_test_util +} // namespace compiler +} // namespace protobuf +} // namespace google diff --git a/src/google/protobuf/compiler/annotation_test_util.h b/src/google/protobuf/compiler/annotation_test_util.h new file mode 100644 index 00000000..90bd88b3 --- /dev/null +++ b/src/google/protobuf/compiler/annotation_test_util.h @@ -0,0 +1,114 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#ifndef GOOGLE_PROTOBUF_COMPILER_ANNOTATION_TEST_UTIL_H__ +#define GOOGLE_PROTOBUF_COMPILER_ANNOTATION_TEST_UTIL_H__ + +#include <google/protobuf/descriptor.pb.h> +#include <google/protobuf/testing/googletest.h> +#include <gtest/gtest.h> + +// Utilities that assist in writing tests for generator annotations. +// See java/internal/annotation_unittest.cc for an example. +namespace google { +namespace protobuf { +namespace compiler { +namespace annotation_test_util { + +// Struct that contains the file generated from a .proto file and its +// GeneratedCodeInfo. For example, the Java generator will fill this struct +// (for some 'foo.proto') with: +// file_path = "Foo.java" +// file_content = content of Foo.java +// file_info = parsed content of Foo.java.pb.meta +struct ExpectedOutput { + string file_path; + string file_content; + GeneratedCodeInfo file_info; + explicit ExpectedOutput(const string& file_path) : file_path(file_path) {} +}; + +// Creates a file with name `filename` and content `data` in temp test +// directory. +void AddFile(const string& filename, const string& data); + +// Runs proto compiler. Captures proto file structrue in FileDescriptorProto. +// Files will be generated in TestTempDir() folder. Callers of this +// function must read generated files themselves. +// +// filename: source .proto file used to generate code. +// plugin_specific_args: command line arguments specific to current generator. +// For Java, this value might be "--java_out=annotate_code:test_temp_dir" +// cli: instance of command line interface to run generator. See Java's +// annotation_unittest.cc for an example of how to initialize it. +// file: output parameter, will be set to the descriptor of the proto file +// specified in filename. +bool RunProtoCompiler(const string& filename, + const string& plugin_specific_args, + CommandLineInterface* cli, FileDescriptorProto* file); + +bool DecodeMetadata(const string& path, GeneratedCodeInfo* info); + +// Finds all of the Annotations for a given source file and path. +// See Location.path in http://google/protobuf/descriptor.proto for +// explanation of what path vector is. +void FindAnnotationsOnPath( + const GeneratedCodeInfo& info, const string& source_file, + const std::vector<int>& path, + std::vector<const GeneratedCodeInfo::Annotation*>* annotations); + +// Finds the Annotation for a given source file and path (or returns null if it +// couldn't). If there are several annotations for given path, returns the first +// one. See Location.path in +// http://google/protobuf/descriptor.proto for explanation of what path +// vector is. +const GeneratedCodeInfo::Annotation* FindAnnotationOnPath( + const GeneratedCodeInfo& info, const string& source_file, + const std::vector<int>& path); + +// Returns true if at least one of the provided annotations covers a given +// substring in file_content. +bool AtLeastOneAnnotationMatchesSubstring( + const string& file_content, + const std::vector<const GeneratedCodeInfo::Annotation*>& annotations, + const string& expected_text); + +// Returns true if the provided annotation covers a given substring in +// file_content. +bool AnnotationMatchesSubstring(const string& file_content, + const GeneratedCodeInfo::Annotation* annotation, + const string& expected_text); + +} // namespace annotation_test_util +} // namespace compiler +} // namespace protobuf + +} // namespace google +#endif // GOOGLE_PROTOBUF_COMPILER_ANNOTATION_TEST_UTIL_H__ diff --git a/src/google/protobuf/compiler/code_generator.h b/src/google/protobuf/compiler/code_generator.h index b917d373..4c2b3ee1 100644 --- a/src/google/protobuf/compiler/code_generator.h +++ b/src/google/protobuf/compiler/code_generator.h @@ -50,6 +50,8 @@ namespace io { class ZeroCopyOutputStream; } class FileDescriptor; namespace compiler { +class AccessInfoMap; + class Version; // Defined in this file. @@ -112,7 +114,8 @@ class LIBPROTOC_EXPORT CodeGenerator { // runs. class LIBPROTOC_EXPORT GeneratorContext { public: - inline GeneratorContext() {} + inline GeneratorContext() { + } virtual ~GeneratorContext(); // Opens the given file, truncating it if it exists, and returns a @@ -148,6 +151,7 @@ class LIBPROTOC_EXPORT GeneratorContext { // this GeneratorContext. virtual void GetCompilerVersion(Version* version) const; + private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(GeneratorContext); }; @@ -162,8 +166,8 @@ typedef GeneratorContext OutputDirectory; // "foo=bar,baz,qux=corge" // parses to the pairs: // ("foo", "bar"), ("baz", ""), ("qux", "corge") -extern void ParseGeneratorParameter(const string&, - std::vector<std::pair<string, string> >*); +LIBPROTOC_EXPORT void ParseGeneratorParameter( + const string&, std::vector<std::pair<string, string> >*); } // namespace compiler } // namespace protobuf diff --git a/src/google/protobuf/compiler/command_line_interface.cc b/src/google/protobuf/compiler/command_line_interface.cc index df03907d..7c45fe75 100644 --- a/src/google/protobuf/compiler/command_line_interface.cc +++ b/src/google/protobuf/compiler/command_line_interface.cc @@ -33,6 +33,8 @@ // Sanjay Ghemawat, Jeff Dean, and others. #include <google/protobuf/compiler/command_line_interface.h> + + #include <google/protobuf/stubs/platform_macros.h> #include <stdio.h> @@ -45,10 +47,7 @@ #endif #include <sys/stat.h> #include <fcntl.h> -#ifdef _MSC_VER -#include <io.h> -#include <direct.h> -#else +#ifndef _MSC_VER #include <unistd.h> #endif #include <errno.h> @@ -68,45 +67,30 @@ #endif #include <google/protobuf/stubs/common.h> +#include <google/protobuf/stubs/logging.h> #include <google/protobuf/stubs/stringprintf.h> -#include <google/protobuf/compiler/importer.h> -#include <google/protobuf/compiler/code_generator.h> -#include <google/protobuf/compiler/plugin.pb.h> #include <google/protobuf/compiler/subprocess.h> #include <google/protobuf/compiler/zip_writer.h> -#include <google/protobuf/descriptor.h> -#include <google/protobuf/text_format.h> -#include <google/protobuf/dynamic_message.h> +#include <google/protobuf/compiler/plugin.pb.h> +#include <google/protobuf/compiler/code_generator.h> +#include <google/protobuf/compiler/importer.h> #include <google/protobuf/io/coded_stream.h> -#include <google/protobuf/io/zero_copy_stream_impl.h> #include <google/protobuf/io/printer.h> -#include <google/protobuf/stubs/logging.h> +#include <google/protobuf/io/zero_copy_stream_impl.h> +#include <google/protobuf/descriptor.h> +#include <google/protobuf/dynamic_message.h> +#include <google/protobuf/text_format.h> #include <google/protobuf/stubs/strutil.h> #include <google/protobuf/stubs/substitute.h> #include <google/protobuf/stubs/map_util.h> #include <google/protobuf/stubs/stl_util.h> +#include <google/protobuf/stubs/io_win32.h> namespace google { namespace protobuf { namespace compiler { -#if defined(_WIN32) -#define mkdir(name, mode) mkdir(name) -#ifndef W_OK -#define W_OK 02 // not defined by MSVC for whatever reason -#endif -#ifndef F_OK -#define F_OK 00 // not defined by MSVC for whatever reason -#endif -#ifndef STDIN_FILENO -#define STDIN_FILENO 0 -#endif -#ifndef STDOUT_FILENO -#define STDOUT_FILENO 1 -#endif -#endif - #ifndef O_BINARY #ifdef _O_BINARY #define O_BINARY _O_BINARY @@ -116,10 +100,15 @@ namespace compiler { #endif namespace { -#if defined(_WIN32) && !defined(__CYGWIN__) -static const char* kPathSeparator = ";"; -#else -static const char* kPathSeparator = ":"; +#if defined(_WIN32) +// DO NOT include <io.h>, instead create functions in io_win32.{h,cc} and import +// them like we do below. +using google::protobuf::internal::win32::access; +using google::protobuf::internal::win32::close; +using google::protobuf::internal::win32::mkdir; +using google::protobuf::internal::win32::open; +using google::protobuf::internal::win32::setmode; +using google::protobuf::internal::win32::write; #endif static const char* kDefaultDirectDependenciesViolationMsg = @@ -141,9 +130,9 @@ static bool IsWindowsAbsolutePath(const string& text) { void SetFdToTextMode(int fd) { #ifdef _WIN32 - if (_setmode(fd, _O_TEXT) == -1) { + if (setmode(fd, _O_TEXT) == -1) { // This should never happen, I think. - GOOGLE_LOG(WARNING) << "_setmode(" << fd << ", _O_TEXT): " << strerror(errno); + GOOGLE_LOG(WARNING) << "setmode(" << fd << ", _O_TEXT): " << strerror(errno); } #endif // (Text and binary are the same on non-Windows platforms.) @@ -151,9 +140,9 @@ void SetFdToTextMode(int fd) { void SetFdToBinaryMode(int fd) { #ifdef _WIN32 - if (_setmode(fd, _O_BINARY) == -1) { + if (setmode(fd, _O_BINARY) == -1) { // This should never happen, I think. - GOOGLE_LOG(WARNING) << "_setmode(" << fd << ", _O_BINARY): " << strerror(errno); + GOOGLE_LOG(WARNING) << "setmode(" << fd << ", _O_BINARY): " << strerror(errno); } #endif // (Text and binary are the same on non-Windows platforms.) @@ -235,9 +224,9 @@ bool IsInstalledProtoPath(const string& path) { return access(file_path.c_str(), F_OK) != -1; } -// Add the paths where google/protobuf/descritor.proto and other well-known +// Add the paths where google/protobuf/descriptor.proto and other well-known // type protos are installed. -void AddDefaultProtoPaths(vector<pair<string, string> >* paths) { +void AddDefaultProtoPaths(std::vector<std::pair<string, string> >* paths) { // TODO(xiaofeng): The code currently only checks relative paths of where // the protoc binary is installed. We probably should make it handle more // cases than that. @@ -253,12 +242,12 @@ void AddDefaultProtoPaths(vector<pair<string, string> >* paths) { path = path.substr(0, pos); // Check the binary's directory. if (IsInstalledProtoPath(path)) { - paths->push_back(pair<string, string>("", path)); + paths->push_back(std::pair<string, string>("", path)); return; } // Check if there is an include subdirectory. if (IsInstalledProtoPath(path + "/include")) { - paths->push_back(pair<string, string>("", path + "/include")); + paths->push_back(std::pair<string, string>("", path + "/include")); return; } // Check if the upper level directory has an "include" subdirectory. @@ -268,7 +257,7 @@ void AddDefaultProtoPaths(vector<pair<string, string> >* paths) { } path = path.substr(0, pos); if (IsInstalledProtoPath(path + "/include")) { - paths->push_back(pair<string, string>("", path + "/include")); + paths->push_back(std::pair<string, string>("", path + "/include")); return; } } @@ -278,11 +267,14 @@ string PluginName(const string& plugin_prefix, const string& directive) { // strip the "--" and "_out/_opt" and add the plugin prefix. return plugin_prefix + "gen-" + directive.substr(2, directive.size() - 6); } + } // namespace // A MultiFileErrorCollector that prints errors to stderr. -class CommandLineInterface::ErrorPrinter : public MultiFileErrorCollector, - public io::ErrorCollector { +class CommandLineInterface::ErrorPrinter + : public MultiFileErrorCollector, + public io::ErrorCollector, + public DescriptorPool::ErrorCollector { public: ErrorPrinter(ErrorFormat format, DiskSourceTree *tree = NULL) : format_(format), tree_(tree), found_errors_(false) {} @@ -309,6 +301,25 @@ class CommandLineInterface::ErrorPrinter : public MultiFileErrorCollector, AddErrorOrWarning("input", line, column, message, "warning", std::clog); } + // implements DescriptorPool::ErrorCollector------------------------- + void AddError( + const string& filename, + const string& element_name, + const Message* descriptor, + ErrorLocation location, + const string& message) { + AddErrorOrWarning(filename, -1, -1, message, "error", std::cerr); + } + + void AddWarning( + const string& filename, + const string& element_name, + const Message* descriptor, + ErrorLocation location, + const string& message) { + AddErrorOrWarning(filename, -1, -1, message, "warning", std::clog); + } + bool FoundErrors() const { return found_errors_; } private: @@ -410,6 +421,13 @@ class CommandLineInterface::MemoryOutputStream virtual int64 ByteCount() const { return inner_->ByteCount(); } private: + // Checks to see if "filename_.meta" exists in directory_; if so, fixes the + // offsets in that GeneratedCodeInfo record to reflect bytes inserted in + // filename_ at original offset insertion_offset with length insertion_length. + // We assume that insertions will not occur within any given annotated span + // of text. + void UpdateMetadata(size_t insertion_offset, size_t insertion_length); + // Where to insert the string when it's done. GeneratorContextImpl* directory_; string filename_; @@ -430,8 +448,7 @@ class CommandLineInterface::MemoryOutputStream CommandLineInterface::GeneratorContextImpl::GeneratorContextImpl( const std::vector<const FileDescriptor*>& parsed_files) : parsed_files_(parsed_files), - had_error_(false) { -} + had_error_(false) {} CommandLineInterface::GeneratorContextImpl::~GeneratorContextImpl() { STLDeleteValues(&files_); @@ -607,6 +624,44 @@ CommandLineInterface::MemoryOutputStream::MemoryOutputStream( inner_(new io::StringOutputStream(&data_)) { } +void CommandLineInterface::MemoryOutputStream::UpdateMetadata( + size_t insertion_offset, size_t insertion_length) { + std::map<string, string*>::iterator meta_file = + directory_->files_.find(filename_ + ".meta"); + if (meta_file == directory_->files_.end() || !meta_file->second) { + // No metadata was recorded for this file. + return; + } + string* encoded_data = meta_file->second; + GeneratedCodeInfo metadata; + bool is_text_format = false; + if (!metadata.ParseFromString(*encoded_data)) { + if (!TextFormat::ParseFromString(*encoded_data, &metadata)) { + // The metadata is invalid. + std::cerr << filename_ + << ".meta: Could not parse metadata as wire or text format." + << std::endl; + return; + } + // Generators that use the public plugin interface emit text-format + // metadata (because in the public plugin protocol, file content must be + // UTF8-encoded strings). + is_text_format = true; + } + for (int i = 0; i < metadata.annotation_size(); ++i) { + GeneratedCodeInfo::Annotation* annotation = metadata.mutable_annotation(i); + if (annotation->begin() >= insertion_offset) { + annotation->set_begin(annotation->begin() + insertion_length); + annotation->set_end(annotation->end() + insertion_length); + } + } + if (is_text_format) { + TextFormat::PrintToString(metadata, encoded_data); + } else { + metadata.SerializeToString(encoded_data); + } +} + CommandLineInterface::MemoryOutputStream::~MemoryOutputStream() { // Make sure all data has been written. inner_.reset(); @@ -684,6 +739,7 @@ CommandLineInterface::MemoryOutputStream::~MemoryOutputStream() { if (indent_.empty()) { // No indent. This makes things easier. target->insert(pos, data_); + UpdateMetadata(pos, data_.size()); } else { // Calculate how much space we need. int indent_size = 0; @@ -693,6 +749,7 @@ CommandLineInterface::MemoryOutputStream::~MemoryOutputStream() { // Make a hole for it. target->insert(pos, data_.size() + indent_size, '\0'); + UpdateMetadata(pos, data_.size() + indent_size); // Now copy in the data. string::size_type data_pos = 0; @@ -720,6 +777,12 @@ CommandLineInterface::MemoryOutputStream::~MemoryOutputStream() { // =================================================================== +#if defined(_WIN32) && !defined(__CYGWIN__) +const char* const CommandLineInterface::kPathSeparator = ";"; +#else +const char* const CommandLineInterface::kPathSeparator = ":"; +#endif + CommandLineInterface::CommandLineInterface() : mode_(MODE_COMPILE), print_mode_(PRINT_NONE), @@ -729,9 +792,7 @@ CommandLineInterface::CommandLineInterface() kDefaultDirectDependenciesViolationMsg), imports_in_descriptor_set_(false), source_info_in_descriptor_set_(false), - disallow_services_(false), - inputs_are_proto_path_relative_(false) { -} + disallow_services_(false) {} CommandLineInterface::~CommandLineInterface() {} void CommandLineInterface::RegisterGenerator(const string& flag_name, @@ -772,63 +833,42 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) { break; } - AddDefaultProtoPaths(&proto_path_); - - // Set up the source tree. - DiskSourceTree source_tree; - for (int i = 0; i < proto_path_.size(); i++) { - source_tree.MapPath(proto_path_[i].first, proto_path_[i].second); - } - - // Map input files to virtual paths if necessary. - if (!inputs_are_proto_path_relative_) { - if (!MakeInputsBeProtoPathRelative(&source_tree)) { + std::vector<const FileDescriptor*> parsed_files; + // null unless descriptor_set_in_names_.empty() + google::protobuf::scoped_ptr<DiskSourceTree> disk_source_tree; + google::protobuf::scoped_ptr<ErrorPrinter> error_collector; + google::protobuf::scoped_ptr<DescriptorPool> descriptor_pool; + google::protobuf::scoped_ptr<DescriptorDatabase> descriptor_database; + if (descriptor_set_in_names_.empty()) { + disk_source_tree.reset(new DiskSourceTree()); + if (!InitializeDiskSourceTree(disk_source_tree.get())) { return 1; } - } - - // Allocate the Importer. - ErrorPrinter error_collector(error_format_, &source_tree); - Importer importer(&source_tree, &error_collector); - - std::vector<const FileDescriptor*> parsed_files; + error_collector.reset( + new ErrorPrinter(error_format_, disk_source_tree.get())); - // Parse each file. - for (int i = 0; i < input_files_.size(); i++) { - // Import the file. - importer.AddUnusedImportTrackFile(input_files_[i]); - const FileDescriptor* parsed_file = importer.Import(input_files_[i]); - importer.ClearUnusedImportTrackFiles(); - if (parsed_file == NULL) return 1; - parsed_files.push_back(parsed_file); + SourceTreeDescriptorDatabase* database = + new SourceTreeDescriptorDatabase(disk_source_tree.get()); + database->RecordErrorsTo(error_collector.get()); + descriptor_database.reset(database); + descriptor_pool.reset(new DescriptorPool( + descriptor_database.get(), database->GetValidationErrorCollector())); + } else { + error_collector.reset(new ErrorPrinter(error_format_)); - // Enforce --disallow_services. - if (disallow_services_ && parsed_file->service_count() > 0) { - std::cerr << parsed_file->name() << ": This file contains services, but " - "--disallow_services was used." << std::endl; + SimpleDescriptorDatabase* database = new SimpleDescriptorDatabase(); + descriptor_database.reset(database); + if (!PopulateSimpleDescriptorDatabase(database)) { 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; - std::cerr << parsed_file->name() << ": " - << StringReplace(direct_dependencies_violation_msg_, "%s", - parsed_file->dependency(i)->name(), - true /* replace_all */) - << std::endl; - } - } - if (indirect_imports) { - return 1; - } - } + descriptor_pool.reset(new DescriptorPool(database, error_collector.get())); + } + descriptor_pool->EnforceWeakDependencies(true); + if (!ParseInputFiles(descriptor_pool.get(), &parsed_files)) { + return 1; } + // We construct a separate GeneratorContext for each output location. Note // that two code generators may output to the same location, in which case // they should share a single GeneratorContext so that OpenForInsert() works. @@ -879,15 +919,16 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) { } if (!dependency_out_name_.empty()) { + GOOGLE_DCHECK(disk_source_tree.get()); if (!GenerateDependencyManifestFile(parsed_files, output_directories, - &source_tree)) { + disk_source_tree.get())) { return 1; } } STLDeleteValues(&output_directories); - if (!descriptor_set_name_.empty()) { + if (!descriptor_set_out_name_.empty()) { if (!WriteDescriptorSet(parsed_files)) { return 1; } @@ -906,13 +947,13 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) { return 1; } } else { - if (!EncodeOrDecode(importer.pool())) { + if (!EncodeOrDecode(descriptor_pool.get())) { return 1; } } } - if (error_collector.FoundErrors()) { + if (error_collector->FoundErrors()) { return 1; } @@ -928,7 +969,7 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) { break; case PRINT_NONE: GOOGLE_LOG(ERROR) << "If the code reaches here, it usually means a bug of " - "flag parsing in the CommonadLineInterface."; + "flag parsing in the CommandLineInterface."; return 1; // Do not add a default case. @@ -938,6 +979,113 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) { return 0; } +bool CommandLineInterface::InitializeDiskSourceTree( + DiskSourceTree* source_tree) { + AddDefaultProtoPaths(&proto_path_); + + // Set up the source tree. + for (int i = 0; i < proto_path_.size(); i++) { + source_tree->MapPath(proto_path_[i].first, proto_path_[i].second); + } + + // Map input files to virtual paths if possible. + if (!MakeInputsBeProtoPathRelative(source_tree)) { + return false; + } + return true; +} + +bool CommandLineInterface::PopulateSimpleDescriptorDatabase( + SimpleDescriptorDatabase* database) { + for (int i = 0; i < descriptor_set_in_names_.size(); i++) { + int fd; + do { + fd = open(descriptor_set_in_names_[i].c_str(), O_RDONLY | O_BINARY); + } while (fd < 0 && errno == EINTR); + if (fd < 0) { + std::cerr << descriptor_set_in_names_[i] << ": " + << strerror(ENOENT) << std::endl; + return false; + } + + FileDescriptorSet file_descriptor_set; + bool parsed = file_descriptor_set.ParseFromFileDescriptor(fd); + if (close(fd) != 0) { + std::cerr << descriptor_set_in_names_[i] << ": close: " + << strerror(errno) + << std::endl; + return false; + } + + if (!parsed) { + std::cerr << descriptor_set_in_names_[i] << ": Unable to parse." + << std::endl; + return false; + } + + for (int j = 0; j < file_descriptor_set.file_size(); j++) { + FileDescriptorProto previously_added_file_descriptor_proto; + if (database->FindFileByName(file_descriptor_set.file(j).name(), + &previously_added_file_descriptor_proto)) { + // already present - skip + continue; + } + if (!database->Add(file_descriptor_set.file(j))) { + return false; + } + } + } + return true; +} + +bool CommandLineInterface::ParseInputFiles( + DescriptorPool* descriptor_pool, + std::vector<const FileDescriptor*>* parsed_files) { + + // Parse each file. + for (int i = 0; i < input_files_.size(); i++) { + // Import the file. + descriptor_pool->AddUnusedImportTrackFile(input_files_[i]); + const FileDescriptor* parsed_file = + descriptor_pool->FindFileByName(input_files_[i]); + descriptor_pool->ClearUnusedImportTrackFiles(); + if (parsed_file == NULL) { + if (!descriptor_set_in_names_.empty()) { + std::cerr << input_files_[i] << ": " << strerror(ENOENT) << std::endl; + } + return false; + } + parsed_files->push_back(parsed_file); + + // Enforce --disallow_services. + if (disallow_services_ && parsed_file->service_count() > 0) { + std::cerr << parsed_file->name() << ": This file contains services, but " + "--disallow_services was used." << std::endl; + return false; + } + + // 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; + std::cerr << parsed_file->name() << ": " + << StringReplace(direct_dependencies_violation_msg_, "%s", + parsed_file->dependency(i)->name(), + true /* replace_all */) + << std::endl; + } + } + if (indirect_imports) { + return false; + } + } + } + return true; +} + void CommandLineInterface::Clear() { // Clear all members that are set by Run(). Note that we must not clear // members which are set by other methods before Run() is called. @@ -948,7 +1096,8 @@ void CommandLineInterface::Clear() { direct_dependencies_violation_msg_ = kDefaultDirectDependenciesViolationMsg; output_directives_.clear(); codec_type_.clear(); - descriptor_set_name_.clear(); + descriptor_set_in_names_.clear(); + descriptor_set_out_name_.clear(); dependency_out_name_.clear(); mode_ = MODE_COMPILE; @@ -962,6 +1111,17 @@ void CommandLineInterface::Clear() { bool CommandLineInterface::MakeInputsBeProtoPathRelative( DiskSourceTree* source_tree) { for (int i = 0; i < input_files_.size(); i++) { + // If the input file path is not a physical file path, it must be a virtual + // path. + if (access(input_files_[i].c_str(), F_OK) < 0) { + string disk_file; + if (source_tree->VirtualFileToDiskFile(input_files_[i], &disk_file)) { + return true; + } else { + std::cerr << input_files_[i] << ": " << strerror(ENOENT) << std::endl; + return false; + } + } string virtual_file, shadowing_disk_file; switch (source_tree->DiskFileToVirtualFile( input_files_[i], &virtual_file, &shadowing_disk_file)) { @@ -979,12 +1139,14 @@ bool CommandLineInterface::MakeInputsBeProtoPathRelative( case DiskSourceTree::CANNOT_OPEN: std::cerr << input_files_[i] << ": " << strerror(errno) << std::endl; return false; - case DiskSourceTree::NO_MAPPING: - // First check if the file exists at all. - if (access(input_files_[i].c_str(), F_OK) < 0) { - // File does not even exist. - std::cerr << input_files_[i] << ": " << strerror(ENOENT) << std::endl; + case DiskSourceTree::NO_MAPPING: { + // Try to interpret the path as a virtual path. + string disk_file; + if (source_tree->VirtualFileToDiskFile(input_files_[i], &disk_file)) { + return true; } else { + // The input file path can't be mapped to any --proto_path and it also + // can't be interpreted as a virtual path. std::cerr << input_files_[i] << ": File does not reside within any path " @@ -993,15 +1155,32 @@ bool CommandLineInterface::MakeInputsBeProtoPathRelative( "proto_path must be an exact prefix of the .proto file " "names -- protoc is too dumb to figure out when two paths " "(e.g. absolute and relative) are equivalent (it's harder " - "than you think)." << std::endl; + "than you think)." + << std::endl; + return false; } - return false; + } } } return true; } +bool CommandLineInterface::ExpandArgumentFile(const string& file, + std::vector<string>* arguments) { + // The argument file is searched in the working directory only. We don't + // use the proto import path here. + std::ifstream file_stream(file.c_str()); + if (!file_stream.is_open()) { + return false; + } + string argument; + // We don't support any kind of shell expansion right now. + while (std::getline(file_stream, argument)) { + arguments->push_back(argument); + } + return true; +} CommandLineInterface::ParseArgumentStatus CommandLineInterface::ParseArguments(int argc, const char* const argv[]) { @@ -1009,11 +1188,19 @@ CommandLineInterface::ParseArguments(int argc, const char* const argv[]) { std::vector<string> arguments; for (int i = 1; i < argc; ++i) { + if (argv[i][0] == '@') { + if (!ExpandArgumentFile(argv[i] + 1, &arguments)) { + std::cerr << "Failed to open argument file: " << (argv[i] + 1) + << std::endl; + return PARSE_ARGUMENT_FAIL; + } + continue; + } arguments.push_back(argv[i]); } // if no arguments are given, show help - if(arguments.empty()) { + if (arguments.empty()) { PrintHelpText(); return PARSE_ARGUMENT_DONE_AND_EXIT; // Exit without running compiler. } @@ -1091,7 +1278,7 @@ CommandLineInterface::ParseArguments(int argc, const char* const argv[]) { return PARSE_ARGUMENT_FAIL; } if (mode_ == MODE_COMPILE && output_directives_.empty() && - descriptor_set_name_.empty()) { + descriptor_set_out_name_.empty()) { std::cerr << "Missing output directives." << std::endl; return PARSE_ARGUMENT_FAIL; } @@ -1106,11 +1293,11 @@ CommandLineInterface::ParseArguments(int argc, const char* const argv[]) { << std::endl; return PARSE_ARGUMENT_FAIL; } - if (imports_in_descriptor_set_ && descriptor_set_name_.empty()) { + if (imports_in_descriptor_set_ && descriptor_set_out_name_.empty()) { std::cerr << "--include_imports only makes sense when combined with " "--descriptor_set_out." << std::endl; } - if (source_info_in_descriptor_set_ && descriptor_set_name_.empty()) { + if (source_info_in_descriptor_set_ && descriptor_set_out_name_.empty()) { std::cerr << "--include_source_info only makes sense when combined with " "--descriptor_set_out." << std::endl; } @@ -1197,11 +1384,20 @@ CommandLineInterface::InterpretArgument(const string& name, input_files_.push_back(value); } else if (name == "-I" || name == "--proto_path") { + if (!descriptor_set_in_names_.empty()) { + std::cerr << "Only one of " << name + << " and --descriptor_set_in can be specified." + << std::endl; + return PARSE_ARGUMENT_FAIL; + } + // Java's -classpath (and some other languages) delimits path components // with colons. Let's accept that syntax too just to make things more // intuitive. std::vector<string> parts = Split( - value, kPathSeparator, true); + value, + CommandLineInterface::kPathSeparator, + true); for (int i = 0; i < parts.size(); i++) { string virtual_path; @@ -1259,8 +1455,38 @@ CommandLineInterface::InterpretArgument(const string& name, } else if (name == "--direct_dependencies_violation_msg") { direct_dependencies_violation_msg_ = value; + } else if (name == "--descriptor_set_in") { + if (!descriptor_set_in_names_.empty()) { + std::cerr << name << " may only be passed once. To specify multiple " + "descriptor sets, pass them all as a single " + "parameter separated by '" + << CommandLineInterface::kPathSeparator << "'." + << std::endl; + return PARSE_ARGUMENT_FAIL; + } + if (value.empty()) { + std::cerr << name << " requires a non-empty value." << std::endl; + return PARSE_ARGUMENT_FAIL; + } + if (!proto_path_.empty()) { + std::cerr << "Only one of " << name + << " and --proto_path can be specified." + << std::endl; + return PARSE_ARGUMENT_FAIL; + } + if (!dependency_out_name_.empty()) { + std::cerr << name << " cannot be used with --dependency_out." + << std::endl; + return PARSE_ARGUMENT_FAIL; + } + + descriptor_set_in_names_ = Split( + value, + CommandLineInterface::kPathSeparator, + true); + } else if (name == "-o" || name == "--descriptor_set_out") { - if (!descriptor_set_name_.empty()) { + if (!descriptor_set_out_name_.empty()) { std::cerr << name << " may only be passed once." << std::endl; return PARSE_ARGUMENT_FAIL; } @@ -1274,7 +1500,7 @@ CommandLineInterface::InterpretArgument(const string& name, "same time." << std::endl; return PARSE_ARGUMENT_FAIL; } - descriptor_set_name_ = value; + descriptor_set_out_name_ = value; } else if (name == "--dependency_out") { if (!dependency_out_name_.empty()) { @@ -1285,6 +1511,11 @@ CommandLineInterface::InterpretArgument(const string& name, std::cerr << name << " requires a non-empty value." << std::endl; return PARSE_ARGUMENT_FAIL; } + if (!descriptor_set_in_names_.empty()) { + std::cerr << name << " cannot be used with --descriptor_set_in." + << std::endl; + return PARSE_ARGUMENT_FAIL; + } dependency_out_name_ = value; } else if (name == "--include_imports") { @@ -1324,7 +1555,7 @@ CommandLineInterface::InterpretArgument(const string& name, << std::endl; return PARSE_ARGUMENT_FAIL; } - if (!output_directives_.empty() || !descriptor_set_name_.empty()) { + if (!output_directives_.empty() || !descriptor_set_out_name_.empty()) { std::cerr << "Cannot use " << name << " and generate code or descriptors at the same time." << std::endl; @@ -1390,7 +1621,7 @@ CommandLineInterface::InterpretArgument(const string& name, << "other info at the same time." << std::endl; return PARSE_ARGUMENT_FAIL; } - if (!output_directives_.empty() || !descriptor_set_name_.empty()) { + if (!output_directives_.empty() || !descriptor_set_out_name_.empty()) { std::cerr << "Cannot use " << name << " and generate code or descriptors at the same time." << std::endl; @@ -1482,6 +1713,14 @@ void CommandLineInterface::PrintHelpText() { " pairs in text format to standard output. No\n" " PROTO_FILES should be given when using this\n" " flag.\n" +" --descriptor_set_in=FILES Specifies a delimited list of FILES\n" +" each containing a FileDescriptorSet (a\n" +" protocol buffer defined in descriptor.proto).\n" +" The FileDescriptor for each of the PROTO_FILES\n" +" provided will be loaded from these\n" +" FileDescriptorSets. If a FileDescriptor\n" +" appears multiple times, the first occurrence\n" +" will be used.\n" " -oFILE, Writes a FileDescriptorSet (a protocol buffer,\n" " --descriptor_set_out=FILE defined in descriptor.proto) containing all of\n" " the input files to FILE.\n" @@ -1527,6 +1766,20 @@ void CommandLineInterface::PrintHelpText() { << string(19 - iter->first.size(), ' ') // Spaces for alignment. << iter->second.help_text << std::endl; } + std::cerr << +" @<filename> Read options and filenames from file. If a\n" +" relative file path is specified, the file\n" +" will be searched in the working directory.\n" +" The --proto_path option will not affect how\n" +" this argument file is searched. Content of\n" +" the file will be expanded in the position of\n" +" @<filename> as in the argument list. Note\n" +" that shell expansion is not applied to the\n" +" content of the file (i.e., you cannot use\n" +" quotes, wildcards, escapes, commands, etc.).\n" +" Each line corresponds to a single argument,\n" +" even if it contains spaces." + << std::endl; } bool CommandLineInterface::GenerateOutput( @@ -1661,6 +1914,7 @@ bool CommandLineInterface::GeneratePluginOutput( request.set_parameter(parameter); } + std::set<const FileDescriptor*> already_seen; for (int i = 0; i < parsed_files.size(); i++) { request.add_file_to_generate(parsed_files[i]->name()); @@ -1829,24 +2083,24 @@ bool CommandLineInterface::WriteDescriptorSet( int fd; do { - fd = open(descriptor_set_name_.c_str(), + fd = open(descriptor_set_out_name_.c_str(), O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666); } while (fd < 0 && errno == EINTR); if (fd < 0) { - perror(descriptor_set_name_.c_str()); + perror(descriptor_set_out_name_.c_str()); return false; } io::FileOutputStream out(fd); if (!file_set.SerializeToZeroCopyStream(&out)) { - std::cerr << descriptor_set_name_ << ": " << strerror(out.GetErrno()) + std::cerr << descriptor_set_out_name_ << ": " << strerror(out.GetErrno()) << std::endl; out.Close(); return false; } if (!out.Close()) { - std::cerr << descriptor_set_name_ << ": " << strerror(out.GetErrno()) + std::cerr << descriptor_set_out_name_ << ": " << strerror(out.GetErrno()) << 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 997c1748..d5d85f2d 100644 --- a/src/google/protobuf/compiler/command_line_interface.h +++ b/src/google/protobuf/compiler/command_line_interface.h @@ -52,17 +52,16 @@ namespace protobuf { class Descriptor; // descriptor.h class DescriptorPool; // descriptor.h class FileDescriptor; // descriptor.h +class FileDescriptorSet; // descriptor.h class FileDescriptorProto; // descriptor.pb.h template<typename T> class RepeatedPtrField; // repeated_field.h +class SimpleDescriptorDatabase; // descriptor_database.h -} // namespace protobuf - -namespace protobuf { namespace compiler { -class CodeGenerator; // code_generator.h -class GeneratorContext; // code_generator.h -class DiskSourceTree; // importer.h +class CodeGenerator; // code_generator.h +class GeneratorContext; // code_generator.h +class DiskSourceTree; // importer.h // This class implements the command-line interface to the protocol compiler. // It is designed to make it very easy to create a custom protocol compiler @@ -91,9 +90,21 @@ class DiskSourceTree; // importer.h // The compiler is invoked with syntax like: // protoc --cpp_out=outdir --foo_out=outdir --proto_path=src src/foo.proto // +// The .proto file to compile can be specified on the command line using either +// its physical file path, or a virtual path relative to a diretory specified +// in --proto_path. For example, for src/foo.proto, the following two protoc +// invocations work the same way: +// 1. protoc --proto_path=src src/foo.proto (physical file path) +// 2. protoc --proto_path=src foo.proto (virtual path relative to src) +// +// If a file path can be interpreted both as a physical file path and as a +// relative virtual path, the physical file path takes precendence. +// // For a full description of the command-line syntax, invoke it with --help. class LIBPROTOC_EXPORT CommandLineInterface { public: + static const char* const kPathSeparator; + CommandLineInterface(); ~CommandLineInterface(); @@ -175,17 +186,11 @@ class LIBPROTOC_EXPORT CommandLineInterface { // it calls strerror(). I'm not sure why you'd want to do this anyway. int Run(int argc, const char* const argv[]); - // Call SetInputsAreCwdRelative(true) if the input files given on the command - // line should be interpreted relative to the proto import path specified - // using --proto_path or -I flags. Otherwise, input file names will be - // interpreted relative to the current working directory (or as absolute - // paths if they start with '/'), though they must still reside inside - // a directory given by --proto_path or the compiler will fail. The latter - // mode is generally more intuitive and easier to use, especially e.g. when - // defining implicit rules in Makefiles. - void SetInputsAreProtoPathRelative(bool enable) { - inputs_are_proto_path_relative_ = enable; - } + // DEPRECATED. Calling this method has no effect. Protocol compiler now + // always try to find the .proto file relative to the current directory + // first and if the file is not found, it will then treat the input path + // as a virutal path. + void SetInputsAreProtoPathRelative(bool /* enable */) {} // Provides some text which will be printed when the --version flag is // used. The version of libprotoc will also be printed on the next line @@ -222,6 +227,9 @@ class LIBPROTOC_EXPORT CommandLineInterface { // Parse all command-line arguments. ParseArgumentStatus ParseArguments(int argc, const char* const argv[]); + // Read an argument file and append the file's content to the list of + // arguments. Return false if the file cannot be read. + bool ExpandArgumentFile(const string& file, std::vector<string>* arguments); // Parses a command-line argument into a name/value pair. Returns // true if the next argument in the argv should be used as the value, @@ -243,6 +251,16 @@ class LIBPROTOC_EXPORT CommandLineInterface { // Print the --help text to stderr. void PrintHelpText(); + // Loads proto_path_ into the provided source_tree. + bool InitializeDiskSourceTree(DiskSourceTree* source_tree); + + // Loads descriptor_set_in into the provided database + bool PopulateSimpleDescriptorDatabase(SimpleDescriptorDatabase* database); + + // Parses input_files_ into parsed_files + bool ParseInputFiles(DescriptorPool* descriptor_pool, + std::vector<const FileDescriptor*>* parsed_files); + // Generate the given output file from the given input. struct OutputDirective; // see below bool GenerateOutput(const std::vector<const FileDescriptor*>& parsed_files, @@ -383,9 +401,13 @@ class LIBPROTOC_EXPORT CommandLineInterface { // decoding. (Empty string indicates --decode_raw.) string codec_type_; + // If --descriptor_set_in was given, these are filenames containing + // parsed FileDescriptorSets to be used for loading protos. Otherwise, empty. + std::vector<string> descriptor_set_in_names_; + // If --descriptor_set_out was given, this is the filename to which the // FileDescriptorSet should be written. Otherwise, empty. - string descriptor_set_name_; + string descriptor_set_out_name_; // If --dependency_out was given, this is the path to the file where the // dependency file will be written. Otherwise, empty. @@ -408,9 +430,6 @@ class LIBPROTOC_EXPORT CommandLineInterface { // Was the --disallow_services flag used? bool disallow_services_; - // See SetInputsAreProtoPathRelative(). - bool inputs_are_proto_path_relative_; - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CommandLineInterface); }; diff --git a/src/google/protobuf/compiler/command_line_interface_unittest.cc b/src/google/protobuf/compiler/command_line_interface_unittest.cc index 366e623f..ef7579a2 100644 --- a/src/google/protobuf/compiler/command_line_interface_unittest.cc +++ b/src/google/protobuf/compiler/command_line_interface_unittest.cc @@ -35,9 +35,8 @@ #include <fcntl.h> #include <sys/stat.h> #include <sys/types.h> -#ifdef _MSC_VER -#include <io.h> -#else + +#ifndef _MSC_VER #include <unistd.h> #endif #include <memory> @@ -65,26 +64,27 @@ #include <gtest/gtest.h> #include <google/protobuf/stubs/strutil.h> +#include <google/protobuf/stubs/io_win32.h> namespace google { namespace protobuf { namespace compiler { +#if defined(_WIN32) +// DO NOT include <io.h>, instead create functions in io_win32.{h,cc} and import +// them like we do below. +using google::protobuf::internal::win32::access; +using google::protobuf::internal::win32::dup; +using google::protobuf::internal::win32::dup2; +using google::protobuf::internal::win32::close; +using google::protobuf::internal::win32::open; +using google::protobuf::internal::win32::write; +#endif + // Disable the whole test when we use tcmalloc for "draconian" heap checks, in // which case tcmalloc will print warnings that fail the plugin tests. #if !GOOGLE_PROTOBUF_HEAP_CHECK_DRACONIAN -#if defined(_WIN32) -#ifndef STDIN_FILENO -#define STDIN_FILENO 0 -#endif -#ifndef STDOUT_FILENO -#define STDOUT_FILENO 1 -#endif -#ifndef F_OK -#define F_OK 00 // not defined by MSVC for whatever reason -#endif -#endif namespace { @@ -129,10 +129,6 @@ class CommandLineInterfaceTest : public testing::Test { // google3. #endif // !PROTOBUF_OPENSOURCE - void SetInputsAreProtoPathRelative(bool enable) { - cli_.SetInputsAreProtoPathRelative(enable); - } - // ----------------------------------------------------------------- // Methods to check the test results (called after Run()). @@ -192,12 +188,17 @@ class CommandLineInterfaceTest : public testing::Test { const string& insertions, const string& proto_name, const string& message_name); + void CheckGeneratedAnnotations(const string& name, const string& file); void ExpectNullCodeGeneratorCalled(const string& parameter); + void ReadDescriptorSet(const string& filename, FileDescriptorSet* descriptor_set); + void WriteDescriptorSet(const string& filename, + const FileDescriptorSet* descriptor_set); + void ExpectFileContent(const string& filename, const string& content); @@ -251,11 +252,6 @@ class CommandLineInterfaceTest::NullCodeGenerator : public CodeGenerator { // =================================================================== void CommandLineInterfaceTest::SetUp() { - // Most of these tests were written before this option was added, so we - // run with the option on (which used to be the only way) except in certain - // tests where we turn it off. - cli_.SetInputsAreProtoPathRelative(true); - temp_directory_ = TestTempDir() + "/proto2_cli_test_temp"; // If the temp directory already exists, it must be left over from a @@ -281,6 +277,7 @@ void CommandLineInterfaceTest::SetUp() { mock_generators_to_delete_.push_back(generator); cli_.RegisterGenerator("--null_out", generator, "Null output."); + disallow_plugins_ = false; } @@ -471,12 +468,18 @@ void CommandLineInterfaceTest::ExpectGeneratedWithInsertions( proto_name, temp_directory_); } +void CommandLineInterfaceTest::CheckGeneratedAnnotations(const string& name, + const string& file) { + MockCodeGenerator::CheckGeneratedAnnotations(name, file, temp_directory_); +} + void CommandLineInterfaceTest::ExpectNullCodeGeneratorCalled( const string& parameter) { EXPECT_TRUE(null_generator_->called_); EXPECT_EQ(parameter, null_generator_->parameter_); } + void CommandLineInterfaceTest::ReadDescriptorSet( const string& filename, FileDescriptorSet* descriptor_set) { string path = temp_directory_ + "/" + filename; @@ -488,6 +491,13 @@ void CommandLineInterfaceTest::ReadDescriptorSet( } } +void CommandLineInterfaceTest::WriteDescriptorSet( + const string& filename, const FileDescriptorSet* descriptor_set) { + string binary_proto; + GOOGLE_CHECK(descriptor_set->SerializeToString(&binary_proto)); + CreateTempFile(filename, binary_proto); +} + void CommandLineInterfaceTest::ExpectCapturedStdout( const string& expected_text) { EXPECT_EQ(expected_text, captured_stdout_); @@ -496,7 +506,8 @@ void CommandLineInterfaceTest::ExpectCapturedStdout( void CommandLineInterfaceTest::ExpectCapturedStdoutSubstringWithZeroReturnCode( const string& expected_substring) { EXPECT_EQ(0, return_code_); - EXPECT_PRED_FORMAT2(testing::IsSubstring, expected_substring, captured_stdout_); + EXPECT_PRED_FORMAT2( + testing::IsSubstring, expected_substring, captured_stdout_); } void CommandLineInterfaceTest::ExpectFileContent( @@ -525,6 +536,22 @@ TEST_F(CommandLineInterfaceTest, BasicOutput) { ExpectGenerated("test_generator", "", "foo.proto", "Foo"); } +TEST_F(CommandLineInterfaceTest, BasicOutput_DescriptorSetIn) { + // Test that the common case works. + FileDescriptorSet file_descriptor_set; + FileDescriptorProto* file_descriptor_proto = file_descriptor_set.add_file(); + file_descriptor_proto->set_name("foo.proto"); + file_descriptor_proto->add_message_type()->set_name("Foo"); + + WriteDescriptorSet("foo.bin", &file_descriptor_set); + + Run("protocol_compiler --test_out=$tmpdir " + "--descriptor_set_in=$tmpdir/foo.bin foo.proto"); + + ExpectNoErrors(); + ExpectGenerated("test_generator", "", "foo.proto", "Foo"); +} + TEST_F(CommandLineInterfaceTest, BasicPlugin) { // Test that basic plugins work. @@ -539,6 +566,23 @@ TEST_F(CommandLineInterfaceTest, BasicPlugin) { ExpectGenerated("test_plugin", "", "foo.proto", "Foo"); } +TEST_F(CommandLineInterfaceTest, BasicPlugin_DescriptorSetIn) { + // Test that basic plugins work. + + FileDescriptorSet file_descriptor_set; + FileDescriptorProto* file_descriptor_proto = file_descriptor_set.add_file(); + file_descriptor_proto->set_name("foo.proto"); + file_descriptor_proto->add_message_type()->set_name("Foo"); + + WriteDescriptorSet("foo.bin", &file_descriptor_set); + + Run("protocol_compiler --plug_out=$tmpdir " + "--descriptor_set_in=$tmpdir/foo.bin foo.proto"); + + ExpectNoErrors(); + ExpectGenerated("test_plugin", "", "foo.proto", "Foo"); +} + TEST_F(CommandLineInterfaceTest, GeneratorAndPlugin) { // Invoke a generator and a plugin at the same time. @@ -554,6 +598,24 @@ TEST_F(CommandLineInterfaceTest, GeneratorAndPlugin) { ExpectGenerated("test_plugin", "", "foo.proto", "Foo"); } +TEST_F(CommandLineInterfaceTest, GeneratorAndPlugin_DescriptorSetIn) { + // Invoke a generator and a plugin at the same time. + + FileDescriptorSet file_descriptor_set; + FileDescriptorProto* file_descriptor_proto = file_descriptor_set.add_file(); + file_descriptor_proto->set_name("foo.proto"); + file_descriptor_proto->add_message_type()->set_name("Foo"); + + WriteDescriptorSet("foo.bin", &file_descriptor_set); + + Run("protocol_compiler --test_out=$tmpdir --plug_out=$tmpdir " + "--descriptor_set_in=$tmpdir/foo.bin foo.proto"); + + ExpectNoErrors(); + ExpectGenerated("test_generator", "", "foo.proto", "Foo"); + ExpectGenerated("test_plugin", "", "foo.proto", "Foo"); +} + TEST_F(CommandLineInterfaceTest, MultipleInputs) { // Test parsing multiple input files. @@ -578,6 +640,34 @@ TEST_F(CommandLineInterfaceTest, MultipleInputs) { "bar.proto", "Bar"); } +TEST_F(CommandLineInterfaceTest, MultipleInputs_DescriptorSetIn) { + // Test parsing multiple input files. + FileDescriptorSet file_descriptor_set; + + FileDescriptorProto* file_descriptor_proto = file_descriptor_set.add_file(); + file_descriptor_proto->set_name("foo.proto"); + file_descriptor_proto->add_message_type()->set_name("Foo"); + + file_descriptor_proto = file_descriptor_set.add_file(); + file_descriptor_proto->set_name("bar.proto"); + file_descriptor_proto->add_message_type()->set_name("Bar"); + + WriteDescriptorSet("foo.bin", &file_descriptor_set); + + Run("protocol_compiler --test_out=$tmpdir --plug_out=$tmpdir " + "--descriptor_set_in=$tmpdir/foo.bin foo.proto bar.proto"); + + ExpectNoErrors(); + ExpectGeneratedWithMultipleInputs("test_generator", "foo.proto,bar.proto", + "foo.proto", "Foo"); + ExpectGeneratedWithMultipleInputs("test_generator", "foo.proto,bar.proto", + "bar.proto", "Bar"); + ExpectGeneratedWithMultipleInputs("test_plugin", "foo.proto,bar.proto", + "foo.proto", "Foo"); + ExpectGeneratedWithMultipleInputs("test_plugin", "foo.proto,bar.proto", + "bar.proto", "Bar"); +} + TEST_F(CommandLineInterfaceTest, MultipleInputsWithImport) { // Test parsing multiple input files with an import of a separate file. @@ -608,6 +698,165 @@ TEST_F(CommandLineInterfaceTest, MultipleInputsWithImport) { "bar.proto", "Bar"); } +TEST_F(CommandLineInterfaceTest, MultipleInputsWithImport_DescriptorSetIn) { + // Test parsing multiple input files with an import of a separate file. + FileDescriptorSet file_descriptor_set; + + FileDescriptorProto* file_descriptor_proto = file_descriptor_set.add_file(); + file_descriptor_proto->set_name("foo.proto"); + file_descriptor_proto->add_message_type()->set_name("Foo"); + + file_descriptor_proto = file_descriptor_set.add_file(); + file_descriptor_proto->set_name("bar.proto"); + file_descriptor_proto->add_dependency("baz.proto"); + DescriptorProto* message = file_descriptor_proto->add_message_type(); + message->set_name("Bar"); + FieldDescriptorProto* field = message->add_field(); + field->set_type_name("Baz"); + field->set_name("a"); + field->set_number(1); + + WriteDescriptorSet("foo_and_bar.bin", &file_descriptor_set); + + file_descriptor_set.clear_file(); + file_descriptor_proto = file_descriptor_set.add_file(); + file_descriptor_proto->set_name("baz.proto"); + file_descriptor_proto->add_message_type()->set_name("Baz"); + + file_descriptor_proto = file_descriptor_set.add_file(); + file_descriptor_proto->set_name("bat.proto"); + file_descriptor_proto->add_dependency("baz.proto"); + message = file_descriptor_proto->add_message_type(); + message->set_name("Bat"); + field = message->add_field(); + field->set_type_name("Baz"); + field->set_name("a"); + field->set_number(1); + + WriteDescriptorSet("baz_and_bat.bin", &file_descriptor_set); + Run(strings::Substitute( + "protocol_compiler --test_out=$$tmpdir --plug_out=$$tmpdir " + "--descriptor_set_in=$0 foo.proto bar.proto", + string("$tmpdir/foo_and_bar.bin") + + CommandLineInterface::kPathSeparator + + "$tmpdir/baz_and_bat.bin")); + + ExpectNoErrors(); + ExpectGeneratedWithMultipleInputs("test_generator", "foo.proto,bar.proto", + "foo.proto", "Foo"); + ExpectGeneratedWithMultipleInputs("test_generator", "foo.proto,bar.proto", + "bar.proto", "Bar"); + ExpectGeneratedWithMultipleInputs("test_plugin", "foo.proto,bar.proto", + "foo.proto", "Foo"); + ExpectGeneratedWithMultipleInputs("test_plugin", "foo.proto,bar.proto", + "bar.proto", "Bar"); + + Run(strings::Substitute( + "protocol_compiler --test_out=$$tmpdir --plug_out=$$tmpdir " + "--descriptor_set_in=$0 baz.proto bat.proto", + string("$tmpdir/foo_and_bar.bin") + + CommandLineInterface::kPathSeparator + + "$tmpdir/baz_and_bat.bin")); + + ExpectNoErrors(); + ExpectGeneratedWithMultipleInputs("test_generator", "baz.proto,bat.proto", + "baz.proto", "Baz"); + ExpectGeneratedWithMultipleInputs("test_generator", "baz.proto,bat.proto", + "bat.proto", "Bat"); + ExpectGeneratedWithMultipleInputs("test_plugin", "baz.proto,bat.proto", + "baz.proto", "Baz"); + ExpectGeneratedWithMultipleInputs("test_plugin", "baz.proto,bat.proto", + "bat.proto", "Bat"); +} + +TEST_F(CommandLineInterfaceTest, + MultipleInputsWithImport_DescriptorSetIn_DuplicateFileDescriptor) { + // Test parsing multiple input files with an import of a separate file. + FileDescriptorSet file_descriptor_set; + + FileDescriptorProto foo_file_descriptor_proto; + foo_file_descriptor_proto.set_name("foo.proto"); + foo_file_descriptor_proto.add_message_type()->set_name("Foo"); + + file_descriptor_set.add_file()->CopyFrom(foo_file_descriptor_proto); + + FileDescriptorProto* file_descriptor_proto = file_descriptor_set.add_file(); + file_descriptor_proto->set_name("bar.proto"); + file_descriptor_proto->add_dependency("baz.proto"); + file_descriptor_proto->add_dependency("foo.proto"); + DescriptorProto* message = file_descriptor_proto->add_message_type(); + message->set_name("Bar"); + FieldDescriptorProto* field = message->add_field(); + field->set_type_name("Baz"); + field->set_name("a"); + field->set_number(1); + field = message->add_field(); + field->set_type_name("Foo"); + field->set_name("f"); + field->set_number(2); + WriteDescriptorSet("foo_and_bar.bin", &file_descriptor_set); + + file_descriptor_set.clear_file(); + file_descriptor_set.add_file()->CopyFrom(foo_file_descriptor_proto); + + file_descriptor_proto = file_descriptor_set.add_file(); + file_descriptor_proto->set_name("baz.proto"); + file_descriptor_proto->add_dependency("foo.proto"); + message = file_descriptor_proto->add_message_type(); + message->set_name("Baz"); + field = message->add_field(); + field->set_type_name("Foo"); + field->set_name("f"); + field->set_number(1); + WriteDescriptorSet("foo_and_baz.bin", &file_descriptor_set); + + Run(strings::Substitute( + "protocol_compiler --test_out=$$tmpdir --plug_out=$$tmpdir " + "--descriptor_set_in=$0 bar.proto", + string("$tmpdir/foo_and_bar.bin") + + CommandLineInterface::kPathSeparator + + "$tmpdir/foo_and_baz.bin")); + + ExpectNoErrors(); + ExpectGenerated("test_generator", "", "bar.proto", "Bar"); + ExpectGenerated("test_plugin", "", "bar.proto", "Bar"); +} + +TEST_F(CommandLineInterfaceTest, + MultipleInputsWithImport_DescriptorSetIn_MissingImport) { + // Test parsing multiple input files with an import of a separate file. + FileDescriptorSet file_descriptor_set; + + FileDescriptorProto* file_descriptor_proto = file_descriptor_set.add_file(); + file_descriptor_proto->set_name("foo.proto"); + file_descriptor_proto->add_message_type()->set_name("Foo"); + + file_descriptor_proto = file_descriptor_set.add_file(); + file_descriptor_proto->set_name("bar.proto"); + file_descriptor_proto->add_dependency("baz.proto"); + DescriptorProto* message = file_descriptor_proto->add_message_type(); + message->set_name("Bar"); + FieldDescriptorProto* field = message->add_field(); + field->set_type_name("Baz"); + field->set_name("a"); + field->set_number(1); + + WriteDescriptorSet("foo_and_bar.bin", &file_descriptor_set); + + file_descriptor_set.clear_file(); + file_descriptor_proto = file_descriptor_set.add_file(); + file_descriptor_proto->set_name("baz.proto"); + file_descriptor_proto->add_message_type()->set_name("Baz"); + + WriteDescriptorSet("baz.bin", &file_descriptor_set); + Run("protocol_compiler --test_out=$tmpdir --plug_out=$tmpdir " + "--descriptor_set_in=$tmpdir/foo_and_bar.bin " + "foo.proto bar.proto"); + ExpectErrorSubstring( + "bar.proto: Import \"baz.proto\" was not found or had errors."); + ExpectErrorSubstring("bar.proto: \"Baz\" is not defined."); +} + TEST_F(CommandLineInterfaceTest, CreateDirectory) { // Test that when we output to a sub-directory, it is created. @@ -754,6 +1003,25 @@ TEST_F(CommandLineInterfaceTest, Insert) { "foo.proto", "Foo"); } +TEST_F(CommandLineInterfaceTest, InsertWithAnnotationFixup) { + // Check that annotation spans are updated after insertions. + + CreateTempFile("foo.proto", + "syntax = \"proto2\";\n" + "message MockCodeGenerator_Annotate {}\n"); + + Run("protocol_compiler " + "--test_out=TestParameter:$tmpdir " + "--plug_out=TestPluginParameter:$tmpdir " + "--test_out=insert=test_generator,test_plugin:$tmpdir " + "--plug_out=insert=test_generator,test_plugin:$tmpdir " + "--proto_path=$tmpdir foo.proto"); + + ExpectNoErrors(); + CheckGeneratedAnnotations("test_generator", "foo.proto"); + CheckGeneratedAnnotations("test_plugin", "foo.proto"); +} + #if defined(_WIN32) TEST_F(CommandLineInterfaceTest, WindowsOutputPath) { @@ -839,17 +1107,11 @@ TEST_F(CommandLineInterfaceTest, ColonDelimitedPath) { "}\n"); CreateTempFile("b/foo.proto", "this should not be parsed\n"); -#undef PATH_SEPARATOR -#if defined(_WIN32) -#define PATH_SEPARATOR ";" -#else -#define PATH_SEPARATOR ":" -#endif - - Run("protocol_compiler --test_out=$tmpdir " - "--proto_path=$tmpdir/a" PATH_SEPARATOR "$tmpdir/b foo.proto"); - -#undef PATH_SEPARATOR + Run(strings::Substitute( + "protocol_compiler --test_out=$$tmpdir --proto_path=$0 foo.proto", + string("$tmpdir/a") + + CommandLineInterface::kPathSeparator + + "$tmpdir/b")); ExpectNoErrors(); ExpectGenerated("test_generator", "", "foo.proto", "Foo"); @@ -1059,8 +1321,6 @@ TEST_F(CommandLineInterfaceTest, DirectDependencies_CustomErrorMessage) { TEST_F(CommandLineInterfaceTest, CwdRelativeInputs) { // Test that we can accept working-directory-relative input files. - SetInputsAreProtoPathRelative(false); - CreateTempFile("foo.proto", "syntax = \"proto2\";\n" "message Foo {}\n"); @@ -1301,6 +1561,36 @@ TEST_F(CommandLineInterfaceTest, WriteDependencyManifestFileForAbsolutePath) { } #endif // !_WIN32 +TEST_F(CommandLineInterfaceTest, TestArgumentFile) { + // Test parsing multiple input files using an argument file. + + CreateTempFile("foo.proto", + "syntax = \"proto2\";\n" + "message Foo {}\n"); + CreateTempFile("bar.proto", + "syntax = \"proto2\";\n" + "message Bar {}\n"); + CreateTempFile("arguments.txt", + "--test_out=$tmpdir\n" + "--plug_out=$tmpdir\n" + "--proto_path=$tmpdir\n" + "--direct_dependencies_violation_msg=%s is not imported\n" + "foo.proto\n" + "bar.proto"); + + Run("protocol_compiler @$tmpdir/arguments.txt"); + + ExpectNoErrors(); + ExpectGeneratedWithMultipleInputs("test_generator", "foo.proto,bar.proto", + "foo.proto", "Foo"); + ExpectGeneratedWithMultipleInputs("test_generator", "foo.proto,bar.proto", + "bar.proto", "Bar"); + ExpectGeneratedWithMultipleInputs("test_plugin", "foo.proto,bar.proto", + "foo.proto", "Foo"); + ExpectGeneratedWithMultipleInputs("test_plugin", "foo.proto,bar.proto", + "bar.proto", "Bar"); +} + // ------------------------------------------------------------------- @@ -1318,6 +1608,17 @@ TEST_F(CommandLineInterfaceTest, ParseErrors) { "foo.proto:2:1: Expected top-level statement (e.g. \"message\").\n"); } +TEST_F(CommandLineInterfaceTest, ParseErrors_DescriptorSetIn) { + // Test that parse errors are reported. + CreateTempFile("foo.bin", "not a FileDescriptorSet"); + + Run("protocol_compiler --test_out=$tmpdir " + "--descriptor_set_in=$tmpdir/foo.bin foo.proto"); + + ExpectErrorText( + "$tmpdir/foo.bin: Unable to parse.\n"); +} + TEST_F(CommandLineInterfaceTest, ParseErrorsMultipleFiles) { // Test that parse errors are reported from multiple files. @@ -1364,16 +1665,23 @@ TEST_F(CommandLineInterfaceTest, InputNotFoundError) { Run("protocol_compiler --test_out=$tmpdir " "--proto_path=$tmpdir foo.proto"); + ExpectErrorText("foo.proto: No such file or directory\n"); +} + +TEST_F(CommandLineInterfaceTest, InputNotFoundError_DescriptorSetIn) { + // Test what happens if the input file is not found. + + Run("protocol_compiler --test_out=$tmpdir " + "--descriptor_set_in=$tmpdir/foo.bin foo.proto"); + ExpectErrorText( - "foo.proto: File not found.\n"); + "$tmpdir/foo.bin: No such file or directory\n"); } TEST_F(CommandLineInterfaceTest, CwdRelativeInputNotFoundError) { // Test what happens when a working-directory-relative input file is not // found. - SetInputsAreProtoPathRelative(false); - Run("protocol_compiler --test_out=$tmpdir " "--proto_path=$tmpdir $tmpdir/foo.proto"); @@ -1385,8 +1693,6 @@ TEST_F(CommandLineInterfaceTest, CwdRelativeInputNotMappedError) { // Test what happens when a working-directory-relative input file is not // mapped to a virtual path. - SetInputsAreProtoPathRelative(false); - CreateTempFile("foo.proto", "syntax = \"proto2\";\n" "message Foo {}\n"); @@ -1411,8 +1717,6 @@ TEST_F(CommandLineInterfaceTest, CwdRelativeInputNotFoundAndNotMappedError) { // Check what happens if the input file is not found *and* is not mapped // in the proto_path. - SetInputsAreProtoPathRelative(false); - // Create a directory called "bar" so that we can point --proto_path at it. CreateTempFile("bar/dummy", ""); @@ -1427,8 +1731,6 @@ TEST_F(CommandLineInterfaceTest, CwdRelativeInputShadowedError) { // Test what happens when a working-directory-relative input file is shadowed // by another file in the virtual path. - SetInputsAreProtoPathRelative(false); - CreateTempFile("foo/foo.proto", "syntax = \"proto2\";\n" "message Foo {}\n"); @@ -1454,8 +1756,34 @@ TEST_F(CommandLineInterfaceTest, ProtoPathNotFoundError) { "--proto_path=$tmpdir/foo foo.proto"); ExpectErrorText( - "$tmpdir/foo: warning: directory does not exist.\n" - "foo.proto: File not found.\n"); + "$tmpdir/foo: warning: directory does not exist.\n" + "foo.proto: No such file or directory\n"); +} + +TEST_F(CommandLineInterfaceTest, ProtoPathAndDescriptorSetIn) { + Run("protocol_compiler --test_out=$tmpdir " + "--proto_path=$tmpdir --descriptor_set_in=$tmpdir/foo.bin foo.proto"); + ExpectErrorText( + "Only one of --descriptor_set_in and --proto_path can be specified.\n"); + + Run("protocol_compiler --test_out=$tmpdir " + "--descriptor_set_in=$tmpdir/foo.bin --proto_path=$tmpdir foo.proto"); + ExpectErrorText( + "Only one of --proto_path and --descriptor_set_in can be specified.\n"); +} + +TEST_F(CommandLineInterfaceTest, ProtoPathAndDependencyOut) { + Run("protocol_compiler --test_out=$tmpdir " + "--dependency_out=$tmpdir/manifest " + "--descriptor_set_in=$tmpdir/foo.bin foo.proto"); + ExpectErrorText( + "--descriptor_set_in cannot be used with --dependency_out.\n"); + + Run("protocol_compiler --test_out=$tmpdir " + "--descriptor_set_in=$tmpdir/foo.bin " + "--dependency_out=$tmpdir/manifest foo.proto"); + ExpectErrorText( + "--dependency_out cannot be used with --descriptor_set_in.\n"); } TEST_F(CommandLineInterfaceTest, MissingInputError) { @@ -1905,9 +2233,16 @@ TEST_F(CommandLineInterfaceTest, PrintFreeFieldNumbers) { // test as a shell script, but we'd like to be able to run the test on // platforms that don't have a Bourne-compatible shell available (especially // Windows/MSVC). -class EncodeDecodeTest : public testing::Test { + +enum EncodeDecodeTestMode { + PROTO_PATH, + DESCRIPTOR_SET_IN +}; + +class EncodeDecodeTest : public testing::TestWithParam<EncodeDecodeTestMode> { protected: virtual void SetUp() { + WriteUnittestProtoDescriptorSet(); duped_stdin_ = dup(STDIN_FILENO); } @@ -1950,7 +2285,18 @@ class EncodeDecodeTest : public testing::Test { std::vector<string> args; args.push_back("protoc"); SplitStringUsing(command, " ", &args); - args.push_back("--proto_path=" + TestSourceDir()); + switch (GetParam()) { + case PROTO_PATH: + args.push_back("--proto_path=" + TestSourceDir()); + break; + case DESCRIPTOR_SET_IN: + args.push_back(StrCat( + "--descriptor_set_in=", + unittest_proto_descriptor_set_filename_)); + break; + default: + ADD_FAILURE() << "unexpected EncodeDecodeTestMode: " << GetParam(); + } google::protobuf::scoped_array<const char * > argv(new const char* [args.size()]); for (int i = 0; i < args.size(); i++) { @@ -1958,7 +2304,6 @@ class EncodeDecodeTest : public testing::Test { } CommandLineInterface cli; - cli.SetInputsAreProtoPathRelative(true); CaptureTestStdout(); CaptureTestStderr(); @@ -1996,12 +2341,37 @@ class EncodeDecodeTest : public testing::Test { } private: + void WriteUnittestProtoDescriptorSet() { + unittest_proto_descriptor_set_filename_ = + TestTempDir() + "/unittest_proto_descriptor_set.bin"; + FileDescriptorSet file_descriptor_set; + protobuf_unittest::TestAllTypes test_all_types; + test_all_types.descriptor()->file()->CopyTo(file_descriptor_set.add_file()); + + protobuf_unittest_import::ImportMessage import_message; + import_message.descriptor()->file()->CopyTo(file_descriptor_set.add_file()); + + + protobuf_unittest_import::PublicImportMessage public_import_message; + public_import_message.descriptor()->file()->CopyTo( + file_descriptor_set.add_file()); + GOOGLE_DCHECK(file_descriptor_set.IsInitialized()); + + string binary_proto; + GOOGLE_CHECK(file_descriptor_set.SerializeToString(&binary_proto)); + GOOGLE_CHECK_OK(File::SetContents( + unittest_proto_descriptor_set_filename_, + binary_proto, + true)); + } + int duped_stdin_; string captured_stdout_; string captured_stderr_; + string unittest_proto_descriptor_set_filename_; }; -TEST_F(EncodeDecodeTest, Encode) { +TEST_P(EncodeDecodeTest, Encode) { RedirectStdinFromFile(TestSourceDir() + "/google/protobuf/" "testdata/text_format_unittest_data_oneof_implemented.txt"); EXPECT_TRUE(Run("google/protobuf/unittest.proto " @@ -2011,7 +2381,7 @@ TEST_F(EncodeDecodeTest, Encode) { ExpectStderrMatchesText(""); } -TEST_F(EncodeDecodeTest, Decode) { +TEST_P(EncodeDecodeTest, Decode) { RedirectStdinFromFile(TestSourceDir() + "/google/protobuf/testdata/golden_message_oneof_implemented"); EXPECT_TRUE(Run("google/protobuf/unittest.proto " @@ -2022,7 +2392,7 @@ TEST_F(EncodeDecodeTest, Decode) { ExpectStderrMatchesText(""); } -TEST_F(EncodeDecodeTest, Partial) { +TEST_P(EncodeDecodeTest, Partial) { RedirectStdinFromText(""); EXPECT_TRUE(Run("google/protobuf/unittest.proto " "--encode=protobuf_unittest.TestRequired")); @@ -2031,7 +2401,7 @@ TEST_F(EncodeDecodeTest, Partial) { "warning: Input message is missing required fields: a, b, c\n"); } -TEST_F(EncodeDecodeTest, DecodeRaw) { +TEST_P(EncodeDecodeTest, DecodeRaw) { protobuf_unittest::TestAllTypes message; message.set_optional_int32(123); message.set_optional_string("foo"); @@ -2045,21 +2415,24 @@ TEST_F(EncodeDecodeTest, DecodeRaw) { ExpectStderrMatchesText(""); } -TEST_F(EncodeDecodeTest, UnknownType) { +TEST_P(EncodeDecodeTest, UnknownType) { EXPECT_FALSE(Run("google/protobuf/unittest.proto " "--encode=NoSuchType")); ExpectStdoutMatchesText(""); ExpectStderrMatchesText("Type not defined: NoSuchType\n"); } -TEST_F(EncodeDecodeTest, ProtoParseError) { +TEST_P(EncodeDecodeTest, ProtoParseError) { EXPECT_FALSE(Run("google/protobuf/no_such_file.proto " "--encode=NoSuchType")); ExpectStdoutMatchesText(""); ExpectStderrMatchesText( - "google/protobuf/no_such_file.proto: File not found.\n"); + "google/protobuf/no_such_file.proto: No such file or directory\n"); } +INSTANTIATE_TEST_CASE_P(FileDescriptorSetSource, + EncodeDecodeTest, + testing::Values(PROTO_PATH, DESCRIPTOR_SET_IN)); } // anonymous namespace #endif // !GOOGLE_PROTOBUF_HEAP_CHECK_DRACONIAN diff --git a/src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc b/src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc index fce58c02..f99159f5 100644 --- a/src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc +++ b/src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc @@ -125,12 +125,9 @@ TEST(BootstrapTest, GeneratedDescriptorMatches) { importer.Import("google/protobuf/descriptor.proto"); const FileDescriptor* plugin_proto_file = importer.Import("google/protobuf/compiler/plugin.proto"); - const FileDescriptor* profile_proto_file = - importer.Import("google/protobuf/compiler/profile.proto"); EXPECT_EQ("", error_collector.text_); ASSERT_TRUE(proto_file != NULL); ASSERT_TRUE(plugin_proto_file != NULL); - ASSERT_TRUE(profile_proto_file != NULL); CppGenerator generator; MockGeneratorContext context; @@ -141,8 +138,6 @@ TEST(BootstrapTest, GeneratedDescriptorMatches) { parameter = "dllexport_decl=LIBPROTOC_EXPORT"; ASSERT_TRUE(generator.Generate(plugin_proto_file, parameter, &context, &error)); - ASSERT_TRUE(generator.Generate(profile_proto_file, parameter, - &context, &error)); context.ExpectFileMatches("google/protobuf/descriptor.pb.h", "google/protobuf/descriptor.pb.h"); @@ -152,10 +147,6 @@ TEST(BootstrapTest, GeneratedDescriptorMatches) { "google/protobuf/compiler/plugin.pb.h"); context.ExpectFileMatches("google/protobuf/compiler/plugin.pb.cc", "google/protobuf/compiler/plugin.pb.cc"); - context.ExpectFileMatches("google/protobuf/compiler/profile.pb.h", - "google/protobuf/compiler/profile.pb.h"); - context.ExpectFileMatches("google/protobuf/compiler/profile.pb.cc", - "google/protobuf/compiler/profile.pb.cc"); } } // namespace diff --git a/src/google/protobuf/compiler/cpp/cpp_enum.cc b/src/google/protobuf/compiler/cpp/cpp_enum.cc index 6a8a83d1..8adee0f5 100644 --- a/src/google/protobuf/compiler/cpp/cpp_enum.cc +++ b/src/google/protobuf/compiler/cpp/cpp_enum.cc @@ -81,10 +81,16 @@ void EnumGenerator::GenerateDefinition(io::Printer* printer) { std::map<string, string> vars; vars["classname"] = classname_; vars["short_name"] = descriptor_->name(); - vars["enumbase"] = classname_ + (options_.proto_h ? " : int" : ""); - - printer->Print(vars, "enum $enumbase$ {\n"); - printer->Annotate("enumbase", descriptor_); + vars["enumbase"] = options_.proto_h ? " : int" : ""; + // These variables are placeholders to pick out the beginning and ends of + // identifiers for annotations (when doing so with existing variables would + // be ambiguous or impossible). They should never be set to anything but the + // empty string. + vars["{"] = ""; + vars["}"] = ""; + + printer->Print(vars, "enum $classname$$enumbase$ {\n"); + printer->Annotate("classname", descriptor_); printer->Indent(); const EnumValueDescriptor* min_value = descriptor_->value(0); @@ -102,7 +108,8 @@ void EnumGenerator::GenerateDefinition(io::Printer* printer) { " PROTOBUF_DEPRECATED" : ""; if (i > 0) printer->Print(",\n"); - printer->Print(vars, "$prefix$$name$$deprecation$ = $number$"); + printer->Print(vars, "${$$prefix$$name$$}$$deprecation$ = $number$"); + printer->Annotate("{", "}", descriptor_->value(i)); if (descriptor_->value(i)->number() < min_value->number()) { min_value = descriptor_->value(i); @@ -134,14 +141,20 @@ void EnumGenerator::GenerateDefinition(io::Printer* printer) { } printer->Print(vars, - "$dllexport$bool $classname$_IsValid(int value);\n" - "const $classname$ $prefix$$short_name$_MIN = $prefix$$min_name$;\n" - "const $classname$ $prefix$$short_name$_MAX = $prefix$$max_name$;\n"); + "$dllexport$bool $classname$_IsValid(int value);\n" + "const $classname$ ${$$prefix$$short_name$_MIN$}$ = " + "$prefix$$min_name$;\n"); + printer->Annotate("{", "}", descriptor_); + printer->Print(vars, + "const $classname$ ${$$prefix$$short_name$_MAX$}$ = " + "$prefix$$max_name$;\n"); + printer->Annotate("{", "}", descriptor_); if (generate_array_size_) { printer->Print(vars, - "const int $prefix$$short_name$_ARRAYSIZE = " - "$prefix$$short_name$_MAX + 1;\n\n"); + "const int ${$$prefix$$short_name$_ARRAYSIZE$}$ = " + "$prefix$$short_name$_MAX + 1;\n\n"); + printer->Annotate("{", "}", descriptor_); } if (HasDescriptorMethods(descriptor_->file(), options_)) { @@ -184,6 +197,8 @@ void EnumGenerator::GenerateSymbolImports(io::Printer* printer) { vars["nested_name"] = descriptor_->name(); vars["classname"] = classname_; vars["constexpr"] = options_.proto_h ? "constexpr " : ""; + vars["{"] = ""; + vars["}"] = ""; printer->Print(vars, "typedef $classname$ $nested_name$;\n"); for (int j = 0; j < descriptor_->value_count(); j++) { @@ -191,22 +206,27 @@ void EnumGenerator::GenerateSymbolImports(io::Printer* printer) { vars["deprecated_attr"] = descriptor_->value(j)->options().deprecated() ? "GOOGLE_PROTOBUF_DEPRECATED_ATTR " : ""; printer->Print(vars, - "$deprecated_attr$static $constexpr$const $nested_name$ $tag$ =\n" + "$deprecated_attr$static $constexpr$const $nested_name$ ${$$tag$$}$ =\n" " $classname$_$tag$;\n"); + printer->Annotate("{", "}", descriptor_->value(j)); } printer->Print(vars, "static inline bool $nested_name$_IsValid(int value) {\n" " return $classname$_IsValid(value);\n" "}\n" - "static const $nested_name$ $nested_name$_MIN =\n" - " $classname$_$nested_name$_MIN;\n" - "static const $nested_name$ $nested_name$_MAX =\n" + "static const $nested_name$ ${$$nested_name$_MIN$}$ =\n" + " $classname$_$nested_name$_MIN;\n"); + printer->Annotate("{", "}", descriptor_); + printer->Print(vars, + "static const $nested_name$ ${$$nested_name$_MAX$}$ =\n" " $classname$_$nested_name$_MAX;\n"); + printer->Annotate("{", "}", descriptor_); if (generate_array_size_) { printer->Print(vars, - "static const int $nested_name$_ARRAYSIZE =\n" + "static const int ${$$nested_name$_ARRAYSIZE$}$ =\n" " $classname$_$nested_name$_ARRAYSIZE;\n"); + printer->Annotate("{", "}", descriptor_); } if (HasDescriptorMethods(descriptor_->file(), options_)) { @@ -229,27 +249,10 @@ void EnumGenerator::GenerateSymbolImports(io::Printer* printer) { } } -void EnumGenerator::GenerateDescriptorInitializer(io::Printer* printer) { - std::map<string, string> vars; - vars["index"] = SimpleItoa(descriptor_->index()); - vars["index_in_metadata"] = SimpleItoa(index_in_metadata_); - - if (descriptor_->containing_type() == NULL) { - printer->Print(vars, - "file_level_enum_descriptors[$index_in_metadata$] = " - "file->enum_type($index$);\n"); - } else { - vars["parent"] = ClassName(descriptor_->containing_type(), false); - printer->Print(vars, - "file_level_enum_descriptors[$index_in_metadata$] = " - "$parent$_descriptor->enum_type($index$);\n"); - } -} - -void EnumGenerator::GenerateMethods(io::Printer* printer) { +void EnumGenerator::GenerateMethods(int idx, io::Printer* printer) { std::map<string, string> vars; vars["classname"] = classname_; - vars["index_in_metadata"] = SimpleItoa(index_in_metadata_); + vars["index_in_metadata"] = SimpleItoa(idx); vars["constexpr"] = options_.proto_h ? "constexpr " : ""; vars["file_namespace"] = FileLevelNamespace(descriptor_->file()->name()); diff --git a/src/google/protobuf/compiler/cpp/cpp_enum.h b/src/google/protobuf/compiler/cpp/cpp_enum.h index 0b568c57..0d2488a9 100644 --- a/src/google/protobuf/compiler/cpp/cpp_enum.h +++ b/src/google/protobuf/compiler/cpp/cpp_enum.h @@ -86,13 +86,10 @@ class EnumGenerator { // Source file stuff. - // Generate code that initializes the global variable storing the enum's - // descriptor. - void GenerateDescriptorInitializer(io::Printer* printer); - // Generate non-inline methods related to the enum, such as IsValidValue(). - // Goes in the .cc file. - void GenerateMethods(io::Printer* printer); + // Goes in the .cc file. EnumDescriptors are stored in an array, idx is + // the index in this array that corresponds with this enum. + void GenerateMethods(int idx, io::Printer* printer); private: const EnumDescriptor* descriptor_; @@ -101,8 +98,6 @@ class EnumGenerator { // whether to generate the *_ARRAYSIZE constant. const bool generate_array_size_; - int index_in_metadata_; - friend class FileGenerator; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumGenerator); }; diff --git a/src/google/protobuf/compiler/cpp/cpp_enum_field.cc b/src/google/protobuf/compiler/cpp/cpp_enum_field.cc index c15be942..50c7b5f3 100644 --- a/src/google/protobuf/compiler/cpp/cpp_enum_field.cc +++ b/src/google/protobuf/compiler/cpp/cpp_enum_field.cc @@ -74,27 +74,26 @@ GeneratePrivateMembers(io::Printer* printer) const { void EnumFieldGenerator:: GenerateAccessorDeclarations(io::Printer* printer) const { + printer->Print(variables_, "$deprecated_attr$$type$ $name$() const;\n"); + printer->Annotate("name", descriptor_); printer->Print(variables_, - "$deprecated_attr$$type$ $name$() const;\n" - "$deprecated_attr$void set_$name$($type$ value);\n"); + "$deprecated_attr$void ${$set_$name$$}$($type$ value);\n"); + printer->Annotate("{", "}", descriptor_); } void EnumFieldGenerator:: -GenerateInlineAccessorDefinitions(io::Printer* printer, - bool is_inline) const { - std::map<string, string> variables(variables_); - variables["inline"] = is_inline ? "inline " : ""; - printer->Print(variables, - "$inline$$type$ $classname$::$name$() const {\n" +GenerateInlineAccessorDefinitions(io::Printer* printer) const { + printer->Print(variables_, + "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, + printer->Print(variables_, " assert($type$_IsValid(value));\n"); } - printer->Print(variables, + printer->Print(variables_, " $set_hasbit$\n" " $name$_ = value;\n" " // @@protoc_insertion_point(field_set:$full_name$)\n" @@ -113,7 +112,7 @@ GenerateMergingCode(io::Printer* printer) const { void EnumFieldGenerator:: GenerateSwappingCode(io::Printer* printer) const { - printer->Print(variables_, "std::swap($name$_, other->$name$_);\n"); + printer->Print(variables_, "swap($name$_, other->$name$_);\n"); } void EnumFieldGenerator:: @@ -143,12 +142,14 @@ GenerateMergeFromCodedStream(io::Printer* printer) const { if (UseUnknownFieldSet(descriptor_->file(), options_)) { printer->Print(variables_, "} else {\n" - " mutable_unknown_fields()->AddVarint($number$, value);\n"); + " mutable_unknown_fields()->AddVarint(\n" + " $number$, static_cast< ::google::protobuf::uint64>(value));\n"); } else { printer->Print( "} else {\n" " unknown_fields_stream.WriteVarint32($tag$u);\n" - " unknown_fields_stream.WriteVarint32(value);\n", + " unknown_fields_stream.WriteVarint32(\n" + " static_cast< ::google::protobuf::uint32>(value));\n", "tag", SimpleItoa(internal::WireFormat::MakeTag(descriptor_))); } printer->Print(variables_, @@ -189,36 +190,33 @@ EnumOneofFieldGenerator(const FieldDescriptor* descriptor, EnumOneofFieldGenerator::~EnumOneofFieldGenerator() {} void EnumOneofFieldGenerator:: -GenerateInlineAccessorDefinitions(io::Printer* printer, - bool is_inline) const { - std::map<string, string> variables(variables_); - variables["inline"] = is_inline ? "inline " : ""; - printer->Print(variables, - "$inline$$type$ $classname$::$name$() const {\n" +GenerateInlineAccessorDefinitions(io::Printer* printer) const { + printer->Print(variables_, + "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" + " return static_cast< $type$ >($field_member$);\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, + printer->Print(variables_, " assert($type$_IsValid(value));\n"); } - printer->Print(variables, + printer->Print(variables_, " if (!has_$name$()) {\n" " clear_$oneof_name$();\n" " set_has_$name$();\n" " }\n" - " $oneof_prefix$$name$_ = value;\n" + " $field_member$ = value;\n" " // @@protoc_insertion_point(field_set:$full_name$)\n" "}\n"); } void EnumOneofFieldGenerator:: GenerateClearingCode(io::Printer* printer) const { - printer->Print(variables_, "$oneof_prefix$$name$_ = $default$;\n"); + printer->Print(variables_, "$field_member$ = $default$;\n"); } void EnumOneofFieldGenerator:: @@ -228,9 +226,8 @@ GenerateSwappingCode(io::Printer* printer) const { void EnumOneofFieldGenerator:: GenerateConstructorCode(io::Printer* printer) const { - printer->Print( - variables_, - "_$classname$_default_instance_.$name$_ = $default$;\n"); + printer->Print(variables_, + "$ns$::_$classname$_default_instance_.$name$_ = $default$;\n"); } // =================================================================== @@ -257,49 +254,56 @@ GeneratePrivateMembers(io::Printer* printer) const { void RepeatedEnumFieldGenerator:: GenerateAccessorDeclarations(io::Printer* printer) const { printer->Print(variables_, - "$deprecated_attr$$type$ $name$(int index) const;\n" - "$deprecated_attr$void set_$name$(int index, $type$ value);\n" - "$deprecated_attr$void add_$name$($type$ value);\n"); + "$deprecated_attr$$type$ $name$(int index) const;\n"); + printer->Annotate("name", descriptor_); + printer->Print( + variables_, + "$deprecated_attr$void ${$set_$name$$}$(int index, $type$ value);\n"); + printer->Annotate("{", "}", descriptor_); printer->Print(variables_, - "$deprecated_attr$const ::google::protobuf::RepeatedField<int>& $name$() const;\n" - "$deprecated_attr$::google::protobuf::RepeatedField<int>* mutable_$name$();\n"); + "$deprecated_attr$void ${$add_$name$$}$($type$ value);\n"); + printer->Annotate("{", "}", descriptor_); + printer->Print( + variables_, + "$deprecated_attr$const ::google::protobuf::RepeatedField<int>& $name$() const;\n"); + printer->Annotate("name", descriptor_); + printer->Print(variables_, + "$deprecated_attr$::google::protobuf::RepeatedField<int>* " + "${$mutable_$name$$}$();\n"); + printer->Annotate("{", "}", descriptor_); } void RepeatedEnumFieldGenerator:: -GenerateInlineAccessorDefinitions(io::Printer* printer, - bool is_inline) const { - std::map<string, string> variables(variables_); - variables["inline"] = is_inline ? "inline " : ""; - printer->Print(variables, - "$inline$$type$ $classname$::$name$(int index) const {\n" +GenerateInlineAccessorDefinitions(io::Printer* printer) const { + printer->Print(variables_, + "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, + printer->Print(variables_, " assert($type$_IsValid(value));\n"); } - printer->Print(variables, + printer->Print(variables_, " $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, + printer->Print(variables_, " assert($type$_IsValid(value));\n"); } - printer->Print(variables, + printer->Print(variables_, " $name$_.Add(value);\n" " // @@protoc_insertion_point(field_add:$full_name$)\n" - "}\n"); - printer->Print(variables, - "$inline$const ::google::protobuf::RepeatedField<int>&\n" + "}\n" + "inline const ::google::protobuf::RepeatedField<int>&\n" "$classname$::$name$() const {\n" " // @@protoc_insertion_point(field_list:$full_name$)\n" " return $name$_;\n" "}\n" - "$inline$::google::protobuf::RepeatedField<int>*\n" + "inline ::google::protobuf::RepeatedField<int>*\n" "$classname$::mutable_$name$() {\n" " // @@protoc_insertion_point(field_mutable_list:$full_name$)\n" " return &$name$_;\n" @@ -344,12 +348,14 @@ GenerateMergeFromCodedStream(io::Printer* printer) const { if (UseUnknownFieldSet(descriptor_->file(), options_)) { printer->Print(variables_, "} else {\n" - " mutable_unknown_fields()->AddVarint($number$, value);\n"); + " mutable_unknown_fields()->AddVarint(\n" + " $number$, static_cast< ::google::protobuf::uint64>(value));\n"); } else { printer->Print( "} else {\n" " unknown_fields_stream.WriteVarint32(tag);\n" - " unknown_fields_stream.WriteVarint32(value);\n"); + " unknown_fields_stream.WriteVarint32(\n" + " static_cast< ::google::protobuf::uint32>(value));\n"); } printer->Print("}\n"); } @@ -391,7 +397,7 @@ GenerateMergeFromCodedStreamWithPacking(io::Printer* printer) const { "::google::protobuf::uint32 length;\n" "DO_(input->ReadVarint32(&length));\n" "::google::protobuf::io::CodedInputStream::Limit limit = " - "input->PushLimit(length);\n" + "input->PushLimit(static_cast<int>(length));\n" "while (input->BytesUntilLimit() > 0) {\n" " int value;\n" " DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n" @@ -407,11 +413,13 @@ GenerateMergeFromCodedStreamWithPacking(io::Printer* printer) const { " } else {\n"); if (UseUnknownFieldSet(descriptor_->file(), options_)) { printer->Print(variables_, - " mutable_unknown_fields()->AddVarint($number$, value);\n"); + " mutable_unknown_fields()->AddVarint(\n" + " $number$, static_cast< ::google::protobuf::uint64>(value));\n"); } else { printer->Print(variables_, " unknown_fields_stream.WriteVarint32(tag);\n" - " unknown_fields_stream.WriteVarint32(value);\n"); + " unknown_fields_stream.WriteVarint32(\n" + " static_cast< ::google::protobuf::uint32>(value));\n"); } printer->Print( " }\n"); @@ -432,7 +440,8 @@ GenerateSerializeWithCachedSizes(io::Printer* printer) const { " $number$,\n" " ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED,\n" " output);\n" - " output->WriteVarint32(_$name$_cached_byte_size_);\n" + " output->WriteVarint32(\n" + " static_cast< ::google::protobuf::uint32>(_$name$_cached_byte_size_));\n" "}\n"); } printer->Print(variables_, @@ -460,7 +469,8 @@ GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const { " ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED,\n" " target);\n" " target = ::google::protobuf::io::CodedOutputStream::WriteVarint32ToArray(" - " _$name$_cached_byte_size_, target);\n" + " static_cast< ::google::protobuf::uint32>(\n" + " _$name$_cached_byte_size_), target);\n" " target = ::google::protobuf::internal::WireFormatLite::WriteEnumNoTagToArray(\n" " this->$name$_, target);\n" "}\n"); @@ -476,19 +486,20 @@ GenerateByteSize(io::Printer* printer) const { printer->Print(variables_, "{\n" " size_t data_size = 0;\n" - " unsigned int count = this->$name$_size();"); + " unsigned int count = static_cast<unsigned int>(this->$name$_size());"); printer->Indent(); printer->Print(variables_, "for (unsigned int i = 0; i < count; i++) {\n" " data_size += ::google::protobuf::internal::WireFormatLite::EnumSize(\n" - " this->$name$(i));\n" + " this->$name$(static_cast<int>(i)));\n" "}\n"); if (descriptor_->is_packed()) { printer->Print(variables_, "if (data_size > 0) {\n" " total_size += $tag_size$ +\n" - " ::google::protobuf::internal::WireFormatLite::Int32Size(data_size);\n" + " ::google::protobuf::internal::WireFormatLite::Int32Size(\n" + " static_cast< ::google::protobuf::int32>(data_size));\n" "}\n" "int cached_size = ::google::protobuf::internal::ToCachedSize(data_size);\n" "GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n" diff --git a/src/google/protobuf/compiler/cpp/cpp_enum_field.h b/src/google/protobuf/compiler/cpp/cpp_enum_field.h index 3ecd7ba8..d0e87b79 100644 --- a/src/google/protobuf/compiler/cpp/cpp_enum_field.h +++ b/src/google/protobuf/compiler/cpp/cpp_enum_field.h @@ -52,8 +52,7 @@ class EnumFieldGenerator : public FieldGenerator { // implements FieldGenerator --------------------------------------- void GeneratePrivateMembers(io::Printer* printer) const; void GenerateAccessorDeclarations(io::Printer* printer) const; - void GenerateInlineAccessorDefinitions(io::Printer* printer, - bool is_inline) const; + void GenerateInlineAccessorDefinitions(io::Printer* printer) const; void GenerateClearingCode(io::Printer* printer) const; void GenerateMergingCode(io::Printer* printer) const; void GenerateSwappingCode(io::Printer* printer) const; @@ -79,8 +78,7 @@ class EnumOneofFieldGenerator : public EnumFieldGenerator { ~EnumOneofFieldGenerator(); // implements FieldGenerator --------------------------------------- - void GenerateInlineAccessorDefinitions(io::Printer* printer, - bool is_inline) const; + void GenerateInlineAccessorDefinitions(io::Printer* printer) const; void GenerateClearingCode(io::Printer* printer) const; void GenerateSwappingCode(io::Printer* printer) const; void GenerateConstructorCode(io::Printer* printer) const; @@ -98,8 +96,7 @@ class RepeatedEnumFieldGenerator : public FieldGenerator { // implements FieldGenerator --------------------------------------- void GeneratePrivateMembers(io::Printer* printer) const; void GenerateAccessorDeclarations(io::Printer* printer) const; - void GenerateInlineAccessorDefinitions(io::Printer* printer, - bool is_inline) const; + void GenerateInlineAccessorDefinitions(io::Printer* printer) const; void GenerateClearingCode(io::Printer* printer) const; void GenerateMergingCode(io::Printer* printer) const; void GenerateSwappingCode(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 e4fce461..0a4e0bb9 100644 --- a/src/google/protobuf/compiler/cpp/cpp_extension.cc +++ b/src/google/protobuf/compiler/cpp/cpp_extension.cc @@ -35,9 +35,10 @@ #include <google/protobuf/compiler/cpp/cpp_extension.h> #include <map> #include <google/protobuf/compiler/cpp/cpp_helpers.h> -#include <google/protobuf/stubs/strutil.h> #include <google/protobuf/io/printer.h> #include <google/protobuf/descriptor.pb.h> +#include <google/protobuf/stubs/strutil.h> + namespace google { namespace protobuf { @@ -166,46 +167,6 @@ void ExtensionGenerator::GenerateDefinition(io::Printer* printer) { " $name$($constant_name$, $default$);\n"); } -void ExtensionGenerator::GenerateRegistration(io::Printer* printer) { - std::map<string, string> vars; - vars["extendee" ] = ExtendeeClassName(descriptor_); - vars["number" ] = SimpleItoa(descriptor_->number()); - vars["field_type" ] = SimpleItoa(static_cast<int>(descriptor_->type())); - vars["is_repeated"] = descriptor_->is_repeated() ? "true" : "false"; - vars["is_packed" ] = (descriptor_->is_repeated() && - descriptor_->options().packed()) - ? "true" : "false"; - - switch (descriptor_->cpp_type()) { - case FieldDescriptor::CPPTYPE_ENUM: - 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$::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$::internal_default_instance(),\n" - " $number$, $field_type$, $is_repeated$, $is_packed$);\n"); - break; - } -} - } // namespace cpp } // namespace compiler } // namespace protobuf diff --git a/src/google/protobuf/compiler/cpp/cpp_extension.h b/src/google/protobuf/compiler/cpp/cpp_extension.h index 1c1caf1f..30236d71 100644 --- a/src/google/protobuf/compiler/cpp/cpp_extension.h +++ b/src/google/protobuf/compiler/cpp/cpp_extension.h @@ -67,9 +67,6 @@ class ExtensionGenerator { // Source file stuff. void GenerateDefinition(io::Printer* printer); - // Generate code to register the extension. - void GenerateRegistration(io::Printer* printer); - private: const FieldDescriptor* descriptor_; string type_traits_; diff --git a/src/google/protobuf/compiler/cpp/cpp_field.cc b/src/google/protobuf/compiler/cpp/cpp_field.cc index 4480a9d2..0cf25b33 100644 --- a/src/google/protobuf/compiler/cpp/cpp_field.cc +++ b/src/google/protobuf/compiler/cpp/cpp_field.cc @@ -61,17 +61,13 @@ using internal::WireFormat; void SetCommonFieldVariables(const FieldDescriptor* descriptor, std::map<string, string>* variables, const Options& options) { + (*variables)["ns"] = Namespace(descriptor); (*variables)["name"] = FieldName(descriptor); (*variables)["index"] = SimpleItoa(descriptor->index()); (*variables)["number"] = SimpleItoa(descriptor->number()); (*variables)["classname"] = ClassName(FieldScope(descriptor), false); (*variables)["declared_type"] = DeclaredTypeMethodName(descriptor->type()); - - // non_null_ptr_to_name is usable only if has_$name$ is true. It yields a - // pointer that will not be NULL. Subclasses of FieldGenerator may set - // (*variables)["non_null_ptr_to_name"] differently. - (*variables)["non_null_ptr_to_name"] = - StrCat("&this->", FieldName(descriptor), "()"); + (*variables)["field_member"] = FieldName(descriptor) + "_"; (*variables)["tag_size"] = SimpleItoa( WireFormat::TagSize(descriptor->number(), descriptor->type())); @@ -80,8 +76,6 @@ void SetCommonFieldVariables(const FieldDescriptor* descriptor, (*variables)["deprecated_attr"] = descriptor->options().deprecated() ? "GOOGLE_PROTOBUF_DEPRECATED_ATTR " : ""; - (*variables)["cppget"] = "Get"; - if (HasFieldPresence(descriptor->file())) { (*variables)["set_hasbit"] = "set_has_" + FieldName(descriptor) + "();"; @@ -92,18 +86,19 @@ void SetCommonFieldVariables(const FieldDescriptor* descriptor, (*variables)["clear_hasbit"] = ""; } - // By default, empty string, so that generic code used for both oneofs and - // singular fields can be written. - (*variables)["oneof_prefix"] = ""; + // These variables are placeholders to pick out the beginning and ends of + // identifiers for annotations (when doing so with existing variables would + // be ambiguous or impossible). They should never be set to anything but the + // empty string. + (*variables)["{"] = ""; + (*variables)["}"] = ""; } void SetCommonOneofFieldVariables(const FieldDescriptor* descriptor, std::map<string, string>* variables) { const string prefix = descriptor->containing_oneof()->name() + "_."; - (*variables)["oneof_prefix"] = prefix; (*variables)["oneof_name"] = descriptor->containing_oneof()->name(); - (*variables)["non_null_ptr_to_name"] = - StrCat(prefix, (*variables)["name"], "_"); + (*variables)["field_member"] = StrCat(prefix, (*variables)["name"], "_"); } FieldGenerator::~FieldGenerator() {} @@ -194,7 +189,6 @@ const FieldGenerator& FieldGeneratorMap::get( return *field_generators_[field->index()]; } - } // namespace cpp } // namespace compiler } // namespace protobuf diff --git a/src/google/protobuf/compiler/cpp/cpp_field.h b/src/google/protobuf/compiler/cpp/cpp_field.h index 00dc25d4..bccfcb9a 100644 --- a/src/google/protobuf/compiler/cpp/cpp_field.h +++ b/src/google/protobuf/compiler/cpp/cpp_field.h @@ -109,19 +109,19 @@ class FieldGenerator { // Generate inline definitions of depenent accessor functions for this field. // These are placed inside the header after all class definitions. virtual void GenerateDependentInlineAccessorDefinitions( - io::Printer* printer) const {} + io::Printer* printer) const {} // Generate inline definitions of accessor functions for this field. // These are placed inside the header after all class definitions. // In non-.proto.h mode, this generates dependent accessor functions as well. virtual void GenerateInlineAccessorDefinitions( - io::Printer* printer, bool is_inline) const = 0; + io::Printer* printer) const = 0; // Generate definitions of accessors that aren't inlined. These are // placed somewhere in the .cc file. // Most field types don't need this, so the default implementation is empty. virtual void GenerateNonInlineAccessorDefinitions( - io::Printer* /*printer*/) const {} + io::Printer* /*printer*/) const {} // Generate lines of code (statements, not declarations) which clear the // field. This is used to define the clear_$name$() method @@ -180,14 +180,14 @@ class FieldGenerator { virtual void GenerateDefaultInstanceAllocator(io::Printer* /*printer*/) const {} - // Generate code that should be run when ShutdownProtobufLibrary() is called, - // to delete all dynamically-allocated objects. - virtual void GenerateShutdownCode(io::Printer* /*printer*/) const {} - // Generate lines to decode this field, which will be placed inside the // message's MergeFromCodedStream() method. virtual void GenerateMergeFromCodedStream(io::Printer* printer) const = 0; + // Returns true if this field's "MergeFromCodedStream" code needs the arena + // to be defined as a variable. + virtual bool MergeFromCodedStreamNeedsArena() const { return false; } + // Generate lines to decode this field from a packed value, which will be // placed inside the message's MergeFromCodedStream() method. virtual void GenerateMergeFromCodedStreamWithPacking(io::Printer* printer) @@ -233,7 +233,6 @@ class FieldGeneratorMap { GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FieldGeneratorMap); }; - } // namespace cpp } // namespace compiler } // namespace protobuf diff --git a/src/google/protobuf/compiler/cpp/cpp_file.cc b/src/google/protobuf/compiler/cpp/cpp_file.cc index e0542ae8..a922ee97 100644 --- a/src/google/protobuf/compiler/cpp/cpp_file.cc +++ b/src/google/protobuf/compiler/cpp/cpp_file.cc @@ -55,70 +55,24 @@ namespace google { namespace protobuf { namespace compiler { namespace cpp { -namespace { -// The list of names that are defined as macros on some platforms. We need to -// #undef them for the generated code to compile. -const char* kMacroNames[] = {"major", "minor"}; - -bool IsMacroName(const string& name) { - // Just do a linear search as the number of elements is very small. - for (int i = 0; i < GOOGLE_ARRAYSIZE(kMacroNames); ++i) { - if (name == kMacroNames[i]) return true; - } - return false; -} - -void CollectMacroNames(const Descriptor* message, std::vector<string>* names) { - for (int i = 0; i < message->field_count(); ++i) { - const FieldDescriptor* field = message->field(i); - if (IsMacroName(field->name())) { - names->push_back(field->name()); - } - } - for (int i = 0; i < message->nested_type_count(); ++i) { - CollectMacroNames(message->nested_type(i), names); - } -} - -void CollectMacroNames(const FileDescriptor* file, std::vector<string>* names) { - // Only do this for protobuf's own types. There are some google3 protos using - // macros as field names and the generated code compiles after the macro - // expansion. Undefing these macros actually breaks such code. - if (file->name() != "google/protobuf/compiler/plugin.proto") { - return; - } - for (int i = 0; i < file->message_type_count(); ++i) { - CollectMacroNames(file->message_type(i), names); - } -} - - -} // namespace - -// =================================================================== FileGenerator::FileGenerator(const FileDescriptor* file, const Options& options) : file_(file), options_(options), scc_analyzer_(options), - message_generators_owner_( - new google::protobuf::scoped_ptr<MessageGenerator>[file->message_type_count()]), enum_generators_owner_( new google::protobuf::scoped_ptr<EnumGenerator>[file->enum_type_count()]), service_generators_owner_( new google::protobuf::scoped_ptr<ServiceGenerator>[file->service_count()]), extension_generators_owner_( new google::protobuf::scoped_ptr<ExtensionGenerator>[file->extension_count()]) { - - for (int i = 0; i < file->message_type_count(); i++) { - message_generators_owner_[i].reset( - new MessageGenerator(file->message_type(i), options, &scc_analyzer_)); - message_generators_owner_[i]->Flatten(&message_generators_); - } - - for (int i = 0; i < message_generators_.size(); i++) { - message_generators_[i]->AddGenerators(&enum_generators_, - &extension_generators_); + std::vector<const Descriptor*> msgs = FlattenMessagesInFile(file); + for (int i = 0; i < msgs.size(); i++) { + // Deleted in destructor + MessageGenerator* msg_gen = + new MessageGenerator(msgs[i], i, options, &scc_analyzer_); + message_generators_.push_back(msg_gen); + msg_gen->AddGenerators(&enum_generators_, &extension_generators_); } for (int i = 0; i < file->enum_type_count(); i++) { @@ -132,6 +86,11 @@ FileGenerator::FileGenerator(const FileDescriptor* file, const Options& options) new ServiceGenerator(file->service(i), options)); service_generators_.push_back(service_generators_owner_[i].get()); } + if (HasGenericServices(file_, options_)) { + for (int i = 0; i < service_generators_.size(); i++) { + service_generators_[i]->index_in_metadata_ = i; + } + } for (int i = 0; i < file->extension_count(); i++) { extension_generators_owner_[i].reset( @@ -139,14 +98,36 @@ FileGenerator::FileGenerator(const FileDescriptor* file, const Options& options) extension_generators_.push_back(extension_generators_owner_[i].get()); } + package_parts_ = Split(file_->package(), ".", true); } -FileGenerator::~FileGenerator() {} +FileGenerator::~FileGenerator() { + for (int i = 0; i < message_generators_.size(); i++) { + delete message_generators_[i]; + } +} void FileGenerator::GenerateMacroUndefs(io::Printer* printer) { + // Only do this for protobuf's own types. There are some google3 protos using + // macros as field names and the generated code compiles after the macro + // expansion. Undefing these macros actually breaks such code. + if (file_->name() != "google/protobuf/compiler/plugin.proto") { + return; + } std::vector<string> names_to_undef; - CollectMacroNames(file_, &names_to_undef); + std::vector<const FieldDescriptor*> fields; + ListAllFields(file_, &fields); + for (int i = 0; i < fields.size(); i++) { + const string& name = fields[i]->name(); + static const char* kMacroNames[] = {"major", "minor"}; + for (int i = 0; i < GOOGLE_ARRAYSIZE(kMacroNames); ++i) { + if (name == kMacroNames[i]) { + names_to_undef.push_back(name); + break; + } + } + } for (int i = 0; i < names_to_undef.size(); ++i) { printer->Print( "#ifdef $name$\n" @@ -162,43 +143,41 @@ void FileGenerator::GenerateHeader(io::Printer* printer) { GenerateMacroUndefs(printer); - GenerateForwardDeclarations(printer); - - // Open namespace. - GenerateNamespaceOpeners(printer); - GenerateGlobalStateFunctionDeclarations(printer); - printer->Print("\n"); + GenerateForwardDeclarations(printer); - GenerateEnumDefinitions(printer); + { + NamespaceOpener ns(Namespace(file_), printer); - printer->Print(kThickSeparator); - printer->Print("\n"); + printer->Print("\n"); - GenerateMessageDefinitions(printer); + GenerateEnumDefinitions(printer); - printer->Print("\n"); - printer->Print(kThickSeparator); - printer->Print("\n"); + printer->Print(kThickSeparator); + printer->Print("\n"); - GenerateServiceDefinitions(printer); + GenerateMessageDefinitions(printer); - GenerateExtensionIdentifiers(printer); + printer->Print("\n"); + printer->Print(kThickSeparator); + printer->Print("\n"); - printer->Print("\n"); - printer->Print(kThickSeparator); - printer->Print("\n"); + GenerateServiceDefinitions(printer); - GenerateInlineFunctionDefinitions(printer); + GenerateExtensionIdentifiers(printer); - printer->Print( - "\n" - "// @@protoc_insertion_point(namespace_scope)\n" - "\n"); + printer->Print("\n"); + printer->Print(kThickSeparator); + printer->Print("\n"); - // Close up namespace. - GenerateNamespaceClosers(printer); + GenerateInlineFunctionDefinitions(printer); + + printer->Print( + "\n" + "// @@protoc_insertion_point(namespace_scope)\n" + "\n"); + } // We need to specialize some templates in the ::google::protobuf namespace: GenerateProto2NamespaceEnumSpecializations(printer); @@ -261,15 +240,12 @@ void FileGenerator::GeneratePBHeader(io::Printer* printer, // TODO(gerbens) remove this. printer->Print( "// @@protoc_insertion_point(includes)\n"); - - // Open namespace. - GenerateNamespaceOpeners(printer); - printer->Print( - "\n" - "// @@protoc_insertion_point(namespace_scope)\n"); - // Close up namespace. - GenerateNamespaceClosers(printer); - + { + NamespaceOpener ns(Namespace(file_), printer); + printer->Print( + "\n" + "// @@protoc_insertion_point(namespace_scope)\n"); + } printer->Print( "\n" "// @@protoc_insertion_point(global_scope)\n" @@ -279,7 +255,7 @@ void FileGenerator::GeneratePBHeader(io::Printer* printer, GenerateBottomHeaderGuard(printer, filename_identifier); } -void FileGenerator::GenerateSource(io::Printer* printer) { +void FileGenerator::GenerateSourceIncludes(io::Printer* printer) { const bool use_system_include = IsWellKnownMessage(file_); string header = StripProto(file_->name()) + (options_.proto_h ? ".proto.h" : ".pb.h"); @@ -287,9 +263,6 @@ void FileGenerator::GenerateSource(io::Printer* printer) { "// Generated by the protocol buffer compiler. DO NOT EDIT!\n" "// source: $filename$\n" "\n" - // The generated code calls accessors that might be deprecated. We don't - // want the compiler to warn in generated code. - "#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION\n" "#include $left$$header$$right$\n" "\n" "#include <algorithm>\n" // for swap() @@ -330,102 +303,154 @@ void FileGenerator::GenerateSource(io::Printer* printer) { } } + // TODO(gerbens) Remove this when all code in google is using the same + // proto library. This is a temporary hack to force build errors if + // the proto library is compiled with GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + // and is also linking internal proto2. This is to prevent regressions while + // we work cleaning up the code base. After this is completed and we have + // one proto lib all code uses this should be removed. + printer->Print( + "// This is a temporary google only hack\n" + "#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS\n" + "#include \"third_party/protobuf/version.h\"\n" + "#endif\n"); + printer->Print( "// @@protoc_insertion_point(includes)\n"); +} - GenerateNamespaceOpeners(printer); +void FileGenerator::GenerateSourceDefaultInstance(int idx, + io::Printer* printer) { + printer->Print( + "class $classname$DefaultTypeInternal {\n" + " public:\n" + " ::google::protobuf::internal::ExplicitlyConstructed<$classname$>\n" + " _instance;\n", + "classname", message_generators_[idx]->classname_); + printer->Indent(); + message_generators_[idx]->GenerateExtraDefaultFields(printer); + printer->Outdent(); + printer->Print("} _$classname$_default_instance_;\n", "classname", + message_generators_[idx]->classname_); +} - for (int i = 0; i < message_generators_.size(); i++) { - string parent; - if (IsMapEntryMessage(message_generators_[i]->descriptor_)) { - parent = ClassName(message_generators_[i]->descriptor_->containing_type(), - false) + - "::"; +namespace { + +// Generates weak symbol declarations for types that are to be considered weakly +// referenced. +void GenerateWeakDeclarations( + const FileDescriptor* file, const Options& options, + SCCAnalyzer* scc_analyzer, + io::Printer* printer) { + std::vector<const FieldDescriptor*> fields; + ListAllFields(file, &fields); + + // To ensure determinism and minimize the number of namespace statements, + // we output the forward declarations sorted on namespace and type / function + // name. + std::set<std::pair<string, string> > messages; + std::set<std::pair<string, string> > inits; + for (int i = 0; i < fields.size(); ++i) { + const FieldDescriptor* field = fields[i]; + bool is_weak = IsImplicitWeakField(field, options); + if (is_weak) { + const Descriptor* msg = field->message_type(); + string flns = FileLevelNamespace(msg); + string repr = ClassName(scc_analyzer->GetSCC(msg)->GetRepresentative()); + inits.insert(std::make_pair(flns, "InitDefaults" + repr)); + inits.insert(std::make_pair(flns, "AddDescriptors")); + messages.insert(std::make_pair(Namespace(msg), ClassName(msg))); } - printer->Print( - "class $classname$DefaultTypeInternal : " - "public ::google::protobuf::internal::ExplicitlyConstructed<$parent$$classname$> " - "{\n", - "parent", parent, "classname", message_generators_[i]->classname_); - printer->Indent(); - message_generators_[i]->GenerateExtraDefaultFields(printer); - printer->Outdent(); - printer->Print( - "} _$classname$_default_instance_;\n", - "classname", message_generators_[i]->classname_); } - for (int i = 0; i < enum_generators_.size(); i++) { - enum_generators_[i]->index_in_metadata_ = i; + if (messages.empty()) { + return; } - if (HasGenericServices(file_, options_)) { - for (int i = 0; i < service_generators_.size(); i++) { - service_generators_[i]->index_in_metadata_ = i; - } + + printer->Print("\n"); + NamespaceOpener ns(printer); + for (std::set<std::pair<string, string> >::const_iterator it = + messages.begin(); + it != messages.end(); ++it) { + ns.ChangeTo(it->first); + printer->Print( + "extern __attribute__((weak)) $classname$DefaultTypeInternal " + "_$classname$_default_instance_;\n", + "classname", it->second); + } + for (std::set<std::pair<string, string> >::const_iterator it = inits.begin(); + it != inits.end(); ++it) { + ns.ChangeTo(it->first); + printer->Print("void $name$() __attribute__((weak));\n", + "name", it->second); } +} - printer->Print( - "\n" - "namespace $file_namespace$ {\n" - "\n", - "file_namespace", FileLevelNamespace(file_->name())); +} // namespace - if (HasDescriptorMethods(file_, options_)) { - printer->Print( - "\n" - "namespace {\n" - "\n"); +void FileGenerator::GenerateSourceForMessage(int idx, io::Printer* printer) { + GenerateSourceIncludes(printer); + GenerateWeakDeclarations(file_, options_, &scc_analyzer_, printer); - if (!message_generators_.empty()) { - printer->Print("::google::protobuf::Metadata file_level_metadata[$size$];\n", - "size", SimpleItoa(message_generators_.size())); - } - if (!enum_generators_.empty()) { - printer->Print( - "const ::google::protobuf::EnumDescriptor* " - "file_level_enum_descriptors[$size$];\n", - "size", SimpleItoa(enum_generators_.size())); - } - if (HasGenericServices(file_, options_) && file_->service_count() > 0) { - printer->Print( - "const ::google::protobuf::ServiceDescriptor* " - "file_level_service_descriptors[$size$];\n", - "size", SimpleItoa(file_->service_count())); + { // package namespace + NamespaceOpener ns(Namespace(file_), printer); + + // Define default instances + GenerateSourceDefaultInstance(idx, printer); + if (options_.lite_implicit_weak_fields) { + printer->Print("void $classname$_ReferenceStrong() {}\n", "classname", + message_generators_[idx]->classname_); } + // Generate classes. + printer->Print("\n"); + message_generators_[idx]->GenerateClassMethods(printer); + printer->Print( - "\n" - "} // namespace\n" - "\n"); + "\n" + "// @@protoc_insertion_point(namespace_scope)\n"); + } // end package namespace + + if (IsSCCRepresentative(message_generators_[idx]->descriptor_)) { + NamespaceOpener ns(FileLevelNamespace(file_), printer); + GenerateInitForSCC(GetSCC(message_generators_[idx]->descriptor_), printer); } - // Define our externally-visible BuildDescriptors() function. (For the lite - // library, all this does is initialize default instances.) - GenerateBuildDescriptors(printer); + + printer->Print( + "namespace google {\nnamespace protobuf {\n"); + message_generators_[idx]->GenerateSourceInProto2Namespace(printer); + printer->Print( + "} // namespace protobuf\n} // namespace google\n"); printer->Print( "\n" - "} // namespace $file_namespace$\n" - "\n", - "file_namespace", FileLevelNamespace(file_->name())); + "// @@protoc_insertion_point(global_scope)\n"); +} + +void FileGenerator::GenerateGlobalSource(io::Printer* printer) { + GenerateSourceIncludes(printer); + GenerateWeakDeclarations(file_, options_, &scc_analyzer_, printer); + + // TODO(gerbens) Generate tables here + + // Define the code to initialize reflection. This code uses a global + // constructor to register reflection data with the runtime pre-main. + if (HasDescriptorMethods(file_, options_)) { + NamespaceOpener ns(FileLevelNamespace(file_), printer); + GenerateReflectionInitializationCode(printer); + } + + NamespaceOpener ns(Namespace(file_), printer); // Generate enums. for (int i = 0; i < enum_generators_.size(); i++) { - enum_generators_[i]->GenerateMethods(printer); + enum_generators_[i]->GenerateMethods(i, printer); } - // Generate classes. - for (int i = 0; i < message_generators_.size(); i++) { - printer->Print("\n"); - printer->Print(kThickSeparator); - printer->Print("\n"); - message_generators_[i]->GenerateClassMethods(printer); - - printer->Print("#if PROTOBUF_INLINE_NOT_IN_HEADERS\n"); - // Generate class inline methods. - message_generators_[i]->GenerateInlineMethods(printer, - /* is_inline = */ false); - printer->Print("#endif // PROTOBUF_INLINE_NOT_IN_HEADERS\n"); + // Define extensions. + for (int i = 0; i < extension_generators_.size(); i++) { + extension_generators_[i]->GenerateDefinition(printer); } if (HasGenericServices(file_, options_)) { @@ -437,17 +462,84 @@ void FileGenerator::GenerateSource(io::Printer* printer) { service_generators_[i]->GenerateImplementation(printer); } } +} - // Define extensions. - for (int i = 0; i < extension_generators_.size(); i++) { - extension_generators_[i]->GenerateDefinition(printer); +void FileGenerator::GenerateSource(io::Printer* printer) { + GenerateSourceIncludes(printer); + GenerateWeakDeclarations(file_, options_, &scc_analyzer_, printer); + + { + NamespaceOpener ns(Namespace(file_), printer); + + // Define default instances + for (int i = 0; i < message_generators_.size(); i++) { + GenerateSourceDefaultInstance(i, printer); + if (options_.lite_implicit_weak_fields) { + printer->Print("void $classname$_ReferenceStrong() {}\n", "classname", + message_generators_[i]->classname_); + } + } + } + + { + NamespaceOpener ns(FileLevelNamespace(file_), printer); + // Define the initialization code to initialize the default instances. + // This code doesn't use a global constructor. + GenerateInitializationCode(printer); + + // Define the code to initialize reflection. This code uses a global + // constructor to register reflection data with the runtime pre-main. + if (HasDescriptorMethods(file_, options_)) { + GenerateReflectionInitializationCode(printer); + } } - printer->Print( - "\n" - "// @@protoc_insertion_point(namespace_scope)\n"); - GenerateNamespaceClosers(printer); + { + NamespaceOpener ns(Namespace(file_), printer); + + // Actually implement the protos + + // Generate enums. + for (int i = 0; i < enum_generators_.size(); i++) { + enum_generators_[i]->GenerateMethods(i, printer); + } + + // Generate classes. + for (int i = 0; i < message_generators_.size(); i++) { + printer->Print("\n"); + printer->Print(kThickSeparator); + printer->Print("\n"); + message_generators_[i]->GenerateClassMethods(printer); + } + + if (HasGenericServices(file_, options_)) { + // Generate services. + for (int i = 0; i < service_generators_.size(); i++) { + if (i == 0) printer->Print("\n"); + printer->Print(kThickSeparator); + printer->Print("\n"); + service_generators_[i]->GenerateImplementation(printer); + } + } + + // Define extensions. + for (int i = 0; i < extension_generators_.size(); i++) { + extension_generators_[i]->GenerateDefinition(printer); + } + + printer->Print( + "\n" + "// @@protoc_insertion_point(namespace_scope)\n"); + } + + printer->Print( + "namespace google {\nnamespace protobuf {\n"); + for (int i = 0; i < message_generators_.size(); i++) { + message_generators_[i]->GenerateSourceInProto2Namespace(printer); + } + printer->Print( + "} // namespace protobuf\n} // namespace google\n"); printer->Print( "\n" @@ -477,7 +569,42 @@ class FileGenerator::ForwardDeclarations { std::map<string, const Descriptor*>& classes() { return classes_; } std::map<string, const EnumDescriptor*>& enums() { return enums_; } - void Print(io::Printer* printer, const Options& options) const { + void PrintForwardDeclarations(io::Printer* printer, + const Options& options) const { + PrintNestedDeclarations(printer, options); + PrintTopLevelDeclarations(printer, options); + } + + + private: + void PrintNestedDeclarations(io::Printer* printer, + const Options& options) const { + PrintDeclarationsInsideNamespace(printer, options); + for (std::map<string, ForwardDeclarations *>::const_iterator + it = namespaces_.begin(), + end = namespaces_.end(); + it != end; ++it) { + printer->Print("namespace $nsname$ {\n", + "nsname", it->first); + it->second->PrintNestedDeclarations(printer, options); + printer->Print("} // namespace $nsname$\n", + "nsname", it->first); + } + } + + void PrintTopLevelDeclarations(io::Printer* printer, + const Options& options) const { + PrintDeclarationsOutsideNamespace(printer, options); + for (std::map<string, ForwardDeclarations *>::const_iterator + it = namespaces_.begin(), + end = namespaces_.end(); + it != end; ++it) { + it->second->PrintTopLevelDeclarations(printer, options); + } + } + + void PrintDeclarationsInsideNamespace(io::Printer* printer, + const Options& options) const { for (std::map<string, const EnumDescriptor *>::const_iterator it = enums_.begin(), end = enums_.end(); @@ -503,34 +630,51 @@ class FileGenerator::ForwardDeclarations { options.dllexport_decl.empty() ? "" : options.dllexport_decl + " ", "classname", it->first); + if (options.lite_implicit_weak_fields) { + printer->Print("void $classname$_ReferenceStrong();\n", + "classname", it->first); + } } - for (std::map<string, ForwardDeclarations *>::const_iterator - it = namespaces_.begin(), - end = namespaces_.end(); + } + + void PrintDeclarationsOutsideNamespace(io::Printer* printer, + const Options& options) const { + if (classes_.size() == 0) return; + + printer->Print( + "namespace google {\nnamespace protobuf {\n"); + for (std::map<string, const Descriptor*>::const_iterator + it = classes_.begin(), + end = classes_.end(); it != end; ++it) { - printer->Print("namespace $nsname$ {\n", - "nsname", it->first); - it->second->Print(printer, options); - printer->Print("} // namespace $nsname$\n", - "nsname", it->first); + const Descriptor* d = it->second; + string extra_class_qualifier; + // "class" is to disambiguate in case there is also a function with this + // name. There is code out there that does this! + printer->Print( + "template<> " + "$dllexport_decl$" + "$class$$classname$* Arena::$func$< $class$$classname$>(Arena*);\n", + "classname", QualifiedClassName(d), + "func", MessageCreateFunction(d), + "class", extra_class_qualifier, + "dllexport_decl", + options.dllexport_decl.empty() ? "" : options.dllexport_decl + " "); } + printer->Print( + "} // namespace protobuf\n} // namespace google\n"); } - - private: std::map<string, ForwardDeclarations*> namespaces_; std::map<string, const Descriptor*> classes_; std::map<string, const EnumDescriptor*> enums_; }; -void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) { +void FileGenerator::GenerateReflectionInitializationCode(io::Printer* printer) { // AddDescriptors() is a file-level procedure which adds the encoded // FileDescriptorProto for this .proto file to the global DescriptorPool for - // generated files (DescriptorPool::generated_pool()). It either runs at - // static initialization time (by default) or when default_instance() is - // called for the first time (in LITE_RUNTIME mode with - // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER flag enabled). This procedure also - // constructs default instances and registers extensions. + // generated files (DescriptorPool::generated_pool()). It ordinarily runs at + // static initialization time, but is not used at all in LITE_RUNTIME mode. // // Its sibling, AssignDescriptors(), actually pulls the compiled // FileDescriptor from the DescriptorPool and uses it to populate all of @@ -539,131 +683,83 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) { // anyone calls descriptor() or GetReflection() on one of the types defined // in the file. - // In optimize_for = LITE_RUNTIME mode, we don't generate AssignDescriptors() - // and we only use AddDescriptors() to allocate default instances. - - // TODO(ckennelly): Gate this with the same options flag to enable - // table-driven parsing. - - printer->Print("PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::ParseTableField\n" - " const TableStruct::entries[] = {\n"); - printer->Indent(); - - std::vector<size_t> entries; - size_t count = 0; - for (int i = 0; i < message_generators_.size(); i++) { - size_t value = message_generators_[i]->GenerateParseOffsets(printer); - entries.push_back(value); - count += value; - } - - // We need these arrays to exist, and MSVC does not like empty arrays. - if (count == 0) { - printer->Print("{0, 0, 0, ::google::protobuf::internal::kInvalidMask, 0, 0},\n"); - } - - printer->Outdent(); - printer->Print( - "};\n" - "\n" - "PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::AuxillaryParseTableField\n" - " const TableStruct::aux[] = {\n"); - printer->Indent(); - - std::vector<size_t> aux_entries; - count = 0; - for (int i = 0; i < message_generators_.size(); i++) { - size_t value = message_generators_[i]->GenerateParseAuxTable(printer); - aux_entries.push_back(value); - count += value; - } - - if (count == 0) { - printer->Print("::google::protobuf::internal::AuxillaryParseTableField(),\n"); + if (!message_generators_.empty()) { + printer->Print("::google::protobuf::Metadata file_level_metadata[$size$];\n", "size", + SimpleItoa(message_generators_.size())); } - - printer->Outdent(); - printer->Print( - "};\n" - "PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::ParseTable const\n" - " TableStruct::schema[] = {\n"); - printer->Indent(); - - size_t offset = 0; - size_t aux_offset = 0; - for (int i = 0; i < message_generators_.size(); i++) { - message_generators_[i]->GenerateParseTable(printer, offset, aux_offset); - offset += entries[i]; - aux_offset += aux_entries[i]; + if (!enum_generators_.empty()) { + printer->Print( + "const ::google::protobuf::EnumDescriptor* " + "file_level_enum_descriptors[$size$];\n", + "size", SimpleItoa(enum_generators_.size())); } - - if (message_generators_.empty()) { - printer->Print("{ NULL, NULL, 0, -1, -1, false },\n"); + if (HasGenericServices(file_, options_) && file_->service_count() > 0) { + printer->Print( + "const ::google::protobuf::ServiceDescriptor* " + "file_level_service_descriptors[$size$];\n", + "size", SimpleItoa(file_->service_count())); } - printer->Outdent(); - printer->Print( - "};\n" - "\n"); - - if (HasDescriptorMethods(file_, options_)) { - if (!message_generators_.empty()) { - printer->Print("const ::google::protobuf::uint32 TableStruct::offsets[] = {\n"); - printer->Indent(); - std::vector<std::pair<size_t, size_t> > pairs; - for (int i = 0; i < message_generators_.size(); i++) { - pairs.push_back(message_generators_[i]->GenerateOffsets(printer)); - } - printer->Outdent(); - printer->Print( - "};\n" - "\n" - "static const ::google::protobuf::internal::MigrationSchema schemas[] = {\n"); - printer->Indent(); - { - int offset = 0; - for (int i = 0; i < message_generators_.size(); i++) { - message_generators_[i]->GenerateSchema(printer, offset, - pairs[i].second); - offset += pairs[i].first; - } - } - printer->Outdent(); - printer->Print( - "};\n" - "\nstatic " - "::google::protobuf::Message const * const file_default_instances[] = {\n"); - printer->Indent(); + if (!message_generators_.empty()) { + printer->Print( + "\n" + "const ::google::protobuf::uint32 TableStruct::offsets[] " + "GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {\n"); + printer->Indent(); + std::vector<std::pair<size_t, size_t> > pairs; + pairs.reserve(message_generators_.size()); + for (int i = 0; i < message_generators_.size(); i++) { + pairs.push_back(message_generators_[i]->GenerateOffsets(printer)); + } + printer->Outdent(); + printer->Print( + "};\n" + "static const ::google::protobuf::internal::MigrationSchema schemas[] " + "GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {\n"); + printer->Indent(); + { + int offset = 0; for (int i = 0; i < message_generators_.size(); i++) { - const Descriptor* descriptor = message_generators_[i]->descriptor_; - printer->Print( - "reinterpret_cast<const " - "::google::protobuf::Message*>(&_$classname$_default_instance_),\n", - "classname", ClassName(descriptor, false)); + message_generators_[i]->GenerateSchema(printer, offset, + pairs[i].second); + offset += pairs[i].first; } - printer->Outdent(); - printer->Print( - "};\n" - "\n"); - } else { - // we still need these symbols to exist + } + printer->Outdent(); + printer->Print( + "};\n" + "\nstatic " + "::google::protobuf::Message const * const file_default_instances[] = {\n"); + printer->Indent(); + for (int i = 0; i < message_generators_.size(); i++) { + const Descriptor* descriptor = message_generators_[i]->descriptor_; printer->Print( - // MSVC doesn't like empty arrays, so we add a dummy. - "const ::google::protobuf::uint32 TableStruct::offsets[] = { ~0u };\n" - "static const ::google::protobuf::internal::MigrationSchema* schemas = NULL;\n" - "static const ::google::protobuf::Message* const* " - "file_default_instances = NULL;\n"); + "reinterpret_cast<const " + "::google::protobuf::Message*>(&$ns$::_$classname$_default_instance_),\n", + "classname", ClassName(descriptor), "ns", Namespace(descriptor)); } + printer->Outdent(); + printer->Print( + "};\n" + "\n"); + } else { + // we still need these symbols to exist + printer->Print( + // MSVC doesn't like empty arrays, so we add a dummy. + "const ::google::protobuf::uint32 TableStruct::offsets[1] = {};\n" + "static const ::google::protobuf::internal::MigrationSchema* schemas = NULL;\n" + "static const ::google::protobuf::Message* const* " + "file_default_instances = NULL;\n" + "\n"); + } - // --------------------------------------------------------------- + // --------------------------------------------------------------- - // protobuf_AssignDescriptorsOnce(): The first time it is called, calls - // AssignDescriptors(). All later times, waits for the first call to - // complete and then returns. - string message_factory = "NULL"; + // protobuf_AssignDescriptorsOnce(): The first time it is called, calls + // AssignDescriptors(). All later times, waits for the first call to + // complete and then returns. + string message_factory = "NULL"; printer->Print( - "namespace {\n" - "\n" "void protobuf_AssignDescriptors() {\n" // Make sure the file has found its way into the pool. If a descriptor // is requested *during* static init then AddDescriptors() may not have @@ -684,20 +780,6 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) { ? "file_level_service_descriptors" : "NULL", "factory", message_factory); - // TODO(gerbens) have the compiler include the schemas for map types - // so that this can go away, and we can potentially use table driven - // serialization for map types as well. - for (int i = 0; i < message_generators_.size(); i++) { - if (!IsMapEntryMessage(message_generators_[i]->descriptor_)) continue; - printer->Print( - "file_level_metadata[$index$].reflection = " - "$parent$::$classname$::CreateReflection(file_level_metadata[$index$]" - ".descriptor, _$classname$_default_instance_.get_mutable());\n", - "index", SimpleItoa(i), "parent", - ClassName(message_generators_[i]->descriptor_->containing_type(), - false), - "classname", ClassName(message_generators_[i]->descriptor_, false)); - } printer->Print( "}\n" "\n" @@ -720,7 +802,8 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) { // protobuf_AssignDescriptorsOnce, because that is called from all the // GetMetadata member methods. printer->Print( - "void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD;\n" + "void protobuf_RegisterTypes(const ::std::string&) " + "GOOGLE_PROTOBUF_ATTRIBUTE_COLD;\n" "void protobuf_RegisterTypes(const ::std::string&) {\n" " protobuf_AssignDescriptorsOnce();\n"); printer->Indent(); @@ -734,89 +817,15 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) { printer->Outdent(); printer->Print( - "}\n" - "\n" - "} // namespace\n"); - } - - // ----------------------------------------------------------------- - - // ShutdownFile(): Deletes descriptors, default instances, etc. on shutdown. - printer->Print( - "\n" - "void TableStruct::Shutdown() {\n"); - printer->Indent(); - - for (int i = 0; i < message_generators_.size(); i++) { - message_generators_[i]->GenerateShutdownCode(printer); - } - - if (HasDescriptorMethods(file_, options_)) { - for (int i = 0; i < message_generators_.size(); i++) { - if (!IsMapEntryMessage(message_generators_[i]->descriptor_)) continue; - printer->Print( - "delete file_level_metadata[$index$].reflection;\n", - "index", SimpleItoa(i)); - } - } - - printer->Outdent(); - printer->Print( - "}\n\n"); - - // ----------------------------------------------------------------- - - // Now generate the InitDefaultsImpl() function. - printer->Print( - "void TableStruct::InitDefaultsImpl() {\n" - " GOOGLE_PROTOBUF_VERIFY_VERSION;\n\n" - // Force initialization of primitive values we depend on. - " ::google::protobuf::internal::InitProtobufDefaults();\n"); - - printer->Indent(); - - // 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 file_namespace = QualifiedFileLevelSymbol( - dependency->package(), FileLevelNamespace(dependency->name())); - // Call its AddDescriptors function. - printer->Print("$file_namespace$::InitDefaults();\n", "file_namespace", - file_namespace); - } - - // Allocate and initialize default instances. This can't be done lazily - // since default instances are returned by simple accessors and are used with - // extensions. Speaking of which, we also register extensions at this time. - for (int i = 0; i < message_generators_.size(); i++) { - message_generators_[i]->GenerateDefaultInstanceAllocator(printer); - } - for (int i = 0; i < extension_generators_.size(); i++) { - extension_generators_[i]->GenerateRegistration(printer); - } - for (int i = 0; i < message_generators_.size(); i++) { - message_generators_[i]->GenerateDefaultInstanceInitializer(printer); - } - printer->Outdent(); - printer->Print( - "}\n" - "\n" - "void InitDefaults() {\n" - " static GOOGLE_PROTOBUF_DECLARE_ONCE(once);\n" - " ::google::protobuf::GoogleOnceInit(&once, &TableStruct::InitDefaultsImpl);\n" - "}\n"); - - // ----------------------------------------------------------------- + "}\n" + "\n"); - // Now generate the AddDescriptors() function. - printer->Print( - "void AddDescriptorsImpl() {\n" - " InitDefaults();\n"); + // Now generate the AddDescriptors() function. + printer->Print( + "void AddDescriptorsImpl() {\n" + " InitDefaults();\n"); + printer->Indent(); - printer->Indent(); - if (HasDescriptorMethods(file_, options_)) { // Embed the descriptor. We simply serialize the entire // FileDescriptorProto // and embed it as a string literal, which is parsed and built into real @@ -826,10 +835,12 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) { string file_data; file_proto.SerializeToString(&file_data); - printer->Print("static const char descriptor[] = {\n"); + printer->Print("static const char descriptor[] " + "GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) " + "= {\n"); printer->Indent(); - if (file_data.size() > 66535) { + if (file_data.size() > 65535) { // Workaround for MSVC: "Error C1091: compiler limit: string exceeds 65535 // bytes in length". Declare a static array of characters rather than use // a string literal. Only write 25 bytes per line. @@ -863,23 +874,18 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) { "::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(\n" " \"$filename$\", &protobuf_RegisterTypes);\n", "filename", file_->name()); - } // 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 file_namespace = QualifiedFileLevelSymbol( - dependency->package(), FileLevelNamespace(dependency->name())); + string file_namespace = FileLevelNamespace(dependency); // Call its AddDescriptors function. - printer->Print("$file_namespace$::AddDescriptors();\n", "file_namespace", + printer->Print("::$file_namespace$::AddDescriptors();\n", "file_namespace", file_namespace); } - printer->Print( - "::google::protobuf::internal::OnShutdown(&TableStruct::Shutdown);\n"); - printer->Outdent(); printer->Print( "}\n" @@ -889,55 +895,235 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) { " ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl);\n" "}\n"); - if (!StaticInitializersForced(file_, options_)) { - printer->Print("#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER\n"); - } + printer->Print( + "// Force AddDescriptors() to be called at dynamic initialization " + "time.\n" + "struct StaticDescriptorInitializer {\n" + " StaticDescriptorInitializer() {\n" + " AddDescriptors();\n" + " }\n" + "} static_descriptor_initializer;\n"); +} + +void FileGenerator::GenerateInitForSCC(const SCC* scc, io::Printer* printer) { + const string scc_name = ClassName(scc->GetRepresentative()); printer->Print( - // With static initializers. - "// Force AddDescriptors() to be called at static initialization time.\n" - "struct StaticDescriptorInitializer {\n" - " StaticDescriptorInitializer() {\n" - " AddDescriptors();\n" - " }\n" - "} static_descriptor_initializer;\n"); - if (!StaticInitializersForced(file_, options_)) { - printer->Print("#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER\n"); + "void InitDefaults$scc_name$Impl() {\n" + " GOOGLE_PROTOBUF_VERIFY_VERSION;\n\n" + "#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS\n" + " ::google::protobuf::internal::InitProtobufDefaultsForceUnique();\n" + "#else\n" + " ::google::protobuf::internal::InitProtobufDefaults();\n" + "#endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS\n", + // Force initialization of primitive values we depend on. + "scc_name", scc_name); + + printer->Indent(); + + // Call the InitDefaults() methods for all of our dependencies, to make + // sure they get added first. + for (int i = 0; i < scc->children.size(); i++) { + const SCC* child_scc = scc->children[i]; + const FileDescriptor* dependency = child_scc->GetRepresentative()->file(); + // Print the namespace prefix for the dependency. + string file_namespace = FileLevelNamespace(dependency); + std::map<string, string> variables; + variables["file_namespace"] = file_namespace; + variables["scc_name"] = ClassName(child_scc->GetRepresentative(), false); + bool using_weak_fields = UsingImplicitWeakFields(file_, options_); + if (using_weak_fields) { + // We're building for lite with implicit weak fields, so we need to handle + // the possibility that this InitDefaults function is not linked into the + // binary. Some of these might actually be guaranteed to be non-null since + // we might have a strong reference to the dependency (via a required + // field, for example), but it's simplest to just assume that any of them + // could be null. + printer->Print( + variables, + "if (&$file_namespace$::InitDefaults$scc_name$ != NULL) {\n" + " $file_namespace$::InitDefaults$scc_name$();\n" + "}\n"); + } else { + printer->Print(variables, + "$file_namespace$::InitDefaults$scc_name$();\n"); + } } -} -void FileGenerator::GenerateNamespaceOpeners(io::Printer* printer) { - if (package_parts_.size() > 0) printer->Print("\n"); + // First construct all the necessary default instances. + for (int i = 0; i < message_generators_.size(); i++) { + if (scc_analyzer_.GetSCC(message_generators_[i]->descriptor_) != scc) { + continue; + } + // TODO(gerbens) This requires this function to be friend. Remove + // the need for this. + message_generators_[i]->GenerateFieldDefaultInstances(printer); + printer->Print( + "{\n" + " void* ptr = &$ns$::_$classname$_default_instance_;\n" + " new (ptr) $ns$::$classname$();\n", + "ns", Namespace(message_generators_[i]->descriptor_), + "classname", ClassName(message_generators_[i]->descriptor_)); + if (!IsMapEntryMessage(message_generators_[i]->descriptor_)) { + printer->Print( + " ::google::protobuf::internal::OnShutdownDestroyMessage(ptr);\n"); + } + printer->Print("}\n"); + } - for (int i = 0; i < package_parts_.size(); i++) { - printer->Print("namespace $part$ {\n", - "part", package_parts_[i]); + // TODO(gerbens) make default instances be the same as normal instances. + // Default instances differ from normal instances because they have cross + // linked message fields. + for (int i = 0; i < message_generators_.size(); i++) { + if (scc_analyzer_.GetSCC(message_generators_[i]->descriptor_) != scc) { + continue; + } + printer->Print("$classname$::InitAsDefaultInstance();\n", "classname", + QualifiedClassName(message_generators_[i]->descriptor_)); } + printer->Outdent(); + printer->Print("}\n\n"); + printer->Print( + "void InitDefaults$scc_name$() {\n" + " static GOOGLE_PROTOBUF_DECLARE_ONCE(once);\n" + " ::google::protobuf::GoogleOnceInit(&once, " + "&InitDefaults$scc_name$Impl);\n" + "}\n\n", + "scc_name", scc_name); } -void FileGenerator::GenerateNamespaceClosers(io::Printer* printer) { - if (package_parts_.size() > 0) printer->Print("\n"); +void FileGenerator::GenerateInitializationCode(io::Printer* printer) { + // Messages depend on the existence of a default instance, which has to + // initialized properly. The default instances are allocated in the data + // segment, but we can't quite allocate the type directly. The destructors + // cannot run at program exit as this could lead to segfaults in a threaded + // environment. Hence these instances must be inplace constructed at first + // use. + + if (options_.table_driven_parsing) { + // TODO(ckennelly): Gate this with the same options flag to enable + // table-driven parsing. + printer->Print( + "PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::ParseTableField\n" + " const TableStruct::entries[] " + "GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {\n"); + printer->Indent(); - for (int i = package_parts_.size() - 1; i >= 0; i--) { - printer->Print("} // namespace $part$\n", - "part", package_parts_[i]); + std::vector<size_t> entries; + size_t count = 0; + for (int i = 0; i < message_generators_.size(); i++) { + size_t value = message_generators_[i]->GenerateParseOffsets(printer); + entries.push_back(value); + count += value; + } + + // We need these arrays to exist, and MSVC does not like empty arrays. + if (count == 0) { + printer->Print("{0, 0, 0, ::google::protobuf::internal::kInvalidMask, 0, 0},\n"); + } + + printer->Outdent(); + printer->Print( + "};\n" + "\n" + "PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::AuxillaryParseTableField\n" + " const TableStruct::aux[] " + "GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {\n"); + printer->Indent(); + + std::vector<size_t> aux_entries; + count = 0; + for (int i = 0; i < message_generators_.size(); i++) { + size_t value = message_generators_[i]->GenerateParseAuxTable(printer); + aux_entries.push_back(value); + count += value; + } + + if (count == 0) { + printer->Print("::google::protobuf::internal::AuxillaryParseTableField(),\n"); + } + + printer->Outdent(); + printer->Print( + "};\n" + "PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::ParseTable const\n" + " TableStruct::schema[] " + "GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {\n"); + printer->Indent(); + + size_t offset = 0; + size_t aux_offset = 0; + for (int i = 0; i < message_generators_.size(); i++) { + message_generators_[i]->GenerateParseTable(printer, offset, aux_offset); + offset += entries[i]; + aux_offset += aux_entries[i]; + } + + if (message_generators_.empty()) { + printer->Print("{ NULL, NULL, 0, -1, -1, false },\n"); + } + + printer->Outdent(); + printer->Print( + "};\n" + "\n"); + } + + if (!message_generators_.empty() && options_.table_driven_serialization) { + printer->Print( + "const ::google::protobuf::internal::FieldMetadata TableStruct::field_metadata[] " + "= {\n"); + printer->Indent(); + std::vector<int> field_metadata_offsets; + int idx = 0; + for (int i = 0; i < message_generators_.size(); i++) { + field_metadata_offsets.push_back(idx); + idx += message_generators_[i]->GenerateFieldMetadata(printer); + } + field_metadata_offsets.push_back(idx); + printer->Outdent(); + printer->Print( + "};\n" + "const ::google::protobuf::internal::SerializationTable " + "TableStruct::serialization_table[] = {\n"); + printer->Indent(); + // We rely on the order we layout the tables to match the order we + // calculate them with FlattenMessagesInFile, so we check here that + // these match exactly. + std::vector<const Descriptor*> calculated_order = + FlattenMessagesInFile(file_); + GOOGLE_CHECK_EQ(calculated_order.size(), message_generators_.size()); + for (int i = 0; i < message_generators_.size(); i++) { + GOOGLE_CHECK_EQ(calculated_order[i], message_generators_[i]->descriptor_); + printer->Print( + "{$num_fields$, TableStruct::field_metadata + $index$},\n", + "classname", message_generators_[i]->classname_, "num_fields", + SimpleItoa(field_metadata_offsets[i + 1] - field_metadata_offsets[i]), + "index", SimpleItoa(field_metadata_offsets[i])); + } + printer->Outdent(); + printer->Print( + "};\n" + "\n"); + } + + // ----------------------------------------------------------------- + // All functionality that need private access. + + // Now generate the InitDefaults for each SCC. + for (int i = 0; i < message_generators_.size(); i++) { + if (IsSCCRepresentative(message_generators_[i]->descriptor_)) { + GenerateInitForSCC(GetSCC(message_generators_[i]->descriptor_), printer); + } } } void FileGenerator::GenerateForwardDeclarations(io::Printer* printer) { ForwardDeclarations decls; - for (int i = 0; i < file_->dependency_count(); i++) { - FileGenerator dependency(file_->dependency(i), options_); - dependency.FillForwardDeclarations(&decls); - } FillForwardDeclarations(&decls); - decls.Print(printer, options_); + decls.PrintForwardDeclarations(printer, options_); } void FileGenerator::FillForwardDeclarations(ForwardDeclarations* decls) { - for (int i = 0; i < file_->public_dependency_count(); i++) { - FileGenerator dependency(file_->public_dependency(i), options_); - dependency.FillForwardDeclarations(decls); - } for (int i = 0; i < package_parts_.size(); i++) { decls = decls->AddOrGetNamespace(package_parts_[i]); } @@ -959,8 +1145,8 @@ void FileGenerator::GenerateTopHeaderGuard(io::Printer* printer, "// Generated by the protocol buffer compiler. DO NOT EDIT!\n" "// source: $filename$\n" "\n" - "#ifndef PROTOBUF_$filename_identifier$__INCLUDED\n" - "#define PROTOBUF_$filename_identifier$__INCLUDED\n" + "#ifndef PROTOBUF_$filename_identifier$_INCLUDED\n" + "#define PROTOBUF_$filename_identifier$_INCLUDED\n" "\n" "#include <string>\n", "filename", file_->name(), "filename_identifier", filename_identifier); @@ -970,11 +1156,14 @@ void FileGenerator::GenerateTopHeaderGuard(io::Printer* printer, void FileGenerator::GenerateBottomHeaderGuard( io::Printer* printer, const string& filename_identifier) { printer->Print( - "#endif // PROTOBUF_$filename_identifier$__INCLUDED\n", + "#endif // PROTOBUF_$filename_identifier$_INCLUDED\n", "filename_identifier", filename_identifier); } void FileGenerator::GenerateLibraryIncludes(io::Printer* printer) { + if (UsingImplicitWeakFields(file_, options_)) { + printer->Print("#include <google/protobuf/implicit_weak_message.h>\n"); + } printer->Print( "#include <google/protobuf/stubs/common.h>\n" @@ -1033,11 +1222,11 @@ void FileGenerator::GenerateLibraryIncludes(io::Printer* printer) { "#include <google/protobuf/map.h>" " // IWYU pragma: export\n"); if (HasDescriptorMethods(file_, options_)) { - printer->Print( - "#include <google/protobuf/map_field_inl.h>\n"); + printer->Print("#include <google/protobuf/map_entry.h>\n"); + printer->Print("#include <google/protobuf/map_field_inl.h>\n"); } else { - printer->Print( - "#include <google/protobuf/map_field_lite.h>\n"); + printer->Print("#include <google/protobuf/map_entry_lite.h>\n"); + printer->Print("#include <google/protobuf/map_field_lite.h>\n"); } } @@ -1104,29 +1293,56 @@ void FileGenerator::GenerateDependencyIncludes(io::Printer* printer) { void FileGenerator::GenerateGlobalStateFunctionDeclarations( io::Printer* printer) { - // Forward-declare the AddDescriptors, AssignDescriptors, and ShutdownFile - // functions, so that we can declare them to be friends of each class. +// Forward-declare the AddDescriptors, InitDefaults because these are called +// by .pb.cc files depending on this file. printer->Print( "\n" "namespace $file_namespace$ {\n" - "// Internal implementation detail -- do not call these.\n" + "// Internal implementation detail -- do not use these members.\n" "struct $dllexport_decl$TableStruct {\n" + // These tables describe how to serialize and parse messages. Used + // for table driven code. " static const ::google::protobuf::internal::ParseTableField entries[];\n" " static const ::google::protobuf::internal::AuxillaryParseTableField aux[];\n" - " static const ::google::protobuf::internal::ParseTable schema[];\n" + " static const ::google::protobuf::internal::ParseTable schema[$num$];\n" + " static const ::google::protobuf::internal::FieldMetadata field_metadata[];\n" + " static const ::google::protobuf::internal::SerializationTable " + "serialization_table[];\n" " static const ::google::protobuf::uint32 offsets[];\n" - // The following function(s) need to be able to access private members of - // the messages defined in the file. So we make them static members. - // This is the internal implementation of InitDefaults. It should only - // be called by InitDefaults which makes sure it will be called only once. - " static void InitDefaultsImpl();\n" - " static void Shutdown();\n" - "};\n" - "void $dllexport_decl$AddDescriptors();\n" - "void $dllexport_decl$InitDefaults();\n" - "} // namespace $file_namespace$\n", - "file_namespace", FileLevelNamespace(file_->name()), "dllexport_decl", + "};\n", + "file_namespace", FileLevelNamespace(file_), "dllexport_decl", + options_.dllexport_decl.empty() ? "" : options_.dllexport_decl + " ", + "num", SimpleItoa(std::max(size_t(1), message_generators_.size()))); + if (HasDescriptorMethods(file_, options_)) { + printer->Print( + "void $dllexport_decl$AddDescriptors();\n", "dllexport_decl", + options_.dllexport_decl.empty() ? "" : options_.dllexport_decl + " "); + } + for (int i = 0; i < message_generators_.size(); i++) { + if (!IsSCCRepresentative(message_generators_[i]->descriptor_)) continue; + string scc_name = ClassName(message_generators_[i]->descriptor_); + // TODO(gerbens) Remove the Impl from header. This is solely because + // it currently still needs to be a friend of the protos. + printer->Print( + "void $dllexport_decl$InitDefaults$scc_name$Impl();\n" + "void $dllexport_decl$InitDefaults$scc_name$();\n", + "scc_name", scc_name, "dllexport_decl", + options_.dllexport_decl.empty() ? "" : options_.dllexport_decl + " "); + } + // TODO(gerbens) This is for proto1 interoperability. Remove when proto1 + // is gone. + printer->Print( + "inline void $dllexport_decl$InitDefaults() {\n", "dllexport_decl", options_.dllexport_decl.empty() ? "" : options_.dllexport_decl + " "); + for (int i = 0; i < message_generators_.size(); i++) { + if (!IsSCCRepresentative(message_generators_[i]->descriptor_)) continue; + string scc_name = ClassName(message_generators_[i]->descriptor_); + printer->Print(" InitDefaults$scc_name$();\n", "scc_name", scc_name); + } + printer->Print("}\n"); + printer->Print( + "} // namespace $file_namespace$\n", + "file_namespace", FileLevelNamespace(file_)); } void FileGenerator::GenerateMessageDefinitions(io::Printer* printer) { @@ -1175,51 +1391,25 @@ void FileGenerator::GenerateExtensionIdentifiers(io::Printer* printer) { } void FileGenerator::GenerateInlineFunctionDefinitions(io::Printer* printer) { - // An aside about inline functions in .proto.h mode: - // - // The PROTOBUF_INLINE_NOT_IN_HEADERS symbol controls conditionally - // moving much of the inline functions to the .pb.cc file, which can be a - // significant performance benefit for compilation time, at the expense - // of non-inline function calls. - // - // However, in .proto.h mode, the definition of the internal dependent - // base class must remain in the header, and can never be out-lined. The - // dependent base class also needs access to has-bit manipuation - // functions, so the has-bit functions must be unconditionally inlined in - // proto_h mode. - // - // This gives us three flavors of functions: - // - // 1. Functions on the message not used by the internal dependent base - // class: in .proto.h mode, only some functions are defined on the - // message class; others are defined on the dependent base class. - // These are guarded and can be out-lined. These are generated by - // GenerateInlineMethods, and include has_* bit functions in - // non-proto_h mode. - // - // 2. Functions on the internal dependent base class: these functions - // are dependent on a template parameter, so they always need to - // remain in the header. - // - // 3. Functions on the message that are used by the dependent base: the - // dependent base class down casts itself to the message - // implementation class to access these functions (the has_* bit - // manipulation functions). Unlike #1, these functions must - // unconditionally remain in the header. These are emitted by - // GenerateDependentInlineMethods, even though they are not actually - // dependent. - - printer->Print("#if !PROTOBUF_INLINE_NOT_IN_HEADERS\n"); + // TODO(gerbens) remove pragmas when gcc is no longer used. Current version + // of gcc fires a bogus error when compiled with strict-aliasing. + printer->Print( + "#ifdef __GNUC__\n" + " #pragma GCC diagnostic push\n" + " #pragma GCC diagnostic ignored \"-Wstrict-aliasing\"\n" + "#endif // __GNUC__\n"); // Generate class inline methods. for (int i = 0; i < message_generators_.size(); i++) { if (i > 0) { printer->Print(kThinSeparator); printer->Print("\n"); } - message_generators_[i]->GenerateInlineMethods(printer, - /* is_inline = */ true); + message_generators_[i]->GenerateInlineMethods(printer); } - printer->Print("#endif // !PROTOBUF_INLINE_NOT_IN_HEADERS\n"); + printer->Print( + "#ifdef __GNUC__\n" + " #pragma GCC diagnostic pop\n" + "#endif // __GNUC__\n"); for (int i = 0; i < message_generators_.size(); i++) { if (i > 0) { @@ -1235,13 +1425,8 @@ void FileGenerator::GenerateProto2NamespaceEnumSpecializations( io::Printer* printer) { // Emit GetEnumDescriptor specializations into google::protobuf namespace: if (HasEnumDefinitions(file_)) { - // The SWIG conditional is to avoid a null-pointer dereference - // (bug 1984964) in swig-1.3.21 resulting from the following syntax: - // namespace X { void Y<Z::W>(); } - // which appears in GetEnumDescriptor() specializations. printer->Print( "\n" - "#ifndef SWIG\n" "namespace google {\nnamespace protobuf {\n" "\n"); for (int i = 0; i < enum_generators_.size(); i++) { @@ -1249,8 +1434,7 @@ void FileGenerator::GenerateProto2NamespaceEnumSpecializations( } printer->Print( "\n" - "} // namespace protobuf\n} // namespace google\n" - "#endif // SWIG\n"); + "} // namespace protobuf\n} // namespace google\n"); } } diff --git a/src/google/protobuf/compiler/cpp/cpp_file.h b/src/google/protobuf/compiler/cpp/cpp_file.h index e10fe2f3..7e61cbad 100644 --- a/src/google/protobuf/compiler/cpp/cpp_file.h +++ b/src/google/protobuf/compiler/cpp/cpp_file.h @@ -35,10 +35,12 @@ #ifndef GOOGLE_PROTOBUF_COMPILER_CPP_FILE_H__ #define GOOGLE_PROTOBUF_COMPILER_CPP_FILE_H__ +#include <algorithm> #include <memory> #ifndef _SHARED_PTR_H #include <google/protobuf/stubs/shared_ptr.h> #endif +#include <set> #include <string> #include <vector> #include <google/protobuf/stubs/common.h> @@ -82,16 +84,21 @@ class FileGenerator { const string& info_path); void GenerateSource(io::Printer* printer); + int NumMessages() const { return message_generators_.size(); } + // Similar to GenerateSource but generates only one message + void GenerateSourceForMessage(int idx, io::Printer* printer); + void GenerateGlobalSource(io::Printer* printer); + private: // Internal type used by GenerateForwardDeclarations (defined in file.cc). class ForwardDeclarations; - // Generate the BuildDescriptors() procedure, which builds all descriptors - // for types defined in the file. - void GenerateBuildDescriptors(io::Printer* printer); + void GenerateSourceIncludes(io::Printer* printer); + void GenerateSourceDefaultInstance(int idx, io::Printer* printer); - void GenerateNamespaceOpeners(io::Printer* printer); - void GenerateNamespaceClosers(io::Printer* printer); + void GenerateInitForSCC(const SCC* scc, io::Printer* printer); + void GenerateInitializationCode(io::Printer* printer); + void GenerateReflectionInitializationCode(io::Printer* printer); // For other imports, generates their forward-declarations. void GenerateForwardDeclarations(io::Printer* printer); @@ -143,11 +150,23 @@ class FileGenerator { // a breaking change so we prefer the #undef approach. void GenerateMacroUndefs(io::Printer* printer); + bool IsSCCRepresentative(const Descriptor* d) { + return GetSCCRepresentative(d) == d; + } + const Descriptor* GetSCCRepresentative(const Descriptor* d) { + return GetSCC(d)->GetRepresentative(); + } + const SCC* GetSCC(const Descriptor* d) { + return scc_analyzer_.GetSCC(d); + } + + const FileDescriptor* file_; const Options options_; SCCAnalyzer scc_analyzer_; + // Contains the post-order walk of all the messages (and child messages) in // this file. If you need a pre-order walk just reverse iterate. std::vector<MessageGenerator*> message_generators_; @@ -155,10 +174,8 @@ class FileGenerator { std::vector<ServiceGenerator*> service_generators_; std::vector<ExtensionGenerator*> extension_generators_; - // These members are just for owning (and thus proper deleting). Some of the - // message_ and enum_generators above are owned by child messages. - google::protobuf::scoped_array<google::protobuf::scoped_ptr<MessageGenerator> > - message_generators_owner_; + // These members are just for owning (and thus proper deleting). + // Nested (enum/extension)_generators are owned by child messages. google::protobuf::scoped_array<google::protobuf::scoped_ptr<EnumGenerator> > enum_generators_owner_; google::protobuf::scoped_array<google::protobuf::scoped_ptr<ServiceGenerator> > service_generators_owner_; diff --git a/src/google/protobuf/compiler/cpp/cpp_generator.cc b/src/google/protobuf/compiler/cpp/cpp_generator.cc index cee31224..5d8ea300 100644 --- a/src/google/protobuf/compiler/cpp/cpp_generator.cc +++ b/src/google/protobuf/compiler/cpp/cpp_generator.cc @@ -41,6 +41,7 @@ #endif #include <utility> +#include <google/protobuf/stubs/strutil.h> #include <google/protobuf/compiler/cpp/cpp_file.h> #include <google/protobuf/compiler/cpp/cpp_helpers.h> #include <google/protobuf/io/printer.h> @@ -84,7 +85,6 @@ bool CppGenerator::Generate(const FileDescriptor* file, // __declspec(dllimport) depending on what is being compiled. // Options file_options; - for (int i = 0; i < options.size(); i++) { if (options[i].first == "dllexport_decl") { file_options.dllexport_decl = options[i].second; @@ -98,14 +98,30 @@ bool CppGenerator::Generate(const FileDescriptor* file, file_options.annotation_guard_name = options[i].second; } else if (options[i].first == "lite") { file_options.enforce_lite = true; + } else if (options[i].first == "lite_implicit_weak_fields") { + file_options.lite_implicit_weak_fields = true; + if (!options[i].second.empty()) { + file_options.num_cc_files = strto32(options[i].second.c_str(), + NULL, 10); + } } else if (options[i].first == "table_driven_parsing") { file_options.table_driven_parsing = true; + } else if (options[i].first == "table_driven_serialization") { + file_options.table_driven_serialization = true; } else { *error = "Unknown generator option: " + options[i].first; return false; } } + // The safe_boundary_check option controls behavior for Google-internal + // protobuf APIs. + if (file_options.safe_boundary_check) { + *error = + "The safe_boundary_check option is not supported outside of Google."; + return false; + } + // ----------------------------------------------------------------- @@ -133,14 +149,13 @@ bool CppGenerator::Generate(const FileDescriptor* file, } } - basename.append(".pb"); { google::protobuf::scoped_ptr<io::ZeroCopyOutputStream> output( - generator_context->Open(basename + ".h")); + generator_context->Open(basename + ".pb.h")); GeneratedCodeInfo annotations; io::AnnotationProtoCollector<GeneratedCodeInfo> annotation_collector( &annotations); - string info_path = basename + ".h.meta"; + string info_path = basename + ".pb.h.meta"; io::Printer printer(output.get(), '$', file_options.annotate_headers ? &annotation_collector : NULL); @@ -153,10 +168,39 @@ bool CppGenerator::Generate(const FileDescriptor* file, } } - // Generate cc file. - { + // Generate cc file(s). + if (UsingImplicitWeakFields(file, file_options)) { + { + // This is the global .cc file, containing enum/services/tables/reflection + google::protobuf::scoped_ptr<io::ZeroCopyOutputStream> output( + generator_context->Open(basename + ".pb.cc")); + io::Printer printer(output.get(), '$'); + file_generator.GenerateGlobalSource(&printer); + } + + int num_cc_files = file_generator.NumMessages(); + + // If we're using implicit weak fields then we allow the user to optionally + // specify how many files to generate, not counting the global pb.cc file. + // If we have more files than messages, then some files will be generated as + // empty placeholders. + if (file_options.num_cc_files > 0) { + GOOGLE_CHECK_LE(file_generator.NumMessages(), file_options.num_cc_files) + << "There must be at least as many numbered .cc files as messages."; + num_cc_files = file_options.num_cc_files; + } + for (int i = 0; i < num_cc_files; i++) { + // TODO(gerbens) Agree on naming scheme. + google::protobuf::scoped_ptr<io::ZeroCopyOutputStream> output( + generator_context->Open(basename + "." + SimpleItoa(i) + ".cc")); + io::Printer printer(output.get(), '$'); + if (i < file_generator.NumMessages()) { + file_generator.GenerateSourceForMessage(i, &printer); + } + } + } else { google::protobuf::scoped_ptr<io::ZeroCopyOutputStream> output( - generator_context->Open(basename + ".cc")); + generator_context->Open(basename + ".pb.cc")); io::Printer printer(output.get(), '$'); file_generator.GenerateSource(&printer); } diff --git a/src/google/protobuf/compiler/cpp/cpp_helpers.cc b/src/google/protobuf/compiler/cpp/cpp_helpers.cc index 9cddba5c..172acedd 100644 --- a/src/google/protobuf/compiler/cpp/cpp_helpers.cc +++ b/src/google/protobuf/compiler/cpp/cpp_helpers.cc @@ -32,19 +32,22 @@ // Based on original Protocol Buffers design by // Sanjay Ghemawat, Jeff Dean, and others. +#include <google/protobuf/stubs/hash.h> #include <limits> #include <map> +#include <queue> #include <vector> -#include <google/protobuf/stubs/hash.h> -#include <google/protobuf/compiler/cpp/cpp_helpers.h> -#include <google/protobuf/io/printer.h> #include <google/protobuf/stubs/logging.h> #include <google/protobuf/stubs/common.h> +#include <google/protobuf/compiler/cpp/cpp_helpers.h> +#include <google/protobuf/io/printer.h> #include <google/protobuf/stubs/strutil.h> #include <google/protobuf/stubs/substitute.h> + + namespace google { namespace protobuf { namespace compiler { @@ -103,6 +106,30 @@ bool HasExtension(const Descriptor* descriptor) { return false; } +// Encode [0..63] as 'A'-'Z', 'a'-'z', '0'-'9', '_' +char Base63Char(int value) { + GOOGLE_CHECK_GE(value, 0); + if (value < 26) return 'A' + value; + value -= 26; + if (value < 26) return 'a' + value; + value -= 26; + if (value < 10) return '0' + value; + GOOGLE_CHECK_EQ(value, 10); + return '_'; +} + +// Given a c identifier has 63 legal characters we can't implement base64 +// encoding. So we return the k least significant "digits" in base 63. +template <typename I> +string Base63(I n, int k) { + string res; + while (k-- > 0) { + res += Base63Char(static_cast<int>(n % 63)); + n /= 63; + } + return res; +} + } // namespace string UnderscoresToCamelCase(const string& input, bool cap_next_letter) { @@ -135,38 +162,62 @@ const char kThickSeparator[] = const char kThinSeparator[] = "// -------------------------------------------------------------------\n"; -string ClassName(const Descriptor* descriptor, bool qualified) { - - // Find "outer", the descriptor of the top-level message in which - // "descriptor" is embedded. - const Descriptor* outer = descriptor; - while (outer->containing_type() != NULL) outer = outer->containing_type(); - - const string& outer_name = outer->full_name(); - string inner_name = descriptor->full_name().substr(outer_name.size()); - - if (qualified) { - return "::" + DotsToColons(outer_name) + DotsToUnderscores(inner_name); - } else { - return outer->name() + DotsToUnderscores(inner_name); +bool CanInitializeByZeroing(const FieldDescriptor* field) { + if (field->is_repeated() || field->is_extension()) return false; + switch (field->cpp_type()) { + case FieldDescriptor::CPPTYPE_ENUM: + return field->default_value_enum()->number() == 0; + case FieldDescriptor::CPPTYPE_INT32: + return field->default_value_int32() == 0; + case FieldDescriptor::CPPTYPE_INT64: + return field->default_value_int64() == 0; + case FieldDescriptor::CPPTYPE_UINT32: + return field->default_value_uint32() == 0; + case FieldDescriptor::CPPTYPE_UINT64: + return field->default_value_uint64() == 0; + case FieldDescriptor::CPPTYPE_FLOAT: + return field->default_value_float() == 0; + case FieldDescriptor::CPPTYPE_DOUBLE: + return field->default_value_double() == 0; + case FieldDescriptor::CPPTYPE_BOOL: + return field->default_value_bool() == false; + default: + return false; } } -string ClassName(const EnumDescriptor* enum_descriptor, bool qualified) { +string ClassName(const Descriptor* descriptor) { + const Descriptor* parent = descriptor->containing_type(); + string res; + if (parent) res += ClassName(parent) + "_"; + res += descriptor->name(); + if (IsMapEntryMessage(descriptor)) res += "_DoNotUse"; + return res; +} + +string ClassName(const EnumDescriptor* enum_descriptor) { if (enum_descriptor->containing_type() == NULL) { - if (qualified) { - return "::" + DotsToColons(enum_descriptor->full_name()); - } else { - return enum_descriptor->name(); - } + return enum_descriptor->name(); } else { - string result = ClassName(enum_descriptor->containing_type(), qualified); - result += '_'; - result += enum_descriptor->name(); - return result; + return ClassName(enum_descriptor->containing_type()) + "_" + + enum_descriptor->name(); } } +string Namespace(const string& package) { + if (package.empty()) return ""; + return "::" + DotsToColons(package); +} + +string DefaultInstanceName(const Descriptor* descriptor) { + string prefix = descriptor->file()->package().empty() ? "" : "::"; + return prefix + DotsToColons(descriptor->file()->package()) + "::_" + + ClassName(descriptor, false) + "_default_instance_"; +} + +string ReferenceFunctionName(const Descriptor* descriptor) { + return QualifiedClassName(descriptor) + "_ReferenceStrong"; +} string DependentBaseClassTemplateName(const Descriptor* descriptor) { return ClassName(descriptor, false) + "_InternalBase"; @@ -203,6 +254,30 @@ string EnumValueName(const EnumValueDescriptor* enum_value) { return result; } +int EstimateAlignmentSize(const FieldDescriptor* field) { + if (field == NULL) return 0; + if (field->is_repeated()) return 8; + switch (field->cpp_type()) { + case FieldDescriptor::CPPTYPE_BOOL: + return 1; + + case FieldDescriptor::CPPTYPE_INT32: + case FieldDescriptor::CPPTYPE_UINT32: + case FieldDescriptor::CPPTYPE_ENUM: + case FieldDescriptor::CPPTYPE_FLOAT: + return 4; + + case FieldDescriptor::CPPTYPE_INT64: + case FieldDescriptor::CPPTYPE_UINT64: + case FieldDescriptor::CPPTYPE_DOUBLE: + case FieldDescriptor::CPPTYPE_STRING: + case FieldDescriptor::CPPTYPE_MESSAGE: + return 8; + } + GOOGLE_LOG(FATAL) << "Can't get here."; + return -1; // Make compiler happy. +} + string FieldConstantName(const FieldDescriptor *field) { string field_name = UnderscoresToCamelCase(field->name(), true); string result = "k" + field_name + "FieldNumber"; @@ -477,19 +552,6 @@ string SafeFunctionName(const Descriptor* descriptor, return function_name; } -bool StaticInitializersForced(const FileDescriptor* file, - const Options& options) { - if (HasDescriptorMethods(file, options) || file->extension_count() > 0) { - return true; - } - for (int i = 0; i < file->message_type_count(); ++i) { - if (HasExtension(file->message_type(i))) { - return true; - } - } - return false; -} - static bool HasMapFields(const Descriptor* descriptor) { for (int i = 0; i < descriptor->field_count(); ++i) { @@ -654,6 +716,24 @@ void GenerateUtf8CheckCodeForCord(const FieldDescriptor* field, "VerifyUtf8Cord", "VerifyUTF8CordNamedField", printer); } +namespace { + +void Flatten(const Descriptor* descriptor, + std::vector<const Descriptor*>* flatten) { + for (int i = 0; i < descriptor->nested_type_count(); i++) + Flatten(descriptor->nested_type(i), flatten); + flatten->push_back(descriptor); +} + +} // namespace + +void FlattenMessagesInFile(const FileDescriptor* file, + std::vector<const Descriptor*>* result) { + for (int i = 0; i < file->message_type_count(); i++) { + Flatten(file->message_type(i), result); + } +} + bool HasWeakFields(const Descriptor* descriptor) { return false; } @@ -662,6 +742,26 @@ bool HasWeakFields(const FileDescriptor* file) { return false; } +bool UsingImplicitWeakFields(const FileDescriptor* file, + const Options& options) { + return options.lite_implicit_weak_fields && + GetOptimizeFor(file, options) == FileOptions::LITE_RUNTIME; +} + + +bool IsImplicitWeakField(const FieldDescriptor* field, const Options& options) { + return UsingImplicitWeakFields(field->file(), options) && + field->type() == FieldDescriptor::TYPE_MESSAGE && + !field->is_required() && !field->is_map() && + field->containing_oneof() == NULL; +} + +struct CompareDescriptors { + bool operator()(const Descriptor* a, const Descriptor* b) { + return a->full_name() < b->full_name(); + } +}; + SCCAnalyzer::NodeData SCCAnalyzer::DFS(const Descriptor* descriptor) { // Must not have visited already. GOOGLE_DCHECK_EQ(cache_.count(descriptor), 0); @@ -701,10 +801,33 @@ SCCAnalyzer::NodeData SCCAnalyzer::DFS(const Descriptor* descriptor) { if (scc_desc == descriptor) break; } + + // The order of descriptors is random and depends how this SCC was + // discovered. In-order to ensure maximum stability we sort it by name. + std::sort(scc->descriptors.begin(), scc->descriptors.end(), + CompareDescriptors()); + AddChildren(scc); } return result; } +void SCCAnalyzer::AddChildren(SCC* scc) { + std::set<const SCC*> seen; + for (int i = 0; i < scc->descriptors.size(); i++) { + const Descriptor* descriptor = scc->descriptors[i]; + for (int j = 0; j < descriptor->field_count(); j++) { + const Descriptor* child_msg = descriptor->field(j)->message_type(); + if (child_msg) { + const SCC* child = GetSCC(child_msg); + if (child == scc) continue; + if (seen.insert(child).second) { + scc->children.push_back(child); + } + } + } + } +} + MessageAnalysis SCCAnalyzer::GetSCCAnalysis(const SCC* scc) { if (analysis_cache_.count(scc)) return analysis_cache_[scc]; MessageAnalysis result = MessageAnalysis(); @@ -757,6 +880,46 @@ MessageAnalysis SCCAnalyzer::GetSCCAnalysis(const SCC* scc) { return analysis_cache_[scc] = result; } +void ListAllFields(const Descriptor* d, + std::vector<const FieldDescriptor*>* fields) { + // Collect sub messages + for (int i = 0; i < d->nested_type_count(); i++) { + ListAllFields(d->nested_type(i), fields); + } + // Collect message level extensions. + for (int i = 0; i < d->extension_count(); i++) { + fields->push_back(d->extension(i)); + } + // Add types of fields necessary + for (int i = 0; i < d->field_count(); i++) { + fields->push_back(d->field(i)); + } +} + +void ListAllFields(const FileDescriptor* d, + std::vector<const FieldDescriptor*>* fields) { + // Collect file level message. + for (int i = 0; i < d->message_type_count(); i++) { + ListAllFields(d->message_type(i), fields); + } + // Collect message level extensions. + for (int i = 0; i < d->extension_count(); i++) { + fields->push_back(d->extension(i)); + } +} + +void ListAllTypesForServices(const FileDescriptor* fd, + std::vector<const Descriptor*>* types) { + for (int i = 0; i < fd->service_count(); i++) { + const ServiceDescriptor* sd = fd->service(i); + for (int j = 0; j < sd->method_count(); j++) { + const MethodDescriptor* method = sd->method(j); + types->push_back(method->input_type()); + types->push_back(method->output_type()); + } + } +} + } // namespace cpp } // namespace compiler } // namespace protobuf diff --git a/src/google/protobuf/compiler/cpp/cpp_helpers.h b/src/google/protobuf/compiler/cpp/cpp_helpers.h index a744a865..4026d0ed 100644 --- a/src/google/protobuf/compiler/cpp/cpp_helpers.h +++ b/src/google/protobuf/compiler/cpp/cpp_helpers.h @@ -38,16 +38,13 @@ #include <map> #include <string> #include <google/protobuf/compiler/cpp/cpp_options.h> +#include <google/protobuf/io/printer.h> #include <google/protobuf/descriptor.pb.h> #include <google/protobuf/descriptor.h> +#include <google/protobuf/stubs/strutil.h> namespace google { namespace protobuf { - -namespace io { -class Printer; -} - namespace compiler { namespace cpp { @@ -56,6 +53,31 @@ namespace cpp { extern const char kThickSeparator[]; extern const char kThinSeparator[]; +// Name space of the proto file. This namespace is such that the string +// "<namespace>::some_name" is the correct fully qualified namespace. +// This means if the package is empty the namespace is "", and otherwise +// the namespace is "::foo::bar::...::baz" without trailing semi-colons. +string Namespace(const string& package); +inline string Namespace(const FileDescriptor* d) { + return Namespace(d->package()); +} +template <typename Desc> +string Namespace(const Desc* d) { + return Namespace(d->file()); +} + +// Returns true if it's safe to reset "field" to zero. +bool CanInitializeByZeroing(const FieldDescriptor* field); + +string ClassName(const Descriptor* descriptor); +string ClassName(const EnumDescriptor* enum_descriptor); +template <typename Desc> +string QualifiedClassName(const Desc* d) { + return Namespace(d) + "::" + ClassName(d); +} + +// DEPRECATED just use ClassName or QualifiedClassName, a boolean is very +// unreadable at the callsite. // Returns the non-nested type name for the given type. If "qualified" is // true, prefix the type with the full namespace. For example, if you had: // package foo.bar; @@ -64,8 +86,21 @@ extern const char kThinSeparator[]; // ::foo::bar::Baz_Qux // While the non-qualified version would be: // Baz_Qux -string ClassName(const Descriptor* descriptor, bool qualified); -string ClassName(const EnumDescriptor* enum_descriptor, bool qualified); +inline string ClassName(const Descriptor* descriptor, bool qualified) { + return qualified ? QualifiedClassName(descriptor) : ClassName(descriptor); +} + +inline string ClassName(const EnumDescriptor* descriptor, bool qualified) { + return qualified ? QualifiedClassName(descriptor) : ClassName(descriptor); +} + +// Fully qualified name of the default_instance of this message. +string DefaultInstanceName(const Descriptor* descriptor); + +// Returns the name of a no-op function that we can call to introduce a linker +// dependency on the given message type. This is used to implement implicit weak +// fields. +string ReferenceFunctionName(const Descriptor* descriptor); // Name of the CRTP class template (for use with proto_h). // This is a class name, like "ProtoName_InternalBase". @@ -89,6 +124,12 @@ string FieldName(const FieldDescriptor* field); // Get the sanitized name that should be used for the given enum in C++ code. string EnumValueName(const EnumValueDescriptor* enum_value); +// Returns an estimate of the compiler's alignment for the field. This +// can't guarantee to be correct because the generated code could be compiled on +// different systems with different alignment rules. The estimates below assume +// 64-bit pointers. +int EstimateAlignmentSize(const FieldDescriptor* field); + // Get the unqualified name that should be used for a field's field // number constant. string FieldConstantName(const FieldDescriptor *field); @@ -147,6 +188,12 @@ string FilenameIdentifier(const string& filename); // For each .proto file generates a unique namespace. In this namespace global // definitions are put to prevent collisions. string FileLevelNamespace(const string& filename); +inline string FileLevelNamespace(const FileDescriptor* file) { + return FileLevelNamespace(file->name()); +} +inline string FileLevelNamespace(const Descriptor* d) { + return FileLevelNamespace(d->file()); +} // Return the qualified C++ name for a file level symbol. string QualifiedFileLevelSymbol(const string& package, const string& name); @@ -159,8 +206,18 @@ string SafeFunctionName(const Descriptor* descriptor, const FieldDescriptor* field, const string& prefix); -// Returns true if unknown fields are preseved after parsing. -inline bool PreserveUnknownFields(const Descriptor* message) { +// Returns true if unknown fields are always preserved after parsing. +inline bool AlwaysPreserveUnknownFields(const FileDescriptor* file) { + return file->syntax() != FileDescriptor::SYNTAX_PROTO3; +} + +// Returns true if unknown fields are preserved after parsing. +inline bool AlwaysPreserveUnknownFields(const Descriptor* message) { + return AlwaysPreserveUnknownFields(message->file()); +} + +// Returns true if generated messages have public unknown fields accessors +inline bool PublicUnknownFieldsAccessors(const Descriptor* message) { return message->file()->syntax() != FileDescriptor::SYNTAX_PROTO3; } @@ -168,10 +225,8 @@ inline bool PreserveUnknownFields(const Descriptor* message) { ::google::protobuf::FileOptions_OptimizeMode GetOptimizeFor( const FileDescriptor* file, const Options& options); -// If PreserveUnknownFields() is true, determines whether unknown -// fields will be stored in an UnknownFieldSet or a string. -// If PreserveUnknownFields() is false, this method will not be -// used. +// Determines whether unknown fields will be stored in an UnknownFieldSet or +// a string. inline bool UseUnknownFieldSet(const FileDescriptor* file, const Options& options) { return GetOptimizeFor(file, options) != FileOptions::LITE_RUNTIME; @@ -214,10 +269,6 @@ inline bool HasFastArraySerialization(const FileDescriptor* file, return GetOptimizeFor(file, options) == FileOptions::SPEED; } -// Returns whether we have to generate code with static initializers. -bool StaticInitializersForced(const FileDescriptor* file, - const Options& options); - inline bool IsMapEntryMessage(const Descriptor* descriptor) { return descriptor->options().map_entry(); @@ -254,6 +305,15 @@ inline bool SupportsArenas(const FieldDescriptor* field) { return SupportsArenas(field->file()); } +inline bool IsCrossFileMessage(const FieldDescriptor* field) { + return field->type() == FieldDescriptor::TYPE_MESSAGE && + field->message_type()->file() != field->file(); +} + +inline string MessageCreateFunction(const Descriptor* d) { + return SupportsArenas(d) ? "CreateMessage" : "Create"; +} + bool IsAnyMessage(const FileDescriptor* descriptor); bool IsAnyMessage(const Descriptor* descriptor); @@ -277,9 +337,26 @@ inline ::google::protobuf::FileOptions_OptimizeMode GetOptimizeFor( : file->options().optimize_for(); } +// This orders the messages in a .pb.cc as it's outputted by file.cc +void FlattenMessagesInFile(const FileDescriptor* file, + std::vector<const Descriptor*>* result); +inline std::vector<const Descriptor*> FlattenMessagesInFile( + const FileDescriptor* file) { + std::vector<const Descriptor*> result; + FlattenMessagesInFile(file, &result); + return result; +} + bool HasWeakFields(const Descriptor* desc); bool HasWeakFields(const FileDescriptor* desc); +// Indicates whether we should use implicit weak fields for this file. +bool UsingImplicitWeakFields(const FileDescriptor* file, + const Options& options); + +// Indicates whether to treat this field as implicitly weak. +bool IsImplicitWeakField(const FieldDescriptor* field, const Options& options); + // Returns true if the "required" restriction check should be ignored for the // given field. inline static bool ShouldIgnoreRequiredFieldCheck(const FieldDescriptor* field, @@ -287,8 +364,46 @@ inline static bool ShouldIgnoreRequiredFieldCheck(const FieldDescriptor* field, return false; } +class LIBPROTOC_EXPORT NamespaceOpener { + public: + explicit NamespaceOpener(io::Printer* printer) : printer_(printer) {} + NamespaceOpener(const string& name, io::Printer* printer) + : printer_(printer) { + ChangeTo(name); + } + ~NamespaceOpener() { ChangeTo(""); } + + void ChangeTo(const string& name) { + std::vector<string> new_stack_ = + Split(name, "::", true); + int len = std::min(name_stack_.size(), new_stack_.size()); + int common_idx = 0; + while (common_idx < len) { + if (name_stack_[common_idx] != new_stack_[common_idx]) break; + common_idx++; + } + for (int i = name_stack_.size() - 1; i >= common_idx; i--) { + printer_->Print("} // namespace $ns$\n", "ns", name_stack_[i]); + } + name_stack_.swap(new_stack_); + for (int i = common_idx; i < name_stack_.size(); i++) { + printer_->Print("namespace $ns$ {\n", "ns", name_stack_[i]); + } + } + + private: + io::Printer* printer_; + std::vector<string> name_stack_; +}; + +// Description of each strongly connected component. Note that the order +// of both the descriptors in this SCC and the order of children is +// deterministic. struct SCC { std::vector<const Descriptor*> descriptors; + std::vector<const SCC*> children; + + const Descriptor* GetRepresentative() const { return descriptors[0]; } }; struct MessageAnalysis { @@ -342,8 +457,16 @@ class LIBPROTOC_EXPORT SCCAnalyzer { // Tarjan's Strongly Connected Components algo NodeData DFS(const Descriptor* descriptor); + + // Add the SCC's that are children of this SCC to its children. + void AddChildren(SCC* scc); }; +void ListAllFields(const FileDescriptor* d, + std::vector<const FieldDescriptor*>* fields); +void ListAllTypesForServices(const FileDescriptor* fd, + std::vector<const Descriptor*>* types); + } // namespace cpp } // namespace compiler } // namespace protobuf diff --git a/src/google/protobuf/compiler/cpp/cpp_map_field.cc b/src/google/protobuf/compiler/cpp/cpp_map_field.cc index 52a3b8b0..b22c0754 100644 --- a/src/google/protobuf/compiler/cpp/cpp_map_field.cc +++ b/src/google/protobuf/compiler/cpp/cpp_map_field.cc @@ -114,72 +114,37 @@ MapFieldGenerator::~MapFieldGenerator() {} void MapFieldGenerator:: GeneratePrivateMembers(io::Printer* printer) const { - if (HasDescriptorMethods(descriptor_->file(), options_)) { - printer->Print( - variables_, - "public:\n" - "class $map_classname$ : public " - "::google::protobuf::internal::MapEntry<$map_classname$, \n" - " $key_cpp$, $val_cpp$,\n" - " $key_wire_type$,\n" - " $val_wire_type$,\n" - " $default_enum_value$ > {\n" - "public:\n" - " typedef ::google::protobuf::internal::MapEntry<$map_classname$, \n" - " $key_cpp$, $val_cpp$,\n" - " $key_wire_type$,\n" - " $val_wire_type$,\n" - " $default_enum_value$ > SuperType;\n" - " $map_classname$();\n" - " $map_classname$(::google::protobuf::Arena* arena);\n" - " void MergeFrom(const ::google::protobuf::Message& other) PROTOBUF_FINAL;\n" - " void MergeFrom(const $map_classname$& other);\n" - " static const Message* internal_default_instance() { return " - "reinterpret_cast<const " - "Message*>(&_$map_classname$_default_instance_); }\n" - " ::google::protobuf::Metadata GetMetadata() const;\n" - "};\n"); - } else { - printer->Print(variables_, - "public:\n" - "typedef ::google::protobuf::internal::MapEntryLite<\n" - " $key_cpp$, $val_cpp$,\n" - " $key_wire_type$,\n" - " $val_wire_type$,\n" - " $default_enum_value$ >\n" - " $map_classname$;\n"); - } printer->Print(variables_, "::google::protobuf::internal::MapField$lite$<\n" " $map_classname$,\n" " $key_cpp$, $val_cpp$,\n" " $key_wire_type$,\n" " $val_wire_type$,\n" - " $default_enum_value$ > $name$_;\n" - "private:\n"); + " $default_enum_value$ > $name$_;\n"); } void MapFieldGenerator:: GenerateAccessorDeclarations(io::Printer* printer) const { - printer->Print(variables_, + printer->Print( + variables_, "$deprecated_attr$const ::google::protobuf::Map< $key_cpp$, $val_cpp$ >&\n" - " $name$() const;\n" - "$deprecated_attr$::google::protobuf::Map< $key_cpp$, $val_cpp$ >*\n" - " mutable_$name$();\n"); + " $name$() const;\n"); + printer->Annotate("name", descriptor_); + printer->Print(variables_, + "$deprecated_attr$::google::protobuf::Map< $key_cpp$, $val_cpp$ >*\n" + " ${$mutable_$name$$}$();\n"); + printer->Annotate("{", "}", descriptor_); } void MapFieldGenerator:: -GenerateInlineAccessorDefinitions(io::Printer* printer, - bool is_inline) const { - std::map<string, string> variables(variables_); - variables["inline"] = is_inline ? "inline" : ""; - printer->Print(variables, - "$inline$ const ::google::protobuf::Map< $key_cpp$, $val_cpp$ >&\n" +GenerateInlineAccessorDefinitions(io::Printer* printer) const { + printer->Print(variables_, + "inline const ::google::protobuf::Map< $key_cpp$, $val_cpp$ >&\n" "$classname$::$name$() const {\n" " // @@protoc_insertion_point(field_map:$full_name$)\n" " return $name$_.GetMap();\n" "}\n" - "$inline$ ::google::protobuf::Map< $key_cpp$, $val_cpp$ >*\n" + "inline ::google::protobuf::Map< $key_cpp$, $val_cpp$ >*\n" "$classname$::mutable_$name$() {\n" " // @@protoc_insertion_point(field_mutable_map:$full_name$)\n" " return $name$_.MutableMap();\n" @@ -188,9 +153,7 @@ GenerateInlineAccessorDefinitions(io::Printer* printer, void MapFieldGenerator:: GenerateClearingCode(io::Printer* printer) const { - std::map<string, string> variables(variables_); - variables["this_message"] = dependent_field_ ? DependentBaseDownCast() : ""; - printer->Print(variables, "$this_message$$name$_.Clear();\n"); + printer->Print(variables_, "$name$_.Clear();\n"); } void MapFieldGenerator:: @@ -256,7 +219,8 @@ GenerateMergeFromCodedStream(io::Printer* printer) const { } else { printer->Print(variables_, " unknown_fields_stream.WriteVarint32($tag$u);\n" - " unknown_fields_stream.WriteVarint32(data.size());\n" + " unknown_fields_stream.WriteVarint32(\n" + " static_cast< ::google::protobuf::uint32>(data.size()));\n" " unknown_fields_stream.WriteString(data);\n"); } @@ -267,12 +231,16 @@ GenerateMergeFromCodedStream(io::Printer* printer) const { if (key_field->type() == FieldDescriptor::TYPE_STRING) { GenerateUtf8CheckCodeForString( - key_field, options_, true, variables_, - StrCat(key, ".data(), ", key, ".length(),\n").data(), printer); + key_field, options_, true, variables_, + StrCat(key, ".data(), static_cast<int>(", key, ".length()),\n").data(), + printer); } if (value_field->type() == FieldDescriptor::TYPE_STRING) { - GenerateUtf8CheckCodeForString(value_field, options_, true, variables_, - StrCat(value, ".data(), ", value, ".length(),\n").data(), printer); + GenerateUtf8CheckCodeForString( + value_field, options_, true, variables_, + StrCat(value, ".data(), static_cast<int>(", value, ".length()),\n") + .data(), + printer); } // If entry is allocated by arena, its desctructor should be avoided. @@ -376,14 +344,14 @@ void MapFieldGenerator::GenerateSerializeWithCachedSizes( printer->Indent(); printer->Indent(); if (string_key) { - GenerateUtf8CheckCodeForString(key_field, options_, false, variables, - "p->first.data(), p->first.length(),\n", - printer); + GenerateUtf8CheckCodeForString( + key_field, options_, false, variables, + "p->first.data(), static_cast<int>(p->first.length()),\n", printer); } if (string_value) { - GenerateUtf8CheckCodeForString(value_field, options_, false, variables, - "p->second.data(), p->second.length(),\n", - printer); + GenerateUtf8CheckCodeForString( + value_field, options_, false, variables, + "p->second.data(), static_cast<int>(p->second.length()),\n", printer); } printer->Outdent(); printer->Outdent(); @@ -404,13 +372,14 @@ void MapFieldGenerator::GenerateSerializeWithCachedSizes( " for (::google::protobuf::Map< $key_cpp$, $val_cpp$ >::const_iterator\n" " it = this->$name$().begin();\n" " it != this->$name$().end(); ++it, ++n) {\n" - " items[n] = SortItem(&*it);\n" + " items[static_cast<ptrdiff_t>(n)] = SortItem(&*it);\n" " }\n" - " ::std::sort(&items[0], &items[n], Less());\n"); + " ::std::sort(&items[0], &items[static_cast<ptrdiff_t>(n)], Less());\n"); printer->Indent(); GenerateSerializationLoop(printer, variables, SupportsArenas(descriptor_), - utf8_check, "for (size_type i = 0; i < n; i++)", - string_key ? "items[i]" : "items[i].second", false); + utf8_check, "for (size_type i = 0; i < n; i++)", + string_key ? "items[static_cast<ptrdiff_t>(i)]" : + "items[static_cast<ptrdiff_t>(i)].second", false); printer->Outdent(); printer->Print( "} else {\n"); diff --git a/src/google/protobuf/compiler/cpp/cpp_map_field.h b/src/google/protobuf/compiler/cpp/cpp_map_field.h index 02e66497..88e3b464 100644 --- a/src/google/protobuf/compiler/cpp/cpp_map_field.h +++ b/src/google/protobuf/compiler/cpp/cpp_map_field.h @@ -49,8 +49,7 @@ class MapFieldGenerator : public FieldGenerator { // implements FieldGenerator --------------------------------------- void GeneratePrivateMembers(io::Printer* printer) const; void GenerateAccessorDeclarations(io::Printer* printer) const; - void GenerateInlineAccessorDefinitions(io::Printer* printer, - bool is_inline) const; + void GenerateInlineAccessorDefinitions(io::Printer* printer) const; void GenerateClearingCode(io::Printer* printer) const; void GenerateMergingCode(io::Printer* printer) const; void GenerateSwappingCode(io::Printer* printer) const; diff --git a/src/google/protobuf/compiler/cpp/cpp_message.cc b/src/google/protobuf/compiler/cpp/cpp_message.cc index d9524f64..9b2f090e 100644 --- a/src/google/protobuf/compiler/cpp/cpp_message.cc +++ b/src/google/protobuf/compiler/cpp/cpp_message.cc @@ -48,10 +48,13 @@ #include <google/protobuf/compiler/cpp/cpp_extension.h> #include <google/protobuf/compiler/cpp/cpp_field.h> #include <google/protobuf/compiler/cpp/cpp_helpers.h> +#include <google/protobuf/compiler/cpp/cpp_padding_optimizer.h> #include <google/protobuf/io/coded_stream.h> #include <google/protobuf/io/printer.h> #include <google/protobuf/descriptor.pb.h> #include <google/protobuf/generated_message_table_driven.h> +#include <google/protobuf/generated_message_util.h> +#include <google/protobuf/map_entry_lite.h> #include <google/protobuf/wire_format.h> #include <google/protobuf/stubs/strutil.h> #include <google/protobuf/stubs/substitute.h> @@ -107,119 +110,19 @@ struct ExtensionRangeSorter { } }; -// This returns an estimate of the compiler's alignment for the field. This -// can't guarantee to be correct because the generated code could be compiled on -// different systems with different alignment rules. The estimates below assume -// 64-bit pointers. -int EstimateAlignmentSize(const FieldDescriptor* field) { - if (field == NULL) return 0; - if (field->is_repeated()) return 8; +bool IsPOD(const FieldDescriptor* field) { + if (field->is_repeated() || field->is_extension()) return false; switch (field->cpp_type()) { - case FieldDescriptor::CPPTYPE_BOOL: - return 1; - - case FieldDescriptor::CPPTYPE_INT32: - case FieldDescriptor::CPPTYPE_UINT32: case FieldDescriptor::CPPTYPE_ENUM: - case FieldDescriptor::CPPTYPE_FLOAT: - return 4; - + case FieldDescriptor::CPPTYPE_INT32: case FieldDescriptor::CPPTYPE_INT64: + case FieldDescriptor::CPPTYPE_UINT32: case FieldDescriptor::CPPTYPE_UINT64: + case FieldDescriptor::CPPTYPE_FLOAT: case FieldDescriptor::CPPTYPE_DOUBLE: - case FieldDescriptor::CPPTYPE_STRING: - case FieldDescriptor::CPPTYPE_MESSAGE: - return 8; - } - GOOGLE_LOG(FATAL) << "Can't get here."; - return -1; // Make compiler happy. -} - -// FieldGroup is just a helper for OptimizePadding below. It holds a vector of -// fields that are grouped together because they have compatible alignment, and -// a preferred location in the final field ordering. -class FieldGroup { - public: - FieldGroup() - : preferred_location_(0) {} - - // A group with a single field. - FieldGroup(float preferred_location, const FieldDescriptor* field) - : preferred_location_(preferred_location), - fields_(1, field) {} - - // Append the fields in 'other' to this group. - void Append(const FieldGroup& other) { - if (other.fields_.empty()) { - return; - } - // Preferred location is the average among all the fields, so we weight by - // the number of fields on each FieldGroup object. - preferred_location_ = - (preferred_location_ * fields_.size() + - (other.preferred_location_ * other.fields_.size())) / - (fields_.size() + other.fields_.size()); - fields_.insert(fields_.end(), other.fields_.begin(), other.fields_.end()); - } - - void SetPreferredLocation(float location) { preferred_location_ = location; } - const std::vector<const FieldDescriptor*>& fields() const { return fields_; } - - // FieldGroup objects sort by their preferred location. - bool operator<(const FieldGroup& other) const { - return preferred_location_ < other.preferred_location_; - } - - private: - // "preferred_location_" is an estimate of where this group should go in the - // final list of fields. We compute this by taking the average index of each - // field in this group in the original ordering of fields. This is very - // approximate, but should put this group close to where its member fields - // originally went. - float preferred_location_; - std::vector<const FieldDescriptor*> fields_; - // We rely on the default copy constructor and operator= so this type can be - // 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; - } -} - -bool IsPOD(const FieldDescriptor* field) { - if (field->is_repeated() || field->is_extension()) return false; - switch (field->cpp_type()) { - case internal::WireFormatLite::CPPTYPE_ENUM: - case internal::WireFormatLite::CPPTYPE_INT32: - case internal::WireFormatLite::CPPTYPE_INT64: - case internal::WireFormatLite::CPPTYPE_UINT32: - case internal::WireFormatLite::CPPTYPE_UINT64: - case internal::WireFormatLite::CPPTYPE_FLOAT: - case internal::WireFormatLite::CPPTYPE_DOUBLE: - case internal::WireFormatLite::CPPTYPE_BOOL: + case FieldDescriptor::CPPTYPE_BOOL: return true; - case internal::WireFormatLite::CPPTYPE_STRING: + case FieldDescriptor::CPPTYPE_STRING: return false; default: return false; @@ -240,133 +143,6 @@ bool CanConstructByZeroing(const FieldDescriptor* field, return ret; } -// Reorder 'fields' so that if the fields are output into a c++ class in the new -// order, fields of similiar family (see below) are together and within each -// family, alignment padding is minimized. -// -// We try to do this while keeping each field as close as possible to its field -// number order so that we don't reduce cache locality much for function that -// access each field in order. Originally, OptimizePadding used declaration -// order for its decisions, but generated code minus the serializer/parsers uses -// the output of OptimizePadding as well (stored in -// MessageGenerator::optimized_order_). Since the serializers use field number -// order, we use that as a tie-breaker. -// -// 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), which allows them to be -// memset. -// -// ZERO_INITIALIZABLE is memset in Clear/SharedCtor -// -// OTHER these fields are initialized one-by-one. -void OptimizePadding(std::vector<const FieldDescriptor*>* fields, - const Options& options) { - // The sorted numeric order of Family determines the declaration order in the - // memory layout. - enum Family { - REPEATED = 0, - STRING = 1, - MESSAGE = 2, - ZERO_INITIALIZABLE = 4, - OTHER = 5, - kMaxFamily - }; - - // First divide fields into those that align to 1 byte, 4 bytes or 8 bytes. - std::vector<FieldGroup> aligned_to_1[kMaxFamily]; - std::vector<FieldGroup> aligned_to_4[kMaxFamily]; - std::vector<FieldGroup> aligned_to_8[kMaxFamily]; - for (int i = 0; i < fields->size(); ++i) { - const FieldDescriptor* field = (*fields)[i]; - - 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; - } - - const int j = field->number(); - switch (EstimateAlignmentSize(field)) { - case 1: aligned_to_1[f].push_back(FieldGroup(j, field)); break; - case 4: aligned_to_4[f].push_back(FieldGroup(j, field)); break; - case 8: aligned_to_8[f].push_back(FieldGroup(j, field)); break; - default: - GOOGLE_LOG(FATAL) << "Unknown alignment size."; - } - } - - // 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 field number - // 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); - } - // Sort by preferred location. - std::stable_sort(aligned_to_8[f].begin(), aligned_to_8[f].end()); - } - - // Now pull out all the FieldDescriptors in order. - fields->clear(); - 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()); - } - } -} - - // Emits an if-statement with a condition that evaluates to true if |field| is // considered non-default (will be sent over the wire), for message types // without true field presence. Should only be called if @@ -421,25 +197,31 @@ bool HasHasMethod(const FieldDescriptor* field) { void CollectMapInfo(const Descriptor* descriptor, std::map<string, string>* variables) { GOOGLE_CHECK(IsMapEntryMessage(descriptor)); + std::map<string, string>& vars = *variables; const FieldDescriptor* key = descriptor->FindFieldByName("key"); const FieldDescriptor* val = descriptor->FindFieldByName("value"); - (*variables)["key"] = PrimitiveTypeName(key->cpp_type()); + vars["key_cpp"] = PrimitiveTypeName(key->cpp_type()); switch (val->cpp_type()) { case FieldDescriptor::CPPTYPE_MESSAGE: - (*variables)["val"] = FieldMessageTypeName(val); + vars["val_cpp"] = FieldMessageTypeName(val); break; case FieldDescriptor::CPPTYPE_ENUM: - (*variables)["val"] = ClassName(val->enum_type(), true); + vars["val_cpp"] = ClassName(val->enum_type(), true); break; default: - (*variables)["val"] = PrimitiveTypeName(val->cpp_type()); - } - (*variables)["key_wire_type"] = - "::google::protobuf::internal::WireFormatLite::TYPE_" + - ToUpper(DeclaredTypeMethodName(key->type())); - (*variables)["val_wire_type"] = - "::google::protobuf::internal::WireFormatLite::TYPE_" + - ToUpper(DeclaredTypeMethodName(val->type())); + vars["val_cpp"] = PrimitiveTypeName(val->cpp_type()); + } + vars["key_wire_type"] = "::google::protobuf::internal::WireFormatLite::TYPE_" + + ToUpper(DeclaredTypeMethodName(key->type())); + vars["val_wire_type"] = "::google::protobuf::internal::WireFormatLite::TYPE_" + + ToUpper(DeclaredTypeMethodName(val->type())); + if (descriptor->file()->syntax() != FileDescriptor::SYNTAX_PROTO3 && + val->type() == FieldDescriptor::TYPE_ENUM) { + const EnumValueDescriptor* default_value = val->default_value_enum(); + vars["default_enum_value"] = Int32ToString(default_value->number()); + } else { + vars["default_enum_value"] = "0"; + } } // Does the given field have a private (internal helper only) has_$name$() @@ -452,22 +234,13 @@ bool HasPrivateHasMethod(const FieldDescriptor* field) { } -bool TableDrivenEnabled(const Descriptor* descriptor, const Options& options) { +bool TableDrivenParsingEnabled( + const Descriptor* descriptor, const Options& options) { if (!options.table_driven_parsing) { return false; } // Consider table-driven parsing. We only do this if: - // - There are no extensions - if (descriptor->extension_range_count() != 0) { - return false; - } - - // - We are not using UnknownFieldSet (part of the non-lite library). - if (UseUnknownFieldSet(descriptor->file(), options)) { - return false; - } - // - We have has_bits for fields. This avoids a check on every field we set // when are present (the common case). if (!HasFieldPresence(descriptor->file())) { @@ -482,16 +255,6 @@ bool TableDrivenEnabled(const Descriptor* descriptor, const Options& options) { max_field_number = field->number(); } - // - There are no map fields. - if (field->is_map()) { - return false; - } - - // - There are no oneof fields. - if (field->containing_oneof()) { - return false; - } - // - There are no weak fields. if (field->options().weak()) { return false; @@ -503,8 +266,10 @@ bool TableDrivenEnabled(const Descriptor* descriptor, const Options& options) { return false; } - // - Field numbers are relatively dense within the actual number of fields - if (max_field_number * table_sparseness >= descriptor->field_count()) { + // - Field numbers are relatively dense within the actual number of fields. + // We check for strictly greater than in the case where there are no fields + // (only extensions) so max_field_number == descriptor->field_count() == 0. + if (max_field_number * table_sparseness > descriptor->field_count()) { return false; } @@ -516,26 +281,174 @@ bool TableDrivenEnabled(const Descriptor* descriptor, const Options& options) { return true; } +void SetUnknkownFieldsVariable(const Descriptor* descriptor, + const Options& options, + std::map<string, string>* variables) { + if (UseUnknownFieldSet(descriptor->file(), options)) { + (*variables)["unknown_fields_type"] = "::google::protobuf::UnknownFieldSet"; + } else { + (*variables)["unknown_fields_type"] = "::std::string"; + } + if (AlwaysPreserveUnknownFields(descriptor)) { + (*variables)["have_unknown_fields"] = + "_internal_metadata_.have_unknown_fields()"; + (*variables)["unknown_fields"] = "_internal_metadata_.unknown_fields()"; + } else { + (*variables)["have_unknown_fields"] = + "(_internal_metadata_.have_unknown_fields() && " + " ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())"; + (*variables)["unknown_fields"] = + "(::google::protobuf::internal::GetProto3PreserveUnknownsDefault()" + " ? _internal_metadata_.unknown_fields()" + " : _internal_metadata_.default_instance())"; + } + (*variables)["mutable_unknown_fields"] = + "_internal_metadata_.mutable_unknown_fields()"; +} + +bool IsCrossFileMapField(const FieldDescriptor* field) { + if (!field->is_map()) { + return false; + } + + const Descriptor* d = field->message_type(); + const FieldDescriptor* value = d->FindFieldByNumber(2); + + return IsCrossFileMessage(value); +} + +bool IsCrossFileMaybeMap(const FieldDescriptor* field) { + if (IsCrossFileMapField(field)) { + return true; + } + + return IsCrossFileMessage(field); +} + +bool IsRequired(const std::vector<const FieldDescriptor*>& v) { + return v.front()->is_required(); +} + +// Allows chunking repeated fields together and non-repeated fields if the +// fields share the same has_byte index. +// TODO(seongkim): use lambda with capture instead of functor. +class MatchRepeatedAndHasByte { + public: + MatchRepeatedAndHasByte(const std::vector<int>* has_bit_indices, + bool has_field_presence) + : has_bit_indices_(*has_bit_indices), + has_field_presence_(has_field_presence) {} + + // Returns true if the following conditions are met: + // --both fields are repeated fields + // --both fields are non-repeated fields with either has_field_presence is + // false or have the same has_byte index. + bool operator()(const FieldDescriptor* a, const FieldDescriptor* b) const { + return a->is_repeated() == b->is_repeated() && + (!has_field_presence_ || a->is_repeated() || + has_bit_indices_[a->index()] / 8 == + has_bit_indices_[b->index()] / 8); + } + + private: + const std::vector<int>& has_bit_indices_; + const bool has_field_presence_; +}; + +// Allows chunking required fields separately after chunking with +// MatchRepeatedAndHasByte. +class MatchRepeatedAndHasByteAndRequired : public MatchRepeatedAndHasByte { + public: + MatchRepeatedAndHasByteAndRequired(const std::vector<int>* has_bit_indices, + bool has_field_presence) + : MatchRepeatedAndHasByte(has_bit_indices, has_field_presence) {} + + bool operator()(const FieldDescriptor* a, const FieldDescriptor* b) const { + return MatchRepeatedAndHasByte::operator()(a, b) && + a->is_required() == b->is_required(); + } +}; + +// Allows chunking zero-initializable fields separately after chunking with +// MatchRepeatedAndHasByte. +class MatchRepeatedAndHasByteAndZeroInits : public MatchRepeatedAndHasByte { + public: + MatchRepeatedAndHasByteAndZeroInits(const std::vector<int>* has_bit_indices, + bool has_field_presence) + : MatchRepeatedAndHasByte(has_bit_indices, has_field_presence) {} + + bool operator()(const FieldDescriptor* a, const FieldDescriptor* b) const { + return MatchRepeatedAndHasByte::operator()(a, b) && + CanInitializeByZeroing(a) == CanInitializeByZeroing(b); + } +}; + +// Collects neighboring fields based on a given criteria (equivalent predicate). +template <typename Predicate> +std::vector<std::vector<const FieldDescriptor*> > CollectFields( + const std::vector<const FieldDescriptor*>& fields, + const Predicate& equivalent) { + std::vector<std::vector<const FieldDescriptor*> > chunks; + if (fields.empty()) { + return chunks; + } + + const FieldDescriptor* last_field = fields.front(); + std::vector<const FieldDescriptor*> chunk; + for (int i = 0; i < fields.size(); i++) { + if (!equivalent(last_field, fields[i]) && !chunk.empty()) { + chunks.push_back(chunk); + chunk.clear(); + } + chunk.push_back(fields[i]); + last_field = fields[i]; + } + if (!chunk.empty()) { + chunks.push_back(chunk); + } + return chunks; +} + +// Returns a bit mask based on has_bit index of "fields" that are typically on +// the same chunk. It is used in a group presence check where _has_bits_ is +// masked to tell if any thing in "fields" is present. +uint32 GenChunkMask(const std::vector<const FieldDescriptor*>& fields, + const std::vector<int>& has_bit_indices) { + GOOGLE_CHECK(!fields.empty()); + int first_index_offset = has_bit_indices[fields.front()->index()] / 32; + uint32 chunk_mask = 0; + for (int i = 0; i < fields.size(); i++) { + const FieldDescriptor* field = fields[i]; + // "index" defines where in the _has_bits_ the field appears. + int index = has_bit_indices[field->index()]; + GOOGLE_CHECK_EQ(first_index_offset, index / 32); + chunk_mask |= static_cast<uint32>(1) << (index % 32); + } + GOOGLE_CHECK_NE(0, chunk_mask); + return chunk_mask; +} + } // anonymous namespace // =================================================================== MessageGenerator::MessageGenerator(const Descriptor* descriptor, + int index_in_file_messages, const Options& options, SCCAnalyzer* scc_analyzer) : descriptor_(descriptor), + index_in_file_messages_(index_in_file_messages), classname_(ClassName(descriptor, false)), options_(options), field_generators_(descriptor, options), max_has_bit_index_(0), - nested_generators_(new google::protobuf::scoped_ptr< - MessageGenerator>[descriptor->nested_type_count()]), enum_generators_( new google::protobuf::scoped_ptr<EnumGenerator>[descriptor->enum_type_count()]), extension_generators_(new google::protobuf::scoped_ptr< ExtensionGenerator>[descriptor->extension_count()]), use_dependent_base_(false), num_weak_fields_(0), + message_layout_helper_(new PaddingOptimizer()), scc_analyzer_(scc_analyzer) { // Compute optimized field order to be used for layout and initialization // purposes. @@ -547,7 +460,8 @@ MessageGenerator::MessageGenerator(const Descriptor* descriptor, optimized_order_.push_back(field); } } - OptimizePadding(&optimized_order_, options_); + + message_layout_helper_->OptimizeLayout(&optimized_order_, options_); if (HasFieldPresence(descriptor_->file())) { // We use -1 as a sentinel. @@ -563,11 +477,6 @@ MessageGenerator::MessageGenerator(const Descriptor* descriptor, } } - for (int i = 0; i < descriptor->nested_type_count(); i++) { - nested_generators_[i].reset(new MessageGenerator(descriptor->nested_type(i), - options, scc_analyzer)); - } - for (int i = 0; i < descriptor->enum_type_count(); i++) { enum_generators_[i].reset( new EnumGenerator(descriptor->enum_type(i), options)); @@ -592,7 +501,10 @@ MessageGenerator::MessageGenerator(const Descriptor* descriptor, use_dependent_base_ = true; } - table_driven_ = TableDrivenEnabled(descriptor_, options_); + table_driven_ = TableDrivenParsingEnabled(descriptor_, options_); + + scc_name_ = + ClassName(scc_analyzer_->GetSCC(descriptor_)->GetRepresentative(), false); } MessageGenerator::~MessageGenerator() {} @@ -610,14 +522,6 @@ size_t MessageGenerator::HasBitsSize() const { return sizeof_has_bits; } -void MessageGenerator::Flatten(std::vector<MessageGenerator*>* list) { - for (int i = 0; i < descriptor_->nested_type_count(); i++) { - nested_generators_[i]->Flatten(list); - } - index_in_file_messages_ = list->size(); - list->push_back(this); -} - void MessageGenerator::AddGenerators( std::vector<EnumGenerator*>* enum_generators, std::vector<ExtensionGenerator*>* extension_generators) { @@ -644,12 +548,6 @@ GenerateDependentFieldAccessorDeclarations(io::Printer* printer) { std::map<string, string> vars; SetCommonFieldVariables(field, &vars, options_); - if (use_dependent_base_ && IsFieldDependent(field)) { - // If the message is dependent, the inline clear_*() method will need - // to delete the message type, so it must be in the dependent base - // class. (See also GenerateFieldAccessorDeclarations.) - printer->Print(vars, "$deprecated_attr$void clear_$name$();\n"); - } // Generate type-specific accessor declarations. field_generators_.get(field).GenerateDependentAccessorDeclarations(printer); printer->Print("\n"); @@ -703,24 +601,25 @@ GenerateFieldAccessorDeclarations(io::Printer* printer) { } if (field->is_repeated()) { - printer->Print(vars, "$deprecated_attr$int $name$_size() const;\n"); + printer->Print(vars, "$deprecated_attr$int ${$$name$_size$}$() const;\n"); + printer->Annotate("{", "}", field); } else if (HasHasMethod(field)) { - printer->Print(vars, "$deprecated_attr$bool has_$name$() const;\n"); + printer->Print(vars, "$deprecated_attr$bool ${$has_$name$$}$() const;\n"); + printer->Annotate("{", "}", field); } else if (HasPrivateHasMethod(field)) { printer->Print(vars, - "private:\n" - "bool has_$name$() const;\n" - "public:\n"); + "private:\n" + "bool ${$has_$name$$}$() const;\n" + "public:\n"); + printer->Annotate("{", "}", field); } - if (!dependent_field) { - // If this field is dependent, then its clear_() method is in the - // depenent base class. (See also GenerateDependentAccessorDeclarations.) - printer->Print(vars, "$deprecated_attr$void clear_$name$();\n"); - } + printer->Print(vars, "$deprecated_attr$void ${$clear_$name$$}$();\n"); + printer->Annotate("{", "}", field); printer->Print(vars, "$deprecated_attr$static const int $constant_name$ = " "$number$;\n"); + printer->Annotate("constant_name", field); // Generate type-specific accessor declarations. field_generators_.get(field).GenerateAccessorDeclarations(printer); @@ -758,36 +657,6 @@ GenerateDependentFieldAccessorDefinitions(io::Printer* printer) { if (field->options().weak()) continue; PrintFieldComment(printer, field); - - // These functions are not really dependent: they are part of the - // (non-dependent) derived class. However, they need to live outside - // any #ifdef guards, so we treat them as if they were dependent. - // - // See the comment in FileGenerator::GenerateInlineFunctionDefinitions - // for a more complete explanation. - if (use_dependent_base_ && IsFieldDependent(field)) { - std::map<string, string> vars; - SetCommonFieldVariables(field, &vars, options_); - vars["inline"] = "inline "; - if (field->containing_oneof()) { - vars["field_name"] = UnderscoresToCamelCase(field->name(), true); - vars["oneof_name"] = field->containing_oneof()->name(); - vars["oneof_index"] = SimpleItoa(field->containing_oneof()->index()); - GenerateOneofMemberHasBits(field, vars, printer); - } else if (!field->is_repeated()) { - // There will be no header guard, so this always has to be inline. - GenerateSingularFieldHasBits(field, vars, printer); - } - // vars needed for clear_(), which is in the dependent base: - // (See also GenerateDependentFieldAccessorDeclarations.) - vars["tmpl"] = "template<class T>\n"; - vars["dependent_classname"] = - DependentBaseClassTemplateName(descriptor_) + "<T>"; - vars["this_message"] = DependentBaseDownCast(); - vars["this_const_message"] = DependentBaseConstDownCast(); - GenerateFieldClear(field, vars, printer); - } - // Generate type-specific accessors. field_generators_.get(field) .GenerateDependentInlineAccessorDefinitions(printer); @@ -798,7 +667,7 @@ GenerateDependentFieldAccessorDefinitions(io::Printer* printer) { // Generate has_$name$() and clear_has_$name$() functions for oneofs // Similar to other has-bits, these must always be in the header if we // are using a dependent base class. - GenerateOneofHasBits(printer, true /* is_inline */); + GenerateOneofHasBits(printer); } void MessageGenerator:: @@ -808,8 +677,7 @@ GenerateSingularFieldHasBits(const FieldDescriptor* field, if (field->options().weak()) { printer->Print( vars, - "$inline$" - "bool $classname$::has_$name$() const {\n" + "inline bool $classname$::has_$name$() const {\n" " return _weak_field_map_.Has($number$);\n" "}\n"); return; @@ -824,16 +692,13 @@ GenerateSingularFieldHasBits(const FieldDescriptor* field, vars["has_mask"] = StrCat(strings::Hex(1u << (has_bit_index % 32), strings::ZERO_PAD_8)); printer->Print(vars, - "$inline$" - "bool $classname$::has_$name$() const {\n" + "inline bool $classname$::has_$name$() const {\n" " return (_has_bits_[$has_array_index$] & 0x$has_mask$u) != 0;\n" "}\n" - "$inline$" - "void $classname$::set_has_$name$() {\n" + "inline void $classname$::set_has_$name$() {\n" " _has_bits_[$has_array_index$] |= 0x$has_mask$u;\n" "}\n" - "$inline$" - "void $classname$::clear_has_$name$() {\n" + "inline void $classname$::clear_has_$name$() {\n" " _has_bits_[$has_array_index$] &= ~0x$has_mask$u;\n" "}\n"); } else { @@ -842,15 +707,13 @@ GenerateSingularFieldHasBits(const FieldDescriptor* field, bool is_lazy = false; if (is_lazy) { printer->Print(vars, - "$inline$" - "bool $classname$::has_$name$() const {\n" + "inline bool $classname$::has_$name$() const {\n" " return !$name$_.IsCleared();\n" "}\n"); } else { printer->Print( vars, - "$inline$" - "bool $classname$::has_$name$() const {\n" + "inline bool $classname$::has_$name$() const {\n" " return this != internal_default_instance() && $name$_ != NULL;\n" "}\n"); } @@ -859,7 +722,7 @@ GenerateSingularFieldHasBits(const FieldDescriptor* field, } void MessageGenerator:: -GenerateOneofHasBits(io::Printer* printer, bool is_inline) { +GenerateOneofHasBits(io::Printer* printer) { for (int i = 0; i < descriptor_->oneof_decl_count(); i++) { std::map<string, string> vars; vars["oneof_name"] = descriptor_->oneof_decl(i)->name(); @@ -867,15 +730,12 @@ GenerateOneofHasBits(io::Printer* printer, bool is_inline) { vars["cap_oneof_name"] = ToUpper(descriptor_->oneof_decl(i)->name()); vars["classname"] = classname_; - vars["inline"] = (is_inline ? "inline " : ""); printer->Print( vars, - "$inline$" - "bool $classname$::has_$oneof_name$() const {\n" + "inline bool $classname$::has_$oneof_name$() const {\n" " return $oneof_name$_case() != $cap_oneof_name$_NOT_SET;\n" "}\n" - "$inline$" - "void $classname$::clear_has_$oneof_name$() {\n" + "inline void $classname$::clear_has_$oneof_name$() {\n" " _oneof_case_[$oneof_index$] = $cap_oneof_name$_NOT_SET;\n" "}\n"); } @@ -892,13 +752,11 @@ GenerateOneofMemberHasBits(const FieldDescriptor* field, // method, so that generated code is slightly cleaner (vs. comparing // _oneof_case_[index] against a constant everywhere). printer->Print(vars, - "$inline$" - "bool $classname$::has_$name$() const {\n" + "inline bool $classname$::has_$name$() const {\n" " return $oneof_name$_case() == k$field_name$;\n" "}\n"); printer->Print(vars, - "$inline$" - "void $classname$::set_has_$name$() {\n" + "inline void $classname$::set_has_$name$() {\n" " _oneof_case_[$oneof_index$] = k$field_name$;\n" "}\n"); } @@ -906,14 +764,14 @@ GenerateOneofMemberHasBits(const FieldDescriptor* field, void MessageGenerator:: GenerateFieldClear(const FieldDescriptor* field, const std::map<string, string>& vars, + bool is_inline, io::Printer* printer) { - // Generate clear_$name$() (See GenerateFieldAccessorDeclarations and - // GenerateDependentFieldAccessorDeclarations, $dependent_classname$ is - // set by the Generate*Definitions functions.) + // Generate clear_$name$(). + if (is_inline) { + printer->Print("inline "); + } printer->Print(vars, - "$tmpl$" - "$inline$" - "void $dependent_classname$::clear_$name$() {\n"); + "void $classname$::clear_$name$() {\n"); printer->Indent(); @@ -921,12 +779,12 @@ GenerateFieldClear(const FieldDescriptor* field, // Clear this field only if it is the active field in this oneof, // otherwise ignore printer->Print(vars, - "if ($this_message$has_$name$()) {\n"); + "if (has_$name$()) {\n"); printer->Indent(); field_generators_.get(field) .GenerateClearingCode(printer); printer->Print(vars, - "$this_message$clear_has_$oneof_name$();\n"); + "clear_has_$oneof_name$();\n"); printer->Outdent(); printer->Print("}\n"); } else { @@ -934,8 +792,7 @@ GenerateFieldClear(const FieldDescriptor* field, .GenerateClearingCode(printer); if (HasFieldPresence(descriptor_->file())) { if (!field->is_repeated() && !field->options().weak()) { - printer->Print(vars, - "$this_message$clear_has_$name$();\n"); + printer->Print(vars, "clear_has_$name$();\n"); } } } @@ -945,7 +802,7 @@ GenerateFieldClear(const FieldDescriptor* field, } void MessageGenerator:: -GenerateFieldAccessorDefinitions(io::Printer* printer, bool is_inline) { +GenerateFieldAccessorDefinitions(io::Printer* printer) { printer->Print("// $classname$\n\n", "classname", classname_); for (int i = 0; i < descriptor_->field_count(); i++) { @@ -955,7 +812,6 @@ GenerateFieldAccessorDefinitions(io::Printer* printer, bool is_inline) { std::map<string, string> vars; SetCommonFieldVariables(field, &vars, options_); - vars["inline"] = is_inline ? "inline " : ""; if (use_dependent_base_ && IsFieldDependent(field)) { vars["tmpl"] = "template<class T>\n"; vars["dependent_classname"] = @@ -972,31 +828,25 @@ GenerateFieldAccessorDefinitions(io::Printer* printer, bool is_inline) { // Generate has_$name$() or $name$_size(). if (field->is_repeated()) { printer->Print(vars, - "$inline$" - "int $classname$::$name$_size() const {\n" + "inline int $classname$::$name$_size() const {\n" " return $name$_.size();\n" "}\n"); } else if (field->containing_oneof()) { vars["field_name"] = UnderscoresToCamelCase(field->name(), true); vars["oneof_name"] = field->containing_oneof()->name(); vars["oneof_index"] = SimpleItoa(field->containing_oneof()->index()); - if (!use_dependent_base_ || !IsFieldDependent(field)) { - GenerateOneofMemberHasBits(field, vars, printer); - } + GenerateOneofMemberHasBits(field, vars, printer); } else { // Singular field. - if (!use_dependent_base_ || !IsFieldDependent(field)) { - GenerateSingularFieldHasBits(field, vars, printer); - } + GenerateSingularFieldHasBits(field, vars, printer); } - if (!use_dependent_base_ || !IsFieldDependent(field)) { - GenerateFieldClear(field, vars, printer); + if (!IsCrossFileMaybeMap(field)) { + GenerateFieldClear(field, vars, true, printer); } // Generate type-specific accessors. - field_generators_.get(field).GenerateInlineAccessorDefinitions(printer, - is_inline); + field_generators_.get(field).GenerateInlineAccessorDefinitions(printer); printer->Print("\n"); } @@ -1005,7 +855,7 @@ GenerateFieldAccessorDefinitions(io::Printer* printer, bool is_inline) { // Generate has_$name$() and clear_has_$name$() functions for oneofs // If we aren't using a dependent base, they can be with the other functions // that are #ifdef-guarded. - GenerateOneofHasBits(printer, is_inline); + GenerateOneofHasBits(printer); } } @@ -1041,7 +891,42 @@ GenerateDependentBaseClassDefinition(io::Printer* printer) { void MessageGenerator:: GenerateClassDefinition(io::Printer* printer) { - if (IsMapEntryMessage(descriptor_)) return; + if (IsMapEntryMessage(descriptor_)) { + std::map<string, string> vars; + vars["classname"] = classname_; + CollectMapInfo(descriptor_, &vars); + vars["lite"] = + HasDescriptorMethods(descriptor_->file(), options_) ? "" : "Lite"; + printer->Print( + vars, + "class $classname$ : public " + "::google::protobuf::internal::MapEntry$lite$<$classname$, \n" + " $key_cpp$, $val_cpp$,\n" + " $key_wire_type$,\n" + " $val_wire_type$,\n" + " $default_enum_value$ > {\n" + "public:\n" + " typedef ::google::protobuf::internal::MapEntry$lite$<$classname$, \n" + " $key_cpp$, $val_cpp$,\n" + " $key_wire_type$,\n" + " $val_wire_type$,\n" + " $default_enum_value$ > SuperType;\n" + " $classname$();\n" + " $classname$(::google::protobuf::Arena* arena);\n" + " void MergeFrom(const $classname$& other);\n" + " static const $classname$* internal_default_instance() { return " + "reinterpret_cast<const " + "$classname$*>(&_$classname$_default_instance_); }\n"); + if (HasDescriptorMethods(descriptor_->file(), options_)) { + printer->Print( + " void MergeFrom(const ::google::protobuf::Message& other) PROTOBUF_FINAL;\n" + " ::google::protobuf::Metadata GetMetadata() const;\n" + "};\n"); + } else { + printer->Print("};\n"); + } + return; + } if (use_dependent_base_) { GenerateDependentBaseClassDefinition(printer); printer->Print("\n"); @@ -1074,55 +959,54 @@ GenerateClassDefinition(io::Printer* printer) { printer->Print(" public:\n"); printer->Indent(); + printer->Print( + vars, + "$classname$();\n" + "virtual ~$classname$();\n" + "\n" + "$classname$(const $classname$& from);\n" + "\n" + "inline $classname$& operator=(const $classname$& from) {\n" + " CopyFrom(from);\n" + " return *this;\n" + "}\n"); + + if (options_.table_driven_serialization) { + printer->Print( + "private:\n" + "const void* InternalGetTable() const;\n" + "public:\n" + "\n"); + } + + // Generate move constructor and move assignment operator. printer->Print(vars, - "$classname$();\n" - "virtual ~$classname$();\n" - "\n" - "$classname$(const $classname$& from);\n" + "#if LANG_CXX11\n" + "$classname$($classname$&& from) noexcept\n" + " : $classname$() {\n" + " *this = ::std::move(from);\n" + "}\n" "\n" - "inline $classname$& operator=(const $classname$& from) {\n" - " CopyFrom(from);\n" + "inline $classname$& operator=($classname$&& from) noexcept {\n" + " if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) {\n" + " if (this != &from) InternalSwap(&from);\n" + " } else {\n" + " CopyFrom(from);\n" + " }\n" " return *this;\n" "}\n" - "\n"); + "#endif\n"); - // Generate move constructor and move assignment operator for types other than - // Any. - #ifdef PROTO_EXPERIMENTAL_ENABLE_MOVE - if (!IsAnyMessage(descriptor_)) { + SetUnknkownFieldsVariable(descriptor_, options_, &vars); + if (PublicUnknownFieldsAccessors(descriptor_)) { printer->Print(vars, - "#if LANG_CXX11\n" - "$classname$($classname$&& from)\n" - " : $classname$() {\n" - " *this = ::std::move(from);\n" - "}\n" - "\n" - "inline $classname$& operator=($classname$&& from) {\n" - " if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) {\n" - " InternalSwap(&from);\n" - " } else {\n" - " CopyFrom(from);\n" - " }\n" - " return *this;\n" - "}\n" - "#endif\n"); - } - #endif - - if (PreserveUnknownFields(descriptor_)) { - string type = UseUnknownFieldSet(descriptor_->file(), options_) - ? "::google::protobuf::UnknownFieldSet" - : "::std::string"; - printer->Print( - "inline const $type$& unknown_fields() const {\n" - " return _internal_metadata_.unknown_fields();\n" - "}\n" - "\n" - "inline $type$* mutable_unknown_fields() {\n" - " return _internal_metadata_.mutable_unknown_fields();\n" - "}\n" - "\n", - "type", type ); + "inline const $unknown_fields_type$& unknown_fields() const {\n" + " return $unknown_fields$;\n" + "}\n" + "inline $unknown_fields_type$* mutable_unknown_fields() {\n" + " return $mutable_unknown_fields$;\n" + "}\n" + "\n"); } // N.B.: We exclude GetArena() when arena support is disabled, falling back on @@ -1182,6 +1066,7 @@ GenerateClassDefinition(io::Printer* printer) { vars["message_index"] = SimpleItoa(index_in_file_messages_); printer->Print( vars, + "static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY\n" "static inline const $classname$* internal_default_instance() {\n" " return reinterpret_cast<const $classname$*>(\n" " &_$classname$_default_instance_);\n" @@ -1190,7 +1075,6 @@ GenerateClassDefinition(io::Printer* printer) { " $message_index$;\n" "\n"); - if (SupportsArenas(descriptor_)) { printer->Print(vars, "void UnsafeArenaSwap($classname$* other);\n"); @@ -1212,14 +1096,22 @@ GenerateClassDefinition(io::Printer* printer) { vars["new_final"] = " PROTOBUF_FINAL"; + vars["create_func"] = MessageCreateFunction(descriptor_); printer->Print(vars, "void Swap($classname$* other);\n" + "friend void swap($classname$& a, $classname$& b) {\n" + " a.Swap(&b);\n" + "}\n" "\n" "// implements Message ----------------------------------------------\n" "\n" - "inline $classname$* New() const$new_final$ { return New(NULL); }\n" + "inline $classname$* New() const$new_final$ {\n" + " return ::google::protobuf::Arena::$create_func$<$classname$>(NULL);\n" + "}\n" "\n" - "$classname$* New(::google::protobuf::Arena* arena) const$new_final$;\n"); + "$classname$* New(::google::protobuf::Arena* arena) const$new_final$ {\n" + " return ::google::protobuf::Arena::$create_func$<$classname$>(arena);\n" + "}\n"); // For instances that derive from Message (rather than MessageLite), some // methods are virtual and should be marked as final. @@ -1250,9 +1142,14 @@ GenerateClassDefinition(io::Printer* printer) { "\n" "size_t ByteSizeLong() const PROTOBUF_FINAL;\n" "bool MergePartialFromCodedStream(\n" - " ::google::protobuf::io::CodedInputStream* input)$merge_partial_final$;\n" - "void SerializeWithCachedSizes(\n" - " ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;\n"); + " ::google::protobuf::io::CodedInputStream* input)$merge_partial_final$;\n"); + if (!options_.table_driven_serialization || + descriptor_->options().message_set_wire_format()) { + printer->Print( + "void SerializeWithCachedSizes(\n" + " ::google::protobuf::io::CodedOutputStream* output) const " + "PROTOBUF_FINAL;\n"); + } // DiscardUnknownFields() is implemented in message.cc using reflections. We // need to implement this function in generated code for messages. if (!UseUnknownFieldSet(descriptor_->file(), options_)) { @@ -1278,6 +1175,9 @@ GenerateClassDefinition(io::Printer* printer) { "final", use_final); if (SupportsArenas(descriptor_)) { printer->Print( + // TODO(gerbens) Make this private! Currently people are deriving from + // protos to give access to this constructor, breaking the invariants + // we rely on. "protected:\n" "explicit $classname$(::google::protobuf::Arena* arena);\n" "private:\n" @@ -1331,6 +1231,8 @@ GenerateClassDefinition(io::Printer* printer) { printer->Print("typedef $nested_full_name$ $nested_name$;\n", "nested_name", nested_type->name(), "nested_full_name", ClassName(nested_type, false)); + printer->Annotate("nested_full_name", nested_type); + printer->Annotate("nested_name", nested_type); } } @@ -1443,7 +1345,7 @@ GenerateClassDefinition(io::Printer* printer) { if (SupportsArenas(descriptor_)) { printer->Print( - "friend class ::google::protobuf::Arena;\n" + "template <typename T> friend class ::google::protobuf::Arena::InternalHelper;\n" "typedef void InternalArenaConstructable_;\n" "typedef void DestructorSkippable_;\n"); } @@ -1521,14 +1423,13 @@ GenerateClassDefinition(io::Printer* printer) { // The TableStruct struct needs access to the private parts, in order to // construct the offsets of all members. - // - // Some InitDefault and Shutdown are defined as static member functions of - // TableStruct such that they are also allowed to access private members. + // TODO(gerbens) Remove the friend for InitDefaults. printer->Print( - "friend struct $file_namespace$::TableStruct;\n", + "friend struct ::$file_namespace$::TableStruct;\n" + "friend void ::$file_namespace$::InitDefaults$scc_name$Impl();\n", // Vars. - "file_namespace", - FileLevelNamespace(descriptor_->file()->name())); + "scc_name", scc_name_, "file_namespace", + FileLevelNamespace(descriptor_)); printer->Outdent(); printer->Print("};"); @@ -1548,9 +1449,9 @@ GenerateDependentInlineMethods(io::Printer* printer) { } void MessageGenerator:: -GenerateInlineMethods(io::Printer* printer, bool is_inline) { +GenerateInlineMethods(io::Printer* printer) { if (IsMapEntryMessage(descriptor_)) return; - GenerateFieldAccessorDefinitions(printer, is_inline); + GenerateFieldAccessorDefinitions(printer); // Generate oneof_case() functions. for (int i = 0; i < descriptor_->oneof_decl_count(); i++) { @@ -1560,11 +1461,9 @@ GenerateInlineMethods(io::Printer* printer, bool is_inline) { descriptor_->oneof_decl(i)->name(), true); vars["oneof_name"] = descriptor_->oneof_decl(i)->name(); vars["oneof_index"] = SimpleItoa(descriptor_->oneof_decl(i)->index()); - vars["inline"] = is_inline ? "inline " : ""; printer->Print( vars, - "$inline$" - "$class_name$::$camel_oneof_name$Case $class_name$::" + "inline $class_name$::$camel_oneof_name$Case $class_name$::" "$oneof_name$_case() const {\n" " return $class_name$::$camel_oneof_name$Case(" "_oneof_case_[$oneof_index$]);\n" @@ -1577,7 +1476,6 @@ GenerateExtraDefaultFields(io::Printer* printer) { // Generate oneof default instance and weak field instances for reflection // usage. if (descriptor_->oneof_decl_count() > 0 || num_weak_fields_ > 0) { - printer->Print("public:\n"); for (int i = 0; i < descriptor_->oneof_decl_count(); i++) { for (int j = 0; j < descriptor_->oneof_decl(i)->field_count(); j++) { const FieldDescriptor* field = descriptor_->oneof_decl(i)->field(j); @@ -1602,13 +1500,14 @@ GenerateExtraDefaultFields(io::Printer* printer) { bool MessageGenerator::GenerateParseTable(io::Printer* printer, size_t offset, size_t aux_offset) { if (!table_driven_) { - printer->Print("{ NULL, NULL, 0, -1, -1, false },\n"); + printer->Print("{ NULL, NULL, 0, -1, -1, -1, -1, NULL, false },\n"); return false; } std::map<string, string> vars; - vars["classname"] = classname_; + vars["classname"] = ClassName(descriptor_); + vars["classtype"] = QualifiedClassName(descriptor_); vars["offset"] = SimpleItoa(offset); vars["aux_offset"] = SimpleItoa(aux_offset); @@ -1635,13 +1534,34 @@ bool MessageGenerator::GenerateParseTable(io::Printer* printer, size_t offset, printer->Print(vars, "-1,\n"); } else { printer->Print(vars, - "GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(\n" - " $classname$, _has_bits_),\n"); + "GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(\n" + " $classtype$, _has_bits_),\n"); } + if (descriptor_->oneof_decl_count() > 0) { + printer->Print(vars, + "GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(\n" + " $classtype$, _oneof_case_),\n"); + } else { + printer->Print("-1, // no _oneof_case_\n"); + } + + if (descriptor_->extension_range_count() > 0) { + printer->Print(vars, + "GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET($classtype$, " + "_extensions_),\n"); + } else { + printer->Print("-1, // no _extensions_\n"); + } + + // TODO(ckennelly): Consolidate this with the calculation for + // AuxillaryParseTableField. + vars["ns"] = Namespace(descriptor_); + printer->Print(vars, - "GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(\n" - " $classname$, _internal_metadata_),\n"); + "GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(\n" + " $classtype$, _internal_metadata_),\n" + "&$ns$::_$classname$_default_instance_,\n"); if (UseUnknownFieldSet(descriptor_->file(), options_)) { printer->Print(vars, "true,\n"); @@ -1656,48 +1576,255 @@ bool MessageGenerator::GenerateParseTable(io::Printer* printer, size_t offset, void MessageGenerator::GenerateSchema(io::Printer* printer, int offset, int has_offset) { - if (IsMapEntryMessage(descriptor_)) return; - std::map<string, string> vars; - vars["classname"] = classname_; + vars["classname"] = QualifiedClassName(descriptor_); vars["offset"] = SimpleItoa(offset); - vars["has_bits_offsets"] = HasFieldPresence(descriptor_->file()) - ? SimpleItoa(offset + has_offset) - : "-1"; + vars["has_bits_offsets"] = + HasFieldPresence(descriptor_->file()) || IsMapEntryMessage(descriptor_) + ? SimpleItoa(offset + has_offset) + : "-1"; printer->Print(vars, "{ $offset$, $has_bits_offsets$, sizeof($classname$)},\n"); } -void MessageGenerator:: -GenerateDefaultInstanceAllocator(io::Printer* printer) { - // Construct the default instances of all fields, as they will be used - // when creating the default instance of the entire message. +namespace { + +// TODO(gerbens) remove this after the next sync with GitHub code base. +// Then the opensource testing has gained the functionality to compile +// the CalcFieldNum given the symbols defined in generated-message-util. +#ifdef OPENSOURCE_PROTOBUF_CPP_BOOTSTRAP +// We need a clean version of CalcFieldNum that doesn't use new functionality +// in the runtime, because this functionality is not yet in the opensource +// runtime + +uint32 CalculateType(uint32 type, uint32 type_class) { + return (type - 1) + type_class * 20; +} + +uint32 CalcFieldNum(const FieldDescriptor* field, const Options& options) { + bool is_a_map = IsMapEntryMessage(field->containing_type()); + int type = field->type(); + if (field->containing_oneof()) { + return CalculateType(type, 4); + } + if (field->is_packed()) { + return CalculateType(type, 3); + } else if (field->is_repeated()) { + return CalculateType(type, 2); + } else if (!HasFieldPresence(field->file()) && + field->containing_oneof() == NULL && !is_a_map) { + return CalculateType(type, 1); + } else { + return CalculateType(type, 0); + } +} + +#else +// We need to calculate for each field what function the table driven code +// should use to serialize it. This returns the index in a lookup table. +uint32 CalcFieldNum(const FieldDescriptor* field, const Options& options) { + bool is_a_map = IsMapEntryMessage(field->containing_type()); + int type = field->type(); + if (field->containing_oneof()) { + return internal::FieldMetadata::CalculateType( + type, internal::FieldMetadata::kOneOf); + } + if (field->is_packed()) { + return internal::FieldMetadata::CalculateType( + type, internal::FieldMetadata::kPacked); + } else if (field->is_repeated()) { + return internal::FieldMetadata::CalculateType( + type, internal::FieldMetadata::kRepeated); + } else if (!HasFieldPresence(field->file()) && + field->containing_oneof() == NULL && !is_a_map) { + return internal::FieldMetadata::CalculateType( + type, internal::FieldMetadata::kNoPresence); + } else { + return internal::FieldMetadata::CalculateType( + type, internal::FieldMetadata::kPresence); + } +} +#endif + +int FindMessageIndexInFile(const Descriptor* descriptor) { + std::vector<const Descriptor*> flatten = + FlattenMessagesInFile(descriptor->file()); + return std::find(flatten.begin(), flatten.end(), descriptor) - + flatten.begin(); +} + +} // namespace + +int MessageGenerator::GenerateFieldMetadata(io::Printer* printer) { + if (!options_.table_driven_serialization) { + return 0; + } + + string full_classname = QualifiedClassName(descriptor_); + + std::vector<const FieldDescriptor*> sorted = SortFieldsByNumber(descriptor_); + if (IsMapEntryMessage(descriptor_)) { + for (int i = 0; i < 2; i++) { + const FieldDescriptor* field = sorted[i]; + uint32 tag = internal::WireFormatLite::MakeTag( + field->number(), WireFormat::WireTypeForFieldType(field->type())); + + std::map<string, string> vars; + vars["classname"] = QualifiedClassName(descriptor_); + vars["field_name"] = FieldName(field); + vars["tag"] = SimpleItoa(tag); + vars["hasbit"] = SimpleItoa(i); + vars["type"] = SimpleItoa(CalcFieldNum(field, options_)); + vars["ptr"] = "NULL"; + if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { + GOOGLE_CHECK(!IsMapEntryMessage(field->message_type())); + { + vars["ptr"] = + "::" + FileLevelNamespace(field->message_type()) + + "::TableStruct::serialization_table + " + + SimpleItoa(FindMessageIndexInFile(field->message_type())); + } + } + printer->Print(vars, + "{GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(" + "::google::protobuf::internal::MapEntryHelper<$classname$::" + "SuperType>, $field_name$_), $tag$," + "GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(" + "::google::protobuf::internal::MapEntryHelper<$classname$::" + "SuperType>, _has_bits_) * 8 + $hasbit$, $type$, " + "$ptr$},\n"); + } + return 2; + } + printer->Print( + "{GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET($classname$, " + "_cached_size_), 0, 0, 0, NULL},\n", + "classname", full_classname); + std::vector<const Descriptor::ExtensionRange*> sorted_extensions; + for (int i = 0; i < descriptor_->extension_range_count(); ++i) { + sorted_extensions.push_back(descriptor_->extension_range(i)); + } + std::sort(sorted_extensions.begin(), sorted_extensions.end(), + ExtensionRangeSorter()); + for (int i = 0, extension_idx = 0; /* no range */; i++) { + for (; extension_idx < sorted_extensions.size() && + (i == sorted.size() || + sorted_extensions[extension_idx]->start < sorted[i]->number()); + extension_idx++) { + const Descriptor::ExtensionRange* range = + sorted_extensions[extension_idx]; + printer->Print( + "{GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET($classname$, " + "_extensions_), $start$, $end$, " + "::google::protobuf::internal::FieldMetadata::kSpecial, " + "reinterpret_cast<const " + "void*>(::google::protobuf::internal::ExtensionSerializer)},\n", + "classname", full_classname, "start", SimpleItoa(range->start), "end", + SimpleItoa(range->end)); + } + if (i == sorted.size()) break; + const FieldDescriptor* field = sorted[i]; + + uint32 tag = internal::WireFormatLite::MakeTag( + field->number(), WireFormat::WireTypeForFieldType(field->type())); + if (field->is_packed()) { + tag = internal::WireFormatLite::MakeTag( + field->number(), WireFormatLite::WIRETYPE_LENGTH_DELIMITED); + } + + string classfieldname = FieldName(field); + if (field->containing_oneof()) { + classfieldname = field->containing_oneof()->name(); + } + std::map<string, string> vars; + vars["classname"] = full_classname; + vars["field_name"] = classfieldname; + vars["tag"] = SimpleItoa(tag); + vars["ptr"] = "NULL"; + if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { + if (IsMapEntryMessage(field->message_type())) { + vars["idx"] = SimpleItoa(FindMessageIndexInFile(field->message_type())); + vars["fieldclassname"] = QualifiedClassName(field->message_type()); + printer->Print(vars, + "{GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET($" + "classname$, $field_name$_), $tag$, $idx$, " + "::google::protobuf::internal::FieldMetadata::kSpecial, " + "reinterpret_cast<const void*>(static_cast< " + "::google::protobuf::internal::SpecialSerializer>(" + "::google::protobuf::internal::MapFieldSerializer< " + "::google::protobuf::internal::MapEntryToMapField<" + "$fieldclassname$>::MapFieldType, " + "TableStruct::serialization_table>))},\n"); + continue; + } else { + vars["ptr"] = + "::" + FileLevelNamespace(field->message_type()) + + "::TableStruct::serialization_table + " + + SimpleItoa(FindMessageIndexInFile(field->message_type())); + } + } + vars["type"] = SimpleItoa(CalcFieldNum(field, options_)); + + + if (field->options().weak()) { + // TODO(gerbens) merge weak fields into ranges + printer->Print(vars, + "{GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET($" + "classname$, _weak_field_map_), $tag$, $tag$, " + "::google::protobuf::internal::FieldMetadata::kSpecial, " + "reinterpret_cast<const " + "void*>(::google::protobuf::internal::WeakFieldSerializer)},\n"); + } else if (field->containing_oneof()) { + vars["oneofoffset"] = + SimpleItoa(sizeof(uint32) * field->containing_oneof()->index()); + printer->Print(vars, + "{GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET($" + "classname$, $field_name$_), $tag$, " + "GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET($" + "classname$, _oneof_case_) + $oneofoffset$, " + "$type$, $ptr$},\n"); + } else if (HasFieldPresence(descriptor_->file()) && + has_bit_indices_[field->index()] != -1) { + vars["hasbitsoffset"] = SimpleItoa(has_bit_indices_[field->index()]); + printer->Print(vars, + "{GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET($" + "classname$, $field_name$_), $tag$, " + "GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET($" + "classname$, _has_bits_) * 8 + $hasbitsoffset$, $type$, " + "$ptr$},\n"); + } else { + printer->Print(vars, + "{GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET($" + "classname$, $field_name$_), $tag$, ~0u, $type$, " + "$ptr$},\n"); + } + } + int num_field_metadata = 1 + sorted.size() + sorted_extensions.size(); + num_field_metadata++; + string serializer = UseUnknownFieldSet(descriptor_->file(), options_) + ? "::google::protobuf::internal::UnknownFieldSetSerializer" + : "::google::protobuf::internal::UnknownFieldSerializerLite"; + printer->Print( + "{GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET($classname$, " + "_internal_metadata_), 0, ~0u, " + "::google::protobuf::internal::FieldMetadata::kSpecial, reinterpret_cast<const " + "void*>($serializer$)},\n", + "classname", full_classname, "serializer", serializer); + return num_field_metadata; +} + +void MessageGenerator::GenerateFieldDefaultInstances(io::Printer* printer) { + // Construct the default instances for all fields that need one. for (int i = 0; i < descriptor_->field_count(); i++) { field_generators_.get(descriptor_->field(i)) .GenerateDefaultInstanceAllocator(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_.DefaultConstruct();\n", - "classname", classname_); } void MessageGenerator:: GenerateDefaultInstanceInitializer(io::Printer* printer) { - if (IsMapEntryMessage(descriptor_)) { - printer->Print( - "_$classname$_default_instance_.get_mutable()->set_default_instance(_$" - "classname$_default_instance_.get_mutable());\n" - "_$classname$_default_instance_.get_mutable()->InitAsDefaultInstance();" - "\n", - "classname", classname_); - return; - } - // 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 @@ -1715,14 +1842,16 @@ GenerateDefaultInstanceInitializer(io::Printer* printer) { if (field->containing_oneof() || field->options().weak()) { name = "_" + classname_ + "_default_instance_."; } else { - name = "_" + classname_ + "_default_instance_.get_mutable()->"; + name = + "_" + classname_ + "_default_instance_._instance.get_mutable()->"; } name += FieldName(field); printer->Print( - "$name$_ = const_cast< $type$*>(\n" + "$ns$::$name$_ = const_cast< $type$*>(\n" " $type$::internal_default_instance());\n", // Vars. - "name", name, "type", FieldMessageTypeName(field)); + "name", name, "type", FieldMessageTypeName(field), "ns", + Namespace(descriptor_)); } else if (field->containing_oneof() && HasDescriptorMethods(descriptor_->file(), options_)) { field_generators_.get(descriptor_->field(i)) @@ -1732,52 +1861,43 @@ GenerateDefaultInstanceInitializer(io::Printer* printer) { } void MessageGenerator:: -GenerateShutdownCode(io::Printer* printer) { - if (IsMapEntryMessage(descriptor_)) return; - - printer->Print("_$classname$_default_instance_.Shutdown();\n", "classname", - classname_); - - if (HasDescriptorMethods(descriptor_->file(), options_)) { - printer->Print("delete file_level_metadata[$index$].reflection;\n", "index", - SimpleItoa(index_in_file_messages_)); - } - - // Handle default instances of fields. - for (int i = 0; i < descriptor_->field_count(); i++) { - field_generators_.get(descriptor_->field(i)) - .GenerateShutdownCode(printer); - } -} - -void MessageGenerator:: GenerateClassMethods(io::Printer* printer) { if (IsMapEntryMessage(descriptor_)) { + printer->Print( + "$classname$::$classname$() {}\n" + "$classname$::$classname$(::google::protobuf::Arena* arena) : " + "SuperType(arena) {}\n" + "void $classname$::MergeFrom(const $classname$& other) {\n" + " MergeFromInternal(other);\n" + "}\n", + "classname", classname_); if (HasDescriptorMethods(descriptor_->file(), options_)) { printer->Print( - "$parent$::$classname$::$classname$() {}\n" - "$parent$::$classname$::$classname$(::google::protobuf::Arena* arena) : " - "SuperType(arena) {}\n" - "::google::protobuf::Metadata $parent$::$classname$::GetMetadata() const {\n" - " $file_namespace$::protobuf_AssignDescriptorsOnce();\n" - " return $file_namespace$::file_level_metadata[$index$];\n" + "::google::protobuf::Metadata $classname$::GetMetadata() const {\n" + " ::$file_namespace$::protobuf_AssignDescriptorsOnce();\n" + " return ::$file_namespace$::file_level_metadata[$index$];\n" "}\n" - "void $parent$::$classname$::MergeFrom(\n" + "void $classname$::MergeFrom(\n" " const ::google::protobuf::Message& other) {\n" " ::google::protobuf::Message::MergeFrom(other);\n" "}\n" - "void $parent$::$classname$::MergeFrom(const $classname$& other) {\n" - " MergeFromInternal(other);\n" - "}\n" "\n", - "file_namespace", FileLevelNamespace(descriptor_->file()->name()), - "parent", ClassName(descriptor_->containing_type(), false), + "file_namespace", FileLevelNamespace(descriptor_), "classname", classname_, "index", SimpleItoa(index_in_file_messages_)); } return; } + // TODO(gerbens) Remove this function. With a little bit of cleanup and + // refactoring this is superfluous. + printer->Print("void $classname$::InitAsDefaultInstance() {\n", "classname", + classname_); + printer->Indent(); + GenerateDefaultInstanceInitializer(printer); + printer->Outdent(); + printer->Print("}\n"); + if (IsAnyMessage(descriptor_)) { printer->Print( "void $classname$::PackFrom(const ::google::protobuf::Message& message) {\n" @@ -1798,8 +1918,17 @@ GenerateClassMethods(io::Printer* printer) { // Generate non-inline field definitions. for (int i = 0; i < descriptor_->field_count(); i++) { - field_generators_.get(descriptor_->field(i)) + const FieldDescriptor* field = descriptor_->field(i); + field_generators_.get(field) .GenerateNonInlineAccessorDefinitions(printer); + if (IsCrossFileMaybeMap(field)) { + std::map<string, string> vars; + SetCommonFieldVariables(field, &vars, options_); + if (field->containing_oneof()) { + SetCommonOneofFieldVariables(field, &vars); + } + GenerateFieldClear(field, vars, false, printer); + } } // Generate field number constants. @@ -1854,16 +1983,26 @@ GenerateClassMethods(io::Printer* printer) { GenerateSwap(printer); printer->Print("\n"); + if (options_.table_driven_serialization) { + printer->Print( + "const void* $classname$::InternalGetTable() const {\n" + " return ::$file_namespace$::TableStruct::serialization_table + " + "$index$;\n" + "}\n" + "\n", + "classname", classname_, "index", SimpleItoa(index_in_file_messages_), + "file_namespace", FileLevelNamespace(descriptor_)); + } if (HasDescriptorMethods(descriptor_->file(), options_)) { printer->Print( "::google::protobuf::Metadata $classname$::GetMetadata() const {\n" " $file_namespace$::protobuf_AssignDescriptorsOnce();\n" - " return " + " return ::" "$file_namespace$::file_level_metadata[kIndexInFileMessages];\n" "}\n" "\n", "classname", classname_, "file_namespace", - FileLevelNamespace(descriptor_->file()->name())); + FileLevelNamespace(descriptor_)); } else { printer->Print( "::std::string $classname$::GetTypeName() const {\n" @@ -1926,13 +2065,25 @@ size_t MessageGenerator::GenerateParseOffsets(io::Printer* printer) { processing_type |= static_cast<unsigned>( field->is_repeated() ? internal::kRepeatedMask : 0); + processing_type |= static_cast<unsigned>( + field->containing_oneof() ? internal::kOneofMask : 0); + + if (field->is_map()) { + processing_type = internal::TYPE_MAP; + } + const unsigned char tag_size = WireFormat::TagSize(field->number(), field->type()); std::map<string, string> vars; - vars["classname"] = classname_; - vars["name"] = FieldName(field); - vars["has"] = SimpleItoa(has_bit_indices_[field->index()]); + vars["classname"] = QualifiedClassName(descriptor_); + if (field->containing_oneof() != NULL) { + vars["name"] = field->containing_oneof()->name(); + vars["presence"] = SimpleItoa(field->containing_oneof()->index()); + } else { + vars["name"] = FieldName(field); + vars["presence"] = SimpleItoa(has_bit_indices_[field->index()]); + } vars["nwtype"] = SimpleItoa(normal_wiretype); vars["pwtype"] = SimpleItoa(packed_wiretype); vars["ptype"] = SimpleItoa(processing_type); @@ -1942,7 +2093,7 @@ size_t MessageGenerator::GenerateParseOffsets(io::Printer* printer) { "{\n" " GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(\n" " $classname$, $name$_),\n" - " static_cast< ::google::protobuf::uint32>($has$),\n" + " static_cast< ::google::protobuf::uint32>($presence$),\n" " $nwtype$, $pwtype$, $ptype$, $tag_size$\n" "},\n"); } @@ -1977,42 +2128,39 @@ size_t MessageGenerator::GenerateParseAuxTable(io::Printer* printer) { printer->Print( vars, "{::google::protobuf::internal::AuxillaryParseTableField::enum_aux{" - "$type$_IsValid, \"$type$\" }},\n"); + "$type$_IsValid}},\n"); last_field_number++; break; case FieldDescriptor::CPPTYPE_MESSAGE: { - std::vector<string> package_parts; - - const Descriptor* outer = field->message_type(); - while (outer->containing_type() != NULL) { - outer = outer->containing_type(); + if (field->is_map()) { + vars["classname"] = QualifiedClassName(field->message_type()); + printer->Print(vars, + "{::google::protobuf::internal::AuxillaryParseTableField::map_" + "aux{&::google::protobuf::internal::ParseMap<$classname$>}},\n"); + last_field_number++; + break; + } else { + vars["classname"] = ClassName(field->message_type(), false); } - - package_parts = Split( - outer->full_name(), ".", true); - // outer->full_name() contains the class itself. Remove it as it is - // used in the name of the default instance variable. - GOOGLE_DCHECK_NE(package_parts.size(), 0); - package_parts.back().clear(); - - vars["classname"] = ClassName(field->message_type(), false); - vars["ns"] = Join(package_parts, "::"); + vars["ns"] = Namespace(field->message_type()); vars["type"] = FieldMessageTypeName(field); - vars["file_namespace"] = FileLevelNamespace(outer->file()->name()); + vars["file_namespace"] = + FileLevelNamespace(field->message_type()); - printer->Print(vars, + printer->Print( + vars, "{::google::protobuf::internal::AuxillaryParseTableField::message_aux{\n" - " &::$ns$_$classname$_default_instance_,\n"); + " &$ns$::_$classname$_default_instance_,\n"); bool dont_emit_table = - !TableDrivenEnabled(field->message_type(), options_); + !TableDrivenParsingEnabled(field->message_type(), options_); if (dont_emit_table) { printer->Print(" NULL,\n"); } else { printer->Print(vars, - " ::$ns$$file_namespace$::TableStruct::schema +\n" - " ::$ns$$classname$::kIndexInFileMessages,\n"); + " ::$file_namespace$::TableStruct::schema +\n" + " $ns$::$classname$::kIndexInFileMessages,\n"); } printer->Print("}},\n"); @@ -2024,8 +2172,9 @@ size_t MessageGenerator::GenerateParseAuxTable(io::Printer* printer) { case FieldOptions::STRING: vars["default"] = field->default_value_string().empty() - ? "&::google::protobuf::internal::fixed_address_empty_string" - : "&" + classname_ + "::_default_" + FieldName(field) + "_"; + ? "&::google::protobuf::internal::fixed_address_empty_string" + : "&" + Namespace(field) + " ::" + classname_ + + "::_default_" + FieldName(field) + "_"; break; case FieldOptions::CORD: case FieldOptions::STRING_PIECE: @@ -2034,16 +2183,10 @@ size_t MessageGenerator::GenerateParseAuxTable(io::Printer* printer) { break; } vars["full_name"] = field->full_name(); - vars["strict"] = - field->file()->syntax() == FileDescriptor::SYNTAX_PROTO3 - ? "true" : "false"; - vars["type"] = field->full_name(); printer->Print(vars, "{::google::protobuf::internal::AuxillaryParseTableField::string_aux{\n" " $default$,\n" - " \"$full_name$\",\n" - " $strict$,\n" - " \"$type$\"\n" + " \"$full_name$\"\n" "}},\n"); last_field_number++; break; @@ -2057,11 +2200,11 @@ size_t MessageGenerator::GenerateParseAuxTable(io::Printer* printer) { std::pair<size_t, size_t> MessageGenerator::GenerateOffsets( io::Printer* printer) { - if (IsMapEntryMessage(descriptor_)) return std::make_pair(0, 0); std::map<string, string> variables; - variables["classname"] = classname_; + string full_classname = QualifiedClassName(descriptor_); + variables["classname"] = full_classname; - if (HasFieldPresence(descriptor_->file())) { + if (HasFieldPresence(descriptor_->file()) || IsMapEntryMessage(descriptor_)) { printer->Print( variables, "GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET($classname$, " @@ -2102,28 +2245,29 @@ std::pair<size_t, size_t> MessageGenerator::GenerateOffsets( for (int i = 0; i < descriptor_->field_count(); i++) { const FieldDescriptor* field = descriptor_->field(i); if (field->containing_oneof() || field->options().weak()) { - printer->Print( - "GOOGLE_PROTOBUF_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET(" - "(&_$classname$_default_instance_), $name$_),\n", - "classname", classname_, "name", FieldName(field)); + printer->Print("offsetof($classname$DefaultTypeInternal, $name$_),\n", + "classname", full_classname, "name", FieldName(field)); } else { printer->Print( "GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET($classname$, " - "$name$_),\n", - "classname", classname_, - "name", FieldName(field)); + "$name$_),\n", + "classname", full_classname, "name", FieldName(field)); } } for (int i = 0; i < descriptor_->oneof_decl_count(); i++) { const OneofDescriptor* oneof = descriptor_->oneof_decl(i); printer->Print( - "GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET($classname$, $name$_),\n", - "classname", classname_, - "name", oneof->name()); + "GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET($classname$, $name$_),\n", + "classname", full_classname, "name", oneof->name()); } - if (HasFieldPresence(descriptor_->file())) { + if (IsMapEntryMessage(descriptor_)) { + entries += 2; + printer->Print( + "0,\n" + "1,\n"); + } else if (HasFieldPresence(descriptor_->file())) { entries += has_bit_indices_.size(); for (int i = 0; i < has_bit_indices_.size(); i++) { const string index = has_bit_indices_[i] >= 0 ? @@ -2175,15 +2319,9 @@ GenerateSharedDestructorCode(io::Printer* printer) { "classname", classname_); printer->Indent(); if (SupportsArenas(descriptor_)) { - // Do nothing when the message is allocated in an arena. printer->Print( - "::google::protobuf::Arena* arena = GetArenaNoVirtual();\n" - "if (arena != NULL) {\n" - " return;\n" - "}\n" - "\n"); + "GOOGLE_DCHECK(GetArenaNoVirtual() == NULL);\n"); } - // Write the destructors for each field except oneof members. // optimized_order_ does not contain oneof fields. for (int i = 0; i < optimized_order_.size(); i++) { @@ -2308,12 +2446,13 @@ void MessageGenerator::GenerateConstructorBody(io::Printer* printer, if (copy_constructor) { pod_template = "::memcpy(&$first$_, &from.$first$_,\n" - " reinterpret_cast<char*>(&$last$_) -\n" - " reinterpret_cast<char*>(&$first$_) + sizeof($last$_));\n"; + " static_cast<size_t>(reinterpret_cast<char*>(&$last$_) -\n" + " reinterpret_cast<char*>(&$first$_)) + sizeof($last$_));\n"; } else { pod_template = - "::memset(&$first$_, 0, reinterpret_cast<char*>(&$last$_) -\n" - " reinterpret_cast<char*>(&$first$_) + sizeof($last$_));\n"; + "::memset(&$first$_, 0, static_cast<size_t>(\n" + " reinterpret_cast<char*>(&$last$_) -\n" + " reinterpret_cast<char*>(&$first$_)) + sizeof($last$_));\n"; } for (int i = 0; i < optimized_order_.size(); ++i) { @@ -2384,8 +2523,7 @@ GenerateStructors(io::Printer* printer) { initializer_with_arena += ", _weak_field_map_(arena)"; } - string initializer_null; - initializer_null = ", _internal_metadata_(NULL)"; + string initializer_null = superclass + "(), _internal_metadata_(NULL)"; if (IsAnyMessage(descriptor_)) { initializer_null += ", _any_metadata_(&type_url_, &value_)"; } @@ -2395,142 +2533,152 @@ GenerateStructors(io::Printer* printer) { printer->Print( "$classname$::$classname$()\n" - " : $superclass$()$initializer$ {\n" + " : $initializer$ {\n" " if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {\n" - " $file_namespace$::InitDefaults();\n" + " ::$file_namespace$::InitDefaults$scc_name$();\n" " }\n" " SharedCtor();\n" " // @@protoc_insertion_point(constructor:$full_name$)\n" "}\n", - "classname", classname_, "superclass", superclass, "full_name", - descriptor_->full_name(), "initializer", initializer_null, - "file_namespace", FileLevelNamespace(descriptor_->file()->name())); + "classname", classname_, "full_name", descriptor_->full_name(), + "scc_name", scc_name_, "initializer", initializer_null, "file_namespace", + FileLevelNamespace(descriptor_)); if (SupportsArenas(descriptor_)) { printer->Print( "$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" - " $file_namespace$::InitDefaults();\n" - "#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER\n" + " ::$file_namespace$::InitDefaults$scc_name$();\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(), - "file_namespace", FileLevelNamespace(descriptor_->file()->name())); + "scc_name", scc_name_, "file_namespace", + FileLevelNamespace(descriptor_)); } // Generate the copy constructor. - printer->Print( - "$classname$::$classname$(const $classname$& from)\n" - " : $superclass$()", - "classname", classname_, - "superclass", superclass, - "full_name", descriptor_->full_name()); - printer->Indent(); - printer->Indent(); - printer->Indent(); + if (UsingImplicitWeakFields(descriptor_->file(), options_)) { + // If we are in lite mode and using implicit weak fields, we generate a + // one-liner copy constructor that delegates to MergeFrom. This saves some + // code size and also cuts down on the complexity of implicit weak fields. + // We might eventually want to do this for all lite protos. + printer->Print( + "$classname$::$classname$(const $classname$& from)\n" + " : $classname$() {\n" + " MergeFrom(from);\n" + "}\n", + "classname", classname_); + } else { + printer->Print( + "$classname$::$classname$(const $classname$& from)\n" + " : $superclass$()", + "classname", classname_, + "superclass", superclass, + "full_name", descriptor_->full_name()); + printer->Indent(); + printer->Indent(); + printer->Indent(); - printer->Print( - ",\n_internal_metadata_(NULL)"); + printer->Print( + ",\n_internal_metadata_(NULL)"); - if (HasFieldPresence(descriptor_->file())) { - printer->Print(",\n_has_bits_(from._has_bits_)"); - } + if (HasFieldPresence(descriptor_->file())) { + printer->Print(",\n_has_bits_(from._has_bits_)"); + } - bool need_to_emit_cached_size = true; - const string cached_size_decl = ",\n_cached_size_(0)"; - // We reproduce the logic used for laying out _cached_sized_ in the class - // definition, as to initialize it in-order. - if (HasFieldPresence(descriptor_->file()) && - (HasBitsSize() % 8) != 0) { - printer->Print(cached_size_decl.c_str()); - need_to_emit_cached_size = false; - } + bool need_to_emit_cached_size = true; + const string cached_size_decl = ",\n_cached_size_(0)"; + // We reproduce the logic used for laying out _cached_sized_ in the class + // definition, as to initialize it in-order. + if (HasFieldPresence(descriptor_->file()) && + (HasBitsSize() % 8) != 0) { + printer->Print(cached_size_decl.c_str()); + need_to_emit_cached_size = false; + } - std::vector<bool> processed(optimized_order_.size(), false); - for (int i = 0; i < optimized_order_.size(); ++i) { - const FieldDescriptor* field = optimized_order_[i]; + std::vector<bool> processed(optimized_order_.size(), false); + for (int i = 0; i < optimized_order_.size(); ++i) { + const FieldDescriptor* field = optimized_order_[i]; - if (!(field->is_repeated() && !(field->is_map())) - ) { - continue; - } + if (!(field->is_repeated() && !(field->is_map())) + ) { + continue; + } - processed[i] = true; - printer->Print(",\n$name$_(from.$name$_)", - "name", FieldName(field)); - } + processed[i] = true; + printer->Print(",\n$name$_(from.$name$_)", + "name", FieldName(field)); + } - if (need_to_emit_cached_size) { - printer->Print(cached_size_decl.c_str()); - need_to_emit_cached_size = false; - } + if (need_to_emit_cached_size) { + printer->Print(cached_size_decl.c_str()); + need_to_emit_cached_size = false; + } - if (IsAnyMessage(descriptor_)) { - printer->Print(",\n_any_metadata_(&type_url_, &value_)"); - } - if (num_weak_fields_ > 0) { - printer->Print(",\n_weak_field_map_(from._weak_field_map_)"); - } + if (IsAnyMessage(descriptor_)) { + printer->Print(",\n_any_metadata_(&type_url_, &value_)"); + } + if (num_weak_fields_ > 0) { + printer->Print(",\n_weak_field_map_(from._weak_field_map_)"); + } - printer->Outdent(); - printer->Outdent(); - printer->Print(" {\n"); + printer->Outdent(); + printer->Outdent(); + printer->Print(" {\n"); - printer->Print( - "_internal_metadata_.MergeFrom(from._internal_metadata_);\n"); + printer->Print( + "_internal_metadata_.MergeFrom(from._internal_metadata_);\n"); - if (descriptor_->extension_range_count() > 0) { - printer->Print("_extensions_.MergeFrom(from._extensions_);\n"); - } + if (descriptor_->extension_range_count() > 0) { + printer->Print("_extensions_.MergeFrom(from._extensions_);\n"); + } - GenerateConstructorBody(printer, processed, true); + GenerateConstructorBody(printer, processed, true); - // Copy oneof fields. Oneof field requires oneof case check. - for (int i = 0; i < descriptor_->oneof_decl_count(); ++i) { - printer->Print( - "clear_has_$oneofname$();\n" - "switch (from.$oneofname$_case()) {\n", - "oneofname", descriptor_->oneof_decl(i)->name()); - printer->Indent(); - for (int j = 0; j < descriptor_->oneof_decl(i)->field_count(); j++) { - const FieldDescriptor* field = descriptor_->oneof_decl(i)->field(j); + // Copy oneof fields. Oneof field requires oneof case check. + for (int i = 0; i < descriptor_->oneof_decl_count(); ++i) { printer->Print( - "case k$field_name$: {\n", - "field_name", UnderscoresToCamelCase(field->name(), true)); + "clear_has_$oneofname$();\n" + "switch (from.$oneofname$_case()) {\n", + "oneofname", descriptor_->oneof_decl(i)->name()); printer->Indent(); - field_generators_.get(field).GenerateMergingCode(printer); + for (int j = 0; j < descriptor_->oneof_decl(i)->field_count(); j++) { + const FieldDescriptor* field = descriptor_->oneof_decl(i)->field(j); + printer->Print( + "case k$field_name$: {\n", + "field_name", UnderscoresToCamelCase(field->name(), true)); + printer->Indent(); + field_generators_.get(field).GenerateMergingCode(printer); + printer->Print( + "break;\n"); + printer->Outdent(); + printer->Print( + "}\n"); + } printer->Print( - "break;\n"); + "case $cap_oneof_name$_NOT_SET: {\n" + " break;\n" + "}\n", + "oneof_index", + SimpleItoa(descriptor_->oneof_decl(i)->index()), + "cap_oneof_name", + ToUpper(descriptor_->oneof_decl(i)->name())); printer->Outdent(); printer->Print( "}\n"); } - printer->Print( - "case $cap_oneof_name$_NOT_SET: {\n" - " break;\n" - "}\n", - "oneof_index", - SimpleItoa(descriptor_->oneof_decl(i)->index()), - "cap_oneof_name", - ToUpper(descriptor_->oneof_decl(i)->name())); + printer->Outdent(); printer->Print( - "}\n"); + " // @@protoc_insertion_point(copy_constructor:$full_name$)\n" + "}\n" + "\n", + "full_name", descriptor_->full_name()); } - printer->Outdent(); - printer->Print( - " // @@protoc_insertion_point(copy_constructor:$full_name$)\n" - "}\n" - "\n", - "full_name", descriptor_->full_name()); - // Generate the shared constructor code. GenerateSharedConstructorCode(printer); @@ -2566,42 +2714,34 @@ GenerateStructors(io::Printer* printer) { !descriptor_->options().no_standard_descriptor_accessor()) { printer->Print( "const ::google::protobuf::Descriptor* $classname$::descriptor() {\n" - " $file_namespace$::protobuf_AssignDescriptorsOnce();\n" - " return " + " ::$file_namespace$::protobuf_AssignDescriptorsOnce();\n" + " return ::" "$file_namespace$::file_level_metadata[kIndexInFileMessages]." "descriptor;\n" "}\n" "\n", "classname", classname_, "file_namespace", - FileLevelNamespace(descriptor_->file()->name())); + FileLevelNamespace(descriptor_)); } printer->Print( "const $classname$& $classname$::default_instance() {\n" - " $file_namespace$::InitDefaults();\n" + " ::$file_namespace$::InitDefaults$scc_name$();\n" " return *internal_default_instance();\n" "}\n\n", - "classname", classname_, "file_namespace", - FileLevelNamespace(descriptor_->file()->name())); + "classname", classname_, "scc_name", scc_name_, "file_namespace", + FileLevelNamespace(descriptor_)); +} - if (SupportsArenas(descriptor_)) { - printer->Print( - "$classname$* $classname$::New(::google::protobuf::Arena* arena) const {\n" - " return ::google::protobuf::Arena::CreateMessage<$classname$>(arena);\n" - "}\n", - "classname", classname_); - } else { - printer->Print( - "$classname$* $classname$::New(::google::protobuf::Arena* arena) const {\n" - " $classname$* n = new $classname$;\n" - " if (arena != NULL) {\n" - " arena->Own(n);\n" - " }\n" - " return n;\n" +void MessageGenerator::GenerateSourceInProto2Namespace(io::Printer* printer) { + printer->Print( + "template<> " + "GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE " + "$classname$* Arena::$create_func$< $classname$ >(Arena* arena) {\n" + " return Arena::$create_func$Internal< $classname$ >(arena);\n" "}\n", - "classname", classname_); - } - + "classname", QualifiedClassName(descriptor_), + "create_func", MessageCreateFunction(descriptor_)); } // Return the number of bits set in n, a non-negative integer. @@ -2614,188 +2754,214 @@ static int popcnt(uint32 n) { return result; } +bool MessageGenerator::MaybeGenerateOptionalFieldCondition( + io::Printer* printer, const FieldDescriptor* field, + int expected_has_bits_index) { + int has_bit_index = has_bit_indices_[field->index()]; + if (!field->options().weak() && + expected_has_bits_index == has_bit_index / 32) { + const string mask = + StrCat(strings::Hex(1u << (has_bit_index % 32), strings::ZERO_PAD_8)); + printer->Print( + "if (cached_has_bits & 0x$mask$u) {\n", + "mask", mask); + return true; + } + return false; +} + void MessageGenerator:: GenerateClear(io::Printer* printer) { + // Performance tuning parameters + const int kMaxUnconditionalPrimitiveBytesClear = 4; + printer->Print( "void $classname$::Clear() {\n" "// @@protoc_insertion_point(message_clear_start:$full_name$)\n", "classname", classname_, "full_name", descriptor_->full_name()); printer->Indent(); + printer->Print( + // TODO(jwb): It would be better to avoid emitting this if it is not used, + // rather than emitting a workaround for the resulting warning. + "::google::protobuf::uint32 cached_has_bits = 0;\n" + "// Prevent compiler warnings about cached_has_bits being unused\n" + "(void) cached_has_bits;\n\n"); + + int cached_has_bit_index = -1; + // Step 1: Extensions if (descriptor_->extension_range_count() > 0) { printer->Print("_extensions_.Clear();\n"); } - int last_i = -1; - for (int i = 0; i < optimized_order_.size(); ) { - // Detect infinite loops. - GOOGLE_CHECK_NE(i, last_i); - last_i = i; - - // Step 2: Repeated fields don't use _has_bits_; emit code to clear them - // here. - for (; i < optimized_order_.size(); i++) { - const FieldDescriptor* field = optimized_order_[i]; - const FieldGenerator& generator = field_generators_.get(field); - - if (!field->is_repeated()) { - break; - } + int unconditional_budget = kMaxUnconditionalPrimitiveBytesClear; + for (int i = 0; i < optimized_order_.size(); i++) { + const FieldDescriptor* field = optimized_order_[i]; - if (use_dependent_base_ && IsFieldDependent(field)) { - printer->Print("clear_$name$();\n", "name", FieldName(field)); - } else { - generator.GenerateMessageClearingCode(printer); - } + if (!CanInitializeByZeroing(field)) { + continue; } - // Step 3: Greedily seek runs of fields that can be cleared by - // memset-to-0. - int last_chunk = -1; - int last_chunk_start = -1; - int last_chunk_end = -1; - uint32 last_chunk_mask = 0; + unconditional_budget -= EstimateAlignmentSize(field); + } - int memset_run_start = -1; - int memset_run_end = -1; - for (; i < optimized_order_.size(); i++) { - const FieldDescriptor* field = optimized_order_[i]; + std::vector<std::vector<const FieldDescriptor*> > chunks_frag = CollectFields( + optimized_order_, + MatchRepeatedAndHasByteAndZeroInits( + &has_bit_indices_, HasFieldPresence(descriptor_->file()))); - if (!CanInitializeByZeroing(field)) { - break; + // Merge next non-zero initializable chunk if it has the same has_byte index + // and not meeting unconditional clear condition. + std::vector<std::vector<const FieldDescriptor*> > chunks; + if (!HasFieldPresence(descriptor_->file())) { + // Don't bother with merging without has_bit field. + chunks = chunks_frag; + } else { + // Note that only the next chunk is considered for merging. + for (int i = 0; i < chunks_frag.size(); i++) { + chunks.push_back(chunks_frag[i]); + const FieldDescriptor* field = chunks_frag[i].front(); + const FieldDescriptor* next_field = + (i + 1) < chunks_frag.size() ? chunks_frag[i + 1].front() : NULL; + if (CanInitializeByZeroing(field) && + (chunks_frag[i].size() == 1 || unconditional_budget < 0) && + next_field != NULL && + has_bit_indices_[field->index()] / 8 == + has_bit_indices_[next_field->index()] / 8) { + GOOGLE_CHECK(!CanInitializeByZeroing(next_field)); + // Insert next chunk to the current one and skip next chunk. + chunks.back().insert(chunks.back().end(), chunks_frag[i + 1].begin(), + chunks_frag[i + 1].end()); + i++; } + } + } - // "index" defines where in the _has_bits_ the field appears. - // "i" is our loop counter within optimized_order_. - int index = HasFieldPresence(descriptor_->file()) ? - has_bit_indices_[field->index()] : 0; - int chunk = index / 8; + for (int chunk_index = 0; chunk_index < chunks.size(); chunk_index++) { + std::vector<const FieldDescriptor*>& chunk = chunks[chunk_index]; + GOOGLE_CHECK(!chunk.empty()); - if (last_chunk == -1) { - last_chunk = chunk; - last_chunk_start = i; - } else if (chunk != last_chunk) { - // Emit the fields for this chunk so far. - break; - } + // Step 2: Repeated fields don't use _has_bits_; emit code to clear them + // here. + if (chunk.front()->is_repeated()) { + for (int i = 0; i < chunk.size(); i++) { + const FieldDescriptor* field = chunk[i]; + const FieldGenerator& generator = field_generators_.get(field); - if (memset_run_start == -1) { - memset_run_start = i; + generator.GenerateMessageClearingCode(printer); } - - memset_run_end = i; - last_chunk_end = i; - last_chunk_mask |= static_cast<uint32>(1) << (index % 32); + continue; } - // Step 4: Non-repeated, non-zero initializable fields. - for (; i < optimized_order_.size(); i++) { - const FieldDescriptor* field = optimized_order_[i]; - if (field->is_repeated() || CanInitializeByZeroing(field)) { - break; - } - - // "index" defines where in the _has_bits_ the field appears. - // "i" is our loop counter within optimized_order_. - int index = HasFieldPresence(descriptor_->file()) ? - has_bit_indices_[field->index()] : 0; - int chunk = index / 8; + // Step 3: Non-repeated fields that can be cleared by memset-to-0, then + // non-repeated, non-zero initializable fields. + int last_chunk = HasFieldPresence(descriptor_->file()) + ? has_bit_indices_[chunk.front()->index()] / 8 + : 0; + int last_chunk_start = 0; + int memset_run_start = -1; + int memset_run_end = -1; - if (last_chunk == -1) { - last_chunk = chunk; - last_chunk_start = i; - } else if (chunk != last_chunk) { - // Emit the fields for this chunk so far. - break; + for (int i = 0; i < chunk.size(); i++) { + const FieldDescriptor* field = chunk[i]; + if (CanInitializeByZeroing(field)) { + if (memset_run_start == -1) { + memset_run_start = i; + } + memset_run_end = i; } - - last_chunk_end = i; - last_chunk_mask |= static_cast<uint32>(1) << (index % 32); } - if (last_chunk != -1) { - GOOGLE_DCHECK_NE(-1, last_chunk_start); - GOOGLE_DCHECK_NE(-1, last_chunk_end); - GOOGLE_DCHECK_NE(0, last_chunk_mask); + const bool have_outer_if = + HasFieldPresence(descriptor_->file()) && chunk.size() > 1 && + (memset_run_end != chunk.size() - 1 || unconditional_budget < 0); + if (have_outer_if) { + uint32 last_chunk_mask = GenChunkMask(chunk, has_bit_indices_); const int count = popcnt(last_chunk_mask); - const bool have_outer_if = HasFieldPresence(descriptor_->file()) && - (last_chunk_start != last_chunk_end); - if (have_outer_if) { - // Check (up to) 8 has_bits at a time if we have more than one field in - // this chunk. Due to field layout ordering, we may check - // _has_bits_[last_chunk * 8 / 32] multiple times. - GOOGLE_DCHECK_LE(2, count); - GOOGLE_DCHECK_GE(8, count); + // Check (up to) 8 has_bits at a time if we have more than one field in + // this chunk. Due to field layout ordering, we may check + // _has_bits_[last_chunk * 8 / 32] multiple times. + GOOGLE_DCHECK_LE(2, count); + GOOGLE_DCHECK_GE(8, count); - printer->Print( - "if (_has_bits_[$index$ / 32] & $mask$u) {\n", - "index", SimpleItoa(last_chunk * 8), - "mask", SimpleItoa(last_chunk_mask)); - printer->Indent(); + if (cached_has_bit_index != last_chunk / 4) { + cached_has_bit_index = last_chunk / 4; + printer->Print("cached_has_bits = _has_bits_[$idx$];\n", "idx", + SimpleItoa(cached_has_bit_index)); } + printer->Print("if (cached_has_bits & $mask$u) {\n", "mask", + SimpleItoa(last_chunk_mask)); + printer->Indent(); + } - if (memset_run_start != -1) { - if (memset_run_start == memset_run_end) { - // For clarity, do not memset a single field. - const FieldGenerator& generator = - field_generators_.get(optimized_order_[memset_run_start]); - generator.GenerateMessageClearingCode(printer); - } else { - const string first_field_name = - FieldName(optimized_order_[memset_run_start]); - const string last_field_name = - FieldName(optimized_order_[memset_run_end]); - - printer->Print( - "::memset(&$first$_, 0, reinterpret_cast<char*>(&$last$_) -\n" - " reinterpret_cast<char*>(&$first$_) + sizeof($last$_));\n", - "first", first_field_name, - "last", last_field_name); - } + if (memset_run_start != -1) { + if (memset_run_start == memset_run_end) { + // For clarity, do not memset a single field. + const FieldGenerator& generator = + field_generators_.get(chunk[memset_run_start]); + generator.GenerateMessageClearingCode(printer); + } else { + const string first_field_name = FieldName(chunk[memset_run_start]); + const string last_field_name = FieldName(chunk[memset_run_end]); - // Advance last_chunk_start to skip over the fields we zeroed/memset. - last_chunk_start = memset_run_end + 1; + printer->Print( + "::memset(&$first$_, 0, static_cast<size_t>(\n" + " reinterpret_cast<char*>(&$last$_) -\n" + " reinterpret_cast<char*>(&$first$_)) + sizeof($last$_));\n", + "first", first_field_name, "last", last_field_name); } - // Go back and emit clears for each of the fields we processed. - for (int j = last_chunk_start; j <= last_chunk_end; j++) { - const FieldDescriptor* field = optimized_order_[j]; - const string fieldname = FieldName(field); - const FieldGenerator& generator = field_generators_.get(field); + // Advance last_chunk_start to skip over the fields we zeroed/memset. + last_chunk_start = memset_run_end + 1; + } + + // Go back and emit clears for each of the fields we processed. + for (int j = last_chunk_start; j < chunk.size(); j++) { + const FieldDescriptor* field = chunk[j]; + const string fieldname = FieldName(field); + const FieldGenerator& generator = field_generators_.get(field); - // It's faster to just overwrite primitive types, but we should only - // clear strings and messages if they were set. - // - // TODO(kenton): Let the CppFieldGenerator decide this somehow. - bool should_check_bit = + // It's faster to just overwrite primitive types, but we should only + // clear strings and messages if they were set. + // + // TODO(kenton): Let the CppFieldGenerator decide this somehow. + bool should_check_bit = field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE || field->cpp_type() == FieldDescriptor::CPPTYPE_STRING; - bool have_enclosing_if = false; - if (should_check_bit && - // If no field presence, then always clear strings/messages as well. - HasFieldPresence(descriptor_->file())) { - printer->Print("if (has_$name$()) {\n", "name", fieldname); - printer->Indent(); - have_enclosing_if = true; + bool have_enclosing_if = false; + if (should_check_bit && + // If no field presence, then always clear strings/messages as well. + HasFieldPresence(descriptor_->file())) { + if (!field->options().weak() && + cached_has_bit_index != (has_bit_indices_[field->index()] / 32)) { + cached_has_bit_index = (has_bit_indices_[field->index()] / 32); + printer->Print("cached_has_bits = _has_bits_[$new_index$];\n", + "new_index", SimpleItoa(cached_has_bit_index)); } - - generator.GenerateMessageClearingCode(printer); - - if (have_enclosing_if) { - printer->Outdent(); - printer->Print("}\n"); + if (!MaybeGenerateOptionalFieldCondition(printer, field, + cached_has_bit_index)) { + printer->Print("if (has_$name$()) {\n", "name", fieldname); } + printer->Indent(); + have_enclosing_if = true; } - if (have_outer_if) { + generator.GenerateMessageClearingCode(printer); + + if (have_enclosing_if) { printer->Outdent(); printer->Print("}\n"); } } + + if (have_outer_if) { + printer->Outdent(); + printer->Print("}\n"); + } } // Step 4: Unions. @@ -2814,9 +2980,7 @@ GenerateClear(io::Printer* printer) { printer->Print("_has_bits_.Clear();\n"); } - if (PreserveUnknownFields(descriptor_)) { - printer->Print("_internal_metadata_.Clear();\n"); - } + printer->Print("_internal_metadata_.Clear();\n"); printer->Outdent(); printer->Print("}\n"); @@ -2920,6 +3084,7 @@ GenerateSwap(io::Printer* printer) { printer->Print("void $classname$::InternalSwap($classname$* other) {\n", "classname", classname_); printer->Indent(); + printer->Print("using std::swap;\n"); if (HasGeneratedMethods(descriptor_->file(), options_)) { for (int i = 0; i < optimized_order_.size(); i++) { @@ -2931,24 +3096,22 @@ GenerateSwap(io::Printer* printer) { for (int i = 0; i < descriptor_->oneof_decl_count(); i++) { printer->Print( - "std::swap($oneof_name$_, other->$oneof_name$_);\n" - "std::swap(_oneof_case_[$i$], other->_oneof_case_[$i$]);\n", + "swap($oneof_name$_, other->$oneof_name$_);\n" + "swap(_oneof_case_[$i$], other->_oneof_case_[$i$]);\n", "oneof_name", descriptor_->oneof_decl(i)->name(), "i", SimpleItoa(i)); } if (HasFieldPresence(descriptor_->file())) { for (int i = 0; i < HasBitsSize() / 4; ++i) { - printer->Print("std::swap(_has_bits_[$i$], other->_has_bits_[$i$]);\n", + printer->Print("swap(_has_bits_[$i$], other->_has_bits_[$i$]);\n", "i", SimpleItoa(i)); } } - if (PreserveUnknownFields(descriptor_)) { - printer->Print("_internal_metadata_.Swap(&other->_internal_metadata_);\n"); - } + printer->Print("_internal_metadata_.Swap(&other->_internal_metadata_);\n"); - printer->Print("std::swap(_cached_size_, other->_cached_size_);\n"); + printer->Print("swap(_cached_size_, other->_cached_size_);\n"); if (descriptor_->extension_range_count() > 0) { printer->Print("_extensions_.Swap(&other->_extensions_);\n"); } @@ -3251,25 +3414,19 @@ GenerateCopyFrom(io::Printer* printer) { void MessageGenerator:: GenerateMergeFromCodedStream(io::Printer* printer) { + std::map<string, string> vars; + SetUnknkownFieldsVariable(descriptor_, options_, &vars); if (descriptor_->options().message_set_wire_format()) { // Special-case MessageSet. - printer->Print( + vars["classname"] = classname_; + printer->Print(vars, "bool $classname$::MergePartialFromCodedStream(\n" - " ::google::protobuf::io::CodedInputStream* input) {\n", - "classname", classname_); - - printer->Print( - " return _extensions_.ParseMessageSet(input, " - "internal_default_instance(),\n" - " mutable_unknown_fields());\n", - // Vars. - "classname", classname_); - - printer->Print( + " ::google::protobuf::io::CodedInputStream* input) {\n" + " return _extensions_.ParseMessageSet(input,\n" + " internal_default_instance(), $mutable_unknown_fields$);\n" "}\n"); return; } - std::vector<const FieldDescriptor*> ordered_fields = SortFieldsByNumber(descriptor_); @@ -3281,14 +3438,17 @@ GenerateMergeFromCodedStream(io::Printer* printer) { if (table_driven_) { printer->Indent(); + const string lite = UseUnknownFieldSet(descriptor_->file(), options_) ? + "" : "Lite"; + printer->Print( - "return ::google::protobuf::internal::MergePartialFromCodedStream(\n" + "return ::google::protobuf::internal::MergePartialFromCodedStream$lite$(\n" " this,\n" - " $file_namespace$::TableStruct::schema[\n" + " ::$file_namespace$::TableStruct::schema[\n" " $classname$::kIndexInFileMessages],\n" " input);\n", - "classname", classname_, - "file_namespace", FileLevelNamespace(descriptor_->file()->name())); + "classname", classname_, "file_namespace", + FileLevelNamespace(descriptor_), "lite", lite); printer->Outdent(); @@ -3296,23 +3456,32 @@ GenerateMergeFromCodedStream(io::Printer* printer) { return; } + if (SupportsArenas(descriptor_)) { + for (int i = 0; i < ordered_fields.size(); i++) { + const FieldDescriptor* field = ordered_fields[i]; + const FieldGenerator& field_generator = field_generators_.get(field); + if (field_generator.MergeFromCodedStreamNeedsArena()) { + printer->Print( + " ::google::protobuf::Arena* arena = GetArenaNoVirtual();\n"); + break; + } + } + } + printer->Print( - "#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure\n" - " ::google::protobuf::uint32 tag;\n"); - - if (PreserveUnknownFields(descriptor_) && - !UseUnknownFieldSet(descriptor_->file(), options_)) { - // Use LazyStringOutputString to avoid initializing unknown fields string - // unless it is actually needed. For the same reason, disable eager refresh - // on the CodedOutputStream. + "#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto " + "failure\n" + " ::google::protobuf::uint32 tag;\n"); + + if (!UseUnknownFieldSet(descriptor_->file(), options_)) { printer->Print( - " ::google::protobuf::io::LazyStringOutputStream unknown_fields_string(\n" - " ::google::protobuf::NewPermanentCallback(&_internal_metadata_,\n" - " &::google::protobuf::internal::InternalMetadataWithArenaLite::\n" - " mutable_unknown_fields));\n" - " ::google::protobuf::io::CodedOutputStream unknown_fields_stream(\n" - " &unknown_fields_string, false);\n", - "classname", classname_); + " ::google::protobuf::internal::LiteUnknownFieldSetter unknown_fields_setter(\n" + " &_internal_metadata_);\n" + " ::google::protobuf::io::StringOutputStream unknown_fields_output(\n" + " unknown_fields_setter.buffer());\n" + " ::google::protobuf::io::CodedOutputStream unknown_fields_stream(\n" + " &unknown_fields_output, false);\n", + "classname", classname_); } printer->Print( @@ -3354,13 +3523,12 @@ GenerateMergeFromCodedStream(io::Printer* printer) { } printer->Print("::std::pair< ::google::protobuf::uint32, bool> p = " - "input->ReadTagWithCutoff$lasttag$($max$u);\n" + "input->ReadTagWithCutoffNoLastTag($max$u);\n" "tag = p.first;\n" "if (!p.second) goto handle_unusual;\n", "max", SimpleItoa(maxtag <= kCutoff0 ? kCutoff0 : (maxtag <= kCutoff1 ? kCutoff1 : - maxtag)), - "lasttag", !capture_last_tag ? "NoLastTag" : ""); + maxtag))); if (descriptor_->field_count() > 0) { // We don't even want to print the switch() if we have no fields because @@ -3395,9 +3563,11 @@ GenerateMergeFromCodedStream(io::Printer* printer) { const FieldGenerator& field_generator = field_generators_.get(field); // Emit code to parse the common, expected case. - printer->Print("if (static_cast< ::google::protobuf::uint8>(tag) ==\n" - " static_cast< ::google::protobuf::uint8>($commontag$u)) {\n", - "commontag", SimpleItoa(WireFormat::MakeTag(field))); + printer->Print( + "if (static_cast< ::google::protobuf::uint8>(tag) ==\n" + " static_cast< ::google::protobuf::uint8>($truncated$u /* $full$ & 0xFF */)) {\n", + "truncated", SimpleItoa(WireFormat::MakeTag(field) & 0xFF), + "full", SimpleItoa(WireFormat::MakeTag(field))); printer->Indent(); if (field->is_packed()) { @@ -3411,22 +3581,30 @@ GenerateMergeFromCodedStream(io::Printer* printer) { if (field->is_packed()) { internal::WireFormatLite::WireType wiretype = WireFormat::WireTypeForFieldType(field->type()); - printer->Print("} else if (static_cast< ::google::protobuf::uint8>(tag) ==\n" - " static_cast< ::google::protobuf::uint8>($uncommontag$u)) {\n", - "uncommontag", SimpleItoa( - internal::WireFormatLite::MakeTag( - field->number(), wiretype))); + const uint32 tag = internal::WireFormatLite::MakeTag( + field->number(), wiretype); + printer->Print( + "} else if (\n" + " static_cast< ::google::protobuf::uint8>(tag) ==\n" + " static_cast< ::google::protobuf::uint8>($truncated$u /* $full$ & 0xFF */)) {\n", + "truncated", SimpleItoa(tag & 0xFF), + "full", SimpleItoa(tag)); + printer->Indent(); field_generator.GenerateMergeFromCodedStream(printer); printer->Outdent(); } else if (field->is_packable() && !field->is_packed()) { internal::WireFormatLite::WireType wiretype = internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED; - printer->Print("} else if (static_cast< ::google::protobuf::uint8>(tag) ==\n" - " static_cast< ::google::protobuf::uint8>($uncommontag$u)) {\n", - "uncommontag", SimpleItoa( - internal::WireFormatLite::MakeTag( - field->number(), wiretype))); + const uint32 tag = internal::WireFormatLite::MakeTag( + field->number(), wiretype); + + printer->Print( + "} else if (\n" + " static_cast< ::google::protobuf::uint8>(tag) ==\n" + " static_cast< ::google::protobuf::uint8>($truncated$u /* $full$ & 0xFF */)) {\n", + "truncated", SimpleItoa(tag & 0xFF), + "full", SimpleItoa(tag)); printer->Indent(); field_generator.GenerateMergeFromCodedStreamWithPacking(printer); printer->Outdent(); @@ -3452,12 +3630,20 @@ GenerateMergeFromCodedStream(io::Printer* printer) { printer->Print("handle_unusual:\n"); printer->Indent(); // If tag is 0 or an end-group tag then this must be the end of the message. - printer->Print( - "if (tag == 0 ||\n" - " ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==\n" - " ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {\n" - " goto success;\n" - "}\n"); + if (capture_last_tag) { + printer->Print( + "if (tag == 0 ||\n" + " ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==\n" + " ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {\n" + " input->SetLastTag(tag);\n" + " goto success;\n" + "}\n"); + } else { + printer->Print( + "if (tag == 0) {\n" + " goto success;\n" + "}\n"); + } // Handle extension ranges. if (descriptor_->extension_range_count() > 0) { @@ -3485,23 +3671,16 @@ GenerateMergeFromCodedStream(io::Printer* printer) { } } printer->Print(") {\n"); - if (PreserveUnknownFields(descriptor_)) { - if (UseUnknownFieldSet(descriptor_->file(), options_)) { - printer->Print( - " DO_(_extensions_.ParseField(tag, input, " - "internal_default_instance(),\n" - " mutable_unknown_fields()));\n"); - } else { - printer->Print( - " DO_(_extensions_.ParseField(tag, input, " - "internal_default_instance(),\n" - " &unknown_fields_stream));\n"); - } + if (UseUnknownFieldSet(descriptor_->file(), options_)) { + printer->Print(vars, + " DO_(_extensions_.ParseField(tag, input,\n" + " internal_default_instance(),\n" + " $mutable_unknown_fields$));\n"); } else { printer->Print( - // With static initializers. - " DO_(_extensions_.ParseField(tag, input, " - "internal_default_instance());\n"); + " DO_(_extensions_.ParseField(tag, input,\n" + " internal_default_instance(),\n" + " &unknown_fields_stream));\n"); } printer->Print( " continue;\n" @@ -3509,19 +3688,14 @@ GenerateMergeFromCodedStream(io::Printer* printer) { } // We really don't recognize this tag. Skip it. - if (PreserveUnknownFields(descriptor_)) { - if (UseUnknownFieldSet(descriptor_->file(), options_)) { - printer->Print( + if (UseUnknownFieldSet(descriptor_->file(), options_)) { + printer->Print(vars, "DO_(::google::protobuf::internal::WireFormat::SkipField(\n" - " input, tag, mutable_unknown_fields()));\n"); - } else { - printer->Print( - "DO_(::google::protobuf::internal::WireFormatLite::SkipField(\n" - " input, tag, &unknown_fields_stream));\n"); - } + " input, tag, $mutable_unknown_fields$));\n"); } else { printer->Print( - "DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag));\n"); + "DO_(::google::protobuf::internal::WireFormatLite::SkipField(\n" + " input, tag, &unknown_fields_stream));\n"); } if (descriptor_->field_count() > 0) { @@ -3658,13 +3832,16 @@ GenerateSerializeWithCachedSizes(io::Printer* printer) { " _extensions_.SerializeMessageSetWithCachedSizes(output);\n", "classname", classname_); GOOGLE_CHECK(UseUnknownFieldSet(descriptor_->file(), options_)); - printer->Print( + std::map<string, string> vars; + SetUnknkownFieldsVariable(descriptor_, options_, &vars); + printer->Print(vars, " ::google::protobuf::internal::WireFormat::SerializeUnknownMessageSetItems(\n" - " unknown_fields(), output);\n"); + " $unknown_fields$, output);\n"); printer->Print( "}\n"); return; } + if (options_.table_driven_serialization) return; printer->Print( "void $classname$::SerializeWithCachedSizes(\n" @@ -3699,10 +3876,12 @@ GenerateSerializeWithCachedSizesToArray(io::Printer* printer) { " deterministic, target);\n", "classname", classname_); GOOGLE_CHECK(UseUnknownFieldSet(descriptor_->file(), options_)); - printer->Print( + std::map<string, string> vars; + SetUnknkownFieldsVariable(descriptor_, options_, &vars); + printer->Print(vars, " target = ::google::protobuf::internal::WireFormat::\n" " SerializeUnknownMessageSetItemsToArray(\n" - " unknown_fields(), target);\n"); + " $unknown_fields$, target);\n"); printer->Print( " return target;\n" "}\n"); @@ -3715,6 +3894,7 @@ GenerateSerializeWithCachedSizesToArray(io::Printer* printer) { "classname", classname_); printer->Indent(); + printer->Print("(void)deterministic; // Unused\n"); printer->Print( "// @@protoc_insertion_point(serialize_to_array_start:$full_name$)\n", "full_name", descriptor_->full_name()); @@ -3866,29 +4046,29 @@ GenerateSerializeWithCachedSizesBody(io::Printer* printer, bool to_array) { } } - if (PreserveUnknownFields(descriptor_)) { - if (UseUnknownFieldSet(descriptor_->file(), options_)) { - printer->Print("if (_internal_metadata_.have_unknown_fields()) {\n"); - printer->Indent(); - if (to_array) { - printer->Print( - "target = " - "::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(\n" - " unknown_fields(), target);\n"); - } else { - printer->Print( - "::google::protobuf::internal::WireFormat::SerializeUnknownFields(\n" - " unknown_fields(), output);\n"); - } - printer->Outdent(); - - printer->Print( - "}\n"); + std::map<string, string> vars; + SetUnknkownFieldsVariable(descriptor_, options_, &vars); + if (UseUnknownFieldSet(descriptor_->file(), options_)) { + printer->Print(vars, + "if ($have_unknown_fields$) {\n"); + printer->Indent(); + if (to_array) { + printer->Print(vars, + "target = " + "::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(\n" + " $unknown_fields$, target);\n"); } else { - printer->Print( - "output->WriteRaw(unknown_fields().data(),\n" - " static_cast<int>(unknown_fields().size()));\n"); + printer->Print(vars, + "::google::protobuf::internal::WireFormat::SerializeUnknownFields(\n" + " $unknown_fields$, output);\n"); } + printer->Outdent(); + + printer->Print("}\n"); + } else { + printer->Print(vars, + "output->WriteRaw($unknown_fields$.data(),\n" + " static_cast<int>($unknown_fields$.size()));\n"); } } @@ -3932,18 +4112,19 @@ void MessageGenerator:: GenerateByteSize(io::Printer* printer) { if (descriptor_->options().message_set_wire_format()) { // Special-case MessageSet. - printer->Print( - "size_t $classname$::ByteSizeLong() const {\n" - "// @@protoc_insertion_point(message_set_byte_size_start:$full_name$)\n" - " size_t total_size = _extensions_.MessageSetByteSize();\n", - "classname", classname_, "full_name", descriptor_->full_name()); GOOGLE_CHECK(UseUnknownFieldSet(descriptor_->file(), options_)); - printer->Print( - "if (_internal_metadata_.have_unknown_fields()) {\n" - " total_size += ::google::protobuf::internal::WireFormat::\n" - " ComputeUnknownMessageSetItemsSize(unknown_fields());\n" - "}\n"); - printer->Print( + std::map<string, string> vars; + SetUnknkownFieldsVariable(descriptor_, options_, &vars); + vars["classname"] = classname_; + vars["full_name"] = descriptor_->full_name(); + printer->Print(vars, + "size_t $classname$::ByteSizeLong() const {\n" + "// @@protoc_insertion_point(message_set_byte_size_start:$full_name$)\n" + " size_t total_size = _extensions_.MessageSetByteSize();\n" + " if ($have_unknown_fields$) {\n" + " total_size += ::google::protobuf::internal::WireFormat::\n" + " ComputeUnknownMessageSetItemsSize($unknown_fields$);\n" + " }\n" " int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);\n" " GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n" " _cached_size_ = cached_size;\n" @@ -3997,19 +4178,19 @@ GenerateByteSize(io::Printer* printer) { "\n"); } - if (PreserveUnknownFields(descriptor_)) { - if (UseUnknownFieldSet(descriptor_->file(), options_)) { - printer->Print( - "if (_internal_metadata_.have_unknown_fields()) {\n" - " total_size +=\n" - " ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(\n" - " unknown_fields());\n" - "}\n"); - } else { - printer->Print( - "total_size += unknown_fields().size();\n" - "\n"); - } + std::map<string, string> vars; + SetUnknkownFieldsVariable(descriptor_, options_, &vars); + if (UseUnknownFieldSet(descriptor_->file(), options_)) { + printer->Print(vars, + "if ($have_unknown_fields$) {\n" + " total_size +=\n" + " ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(\n" + " $unknown_fields$);\n" + "}\n"); + } else { + printer->Print(vars, + "total_size += $unknown_fields$.size();\n" + "\n"); } // Handle required fields (if any). We expect all of them to be @@ -4050,28 +4231,30 @@ GenerateByteSize(io::Printer* printer) { } } - int last_i = -1; - for (int i = 0; i < optimized_order_.size(); ) { - // Detect infinite loops. - GOOGLE_CHECK_NE(i, last_i); - last_i = i; + std::vector<std::vector<const FieldDescriptor*> > chunks = CollectFields( + optimized_order_, + MatchRepeatedAndHasByteAndRequired( + &has_bit_indices_, HasFieldPresence(descriptor_->file()))); - // Skip required fields. - for (; i < optimized_order_.size() && - optimized_order_[i]->is_required(); i++) { - } + // Remove chunks with required fields. + chunks.erase(std::remove_if(chunks.begin(), chunks.end(), IsRequired), + chunks.end()); + + for (int chunk_index = 0; chunk_index < chunks.size(); chunk_index++) { + const std::vector<const FieldDescriptor*>& chunk = chunks[chunk_index]; + GOOGLE_CHECK(!chunk.empty()); // Handle repeated fields. - for (; i < optimized_order_.size(); i++) { - const FieldDescriptor* field = optimized_order_[i]; - if (!field->is_repeated()) { - break; - } + if (chunk.front()->is_repeated()) { + for (int i = 0; i < chunk.size(); i++) { + const FieldDescriptor* field = chunk[i]; - PrintFieldComment(printer, field); - const FieldGenerator& generator = field_generators_.get(field); - generator.GenerateByteSize(printer); - printer->Print("\n"); + PrintFieldComment(printer, field); + const FieldGenerator& generator = field_generators_.get(field); + generator.GenerateByteSize(printer); + printer->Print("\n"); + } + continue; } // Handle optional (non-repeated/oneof) fields. @@ -4083,92 +4266,62 @@ GenerateByteSize(io::Printer* printer) { // descriptor_->field(8), descriptor_->field(9), ... // descriptor_->field(15), // etc. - int last_chunk = -1; - int last_chunk_start = -1; - int last_chunk_end = -1; - uint32 last_chunk_mask = 0; - for (; i < optimized_order_.size(); i++) { - const FieldDescriptor* field = optimized_order_[i]; - if (field->is_repeated() || field->is_required()) { - break; - } + int last_chunk = HasFieldPresence(descriptor_->file()) + ? has_bit_indices_[chunk.front()->index()] / 8 + : 0; + GOOGLE_DCHECK_NE(-1, last_chunk); - // "index" defines where in the _has_bits_ the field appears. - // "i" is our loop counter within optimized_order_. - int index = HasFieldPresence(descriptor_->file()) ? - has_bit_indices_[field->index()] : 0; - int chunk = index / 8; + const bool have_outer_if = + HasFieldPresence(descriptor_->file()) && chunk.size() > 1; - if (last_chunk == -1) { - last_chunk = chunk; - last_chunk_start = i; - } else if (chunk != last_chunk) { - // Emit the fields for this chunk so far. - break; - } + if (have_outer_if) { + uint32 last_chunk_mask = GenChunkMask(chunk, has_bit_indices_); + const int count = popcnt(last_chunk_mask); - last_chunk_end = i; - last_chunk_mask |= static_cast<uint32>(1) << (index % 32); - } + // Check (up to) 8 has_bits at a time if we have more than one field in + // this chunk. Due to field layout ordering, we may check + // _has_bits_[last_chunk * 8 / 32] multiple times. + GOOGLE_DCHECK_LE(2, count); + GOOGLE_DCHECK_GE(8, count); - if (last_chunk != -1) { - GOOGLE_DCHECK_NE(-1, last_chunk_start); - GOOGLE_DCHECK_NE(-1, last_chunk_end); - GOOGLE_DCHECK_NE(0, last_chunk_mask); + printer->Print("if (_has_bits_[$index$ / 32] & $mask$u) {\n", "index", + SimpleItoa(last_chunk * 8), "mask", + SimpleItoa(last_chunk_mask)); + printer->Indent(); + } - const int count = popcnt(last_chunk_mask); - const bool have_outer_if = HasFieldPresence(descriptor_->file()) && - (last_chunk_start != last_chunk_end); + // Go back and emit checks for each of the fields we processed. + for (int j = 0; j < chunk.size(); j++) { + const FieldDescriptor* field = chunk[j]; + const FieldGenerator& generator = field_generators_.get(field); - if (have_outer_if) { - // Check (up to) 8 has_bits at a time if we have more than one field in - // this chunk. Due to field layout ordering, we may check - // _has_bits_[last_chunk * 8 / 32] multiple times. - GOOGLE_DCHECK_LE(2, count); - GOOGLE_DCHECK_GE(8, count); + PrintFieldComment(printer, field); - printer->Print( - "if (_has_bits_[$index$ / 32] & $mask$u) {\n", - "index", SimpleItoa(last_chunk * 8), - "mask", SimpleItoa(last_chunk_mask)); + bool have_enclosing_if = false; + if (HasFieldPresence(descriptor_->file())) { + printer->Print("if (has_$name$()) {\n", "name", FieldName(field)); printer->Indent(); + have_enclosing_if = true; + } else { + // Without field presence: field is serialized only if it has a + // non-default value. + have_enclosing_if = + EmitFieldNonDefaultCondition(printer, "this->", field); } - // Go back and emit checks for each of the fields we processed. - for (int j = last_chunk_start; j <= last_chunk_end; j++) { - const FieldDescriptor* field = optimized_order_[j]; - const FieldGenerator& generator = field_generators_.get(field); - - PrintFieldComment(printer, field); - - bool have_enclosing_if = false; - if (HasFieldPresence(descriptor_->file())) { - printer->Print( - "if (has_$name$()) {\n", - "name", FieldName(field)); - printer->Indent(); - have_enclosing_if = true; - } else { - // Without field presence: field is serialized only if it has a - // non-default value. - have_enclosing_if = EmitFieldNonDefaultCondition( - printer, "this->", field); - } - - generator.GenerateByteSize(printer); + generator.GenerateByteSize(printer); - if (have_enclosing_if) { - printer->Outdent(); - printer->Print( + if (have_enclosing_if) { + printer->Outdent(); + printer->Print( "}\n" "\n"); - } } + } - if (have_outer_if) { - printer->Outdent(); - printer->Print("}\n"); - } + if (have_outer_if) { + printer->Outdent(); + printer->Print("}\n"); } } @@ -4268,10 +4421,17 @@ GenerateIsInitialized(io::Printer* printer) { !ShouldIgnoreRequiredFieldCheck(field, options_) && scc_analyzer_->HasRequiredFields(field->message_type())) { if (field->is_repeated()) { - printer->Print( - "if (!::google::protobuf::internal::AllAreInitialized(this->$name$()))" - " return false;\n", - "name", FieldName(field)); + if (IsImplicitWeakField(field, options_)) { + printer->Print( + "if (!::google::protobuf::internal::AllAreInitializedWeak(this->$name$_))" + " return false;\n", + "name", FieldName(field)); + } else { + printer->Print( + "if (!::google::protobuf::internal::AllAreInitialized(this->$name$()))" + " return false;\n", + "name", FieldName(field)); + } } else if (field->options().weak()) { continue; } else { @@ -4358,7 +4518,6 @@ GenerateIsInitialized(io::Printer* printer) { "}\n"); } - } // namespace cpp } // namespace compiler } // namespace protobuf diff --git a/src/google/protobuf/compiler/cpp/cpp_message.h b/src/google/protobuf/compiler/cpp/cpp_message.h index 23aaeeb0..06e2030b 100644 --- a/src/google/protobuf/compiler/cpp/cpp_message.h +++ b/src/google/protobuf/compiler/cpp/cpp_message.h @@ -43,6 +43,7 @@ #include <string> #include <google/protobuf/compiler/cpp/cpp_field.h> #include <google/protobuf/compiler/cpp/cpp_helpers.h> +#include <google/protobuf/compiler/cpp/cpp_message_layout_helper.h> #include <google/protobuf/compiler/cpp/cpp_options.h> namespace google { @@ -62,12 +63,10 @@ class ExtensionGenerator; // extension.h class MessageGenerator { public: // See generator.cc for the meaning of dllexport_decl. - MessageGenerator(const Descriptor* descriptor, const Options& options, - SCCAnalyzer* scc_analyzer); + MessageGenerator(const Descriptor* descriptor, int index_in_file_messages, + const Options& options, SCCAnalyzer* scc_analyzer); ~MessageGenerator(); - // Appends the pre-order walk of the nested generators to list. - void Flatten(std::vector<MessageGenerator*>* list); // Append the two types of nested generators to the corresponding vector. void AddGenerators(std::vector<EnumGenerator*>* enum_generators, std::vector<ExtensionGenerator*>* extension_generators); @@ -86,7 +85,7 @@ class MessageGenerator { // Generate definitions of inline methods (placed at the end of the header // file). - void GenerateInlineMethods(io::Printer* printer, bool is_inline); + void GenerateInlineMethods(io::Printer* printer); // Dependent methods are always inline. void GenerateDependentInlineMethods(io::Printer* printer); @@ -96,28 +95,27 @@ class MessageGenerator { // Generate extra fields void GenerateExtraDefaultFields(io::Printer* printer); - // Generates code that allocates the message's default instance. - void GenerateDefaultInstanceAllocator(io::Printer* printer); + // Generates code that creates default instances for fields. + void GenerateFieldDefaultInstances(io::Printer* printer); // Generates code that initializes the message's default instance. This // is separate from allocating because all default instances must be // allocated before any can be initialized. void GenerateDefaultInstanceInitializer(io::Printer* printer); - // Generates code that should be run when ShutdownProtobufLibrary() is called, - // to delete all dynamically-allocated objects. - void GenerateShutdownCode(io::Printer* printer); - // Generate all non-inline methods for this class. void GenerateClassMethods(io::Printer* printer); + // Generate source file code that should go outside any namespace. + void GenerateSourceInProto2Namespace(io::Printer* printer); + private: // Generate declarations and definitions of accessors for fields. void GenerateDependentBaseClassDefinition(io::Printer* printer); void GenerateDependentFieldAccessorDeclarations(io::Printer* printer); void GenerateFieldAccessorDeclarations(io::Printer* printer); void GenerateDependentFieldAccessorDefinitions(io::Printer* printer); - void GenerateFieldAccessorDefinitions(io::Printer* printer, bool is_inline); + void GenerateFieldAccessorDefinitions(io::Printer* printer); // Generate the table-driven parsing array. Returns the number of entries // generated. @@ -132,6 +130,9 @@ class MessageGenerator { // of entries generated and the index of the first has_bit entry. std::pair<size_t, size_t> GenerateOffsets(io::Printer* printer); void GenerateSchema(io::Printer* printer, int offset, int has_offset); + // For each field generates a table entry describing the field for the + // table driven serializer. + int GenerateFieldMetadata(io::Printer* printer); // Generate constructors and destructor. void GenerateStructors(io::Printer* printer); @@ -147,6 +148,13 @@ class MessageGenerator { // Generate the arena-specific destructor code. void GenerateArenaDestructorCode(io::Printer* printer); + // Helper for GenerateClear and others. Optionally emits a condition that + // assumes the existence of the cached_has_bits variable, and returns true if + // the condition was printed. + bool MaybeGenerateOptionalFieldCondition(io::Printer* printer, + const FieldDescriptor* field, + int expected_has_bits_index); + // Generate standard Message methods. void GenerateClear(io::Printer* printer); void GenerateOneofClear(io::Printer* printer); @@ -179,13 +187,12 @@ class MessageGenerator { io::Printer* printer, const Descriptor::ExtensionRange* range, bool unbounded); - // Generates has_foo() functions and variables for singular field has-bits. void GenerateSingularFieldHasBits(const FieldDescriptor* field, std::map<string, string> vars, io::Printer* printer); // Generates has_foo() functions and variables for oneof field has-bits. - void GenerateOneofHasBits(io::Printer* printer, bool is_inline); + void GenerateOneofHasBits(io::Printer* printer); // Generates has_foo_bar() functions for oneof members. void GenerateOneofMemberHasBits(const FieldDescriptor* field, const std::map<string, string>& vars, @@ -193,6 +200,7 @@ class MessageGenerator { // Generates the clear_foo() method for a field. void GenerateFieldClear(const FieldDescriptor* field, const std::map<string, string>& vars, + bool is_inline, io::Printer* printer); void GenerateConstructorBody(io::Printer* printer, @@ -203,6 +211,7 @@ class MessageGenerator { std::vector<uint32> RequiredFieldsBitMask() const; const Descriptor* descriptor_; + int index_in_file_messages_; string classname_; Options options_; FieldGeneratorMap field_generators_; @@ -213,7 +222,6 @@ class MessageGenerator { std::vector<const FieldDescriptor *> optimized_order_; std::vector<int> has_bit_indices_; int max_has_bit_index_; - google::protobuf::scoped_array<google::protobuf::scoped_ptr<MessageGenerator> > nested_generators_; google::protobuf::scoped_array<google::protobuf::scoped_ptr<EnumGenerator> > enum_generators_; google::protobuf::scoped_array<google::protobuf::scoped_ptr<ExtensionGenerator> > extension_generators_; int num_required_fields_; @@ -222,9 +230,10 @@ class MessageGenerator { // table_driven_ indicates the generated message uses table-driven parsing. bool table_driven_; - int index_in_file_messages_; + google::protobuf::scoped_ptr<MessageLayoutHelper> message_layout_helper_; SCCAnalyzer* scc_analyzer_; + string scc_name_; friend class FileGenerator; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageGenerator); diff --git a/src/google/protobuf/compiler/cpp/cpp_message_field.cc b/src/google/protobuf/compiler/cpp/cpp_message_field.cc index fc3c4564..530a6392 100644 --- a/src/google/protobuf/compiler/cpp/cpp_message_field.cc +++ b/src/google/protobuf/compiler/cpp/cpp_message_field.cc @@ -45,15 +45,44 @@ namespace cpp { namespace { +// When we are generating code for implicit weak fields, we need to insert some +// additional casts. These functions return the casted expression if +// implicit_weak_field is true but otherwise return the original expression. +// Ordinarily a static_cast is enough to cast google::protobuf::MessageLite* to a class +// deriving from it, but we need a reinterpret_cast in cases where the generated +// message is forward-declared but its full definition is not visible. +string StaticCast(const string& type, const string& expression, + bool implicit_weak_field) { + if (implicit_weak_field) { + return "static_cast< " + type + " >(" + expression + ")"; + } else { + return expression; + } +} + +string ReinterpretCast(const string& type, const string& expression, + bool implicit_weak_field) { + if (implicit_weak_field) { + return "reinterpret_cast< " + type + " >(" + expression + ")"; + } else { + return expression; + } +} + void SetMessageVariables(const FieldDescriptor* descriptor, std::map<string, string>* variables, const Options& options) { SetCommonFieldVariables(descriptor, variables, options); (*variables)["type"] = FieldMessageTypeName(descriptor); - if (descriptor->options().weak() || !descriptor->containing_oneof()) { - (*variables)["non_null_ptr_to_name"] = - StrCat("this->", (*variables)["name"], "_"); - } + (*variables)["casted_member"] = + ReinterpretCast((*variables)["type"] + "*", (*variables)["name"] + "_", + IsImplicitWeakField(descriptor, options)); + (*variables)["type_default_instance"] = + DefaultInstanceName(descriptor->message_type()); + (*variables)["type_reference_function"] = + IsImplicitWeakField(descriptor, options) + ? (" " + ReferenceFunctionName(descriptor->message_type()) + "();\n") + : ""; (*variables)["stream_writer"] = (*variables)["declared_type"] + (HasFastArraySerialization(descriptor->message_type()->file(), options) @@ -65,14 +94,8 @@ void SetMessageVariables(const FieldDescriptor* descriptor, SafeFunctionName(descriptor->containing_type(), descriptor, "release_"); (*variables)["full_name"] = descriptor->full_name(); - if (options.proto_h && IsFieldDependent(descriptor)) { - (*variables)["dependent_type"] = "T::" + DependentTypeName(descriptor); - (*variables)["dependent_typename"] = - "typename T::" + DependentTypeName(descriptor); - } else { - (*variables)["dependent_type"] = FieldMessageTypeName(descriptor); - (*variables)["dependent_typename"] = FieldMessageTypeName(descriptor); - } + (*variables)["create_func"] = + MessageCreateFunction(descriptor->message_type()); } } // namespace @@ -83,7 +106,7 @@ MessageFieldGenerator::MessageFieldGenerator(const FieldDescriptor* descriptor, const Options& options) : FieldGenerator(options), descriptor_(descriptor), - dependent_field_(options.proto_h && IsFieldDependent(descriptor)) { + implicit_weak_field_(IsImplicitWeakField(descriptor, options)) { SetMessageVariables(descriptor, &variables_, options); } @@ -91,108 +114,85 @@ MessageFieldGenerator::~MessageFieldGenerator() {} void MessageFieldGenerator:: GeneratePrivateMembers(io::Printer* printer) const { - printer->Print(variables_, "$type$* $name$_;\n"); -} - -void MessageFieldGenerator:: -GenerateGetterDeclaration(io::Printer* printer) const { - printer->Print(variables_, - "$deprecated_attr$const $type$& $name$() const;\n"); -} - -void MessageFieldGenerator:: -GenerateDependentAccessorDeclarations(io::Printer* printer) const { - if (!dependent_field_) { - return; + if (implicit_weak_field_) { + printer->Print(variables_, "google::protobuf::MessageLite* $name$_;\n"); + } else { + printer->Print(variables_, "$type$* $name$_;\n"); } - // Arena manipulation code is out-of-line in the derived message class. - printer->Print(variables_, - "$deprecated_attr$$type$* mutable_$name$();\n" - "$deprecated_attr$$type$* $release_name$();\n" - "$deprecated_attr$void set_allocated_$name$($type$* $name$);\n"); } void MessageFieldGenerator:: GenerateAccessorDeclarations(io::Printer* printer) const { - if (SupportsArenas(descriptor_)) { + if (implicit_weak_field_) { + // These private accessors are used by MergeFrom and + // MergePartialFromCodedStream, and their purpose is to provide access to + // the field without creating a strong dependency on the message type. printer->Print(variables_, "private:\n" - "void _slow_mutable_$name$();\n"); - if (SupportsArenas(descriptor_->message_type())) { - printer->Print(variables_, - "void _slow_set_allocated_$name$(\n" - " ::google::protobuf::Arena* message_arena, $type$** $name$);\n"); - } - printer->Print(variables_, - "$type$* _slow_$release_name$();\n" + "const google::protobuf::MessageLite& _internal_$name$() const;\n" + "google::protobuf::MessageLite* _internal_mutable_$name$();\n" "public:\n"); } - GenerateGetterDeclaration(printer); - if (!dependent_field_) { - printer->Print(variables_, - "$deprecated_attr$$type$* mutable_$name$();\n" - "$deprecated_attr$$type$* $release_name$();\n" - "$deprecated_attr$void set_allocated_$name$($type$* $name$);\n"); - } + printer->Print(variables_, + "$deprecated_attr$const $type$& $name$() const;\n"); + printer->Annotate("name", descriptor_); + printer->Print(variables_, "$deprecated_attr$$type$* $release_name$();\n"); + printer->Annotate("release_name", descriptor_); + printer->Print(variables_, + "$deprecated_attr$$type$* ${$mutable_$name$$}$();\n"); + printer->Annotate("{", "}", descriptor_); + printer->Print(variables_, + "$deprecated_attr$void ${$set_allocated_$name$$}$" + "($type$* $name$);\n"); + printer->Annotate("{", "}", descriptor_); if (SupportsArenas(descriptor_)) { printer->Print(variables_, - "$deprecated_attr$$type$* unsafe_arena_release_$name$();\n" - "$deprecated_attr$void unsafe_arena_set_allocated_$name$(\n" - " $type$* $name$);\n"); + "$deprecated_attr$void " + "${$unsafe_arena_set_allocated_$name$$}$(\n" + " $type$* $name$);\n"); + printer->Annotate("{", "}", descriptor_); + printer->Print( + variables_, + "$deprecated_attr$$type$* ${$unsafe_arena_release_$name$$}$();\n"); + printer->Annotate("{", "}", descriptor_); } } void MessageFieldGenerator::GenerateNonInlineAccessorDefinitions( io::Printer* printer) const { - if (SupportsArenas(descriptor_)) { + if (implicit_weak_field_) { printer->Print(variables_, - "void $classname$::_slow_mutable_$name$() {\n"); - if (SupportsArenas(descriptor_->message_type())) { - printer->Print(variables_, - " $name$_ = ::google::protobuf::Arena::CreateMessage< $type$ >(\n" - " GetArenaNoVirtual());\n"); - } else { - printer->Print(variables_, - " $name$_ = ::google::protobuf::Arena::Create< $type$ >(\n" - " GetArenaNoVirtual());\n"); - } - printer->Print(variables_, - "}\n" - "$type$* $classname$::_slow_$release_name$() {\n" - " if ($name$_ == NULL) {\n" - " return NULL;\n" + "const google::protobuf::MessageLite& $classname$::_internal_$name$() const {\n" + " if ($name$_ != NULL) {\n" + " return *$name$_;\n" + " } else if (&$type_default_instance$ != NULL) {\n" + " return *reinterpret_cast<const google::protobuf::MessageLite*>(\n" + " &$type_default_instance$);\n" " } else {\n" - " $type$* temp = new $type$(*$name$_);\n" - " $name$_ = NULL;\n" - " return temp;\n" + " return *reinterpret_cast<const google::protobuf::MessageLite*>(\n" + " &::google::protobuf::internal::implicit_weak_message_default_instance);\n" " }\n" - "}\n" - "$type$* $classname$::unsafe_arena_release_$name$() {\n" - " // @@protoc_insertion_point(field_unsafe_arena_release:$full_name$)\n" - " $clear_hasbit$\n" - " $type$* temp = $name$_;\n" - " $name$_ = NULL;\n" - " return temp;\n" "}\n"); - if (SupportsArenas(descriptor_->message_type())) { - // NOTE: the same logic is mirrored in weak_message_field.cc. Any - // arena-related semantics changes should be made in both places. + } + if (SupportsArenas(descriptor_)) { + if (implicit_weak_field_) { printer->Print(variables_, - "void $classname$::_slow_set_allocated_$name$(\n" - " ::google::protobuf::Arena* message_arena, $type$** $name$) {\n" - " if (message_arena != NULL && \n" - " ::google::protobuf::Arena::GetArena(*$name$) == NULL) {\n" - " message_arena->Own(*$name$);\n" - " } else if (message_arena !=\n" - " ::google::protobuf::Arena::GetArena(*$name$)) {\n" - " $type$* new_$name$ = \n" - " ::google::protobuf::Arena::CreateMessage< $type$ >(\n" - " message_arena);\n" - " new_$name$->CopyFrom(**$name$);\n" - " *$name$ = new_$name$;\n" - " }\n" - "}\n"); + "google::protobuf::MessageLite* $classname$::_internal_mutable_$name$() {\n" + " $set_hasbit$\n" + " if ($name$_ == NULL) {\n" + " if (&$type_default_instance$ == NULL) {\n" + " $name$_ = ::google::protobuf::Arena::CreateMessage<\n" + " ::google::protobuf::internal::ImplicitWeakMessage>(\n" + " GetArenaNoVirtual());\n" + " } else {\n" + " $name$_ = reinterpret_cast<const google::protobuf::MessageLite*>(\n" + " &$type_default_instance$)->New(GetArenaNoVirtual());\n" + " }\n" + " }\n" + " return $name$_;\n" + "}\n"); } + printer->Print(variables_, "void $classname$::unsafe_arena_set_allocated_$name$(\n" " $type$* $name$) {\n" @@ -210,279 +210,148 @@ void MessageFieldGenerator::GenerateNonInlineAccessorDefinitions( " // @@protoc_insertion_point(field_unsafe_arena_set_allocated" ":$full_name$)\n" "}\n"); + } else if (implicit_weak_field_) { + printer->Print(variables_, + "google::protobuf::MessageLite* $classname$::_internal_mutable_$name$() {\n" + " $set_hasbit$\n" + " if ($name$_ == NULL) {\n" + " if (&$type_default_instance$ == NULL) {\n" + " $name$_ = new ::google::protobuf::internal::ImplicitWeakMessage;\n" + " } else {\n" + " $name$_ = reinterpret_cast<const google::protobuf::MessageLite*>(\n" + " &$type_default_instance$)->New();\n" + " }\n" + " }\n" + " return $name$_;\n" + "}\n"); } } void MessageFieldGenerator:: -GenerateDependentInlineAccessorDefinitions(io::Printer* printer) const { - if (!dependent_field_) { - return; - } +GenerateInlineAccessorDefinitions(io::Printer* printer) const { + printer->Print(variables_, + "inline const $type$& $classname$::$name$() const {\n" + "$type_reference_function$" + " const $type$* p = $casted_member$;\n" + " // @@protoc_insertion_point(field_get:$full_name$)\n" + " return p != NULL ? *p : *reinterpret_cast<const $type$*>(\n" + " &$type_default_instance$);\n" + "}\n"); - std::map<string, string> variables(variables_); - // For the CRTP base class, all mutation methods are dependent, and so - // they must be in the header. - variables["dependent_classname"] = - DependentBaseClassTemplateName(descriptor_->containing_type()) + "<T>"; - variables["this_message"] = DependentBaseDownCast(); - if (!variables["set_hasbit"].empty()) { - variables["set_hasbit"] = - variables["this_message"] + variables["set_hasbit"]; - } - if (!variables["clear_hasbit"].empty()) { - variables["clear_hasbit"] = - variables["this_message"] + variables["clear_hasbit"]; + printer->Print(variables_, + "inline $type$* $classname$::$release_name$() {\n" + " // @@protoc_insertion_point(field_release:$full_name$)\n" + "$type_reference_function$" + " $clear_hasbit$\n" + " $type$* temp = $casted_member$;\n"); + if (SupportsArenas(descriptor_)) { + printer->Print(variables_, + " if (GetArenaNoVirtual() != NULL) {\n" + " temp = ::google::protobuf::internal::DuplicateIfNonNull(temp, NULL);\n" + " }\n"); } + printer->Print(variables_, + " $name$_ = NULL;\n" + " return temp;\n" + "}\n"); if (SupportsArenas(descriptor_)) { - printer->Print(variables, - "template <class T>\n" - "inline $type$* $dependent_classname$::mutable_$name$() {\n" - " $set_hasbit$\n" - " $dependent_typename$*& $name$_ = $this_message$$name$_;\n" - " if ($name$_ == NULL) {\n" - " $this_message$_slow_mutable_$name$();\n" - " }\n" - " // @@protoc_insertion_point(field_mutable:$full_name$)\n" - " return $name$_;\n" - "}\n" - "template <class T>\n" - "inline $type$* $dependent_classname$::$release_name$() {\n" - " // @@protoc_insertion_point(field_release:$full_name$)\n" - " $dependent_typename$*& $name$_ = $this_message$$name$_;\n" - " $clear_hasbit$\n" - " if ($this_message$GetArenaNoVirtual() != NULL) {\n" - " return $this_message$_slow_$release_name$();\n" - " } else {\n" - " $dependent_typename$* temp = $name$_;\n" - " $name$_ = NULL;\n" - " return temp;\n" - " }\n" - "}\n" - "template <class T>\n" - "inline void $dependent_classname$::" - "set_allocated_$name$($type$* $name$) {\n" - " ::google::protobuf::Arena* message_arena = $this_message$GetArenaNoVirtual();\n" - " $dependent_typename$*& $name$_ = $this_message$$name$_;\n" - " if (message_arena == NULL) {\n" - " delete $name$_;\n" - " }\n" - " if ($name$ != NULL) {\n"); - if (SupportsArenas(descriptor_->message_type())) { - // If we're on an arena and the incoming message is not, simply Own() it - // rather than copy to the arena -- either way we need a heap dealloc, - // so we might as well defer it. Otherwise, if incoming message is on a - // different ownership domain (specific arena, or the heap) than we are, - // copy to our arena (or heap, as the case may be). - printer->Print(variables, - " $this_message$_slow_set_allocated_$name$(message_arena, " - "&$name$);\n"); - } else { - printer->Print(variables, - " if (message_arena != NULL) {\n" - " message_arena->Own($name$);\n" - " }\n"); - } - printer->Print(variables, - " }\n" - " $name$_ = $name$;\n" - " if ($name$) {\n" - " $set_hasbit$\n" - " } else {\n" - " $clear_hasbit$\n" - " }\n" - // TODO(dlj): move insertion points to message class. - " // @@protoc_insertion_point(field_set_allocated:$full_name$)\n" - "}\n"); - } else { - printer->Print(variables, - "template <class T>\n" - "inline $type$* $dependent_classname$::mutable_$name$() {\n" - " $set_hasbit$\n" - " $dependent_typename$*& $name$_ = $this_message$$name$_;\n" - " if ($name$_ == NULL) {\n" - " $name$_ = new $dependent_typename$;\n" - " }\n" - " // @@protoc_insertion_point(field_mutable:$full_name$)\n" - " return $name$_;\n" - "}\n" - "template <class T>\n" - "inline $type$* $dependent_classname$::$release_name$() {\n" - " // @@protoc_insertion_point(field_release:$full_name$)\n" + printer->Print(variables_, + "inline $type$* $classname$::unsafe_arena_release_$name$() {\n" + " // @@protoc_insertion_point(field_unsafe_arena_release:$full_name$)\n" + "$type_reference_function$" " $clear_hasbit$\n" - " $dependent_typename$*& $name$_ = $this_message$$name$_;\n" - " $dependent_typename$* temp = $name$_;\n" + " $type$* temp = $casted_member$;\n" " $name$_ = NULL;\n" " return temp;\n" - "}\n" - "template <class T>\n" - "inline void $dependent_classname$::" - "set_allocated_$name$($type$* $name$) {\n" - " $dependent_typename$*& $name$_ = $this_message$$name$_;\n" - " delete $name$_;\n"); - - if (SupportsArenas(descriptor_->message_type())) { - printer->Print(variables, - " if ($name$ != NULL && static_cast< $dependent_typename$* >($name$)" - "->GetArena() != NULL) {\n" - " $dependent_typename$* new_$name$ = new $dependent_typename$;\n" - " new_$name$->CopyFrom(*$name$);\n" - " $name$ = new_$name$;\n" - " }\n"); - } - - printer->Print(variables, - " $name$_ = $name$;\n" - " if ($name$) {\n" - " $set_hasbit$\n" - " } else {\n" - " $clear_hasbit$\n" - " }\n" - " // @@protoc_insertion_point(field_set_allocated:$full_name$)\n" "}\n"); } -} -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. - std::map<string, string> variables(variables_); - variables["inline"] = is_inline ? "inline " : ""; - printer->Print(variables, - "$inline$const $type$& $classname$::$name$() const {\n" - " // @@protoc_insertion_point(field_get:$full_name$)\n" - " return $name$_ != NULL ? *$name$_\n" - " : *internal_default_instance()->$name$_;\n" - "}\n"); - return; + printer->Print(variables_, + "inline $type$* $classname$::mutable_$name$() {\n" + "$type_reference_function$" + " $set_hasbit$\n" + " if ($name$_ == NULL) {\n"); + if (implicit_weak_field_) { + printer->Print(variables_, + " _internal_mutable_$name$();\n"); + } else { + printer->Print(variables_, + " $name$_ = ::google::protobuf::Arena::$create_func$< $type$ >(\n" + " GetArenaNoVirtual());\n"); } - - std::map<string, string> variables(variables_); - variables["inline"] = is_inline ? "inline " : ""; - printer->Print(variables, - "$inline$const $type$& $classname$::$name$() const {\n" - " // @@protoc_insertion_point(field_get:$full_name$)\n" - " return $name$_ != NULL ? *$name$_\n" - " : *$type$::internal_default_instance();\n" + printer->Print(variables_, + " }\n" + " // @@protoc_insertion_point(field_mutable:$full_name$)\n" + " return $casted_member$;\n" "}\n"); - if (SupportsArenas(descriptor_)) { - printer->Print(variables, - "$inline$" - "$type$* $classname$::mutable_$name$() {\n" - " $set_hasbit$\n" - " if ($name$_ == NULL) {\n" - " _slow_mutable_$name$();\n" - " }\n" - " // @@protoc_insertion_point(field_mutable:$full_name$)\n" - " return $name$_;\n" - "}\n" - "$inline$" - "$type$* $classname$::$release_name$() {\n" - " // @@protoc_insertion_point(field_release:$full_name$)\n" - " $clear_hasbit$\n" - " if (GetArenaNoVirtual() != NULL) {\n" - " return _slow_$release_name$();\n" - " } else {\n" - " $type$* temp = $name$_;\n" - " $name$_ = NULL;\n" - " return temp;\n" - " }\n" - "}\n" - "$inline$ " - "void $classname$::set_allocated_$name$($type$* $name$) {\n" - " ::google::protobuf::Arena* message_arena = GetArenaNoVirtual();\n" - " if (message_arena == NULL) {\n" - " delete $name$_;\n" - " }\n" - " if ($name$ != NULL) {\n"); - if (SupportsArenas(descriptor_->message_type())) { - // If we're on an arena and the incoming message is not, simply Own() it - // rather than copy to the arena -- either way we need a heap dealloc, - // so we might as well defer it. Otherwise, if incoming message is on a - // different ownership domain (specific arena, or the heap) than we are, - // copy to our arena (or heap, as the case may be). - printer->Print(variables, - " _slow_set_allocated_$name$(message_arena, &$name$);\n"); - } else { - printer->Print(variables, - " if (message_arena != NULL) {\n" - " message_arena->Own($name$);\n" - " }\n"); - } - printer->Print(variables, - " }\n" - " $name$_ = $name$;\n" - " if ($name$) {\n" - " $set_hasbit$\n" - " } else {\n" - " $clear_hasbit$\n" - " }\n" - " // @@protoc_insertion_point(field_set_allocated:$full_name$)\n" - "}\n"); + // We handle the most common case inline, and delegate less common cases to + // the slow fallback function. + printer->Print(variables_, + "inline void $classname$::set_allocated_$name$($type$* $name$) {\n" + " ::google::protobuf::Arena* message_arena = GetArenaNoVirtual();\n"); + printer->Print(variables_, + " if (message_arena == NULL) {\n"); + if (IsCrossFileMessage(descriptor_)) { + printer->Print(variables_, + " delete reinterpret_cast< ::google::protobuf::MessageLite*>($name$_);\n"); } else { - printer->Print(variables, - "$inline$" - "$type$* $classname$::mutable_$name$() {\n" - " $set_hasbit$\n" - " if ($name$_ == NULL) {\n" - " $name$_ = new $type$;\n" - " }\n" - " // @@protoc_insertion_point(field_mutable:$full_name$)\n" - " return $name$_;\n" - "}\n" - "$inline$" - "$type$* $classname$::$release_name$() {\n" - " // @@protoc_insertion_point(field_release:$full_name$)\n" - " $clear_hasbit$\n" - " $type$* temp = $name$_;\n" - " $name$_ = NULL;\n" - " return temp;\n" - "}\n" - "$inline$" - "void $classname$::set_allocated_$name$($type$* $name$) {\n" - " delete $name$_;\n"); - - if (SupportsArenas(descriptor_->message_type())) { - printer->Print(variables, - " if ($name$ != NULL && $name$->GetArena() != NULL) {\n" - " $type$* new_$name$ = new $type$;\n" - " new_$name$->CopyFrom(*$name$);\n" - " $name$ = new_$name$;\n" - " }\n"); - } - - printer->Print(variables, - " $name$_ = $name$;\n" - " if ($name$) {\n" - " $set_hasbit$\n" - " } else {\n" - " $clear_hasbit$\n" - " }\n" - " // @@protoc_insertion_point(field_set_allocated:$full_name$)\n" - "}\n"); + printer->Print(variables_, + " delete $name$_;\n"); + } + printer->Print(variables_, + " }\n" + " if ($name$) {\n"); + if (SupportsArenas(descriptor_->message_type()) && + IsCrossFileMessage(descriptor_)) { + // We have to read the arena through the virtual method, because the type + // isn't defined in this file. + printer->Print(variables_, + " ::google::protobuf::Arena* submessage_arena =\n" + " reinterpret_cast< ::google::protobuf::MessageLite*>($name$)->GetArena();\n"); + } else if (!SupportsArenas(descriptor_->message_type())) { + printer->Print(variables_, + " ::google::protobuf::Arena* submessage_arena = NULL;\n"); + } else { + printer->Print(variables_, + " ::google::protobuf::Arena* submessage_arena =\n" + " ::google::protobuf::Arena::GetArena($name$);\n"); } + printer->Print(variables_, + " if (message_arena != submessage_arena) {\n" + " $name$ = ::google::protobuf::internal::GetOwnedMessage(\n" + " message_arena, $name$, submessage_arena);\n" + " }\n" + " $set_hasbit$\n" + " } else {\n" + " $clear_hasbit$\n" + " }\n"); + if (implicit_weak_field_) { + printer->Print(variables_, + " $name$_ = reinterpret_cast<MessageLite*>($name$);\n"); + } else { + printer->Print(variables_, + " $name$_ = $name$;\n"); + } + printer->Print(variables_, + " // @@protoc_insertion_point(field_set_allocated:$full_name$)\n" + "}\n"); } void MessageFieldGenerator:: GenerateClearingCode(io::Printer* printer) const { - std::map<string, string> variables(variables_); - variables["this_message"] = dependent_field_ ? DependentBaseDownCast() : ""; if (!HasFieldPresence(descriptor_->file())) { // If we don't have has-bits, message presence is indicated only by ptr != // NULL. Thus on clear, we need to delete the object. - printer->Print(variables, - "if ($this_message$GetArenaNoVirtual() == NULL && " - "$this_message$$name$_ != NULL) delete $this_message$$name$_;\n" - "$this_message$$name$_ = NULL;\n"); + printer->Print(variables_, + "if (GetArenaNoVirtual() == NULL && $name$_ != NULL) {\n" + " delete $name$_;\n" + "}\n" + "$name$_ = NULL;\n"); } else { - printer->Print(variables, - "if ($this_message$$name$_ != NULL) $this_message$$name$_->" - "$dependent_type$::Clear();\n"); + printer->Print(variables_, + "if ($name$_ != NULL) $name$_->Clear();\n"); } } @@ -499,30 +368,36 @@ GenerateMessageClearingCode(io::Printer* printer) const { } else { printer->Print(variables_, "GOOGLE_DCHECK($name$_ != NULL);\n" - "$name$_->$type$::Clear();\n"); + "$name$_->Clear();\n"); } } void MessageFieldGenerator:: GenerateMergingCode(io::Printer* printer) const { - printer->Print(variables_, - "mutable_$name$()->$type$::MergeFrom(from.$name$());\n"); + if (implicit_weak_field_) { + printer->Print(variables_, + "_internal_mutable_$name$()->CheckTypeAndMergeFrom(\n" + " from._internal_$name$());\n"); + } else { + printer->Print(variables_, + "mutable_$name$()->$type$::MergeFrom(from.$name$());\n"); + } } void MessageFieldGenerator:: GenerateSwappingCode(io::Printer* printer) const { - printer->Print(variables_, "std::swap($name$_, other->$name$_);\n"); + printer->Print(variables_, "swap($name$_, other->$name$_);\n"); } void MessageFieldGenerator:: GenerateDestructorCode(io::Printer* printer) const { + // TODO(gerbens) Remove this when we don't need to destruct default instances. // In google3 a default instance will never get deleted so we don't need to // worry about that but in opensource protobuf default instances are deleted // in shutdown process and we need to take special care when handling them. printer->Print(variables_, - "if (this != internal_default_instance()) {\n" - " delete $name$_;\n" - "}\n"); + "if (this != internal_default_instance()) "); + printer->Print(variables_, "delete $name$_;\n"); } void MessageFieldGenerator:: @@ -532,25 +407,6 @@ GenerateConstructorCode(io::Printer* printer) const { void MessageFieldGenerator:: GenerateCopyConstructorCode(io::Printer* printer) const { - // For non-Arena enabled messages, everything always goes on the heap. - // - // For Arena enabled messages, the logic is a bit more convoluted. - // - // In the copy constructor, we call InternalMetadataWithArena::MergeFrom, - // which does *not* copy the Arena pointer. In the generated MergeFrom - // (see MessageFieldGenerator::GenerateMergingCode), we: - // -> copy the has bits (but this is done in bulk by a memcpy in the copy - // constructor) - // -> check whether the destination field pointer is NULL (it will be, since - // we're initializing it and would have called SharedCtor) and if so: - // -> call _slow_mutable_$name$(), which calls either - // ::google::protobuf::Arena::CreateMessage<>(GetArenaNoVirtual()), or - // ::google::protobuf::Arena::Create<>(GetArenaNoVirtual()) - // - // At this point, GetArenaNoVirtual returns NULL since the Arena pointer - // wasn't copied, so both of these methods allocate the submessage on the - // heap. - printer->Print(variables_, "if (from.has_$name$()) {\n" " $name$_ = new $type$(*from.$name$_);\n" @@ -561,13 +417,17 @@ GenerateCopyConstructorCode(io::Printer* printer) const { void MessageFieldGenerator:: GenerateMergeFromCodedStream(io::Printer* printer) const { - if (descriptor_->type() == FieldDescriptor::TYPE_MESSAGE) { + if (implicit_weak_field_) { printer->Print(variables_, - "DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(\n" + "DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(\n" + " input, _internal_mutable_$name$()));\n"); + } else if (descriptor_->type() == FieldDescriptor::TYPE_MESSAGE) { + printer->Print(variables_, + "DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(\n" " input, mutable_$name$()));\n"); } else { printer->Print(variables_, - "DO_(::google::protobuf::internal::WireFormatLite::ReadGroupNoVirtual(\n" + "DO_(::google::protobuf::internal::WireFormatLite::ReadGroup(\n" " $number$, input, mutable_$name$()));\n"); } } @@ -576,23 +436,23 @@ void MessageFieldGenerator:: GenerateSerializeWithCachedSizes(io::Printer* printer) const { printer->Print(variables_, "::google::protobuf::internal::WireFormatLite::Write$stream_writer$(\n" - " $number$, *$non_null_ptr_to_name$, output);\n"); + " $number$, *$field_member$, output);\n"); } void MessageFieldGenerator:: GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const { printer->Print(variables_, "target = ::google::protobuf::internal::WireFormatLite::\n" - " InternalWrite$declared_type$NoVirtualToArray(\n" - " $number$, *$non_null_ptr_to_name$, deterministic, target);\n"); + " InternalWrite$declared_type$ToArray(\n" + " $number$, *$field_member$, deterministic, target);\n"); } void MessageFieldGenerator:: GenerateByteSize(io::Printer* printer) const { printer->Print(variables_, "total_size += $tag_size$ +\n" - " ::google::protobuf::internal::WireFormatLite::$declared_type$SizeNoVirtual(\n" - " *$non_null_ptr_to_name$);\n"); + " ::google::protobuf::internal::WireFormatLite::$declared_type$Size(\n" + " *$field_member$);\n"); } // =================================================================== @@ -607,177 +467,85 @@ MessageOneofFieldGenerator(const FieldDescriptor* descriptor, MessageOneofFieldGenerator::~MessageOneofFieldGenerator() {} - -void MessageOneofFieldGenerator:: -GenerateDependentAccessorDeclarations(io::Printer* printer) const { - // Oneof field getters must be dependent as they call default_instance(). - // Otherwise, the logic is the same as MessageFields. - if (!dependent_field_) { - return; - } +void MessageOneofFieldGenerator::GenerateNonInlineAccessorDefinitions( + io::Printer* printer) const { printer->Print(variables_, - "$deprecated_attr$const $type$& $name$() const;\n"); - MessageFieldGenerator::GenerateDependentAccessorDeclarations(printer); -} - -void MessageOneofFieldGenerator:: -GenerateGetterDeclaration(io::Printer* printer) const { - // Oneof field getters must be dependent as they call default_instance(). - // Unlike MessageField, this means there is no (non-dependent) getter to - // generate. - if (dependent_field_) { - return; + "void $classname$::set_allocated_$name$($type$* $name$) {\n" + " ::google::protobuf::Arena* message_arena = GetArenaNoVirtual();\n" + " clear_$oneof_name$();\n" + " if ($name$) {\n"); + if (SupportsArenas(descriptor_->message_type()) && + descriptor_->file() != descriptor_->message_type()->file()) { + // We have to read the arena through the virtual method, because the type + // isn't defined in this file. + printer->Print(variables_, + " ::google::protobuf::Arena* submessage_arena =\n" + " reinterpret_cast< ::google::protobuf::MessageLite*>($name$)->GetArena();\n"); + } else if (!SupportsArenas(descriptor_->message_type())) { + printer->Print(variables_, + " ::google::protobuf::Arena* submessage_arena = NULL;\n"); + } else { + printer->Print(variables_, + " ::google::protobuf::Arena* submessage_arena =\n" + " ::google::protobuf::Arena::GetArena($name$);\n"); } printer->Print(variables_, - "$deprecated_attr$const $type$& $name$() const;\n"); -} - -void MessageOneofFieldGenerator:: -GenerateDependentInlineAccessorDefinitions(io::Printer* printer) const { - // For the CRTP base class, all mutation methods are dependent, and so - // they must be in the header. - if (!dependent_base_) { - return; - } - std::map<string, string> variables(variables_); - variables["inline"] = "inline "; - variables["dependent_classname"] = - DependentBaseClassTemplateName(descriptor_->containing_type()) + "<T>"; - variables["this_message"] = "reinterpret_cast<T*>(this)->"; - // Const message access is needed for the dependent getter. - variables["this_const_message"] = "reinterpret_cast<const T*>(this)->"; - variables["tmpl"] = "template <class T>\n"; - variables["field_member"] = variables["this_message"] + - variables["oneof_prefix"] + variables["name"] + - "_"; - InternalGenerateInlineAccessorDefinitions(variables, printer); + " if (message_arena != submessage_arena) {\n" + " $name$ = ::google::protobuf::internal::GetOwnedMessage(\n" + " message_arena, $name$, submessage_arena);\n" + " }\n" + " set_has_$name$();\n" + " $field_member$ = $name$;\n" + " }\n" + " // @@protoc_insertion_point(field_set_allocated:$full_name$)\n" + "}\n"); } void MessageOneofFieldGenerator:: -GenerateInlineAccessorDefinitions(io::Printer* printer, - bool is_inline) const { - if (dependent_base_) { - return; +GenerateInlineAccessorDefinitions(io::Printer* printer) const { + printer->Print(variables_, + "inline $type$* $classname$::$release_name$() {\n" + " // @@protoc_insertion_point(field_release:$full_name$)\n" + " if (has_$name$()) {\n" + " clear_has_$oneof_name$();\n" + " $type$* temp = $field_member$;\n"); + if (SupportsArenas(descriptor_)) { + printer->Print(variables_, + " if (GetArenaNoVirtual() != NULL) {\n" + " temp = ::google::protobuf::internal::DuplicateIfNonNull(temp, NULL);\n" + " }\n"); } - std::map<string, string> variables(variables_); - variables["inline"] = is_inline ? "inline " : ""; - variables["dependent_classname"] = variables["classname"]; - variables["this_message"] = ""; - variables["this_const_message"] = ""; - variables["tmpl"] = ""; - variables["field_member"] = - variables["oneof_prefix"] + variables["name"] + "_"; - variables["dependent_type"] = variables["type"]; - InternalGenerateInlineAccessorDefinitions(variables, printer); -} + printer->Print(variables_, + " $field_member$ = NULL;\n" + " return temp;\n" + " } else {\n" + " return NULL;\n" + " }\n" + "}\n"); -void MessageOneofFieldGenerator::InternalGenerateInlineAccessorDefinitions( - const std::map<string, string>& variables, io::Printer* printer) const { - printer->Print(variables, - "$tmpl$" - "$inline$ " - "const $type$& $dependent_classname$::$name$() const {\n" + printer->Print(variables_, + "inline const $type$& $classname$::$name$() const {\n" " // @@protoc_insertion_point(field_get:$full_name$)\n" - " return $this_const_message$has_$name$()\n" - " ? *$this_const_message$$oneof_prefix$$name$_\n" - " : $dependent_type$::default_instance();\n" + " return has_$name$()\n" + " ? *$field_member$\n" + " : *reinterpret_cast< $type$*>(&$type_default_instance$);\n" "}\n"); if (SupportsArenas(descriptor_)) { - printer->Print(variables, - "$tmpl$" - "$inline$" - "$type$* $dependent_classname$::mutable_$name$() {\n" - " if (!$this_message$has_$name$()) {\n" - " $this_message$clear_$oneof_name$();\n" - " $this_message$set_has_$name$();\n"); - if (SupportsArenas(descriptor_->message_type())) { - printer->Print(variables, - " $field_member$ = \n" - " ::google::protobuf::Arena::CreateMessage< $dependent_typename$ >(\n" - " $this_message$GetArenaNoVirtual());\n"); - } else { - printer->Print(variables, - " $this_message$$oneof_prefix$$name$_ = \n" - " ::google::protobuf::Arena::Create< $dependent_typename$ >(\n" - " $this_message$GetArenaNoVirtual());\n"); - } - printer->Print(variables, - " }\n" - " // @@protoc_insertion_point(field_mutable:$full_name$)\n" - " return $field_member$;\n" - "}\n" - "$tmpl$" - "$inline$" - "$type$* $dependent_classname$::$release_name$() {\n" - " // @@protoc_insertion_point(field_release:$full_name$)\n" - " if ($this_message$has_$name$()) {\n" - " $this_message$clear_has_$oneof_name$();\n" - " 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$(*$field_member$);\n" - " $field_member$ = NULL;\n" - " return temp;\n" - " } else {\n" - " $dependent_typename$* temp = $field_member$;\n" - " $field_member$ = NULL;\n" - " return temp;\n" - " }\n" - " } else {\n" - " return NULL;\n" - " }\n" - "}\n" - "$tmpl$" - "$inline$" - "void $dependent_classname$::" - "set_allocated_$name$($type$* $name$) {\n" - " $this_message$clear_$oneof_name$();\n" - " if ($name$) {\n"); - - if (SupportsArenas(descriptor_->message_type())) { - printer->Print(variables, - // If incoming message is on the heap and we are on an arena, just Own() - // it (see above). If it's on a different arena than we are or one of us - // is on the heap, we make a copy to our arena/heap. - " if ($this_message$GetArenaNoVirtual() != NULL &&\n" - " ::google::protobuf::Arena::GetArena($name$) == NULL) {\n" - " $this_message$GetArenaNoVirtual()->Own($name$);\n" - " } else if ($this_message$GetArenaNoVirtual() !=\n" - " ::google::protobuf::Arena::GetArena($name$)) {\n" - " $dependent_typename$* new_$name$ = \n" - " ::google::protobuf::Arena::CreateMessage< $dependent_typename$ >(\n" - " $this_message$GetArenaNoVirtual());\n" - " new_$name$->CopyFrom(*$name$);\n" - " $name$ = new_$name$;\n" - " }\n"); - } else { - printer->Print(variables, - " if ($this_message$GetArenaNoVirtual() != NULL) {\n" - " $this_message$GetArenaNoVirtual()->Own($name$);\n" - " }\n"); - } - - printer->Print(variables, - " $this_message$set_has_$name$();\n" - " $field_member$ = $name$;\n" - " }\n" - " // @@protoc_insertion_point(field_set_allocated:$full_name$)\n" - "}\n" - "$inline$ $type$* $classname$::unsafe_arena_release_$name$() {\n" + printer->Print(variables_, + "inline $type$* $classname$::unsafe_arena_release_$name$() {\n" " // @@protoc_insertion_point(field_unsafe_arena_release" ":$full_name$)\n" " if (has_$name$()) {\n" " clear_has_$oneof_name$();\n" - " $type$* temp = $oneof_prefix$$name$_;\n" - " $oneof_prefix$$name$_ = NULL;\n" + " $type$* temp = $field_member$;\n" + " $field_member$ = NULL;\n" " return temp;\n" " } else {\n" " return NULL;\n" " }\n" "}\n" - "$inline$ void $classname$::unsafe_arena_set_allocated_$name$" + "inline void $classname$::unsafe_arena_set_allocated_$name$" "($type$* $name$) {\n" // We rely on the oneof clear method to free the earlier contents of this // oneof. We can directly use the pointer we're given to set the new @@ -785,73 +553,36 @@ void MessageOneofFieldGenerator::InternalGenerateInlineAccessorDefinitions( " clear_$oneof_name$();\n" " if ($name$) {\n" " set_has_$name$();\n" - " $oneof_prefix$$name$_ = $name$;\n" + " $field_member$ = $name$;\n" " }\n" " // @@protoc_insertion_point(field_unsafe_arena_set_allocated:" "$full_name$)\n" "}\n"); - } else { - printer->Print(variables, - "$tmpl$" - "$inline$" - "$type$* $dependent_classname$::mutable_$name$() {\n" - " if (!$this_message$has_$name$()) {\n" - " $this_message$clear_$oneof_name$();\n" - " $this_message$set_has_$name$();\n" - " $field_member$ = new $dependent_typename$;\n" - " }\n" - " // @@protoc_insertion_point(field_mutable:$full_name$)\n" - " return $field_member$;\n" - "}\n" - "$tmpl$" - "$inline$" - "$type$* $dependent_classname$::$release_name$() {\n" - " // @@protoc_insertion_point(field_release:$full_name$)\n" - " if ($this_message$has_$name$()) {\n" - " $this_message$clear_has_$oneof_name$();\n" - " $dependent_typename$* temp = $field_member$;\n" - " $field_member$ = NULL;\n" - " return temp;\n" - " } else {\n" - " return NULL;\n" - " }\n" - "}\n" - "$tmpl$" - "$inline$" - "void $dependent_classname$::" - "set_allocated_$name$($type$* $name$) {\n" - " $this_message$clear_$oneof_name$();\n" - " if ($name$) {\n"); - if (SupportsArenas(descriptor_->message_type())) { - printer->Print(variables, - " if (static_cast< $dependent_typename$*>($name$)->" - "GetArena() != NULL) {\n" - " $dependent_typename$* new_$name$ = new $dependent_typename$;\n" - " new_$name$->CopyFrom(*$name$);\n" - " $name$ = new_$name$;\n" - " }\n"); - } - printer->Print(variables, - " $this_message$set_has_$name$();\n" - " $field_member$ = $name$;\n" - " }\n" - " // @@protoc_insertion_point(field_set_allocated:$full_name$)\n" - "}\n"); } + + printer->Print(variables_, + "inline $type$* $classname$::mutable_$name$() {\n" + " if (!has_$name$()) {\n" + " clear_$oneof_name$();\n" + " set_has_$name$();\n" + " $field_member$ = ::google::protobuf::Arena::$create_func$< $type$ >(\n" + " GetArenaNoVirtual());\n" + " }\n" + " // @@protoc_insertion_point(field_mutable:$full_name$)\n" + " return $field_member$;\n" + "}\n"); } void MessageOneofFieldGenerator:: GenerateClearingCode(io::Printer* printer) const { - std::map<string, string> variables(variables_); - variables["this_message"] = dependent_field_ ? DependentBaseDownCast() : ""; if (SupportsArenas(descriptor_)) { - printer->Print(variables, - "if ($this_message$GetArenaNoVirtual() == NULL) {\n" - " delete $this_message$$oneof_prefix$$name$_;\n" + printer->Print(variables_, + "if (GetArenaNoVirtual() == NULL) {\n" + " delete $field_member$;\n" "}\n"); } else { - printer->Print(variables, - "delete $this_message$$oneof_prefix$$name$_;\n"); + printer->Print(variables_, + "delete $field_member$;\n"); } } @@ -884,7 +615,7 @@ RepeatedMessageFieldGenerator::RepeatedMessageFieldGenerator( : FieldGenerator(options), descriptor_(descriptor), dependent_field_(options.proto_h && IsFieldDependent(descriptor)), - dependent_getter_(dependent_field_ && options.safe_boundary_check) { + implicit_weak_field_(IsImplicitWeakField(descriptor, options)) { SetMessageVariables(descriptor, &variables_, options); } @@ -898,25 +629,12 @@ GeneratePrivateMembers(io::Printer* printer) const { void RepeatedMessageFieldGenerator:: InternalGenerateTypeDependentAccessorDeclarations(io::Printer* printer) const { - printer->Print(variables_, - "$deprecated_attr$$type$* mutable_$name$(int index);\n" - "$deprecated_attr$$type$* add_$name$();\n"); - if (dependent_getter_) { - printer->Print(variables_, - "$deprecated_attr$const ::google::protobuf::RepeatedPtrField< $type$ >&\n" - " $name$() const;\n"); - } - printer->Print(variables_, - "$deprecated_attr$::google::protobuf::RepeatedPtrField< $type$ >*\n" - " mutable_$name$();\n"); + printer->Print(variables_, "$deprecated_attr$$type$* ${$add_$name$$}$();\n"); + printer->Annotate("{", "}", descriptor_); } void RepeatedMessageFieldGenerator:: GenerateDependentAccessorDeclarations(io::Printer* printer) const { - if (dependent_getter_) { - printer->Print(variables_, - "$deprecated_attr$const $type$& $name$(int index) const;\n"); - } if (dependent_field_) { InternalGenerateTypeDependentAccessorDeclarations(printer); } @@ -924,18 +642,24 @@ GenerateDependentAccessorDeclarations(io::Printer* printer) const { void RepeatedMessageFieldGenerator:: GenerateAccessorDeclarations(io::Printer* printer) const { - if (!dependent_getter_) { - printer->Print(variables_, - "$deprecated_attr$const $type$& $name$(int index) const;\n"); - } + printer->Print(variables_, + "$deprecated_attr$$type$* ${$mutable_$name$$}$(int index);\n"); + printer->Annotate("{", "}", descriptor_); + printer->Print(variables_, + "$deprecated_attr$::google::protobuf::RepeatedPtrField< $type$ >*\n" + " ${$mutable_$name$$}$();\n"); + printer->Annotate("{", "}", descriptor_); + + printer->Print(variables_, + "$deprecated_attr$const $type$& $name$(int index) const;\n"); + printer->Annotate("name", descriptor_); if (!dependent_field_) { InternalGenerateTypeDependentAccessorDeclarations(printer); } - if (!dependent_getter_) { - printer->Print(variables_, - "$deprecated_attr$const ::google::protobuf::RepeatedPtrField< $type$ >&\n" - " $name$() const;\n"); - } + printer->Print(variables_, + "$deprecated_attr$const ::google::protobuf::RepeatedPtrField< $type$ >&\n" + " $name$() const;\n"); + printer->Annotate("name", descriptor_); } void RepeatedMessageFieldGenerator:: @@ -951,114 +675,97 @@ GenerateDependentInlineAccessorDefinitions(io::Printer* printer) const { variables["this_message"] = DependentBaseDownCast(); variables["this_const_message"] = DependentBaseConstDownCast(); - if (dependent_getter_) { - printer->Print(variables, - "template <class T>\n" - "inline const $type$& $dependent_classname$::$name$(int index) const {\n" - " // @@protoc_insertion_point(field_get:$full_name$)\n" - " return $this_const_message$$name$_.$cppget$(index);\n" - "}\n"); - } - // Generate per-element accessors: printer->Print(variables, "template <class T>\n" - "inline $type$* $dependent_classname$::mutable_$name$(int index) {\n" - // TODO(dlj): move insertion points - " // @@protoc_insertion_point(field_mutable:$full_name$)\n" - " return $this_message$$name$_.Mutable(index);\n" - "}\n" - "template <class T>\n" "inline $type$* $dependent_classname$::add_$name$() {\n" " // @@protoc_insertion_point(field_add:$full_name$)\n" + "$type_reference_function$" " return $this_message$$name$_.Add();\n" "}\n"); +} - if (dependent_getter_) { - printer->Print(variables, - "template <class T>\n" - "inline const ::google::protobuf::RepeatedPtrField< $type$ >&\n" - "$dependent_classname$::$name$() const {\n" - " // @@protoc_insertion_point(field_list:$full_name$)\n" - " return $this_const_message$$name$_;\n" - "}\n"); - } - - // Generate mutable access to the entire list: - printer->Print(variables, - "template <class T>\n" +void RepeatedMessageFieldGenerator:: +GenerateInlineAccessorDefinitions(io::Printer* printer) const { + printer->Print(variables_, + "inline $type$* $classname$::mutable_$name$(int index) {\n" + // TODO(dlj): move insertion points + " // @@protoc_insertion_point(field_mutable:$full_name$)\n" + "$type_reference_function$" + " return $name$_.Mutable(index);\n" + "}\n" "inline ::google::protobuf::RepeatedPtrField< $type$ >*\n" - "$dependent_classname$::mutable_$name$() {\n" + "$classname$::mutable_$name$() {\n" " // @@protoc_insertion_point(field_mutable_list:$full_name$)\n" - " return &$this_message$$name$_;\n" + "$type_reference_function$" + " return &$name$_;\n" "}\n"); -} -void RepeatedMessageFieldGenerator:: -GenerateInlineAccessorDefinitions(io::Printer* printer, - bool is_inline) const { - std::map<string, string> variables(variables_); - variables["inline"] = is_inline ? "inline " : ""; - - if (!dependent_getter_) { - printer->Print(variables, - "$inline$" - "const $type$& $classname$::$name$(int index) const {\n" + if (options_.safe_boundary_check) { + printer->Print(variables_, + "inline const $type$& $classname$::$name$(int index) const {\n" " // @@protoc_insertion_point(field_get:$full_name$)\n" - " return $name$_.$cppget$(index);\n" + "$type_reference_function$" + " return $name$_.InternalCheckedGet(index,\n" + " *reinterpret_cast<const $type$*>(&$type_default_instance$));\n" + "}\n"); + } else { + printer->Print(variables_, + "inline const $type$& $classname$::$name$(int index) const {\n" + " // @@protoc_insertion_point(field_get:$full_name$)\n" + "$type_reference_function$" + " return $name$_.Get(index);\n" "}\n"); } if (!dependent_field_) { - printer->Print(variables, - "$inline$" - "$type$* $classname$::mutable_$name$(int index) {\n" - // TODO(dlj): move insertion points - " // @@protoc_insertion_point(field_mutable:$full_name$)\n" - " return $name$_.Mutable(index);\n" - "}\n" - "$inline$" - "$type$* $classname$::add_$name$() {\n" + printer->Print(variables_, + "inline $type$* $classname$::add_$name$() {\n" " // @@protoc_insertion_point(field_add:$full_name$)\n" + "$type_reference_function$" " return $name$_.Add();\n" "}\n"); } - if (!dependent_field_) { - printer->Print(variables, - "$inline$" - "::google::protobuf::RepeatedPtrField< $type$ >*\n" - "$classname$::mutable_$name$() {\n" - " // @@protoc_insertion_point(field_mutable_list:$full_name$)\n" - " return &$name$_;\n" - "}\n"); - } - if (!dependent_getter_) { - printer->Print(variables, - "$inline$" - "const ::google::protobuf::RepeatedPtrField< $type$ >&\n" - "$classname$::$name$() const {\n" - " // @@protoc_insertion_point(field_list:$full_name$)\n" - " return $name$_;\n" - "}\n"); - } + printer->Print(variables_, + "inline const ::google::protobuf::RepeatedPtrField< $type$ >&\n" + "$classname$::$name$() const {\n" + " // @@protoc_insertion_point(field_list:$full_name$)\n" + "$type_reference_function$" + " return $name$_;\n" + "}\n"); } void RepeatedMessageFieldGenerator:: GenerateClearingCode(io::Printer* printer) const { - std::map<string, string> variables(variables_); - variables["this_message"] = dependent_field_ ? DependentBaseDownCast() : ""; - printer->Print(variables, "$this_message$$name$_.Clear();\n"); + if (implicit_weak_field_) { + printer->Print( + variables_, + "CastToBase(&$name$_)->Clear<" + "::google::protobuf::internal::ImplicitWeakTypeHandler<$type$>>();\n"); + } else { + printer->Print(variables_, "$name$_.Clear();\n"); + } } void RepeatedMessageFieldGenerator:: GenerateMergingCode(io::Printer* printer) const { - printer->Print(variables_, "$name$_.MergeFrom(from.$name$_);\n"); + if (implicit_weak_field_) { + printer->Print( + variables_, + "CastToBase(&$name$_)->MergeFrom<" + "::google::protobuf::internal::ImplicitWeakTypeHandler<$type$>>(CastToBase(" + "from.$name$_));\n"); + } else { + printer->Print(variables_, "$name$_.MergeFrom(from.$name$_);\n"); + } } void RepeatedMessageFieldGenerator:: GenerateSwappingCode(io::Printer* printer) const { - printer->Print(variables_, "$name$_.InternalSwap(&other->$name$_);\n"); + printer->Print( + variables_, + "CastToBase(&$name$_)->InternalSwap(CastToBase(&other->$name$_));\n"); } void RepeatedMessageFieldGenerator:: @@ -1069,34 +776,55 @@ GenerateConstructorCode(io::Printer* printer) const { void RepeatedMessageFieldGenerator:: GenerateMergeFromCodedStream(io::Printer* printer) const { if (descriptor_->type() == FieldDescriptor::TYPE_MESSAGE) { - printer->Print(variables_, - "DO_(::google::protobuf::internal::WireFormatLite::" - "ReadMessageNoVirtual(\n" - " input, add_$name$()));\n"); + if (implicit_weak_field_) { + printer->Print(variables_, + "DO_(::google::protobuf::internal::WireFormatLite::" + "ReadMessage(input, CastToBase(&$name$_)->AddWeak(\n" + " reinterpret_cast<const ::google::protobuf::MessageLite*>(\n" + " &$type_default_instance$))));\n"); + } else { + printer->Print(variables_, + "DO_(::google::protobuf::internal::WireFormatLite::" + "ReadMessage(\n" + " input, add_$name$()));\n"); + } } else { printer->Print(variables_, "DO_(::google::protobuf::internal::WireFormatLite::" - "ReadGroupNoVirtual(\n" - " $number$, input, add_$name$()));\n"); + "ReadGroup($number$, input, add_$name$()));\n"); } } void RepeatedMessageFieldGenerator:: GenerateSerializeWithCachedSizes(io::Printer* printer) const { printer->Print(variables_, - "for (unsigned int i = 0, n = this->$name$_size(); i < n; i++) {\n" + "for (unsigned int i = 0,\n" + " n = static_cast<unsigned int>(this->$name$_size()); i < n; i++) {\n" " ::google::protobuf::internal::WireFormatLite::Write$stream_writer$(\n" - " $number$, this->$name$(i), output);\n" + " $number$,\n"); + if (implicit_weak_field_) { + printer->Print( + variables_, + " CastToBase($name$_).Get<" + "::google::protobuf::internal::ImplicitWeakTypeHandler<$type$>>(" + "static_cast<int>(i)),\n"); + } else { + printer->Print(variables_, + " this->$name$(static_cast<int>(i)),\n"); + } + printer->Print(variables_, + " output);\n" "}\n"); } void RepeatedMessageFieldGenerator:: GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const { printer->Print(variables_, - "for (unsigned int i = 0, n = this->$name$_size(); i < n; i++) {\n" + "for (unsigned int i = 0,\n" + " n = static_cast<unsigned int>(this->$name$_size()); i < n; i++) {\n" " target = ::google::protobuf::internal::WireFormatLite::\n" - " InternalWrite$declared_type$NoVirtualToArray(\n" - " $number$, this->$name$(i), deterministic, target);\n" + " InternalWrite$declared_type$ToArray(\n" + " $number$, this->$name$(static_cast<int>(i)), deterministic, target);\n" "}\n"); } @@ -1104,15 +832,24 @@ void RepeatedMessageFieldGenerator:: GenerateByteSize(io::Printer* printer) const { printer->Print(variables_, "{\n" - " unsigned int count = this->$name$_size();\n"); + " unsigned int count = static_cast<unsigned int>(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"); + " ::google::protobuf::internal::WireFormatLite::$declared_type$Size(\n"); + if (implicit_weak_field_) { + printer->Print( + variables_, + " CastToBase($name$_).Get<" + "::google::protobuf::internal::ImplicitWeakTypeHandler<$type$>>(" + "static_cast<int>(i)));\n"); + } else { + printer->Print(variables_, + " this->$name$(static_cast<int>(i)));\n"); + } + printer->Print(variables_, "}\n"); printer->Outdent(); printer->Print("}\n"); } diff --git a/src/google/protobuf/compiler/cpp/cpp_message_field.h b/src/google/protobuf/compiler/cpp/cpp_message_field.h index cd9737f0..e165404f 100644 --- a/src/google/protobuf/compiler/cpp/cpp_message_field.h +++ b/src/google/protobuf/compiler/cpp/cpp_message_field.h @@ -44,6 +44,8 @@ namespace protobuf { namespace compiler { namespace cpp { +bool IsImplicitWeakField(const FieldDescriptor* field, const Options& options); + class MessageFieldGenerator : public FieldGenerator { public: MessageFieldGenerator(const FieldDescriptor* descriptor, @@ -52,11 +54,8 @@ class MessageFieldGenerator : public FieldGenerator { // implements FieldGenerator --------------------------------------- void GeneratePrivateMembers(io::Printer* printer) const; - void GenerateDependentAccessorDeclarations(io::Printer* printer) const; void GenerateAccessorDeclarations(io::Printer* printer) const; - void GenerateDependentInlineAccessorDefinitions(io::Printer* printer) const; - void GenerateInlineAccessorDefinitions(io::Printer* printer, - bool is_inline) const; + void GenerateInlineAccessorDefinitions(io::Printer* printer) const; void GenerateNonInlineAccessorDefinitions(io::Printer* printer) const; void GenerateClearingCode(io::Printer* printer) const; void GenerateMessageClearingCode(io::Printer* printer) const; @@ -71,13 +70,8 @@ class MessageFieldGenerator : public FieldGenerator { void GenerateByteSize(io::Printer* printer) const; protected: - void GenerateArenaManipulationCode(const std::map<string, string>& variables, - io::Printer* printer) const; - - virtual void GenerateGetterDeclaration(io::Printer* printer) const; - const FieldDescriptor* descriptor_; - const bool dependent_field_; + const bool implicit_weak_field_; std::map<string, string> variables_; private: @@ -91,11 +85,8 @@ class MessageOneofFieldGenerator : public MessageFieldGenerator { ~MessageOneofFieldGenerator(); // implements FieldGenerator --------------------------------------- - void GenerateDependentAccessorDeclarations(io::Printer* printer) const; - void GenerateDependentInlineAccessorDefinitions(io::Printer* printer) const; - void GenerateInlineAccessorDefinitions(io::Printer* printer, - bool is_inline) const; - void GenerateNonInlineAccessorDefinitions(io::Printer* printer) const { } + void GenerateInlineAccessorDefinitions(io::Printer* printer) const; + void GenerateNonInlineAccessorDefinitions(io::Printer* printer) const; void GenerateClearingCode(io::Printer* printer) const; // MessageFieldGenerator, from which we inherit, overrides this so we need to @@ -105,13 +96,7 @@ class MessageOneofFieldGenerator : public MessageFieldGenerator { void GenerateDestructorCode(io::Printer* printer) const; void GenerateConstructorCode(io::Printer* printer) const; - protected: - void GenerateGetterDeclaration(io::Printer* printer) const; - private: - void InternalGenerateInlineAccessorDefinitions( - const std::map<string, string>& variables, io::Printer* printer) const; - const bool dependent_base_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageOneofFieldGenerator); }; @@ -127,8 +112,7 @@ class RepeatedMessageFieldGenerator : public FieldGenerator { void GenerateDependentAccessorDeclarations(io::Printer* printer) const; void GenerateAccessorDeclarations(io::Printer* printer) const; void GenerateDependentInlineAccessorDefinitions(io::Printer* printer) const; - void GenerateInlineAccessorDefinitions(io::Printer* printer, - bool is_inline) const; + void GenerateInlineAccessorDefinitions(io::Printer* printer) const; void GenerateClearingCode(io::Printer* printer) const; void GenerateMergingCode(io::Printer* printer) const; void GenerateSwappingCode(io::Printer* printer) const; @@ -145,7 +129,7 @@ class RepeatedMessageFieldGenerator : public FieldGenerator { const FieldDescriptor* descriptor_; const bool dependent_field_; - const bool dependent_getter_; + const bool implicit_weak_field_; std::map<string, string> variables_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedMessageFieldGenerator); diff --git a/src/google/protobuf/unittest_import_proto3.proto b/src/google/protobuf/compiler/cpp/cpp_message_layout_helper.h index 59673eaf..d502a6f0 100644 --- a/src/google/protobuf/unittest_import_proto3.proto +++ b/src/google/protobuf/compiler/cpp/cpp_message_layout_helper.h @@ -28,41 +28,34 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Author: kenton@google.com (Kenton Varda) +// Author: seongkim@google.com (Seong Beom Kim) // Based on original Protocol Buffers design by // Sanjay Ghemawat, Jeff Dean, and others. -// -// A proto file which is imported by unittest_proto3.proto to test importing. - -syntax = "proto3"; - -// We don't put this in a package within proto2 because we need to make sure -// that the generated code doesn't depend on being in the proto2 namespace. -// In test_util.h we do -// "using namespace unittest_import = protobuf_unittest_import". -package protobuf_unittest_import; -option optimize_for = SPEED; -option cc_enable_arenas = true; +#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_MESSAGE_LAYOUT_HELPER_H__ +#define GOOGLE_PROTOBUF_COMPILER_CPP_MESSAGE_LAYOUT_HELPER_H__ -// Exercise the java_package option. -option java_package = "com.google.protobuf.test"; -option csharp_namespace = "Google.Protobuf.TestProtos"; +#include <google/protobuf/compiler/cpp/cpp_options.h> +#include <google/protobuf/descriptor.h> -// Do not set a java_outer_classname here to verify that Proto2 works without -// one. +namespace google { +namespace protobuf { +namespace compiler { +namespace cpp { -// Test public import -import public "google/protobuf/unittest_import_public_proto3.proto"; +// Provides an abstract interface to optimize message layout +// by rearranging the fields of a message. +class MessageLayoutHelper { + public: + virtual ~MessageLayoutHelper() {} -message ImportMessage { - int32 d = 1; -} + virtual void OptimizeLayout(std::vector<const FieldDescriptor*>* fields, + const Options& options) = 0; +}; -enum ImportEnum { - IMPORT_ENUM_UNSPECIFIED = 0; - IMPORT_FOO = 7; - IMPORT_BAR = 8; - IMPORT_BAZ = 9; -} +} // namespace cpp +} // namespace compiler +} // namespace protobuf +} // namespace google +#endif // GOOGLE_PROTOBUF_COMPILER_CPP_MESSAGE_LAYOUT_HELPER_H__ diff --git a/src/google/protobuf/compiler/cpp/cpp_move_unittest.cc b/src/google/protobuf/compiler/cpp/cpp_move_unittest.cc new file mode 100644 index 00000000..f72a7d60 --- /dev/null +++ b/src/google/protobuf/compiler/cpp/cpp_move_unittest.cc @@ -0,0 +1,169 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include <google/protobuf/stubs/common.h> +#include <google/protobuf/test_util.h> +#include <google/protobuf/unittest.pb.h> +#include <gtest/gtest.h> + +#if LANG_CXX11 +#include <google/protobuf/stubs/type_traits.h> +#endif + +namespace google { +namespace protobuf { +namespace compiler { +namespace cpp { + +// Can't use an anonymous namespace here due to brokenness of Tru64 compiler. +namespace cpp_unittest { + +// Moves are enabled only when compiling with a C++11 compiler or newer. +#if LANG_CXX11 + +TEST(MovableMessageTest, MoveConstructor) { + protobuf_unittest::TestAllTypes message1; + TestUtil::SetAllFields(&message1); + const auto* nested = &message1.optional_nested_message(); + + protobuf_unittest::TestAllTypes message2(std::move(message1)); + TestUtil::ExpectAllFieldsSet(message2); + + // Check if the optional_nested_message was actually moved (and not just + // copied). + EXPECT_EQ(nested, &message2.optional_nested_message()); + EXPECT_NE(nested, &message1.optional_nested_message()); +} + +TEST(MovableMessageTest, MoveAssignmentOperator) { + protobuf_unittest::TestAllTypes message1; + TestUtil::SetAllFields(&message1); + const auto* nested = &message1.optional_nested_message(); + + protobuf_unittest::TestAllTypes message2; + message2 = std::move(message1); + TestUtil::ExpectAllFieldsSet(message2); + + // Check if the optional_nested_message was actually moved (and not just + // copied). + EXPECT_EQ(nested, &message2.optional_nested_message()); + EXPECT_NE(nested, &message1.optional_nested_message()); +} + +TEST(MovableMessageTest, SelfMoveAssignment) { + // The `self` reference is necessary to defeat -Wself-move. + protobuf_unittest::TestAllTypes message, &self = message; + TestUtil::SetAllFields(&message); + message = std::move(self); + TestUtil::ExpectAllFieldsSet(message); +} + +TEST(MovableMessageTest, MoveSameArena) { + Arena arena; + + auto* message1_on_arena = + Arena::CreateMessage<protobuf_unittest::TestAllTypes>(&arena); + TestUtil::SetAllFields(message1_on_arena); + const auto* nested = &message1_on_arena->optional_nested_message(); + + auto* message2_on_arena = + Arena::CreateMessage<protobuf_unittest::TestAllTypes>(&arena); + + // Moving messages on the same arena should lead to swapped pointers. + *message2_on_arena = std::move(*message1_on_arena); + EXPECT_EQ(nested, &message2_on_arena->optional_nested_message()); +} + +TEST(MovableMessageTest, MoveDifferentArenas) { + Arena arena1, arena2; + + auto* message1_on_arena = + Arena::CreateMessage<protobuf_unittest::TestAllTypes>(&arena1); + TestUtil::SetAllFields(message1_on_arena); + const auto* nested = &message1_on_arena->optional_nested_message(); + + auto* message2_on_arena = + Arena::CreateMessage<protobuf_unittest::TestAllTypes>(&arena2); + + // Moving messages on two different arenas should lead to a copy. + *message2_on_arena = std::move(*message1_on_arena); + EXPECT_NE(nested, &message2_on_arena->optional_nested_message()); + TestUtil::ExpectAllFieldsSet(*message1_on_arena); + TestUtil::ExpectAllFieldsSet(*message2_on_arena); +} + +TEST(MovableMessageTest, MoveFromArena) { + Arena arena; + + auto* message1_on_arena = + Arena::CreateMessage<protobuf_unittest::TestAllTypes>(&arena); + TestUtil::SetAllFields(message1_on_arena); + const auto* nested = &message1_on_arena->optional_nested_message(); + + protobuf_unittest::TestAllTypes message2; + + // Moving from a message on the arena should lead to a copy. + message2 = std::move(*message1_on_arena); + EXPECT_NE(nested, &message2.optional_nested_message()); + TestUtil::ExpectAllFieldsSet(*message1_on_arena); + TestUtil::ExpectAllFieldsSet(message2); +} + +TEST(MovableMessageTest, MoveToArena) { + Arena arena; + + protobuf_unittest::TestAllTypes message1; + TestUtil::SetAllFields(&message1); + const auto* nested = &message1.optional_nested_message(); + + auto* message2_on_arena = + Arena::CreateMessage<protobuf_unittest::TestAllTypes>(&arena); + + // Moving to a message on the arena should lead to a copy. + *message2_on_arena = std::move(message1); + EXPECT_NE(nested, &message2_on_arena->optional_nested_message()); + TestUtil::ExpectAllFieldsSet(message1); + TestUtil::ExpectAllFieldsSet(*message2_on_arena); +} + +TEST(MovableMessageTest, Noexcept) { + EXPECT_TRUE( + std::is_nothrow_move_constructible<protobuf_unittest::TestAllTypes>()); + EXPECT_TRUE(std::is_nothrow_move_assignable<protobuf_unittest::TestAllTypes>()); +} + +#endif // LANG_CXX11 + +} // namespace cpp_unittest + +} // namespace cpp +} // namespace compiler +} // namespace protobuf +} // namespace google diff --git a/src/google/protobuf/compiler/cpp/cpp_options.h b/src/google/protobuf/compiler/cpp/cpp_options.h index bdaa12a5..b0dd8836 100644 --- a/src/google/protobuf/compiler/cpp/cpp_options.h +++ b/src/google/protobuf/compiler/cpp/cpp_options.h @@ -39,6 +39,8 @@ namespace google { namespace protobuf { namespace compiler { +class AccessInfoMap; + namespace cpp { // Generator options (see generator.cc for a description of each): @@ -49,7 +51,11 @@ struct Options { transitive_pb_h(true), annotate_headers(false), enforce_lite(false), - table_driven_parsing(false) {} + table_driven_parsing(false), + table_driven_serialization(false), + lite_implicit_weak_fields(false), + num_cc_files(0), + access_info_map(NULL) {} string dllexport_decl; bool safe_boundary_check; @@ -58,8 +64,12 @@ struct Options { bool annotate_headers; bool enforce_lite; bool table_driven_parsing; + bool table_driven_serialization; + bool lite_implicit_weak_fields; + int num_cc_files; string annotation_pragma_name; string annotation_guard_name; + const AccessInfoMap* access_info_map; }; } // namespace cpp diff --git a/src/google/protobuf/compiler/cpp/cpp_padding_optimizer.cc b/src/google/protobuf/compiler/cpp/cpp_padding_optimizer.cc new file mode 100644 index 00000000..e9303865 --- /dev/null +++ b/src/google/protobuf/compiler/cpp/cpp_padding_optimizer.cc @@ -0,0 +1,220 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include <google/protobuf/compiler/cpp/cpp_padding_optimizer.h> + +#include <google/protobuf/compiler/cpp/cpp_helpers.h> + +namespace google { +namespace protobuf { +namespace compiler { +namespace cpp { + +namespace { + +// FieldGroup is just a helper for PaddingOptimizer below. It holds a vector of +// fields that are grouped together because they have compatible alignment, and +// a preferred location in the final field ordering. +class FieldGroup { + public: + FieldGroup() : preferred_location_(0) {} + + // A group with a single field. + FieldGroup(float preferred_location, const FieldDescriptor* field) + : preferred_location_(preferred_location), fields_(1, field) {} + + // Append the fields in 'other' to this group. + void Append(const FieldGroup& other) { + if (other.fields_.empty()) { + return; + } + // Preferred location is the average among all the fields, so we weight by + // the number of fields on each FieldGroup object. + preferred_location_ = (preferred_location_ * fields_.size() + + (other.preferred_location_ * other.fields_.size())) / + (fields_.size() + other.fields_.size()); + fields_.insert(fields_.end(), other.fields_.begin(), other.fields_.end()); + } + + void SetPreferredLocation(float location) { preferred_location_ = location; } + const std::vector<const FieldDescriptor*>& fields() const { return fields_; } + + // FieldGroup objects sort by their preferred location. + bool operator<(const FieldGroup& other) const { + return preferred_location_ < other.preferred_location_; + } + + private: + // "preferred_location_" is an estimate of where this group should go in the + // final list of fields. We compute this by taking the average index of each + // field in this group in the original ordering of fields. This is very + // approximate, but should put this group close to where its member fields + // originally went. + float preferred_location_; + std::vector<const FieldDescriptor*> fields_; + // We rely on the default copy constructor and operator= so this type can be + // used in a vector. +}; + +} // namespace + +// Reorder 'fields' so that if the fields are output into a c++ class in the new +// order, fields of similar 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 field +// number order so that we don't reduce cache locality much for function that +// access each field in order. Originally, OptimizePadding used declaration +// order for its decisions, but generated code minus the serializer/parsers uses +// the output of OptimizePadding as well (stored in +// MessageGenerator::optimized_order_). Since the serializers use field number +// order, we use that as a tie-breaker. +// +// 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), which allows them to be +// memset. +// +// ZERO_INITIALIZABLE is memset in Clear/SharedCtor +// +// OTHER these fields are initialized one-by-one. +void PaddingOptimizer::OptimizeLayout( + std::vector<const FieldDescriptor*>* fields, const Options& options) { + // The sorted numeric order of Family determines the declaration order in the + // memory layout. + enum Family { + REPEATED = 0, + STRING = 1, + MESSAGE = 3, + ZERO_INITIALIZABLE = 4, + OTHER = 5, + kMaxFamily + }; + + // First divide fields into those that align to 1 byte, 4 bytes or 8 bytes. + std::vector<FieldGroup> aligned_to_1[kMaxFamily]; + std::vector<FieldGroup> aligned_to_4[kMaxFamily]; + std::vector<FieldGroup> aligned_to_8[kMaxFamily]; + for (int i = 0; i < fields->size(); ++i) { + const FieldDescriptor* field = (*fields)[i]; + + 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; + } + + const int j = field->number(); + switch (EstimateAlignmentSize(field)) { + case 1: + aligned_to_1[f].push_back(FieldGroup(j, field)); + break; + case 4: + aligned_to_4[f].push_back(FieldGroup(j, field)); + break; + case 8: + aligned_to_8[f].push_back(FieldGroup(j, field)); + break; + default: + GOOGLE_LOG(FATAL) << "Unknown alignment size " << EstimateAlignmentSize(field) + << "for a field " << field->full_name() << "."; + } + } + + // 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 field number + // 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); + } + // Sort by preferred location. + std::stable_sort(aligned_to_8[f].begin(), aligned_to_8[f].end()); + } + + // Now pull out all the FieldDescriptors in order. + fields->clear(); + 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()); + } + } +} + +} // namespace cpp +} // namespace compiler +} // namespace protobuf +} // namespace google diff --git a/src/google/protobuf/compiler/profile.proto b/src/google/protobuf/compiler/cpp/cpp_padding_optimizer.h index 09ebe091..9641ba40 100644 --- a/src/google/protobuf/compiler/profile.proto +++ b/src/google/protobuf/compiler/cpp/cpp_padding_optimizer.h @@ -29,40 +29,36 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Author: seongkim@google.com (Seong Beom Kim) -// -// protoc (Protocol Compiler) can generate more efficient code -// if it knows how a workload accesses fields of a message; -// e.g. some much more frequently than others. -// -// Protos defined here describe the access information per message -// and per field. Note that one can use any methods to collect -// the access patterns like CPU profiling, instrumented build, etc. +// Based on original Protocol Buffers design by +// Sanjay Ghemawat, Jeff Dean, and others. + +#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_PADDING_OPTIMIZER_H__ +#define GOOGLE_PROTOBUF_COMPILER_CPP_PADDING_OPTIMIZER_H__ + +#include <google/protobuf/compiler/cpp/cpp_message_layout_helper.h> -syntax = "proto2"; +namespace google { +namespace protobuf { +namespace compiler { +namespace cpp { -package google.protobuf.compiler; +// Rearranges the fields of a message to minimize padding. +// Fields are grouped by the type and the size. +// For example, grouping four boolean fields and one int32 +// field results in zero padding overhead. See OptimizeLayout's +// comment for details. +class PaddingOptimizer : public MessageLayoutHelper { + public: + PaddingOptimizer() {} + ~PaddingOptimizer() {} -// To convey the access pattern of a field, it classifies -// the type of the accessor methods into getters, setters and -// configs. Getters and setters read and write the field -// respectively and other operations like checking if the field -// exists are considered as configs. -message FieldAccessInfo { - optional string name = 1; - optional uint64 getters_count = 2; - optional uint64 setters_count = 3; - optional uint64 configs_count = 4; -} + void OptimizeLayout(std::vector<const FieldDescriptor*>* fields, + const Options& options); +}; -// "count" correlates with how many samples an access info has -// for a message. High "count" means more confident optimization -// based on the info. -message MessageAccessInfo { - optional string name = 1; - optional uint64 count = 2; - repeated FieldAccessInfo field = 3; -} +} // namespace cpp +} // namespace compiler +} // namespace protobuf -message AccessInfo { - repeated MessageAccessInfo message = 1; -} +} // namespace google +#endif // GOOGLE_PROTOBUF_COMPILER_CPP_PADDING_OPTIMIZER_H__ diff --git a/src/google/protobuf/compiler/cpp/cpp_plugin_unittest.cc b/src/google/protobuf/compiler/cpp/cpp_plugin_unittest.cc index 34a41d82..ceb2270e 100644 --- a/src/google/protobuf/compiler/cpp/cpp_plugin_unittest.cc +++ b/src/google/protobuf/compiler/cpp/cpp_plugin_unittest.cc @@ -132,7 +132,7 @@ class TestGenerator : public CodeGenerator { // Check field accessors for a message inside oneof{}: TryInsert("test.pb.h", "field_get:foo.Bar.oneOfMessage", context); TryInsert("test.pb.h", "field_mutable:foo.Bar.oneOfMessage", context); - TryInsert("test.pb.h", "field_set_allocated:foo.Bar.oneOfMessage", context); + TryInsert("test.pb.cc", "field_set_allocated:foo.Bar.oneOfMessage", context); // Check field accessors for an optional enum: TryInsert("test.pb.h", "field_get:foo.Bar.optEnum", context); diff --git a/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc b/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc index 020c1941..701f9d2d 100644 --- a/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc +++ b/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc @@ -115,21 +115,21 @@ GeneratePrivateMembers(io::Printer* printer) const { void PrimitiveFieldGenerator:: GenerateAccessorDeclarations(io::Printer* printer) const { + printer->Print(variables_, "$deprecated_attr$$type$ $name$() const;\n"); + printer->Annotate("name", descriptor_); printer->Print(variables_, - "$deprecated_attr$$type$ $name$() const;\n" - "$deprecated_attr$void set_$name$($type$ value);\n"); + "$deprecated_attr$void ${$set_$name$$}$($type$ value);\n"); + printer->Annotate("{", "}", descriptor_); } void PrimitiveFieldGenerator:: -GenerateInlineAccessorDefinitions(io::Printer* printer, bool is_inline) const { - std::map<string, string> variables(variables_); - variables["inline"] = is_inline ? "inline " : ""; - printer->Print(variables, - "$inline$$type$ $classname$::$name$() const {\n" +GenerateInlineAccessorDefinitions(io::Printer* printer) const { + printer->Print(variables_, + "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" @@ -148,7 +148,7 @@ GenerateMergingCode(io::Printer* printer) const { void PrimitiveFieldGenerator:: GenerateSwappingCode(io::Printer* printer) const { - printer->Print(variables_, "std::swap($name$_, other->$name$_);\n"); + printer->Print(variables_, "swap($name$_, other->$name$_);\n"); } void PrimitiveFieldGenerator:: @@ -210,30 +210,28 @@ PrimitiveOneofFieldGenerator(const FieldDescriptor* descriptor, PrimitiveOneofFieldGenerator::~PrimitiveOneofFieldGenerator() {} void PrimitiveOneofFieldGenerator:: -GenerateInlineAccessorDefinitions(io::Printer* printer, bool is_inline) const { - std::map<string, string> variables(variables_); - variables["inline"] = is_inline ? "inline " : ""; - printer->Print(variables, - "$inline$$type$ $classname$::$name$() const {\n" +GenerateInlineAccessorDefinitions(io::Printer* printer) const { + printer->Print(variables_, + "inline $type$ $classname$::$name$() const {\n" " // @@protoc_insertion_point(field_get:$full_name$)\n" " if (has_$name$()) {\n" - " return $oneof_prefix$$name$_;\n" + " return $field_member$;\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" " }\n" - " $oneof_prefix$$name$_ = value;\n" + " $field_member$ = value;\n" " // @@protoc_insertion_point(field_set:$full_name$)\n" "}\n"); } void PrimitiveOneofFieldGenerator:: GenerateClearingCode(io::Printer* printer) const { - printer->Print(variables_, "$oneof_prefix$$name$_ = $default$;\n"); + printer->Print(variables_, "$field_member$ = $default$;\n"); } void PrimitiveOneofFieldGenerator:: @@ -243,9 +241,8 @@ GenerateSwappingCode(io::Printer* printer) const { void PrimitiveOneofFieldGenerator:: GenerateConstructorCode(io::Printer* printer) const { - printer->Print( - variables_, - "_$classname$_default_instance_.$name$_ = $default$;\n"); + printer->Print(variables_, + "$ns$::_$classname$_default_instance_.$name$_ = $default$;\n"); } void PrimitiveOneofFieldGenerator:: @@ -254,7 +251,7 @@ GenerateMergeFromCodedStream(io::Printer* printer) const { "clear_$oneof_name$();\n" "DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n" " $type$, $wire_format_field_type$>(\n" - " input, &$oneof_prefix$$name$_)));\n" + " input, &$field_member$)));\n" "set_has_$name$();\n"); } @@ -290,40 +287,46 @@ GeneratePrivateMembers(io::Printer* printer) const { void RepeatedPrimitiveFieldGenerator:: GenerateAccessorDeclarations(io::Printer* printer) const { printer->Print(variables_, - "$deprecated_attr$$type$ $name$(int index) const;\n" - "$deprecated_attr$void set_$name$(int index, $type$ value);\n" - "$deprecated_attr$void add_$name$($type$ value);\n"); + "$deprecated_attr$$type$ $name$(int index) const;\n"); + printer->Annotate("name", descriptor_); + printer->Print( + variables_, + "$deprecated_attr$void ${$set_$name$$}$(int index, $type$ value);\n"); + printer->Annotate("{", "}", descriptor_); + printer->Print(variables_, + "$deprecated_attr$void ${$add_$name$$}$($type$ value);\n"); + printer->Annotate("{", "}", descriptor_); + printer->Print(variables_, + "$deprecated_attr$const ::google::protobuf::RepeatedField< $type$ >&\n" + " $name$() const;\n"); + printer->Annotate("name", descriptor_); printer->Print(variables_, - "$deprecated_attr$const ::google::protobuf::RepeatedField< $type$ >&\n" - " $name$() const;\n" - "$deprecated_attr$::google::protobuf::RepeatedField< $type$ >*\n" - " mutable_$name$();\n"); + "$deprecated_attr$::google::protobuf::RepeatedField< $type$ >*\n" + " ${$mutable_$name$$}$();\n"); + printer->Annotate("{", "}", descriptor_); } void RepeatedPrimitiveFieldGenerator:: -GenerateInlineAccessorDefinitions(io::Printer* printer, bool is_inline) const { - std::map<string, string> variables(variables_); - variables["inline"] = is_inline ? "inline " : ""; - printer->Print(variables, - "$inline$$type$ $classname$::$name$(int index) const {\n" +GenerateInlineAccessorDefinitions(io::Printer* printer) const { + printer->Print(variables_, + "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" + "}\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" @@ -382,7 +385,8 @@ GenerateSerializeWithCachedSizes(io::Printer* printer) const { "$number$, " "::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED, " "output);\n" - " output->WriteVarint32(_$name$_cached_byte_size_);\n"); + " output->WriteVarint32(static_cast< ::google::protobuf::uint32>(\n" + " _$name$_cached_byte_size_));\n"); if (FixedSize(descriptor_->type()) > 0) { // TODO(ckennelly): Use RepeatedField<T>::unsafe_data() via @@ -422,7 +426,8 @@ GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const { " ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED,\n" " target);\n" " target = ::google::protobuf::io::CodedOutputStream::WriteVarint32ToArray(\n" - " _$name$_cached_byte_size_, target);\n" + " static_cast< ::google::protobuf::int32>(\n" + " _$name$_cached_byte_size_), target);\n" " target = ::google::protobuf::internal::WireFormatLite::\n" " Write$declared_type$NoTagToArray(this->$name$_, target);\n" "}\n"); @@ -444,7 +449,7 @@ GenerateByteSize(io::Printer* printer) const { " $declared_type$Size(this->$name$_);\n"); } else { printer->Print(variables_, - "unsigned int count = this->$name$_size();\n" + "unsigned int count = static_cast<unsigned int>(this->$name$_size());\n" "size_t data_size = $fixed_size$UL * count;\n"); } @@ -452,7 +457,8 @@ GenerateByteSize(io::Printer* printer) const { printer->Print(variables_, "if (data_size > 0) {\n" " total_size += $tag_size$ +\n" - " ::google::protobuf::internal::WireFormatLite::Int32Size(data_size);\n" + " ::google::protobuf::internal::WireFormatLite::Int32Size(\n" + " static_cast< ::google::protobuf::int32>(data_size));\n" "}\n" "int cached_size = ::google::protobuf::internal::ToCachedSize(data_size);\n" "GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n" diff --git a/src/google/protobuf/compiler/cpp/cpp_primitive_field.h b/src/google/protobuf/compiler/cpp/cpp_primitive_field.h index 44c9ff3e..d52228e9 100644 --- a/src/google/protobuf/compiler/cpp/cpp_primitive_field.h +++ b/src/google/protobuf/compiler/cpp/cpp_primitive_field.h @@ -53,8 +53,7 @@ class PrimitiveFieldGenerator : public FieldGenerator { // implements FieldGenerator --------------------------------------- void GeneratePrivateMembers(io::Printer* printer) const; void GenerateAccessorDeclarations(io::Printer* printer) const; - void GenerateInlineAccessorDefinitions(io::Printer* printer, - bool is_inline) const; + void GenerateInlineAccessorDefinitions(io::Printer* printer) const; void GenerateClearingCode(io::Printer* printer) const; void GenerateMergingCode(io::Printer* printer) const; void GenerateSwappingCode(io::Printer* printer) const; @@ -80,8 +79,7 @@ class PrimitiveOneofFieldGenerator : public PrimitiveFieldGenerator { ~PrimitiveOneofFieldGenerator(); // implements FieldGenerator --------------------------------------- - void GenerateInlineAccessorDefinitions(io::Printer* printer, - bool is_inline) const; + void GenerateInlineAccessorDefinitions(io::Printer* printer) const; void GenerateClearingCode(io::Printer* printer) const; void GenerateSwappingCode(io::Printer* printer) const; void GenerateConstructorCode(io::Printer* printer) const; @@ -100,8 +98,7 @@ class RepeatedPrimitiveFieldGenerator : public FieldGenerator { // implements FieldGenerator --------------------------------------- void GeneratePrivateMembers(io::Printer* printer) const; void GenerateAccessorDeclarations(io::Printer* printer) const; - void GenerateInlineAccessorDefinitions(io::Printer* printer, - bool is_inline) const; + void GenerateInlineAccessorDefinitions(io::Printer* printer) const; void GenerateClearingCode(io::Printer* printer) const; void GenerateMergingCode(io::Printer* printer) const; void GenerateSwappingCode(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 7a849e2e..c9901e84 100644 --- a/src/google/protobuf/compiler/cpp/cpp_string_field.cc +++ b/src/google/protobuf/compiler/cpp/cpp_string_field.cc @@ -58,8 +58,8 @@ void SetStringVariables(const FieldDescriptor* descriptor, (*variables)["default_variable"] = descriptor->default_value_string().empty() ? "&::google::protobuf::internal::GetEmptyStringAlreadyInited()" - : "&" + (*variables)["classname"] + "::" + default_variable_string + - ".get()"; + : "&" + Namespace(descriptor) + "::" + (*variables)["classname"] + + "::" + default_variable_string + ".get()"; (*variables)["pointer_type"] = descriptor->type() == FieldDescriptor::TYPE_BYTES ? "void" : "char"; (*variables)["null_check"] = "GOOGLE_DCHECK(value != NULL);\n"; @@ -71,6 +71,9 @@ void SetStringVariables(const FieldDescriptor* descriptor, (*variables)["full_name"] = descriptor->full_name(); (*variables)["string_piece"] = "::std::string"; + + (*variables)["lite"] = + HasDescriptorMethods(descriptor->file(), options) ? "" : "Lite"; } } // namespace @@ -79,7 +82,8 @@ void SetStringVariables(const FieldDescriptor* descriptor, StringFieldGenerator::StringFieldGenerator(const FieldDescriptor* descriptor, const Options& options) - : FieldGenerator(options), descriptor_(descriptor) { + : FieldGenerator(options), descriptor_(descriptor), + lite_(!HasDescriptorMethods(descriptor->file(), options)) { SetStringVariables(descriptor, &variables_, options); } @@ -142,31 +146,55 @@ GenerateAccessorDeclarations(io::Printer* printer) const { } printer->Print(variables_, - "$deprecated_attr$const ::std::string& $name$() const;\n" - "$deprecated_attr$void set_$name$(const ::std::string& value);\n"); + "$deprecated_attr$const ::std::string& $name$() const;\n"); + printer->Annotate("name", descriptor_); + printer->Print( + variables_, + "$deprecated_attr$void ${$set_$name$$}$(const ::std::string& value);\n"); + printer->Annotate("{", "}", descriptor_); - if (!SupportsArenas(descriptor_)) { - printer->Print(variables_, - "#if LANG_CXX11\n" - "$deprecated_attr$void set_$name$(::std::string&& value);\n" - "#endif\n"); - } + printer->Print(variables_, + "#if LANG_CXX11\n" + "$deprecated_attr$void ${$set_$name$$}$(::std::string&& value);\n" + "#endif\n"); + printer->Annotate("{", "}", descriptor_); + printer->Print( + variables_, + "$deprecated_attr$void ${$set_$name$$}$(const char* value);\n"); + printer->Annotate("{", "}", descriptor_); printer->Print(variables_, - "$deprecated_attr$void set_$name$(const char* value);\n" - "$deprecated_attr$void set_$name$(const $pointer_type$* value, size_t size)" - ";\n" - "$deprecated_attr$::std::string* mutable_$name$();\n" - "$deprecated_attr$::std::string* $release_name$();\n" - "$deprecated_attr$void set_allocated_$name$(::std::string* $name$);\n"); + "$deprecated_attr$void ${$set_$name$$}$(const $pointer_type$* " + "value, size_t size)" + ";\n"); + printer->Annotate("{", "}", descriptor_); + printer->Print(variables_, + "$deprecated_attr$::std::string* ${$mutable_$name$$}$();\n"); + printer->Annotate("{", "}", descriptor_); + printer->Print(variables_, "$deprecated_attr$::std::string* $release_name$();\n"); + printer->Annotate("release_name", descriptor_); + printer->Print( + variables_, + "$deprecated_attr$void ${$set_allocated_$name$$}$(::std::string* $name$);\n"); + printer->Annotate("{", "}", descriptor_); if (SupportsArenas(descriptor_)) { - printer->Print(variables_, - "$deprecated_attr$::std::string* unsafe_arena_release_$name$();\n" - "$deprecated_attr$void unsafe_arena_set_allocated_$name$(\n" - " ::std::string* $name$);\n"); + printer->Print( + variables_, + "PROTOBUF_RUNTIME_DEPRECATED(\"The unsafe_arena_ accessors for\"\n" + "\" string fields are deprecated and will be removed in a\"\n" + "\" future release.\")\n" + "::std::string* ${$unsafe_arena_release_$name$$}$();\n"); + printer->Annotate("{", "}", descriptor_); + printer->Print( + variables_, + "PROTOBUF_RUNTIME_DEPRECATED(\"The unsafe_arena_ accessors for\"\n" + "\" string fields are deprecated and will be removed in a\"\n" + "\" future release.\")\n" + "void ${$unsafe_arena_set_allocated_$name$$}$(\n" + " ::std::string* $name$);\n"); + printer->Annotate("{", "}", descriptor_); } - if (unknown_ctype) { printer->Outdent(); printer->Print(" public:\n"); @@ -175,57 +203,54 @@ GenerateAccessorDeclarations(io::Printer* printer) const { } void StringFieldGenerator:: -GenerateInlineAccessorDefinitions(io::Printer* printer, - bool is_inline) const { - std::map<string, string> variables(variables_); - variables["inline"] = is_inline ? "inline " : ""; +GenerateInlineAccessorDefinitions(io::Printer* printer) const { if (SupportsArenas(descriptor_)) { printer->Print( - variables, - "$inline$const ::std::string& $classname$::$name$() const {\n" + variables_, + "inline const ::std::string& $classname$::$name$() const {\n" " // @@protoc_insertion_point(field_get:$full_name$)\n" " return $name$_.Get();\n" "}\n" - "$inline$void $classname$::set_$name$(const ::std::string& value) {\n" + "inline void $classname$::set_$name$(const ::std::string& value) {\n" " $set_hasbit$\n" - " $name$_.Set($default_variable$, value, GetArenaNoVirtual());\n" + " $name$_.Set$lite$($default_variable$, value, GetArenaNoVirtual());\n" " // @@protoc_insertion_point(field_set:$full_name$)\n" "}\n" - "$inline$void $classname$::set_$name$(const char* value) {\n" + "#if LANG_CXX11\n" + "inline void $classname$::set_$name$(::std::string&& value) {\n" + " $set_hasbit$\n" + " $name$_.Set$lite$(\n" + " $default_variable$, ::std::move(value), GetArenaNoVirtual());\n" + " // @@protoc_insertion_point(field_set_rvalue:$full_name$)\n" + "}\n" + "#endif\n" + "inline void $classname$::set_$name$(const char* value) {\n" " $null_check$" " $set_hasbit$\n" - " $name$_.Set($default_variable$, $string_piece$(value),\n" + " $name$_.Set$lite$($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" - " $name$_.Set($default_variable$, $string_piece$(\n" + " $name$_.Set$lite$($default_variable$, $string_piece$(\n" " reinterpret_cast<const char*>(value), size), " "GetArenaNoVirtual());\n" " // @@protoc_insertion_point(field_set_pointer:$full_name$)\n" "}\n" - "$inline$::std::string* $classname$::mutable_$name$() {\n" + "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" - " // " - "@@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" @@ -235,7 +260,15 @@ 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 ::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$::unsafe_arena_set_allocated_$name$(\n" " ::std::string* $name$) {\n" " GOOGLE_DCHECK(GetArenaNoVirtual() != NULL);\n" " if ($name$ != NULL) {\n" @@ -251,31 +284,31 @@ GenerateInlineAccessorDefinitions(io::Printer* printer, } else { // No-arena case. printer->Print( - variables, - "$inline$const ::std::string& $classname$::$name$() const {\n" + variables_, + "inline const ::std::string& $classname$::$name$() const {\n" " // @@protoc_insertion_point(field_get:$full_name$)\n" " return $name$_.GetNoArena();\n" "}\n" - "$inline$void $classname$::set_$name$(const ::std::string& value) {\n" + "inline void $classname$::set_$name$(const ::std::string& value) {\n" " $set_hasbit$\n" " $name$_.SetNoArena($default_variable$, value);\n" " // @@protoc_insertion_point(field_set:$full_name$)\n" "}\n" "#if LANG_CXX11\n" - "$inline$void $classname$::set_$name$(::std::string&& value) {\n" + "inline void $classname$::set_$name$(::std::string&& value) {\n" " $set_hasbit$\n" " $name$_.SetNoArena(\n" " $default_variable$, ::std::move(value));\n" " // @@protoc_insertion_point(field_set_rvalue:$full_name$)\n" "}\n" "#endif\n" - "$inline$void $classname$::set_$name$(const char* value) {\n" + "inline void $classname$::set_$name$(const char* value) {\n" " $null_check$" " $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" @@ -283,17 +316,17 @@ GenerateInlineAccessorDefinitions(io::Printer* printer, " $string_piece$(reinterpret_cast<const char*>(value), size));\n" " // @@protoc_insertion_point(field_set_pointer:$full_name$)\n" "}\n" - "$inline$::std::string* $classname$::mutable_$name$() {\n" + "inline ::std::string* $classname$::mutable_$name$() {\n" " $set_hasbit$\n" " // @@protoc_insertion_point(field_mutable:$full_name$)\n" " return $name$_.MutableNoArena($default_variable$);\n" "}\n" - "$inline$::std::string* $classname$::$release_name$() {\n" + "inline ::std::string* $classname$::$release_name$() {\n" " // @@protoc_insertion_point(field_release:$full_name$)\n" " $clear_hasbit$\n" " return $name$_.ReleaseNoArena($default_variable$);\n" "}\n" - "$inline$void $classname$::set_allocated_$name$(::std::string* $name$) {\n" + "inline void $classname$::set_allocated_$name$(::std::string* $name$) {\n" " if ($name$ != NULL) {\n" " $set_hasbit$\n" " } else {\n" @@ -369,11 +402,11 @@ GenerateMessageClearingCode(io::Printer* printer) const { // When Arenas are disabled and field presence has been checked, we can // safely treat the ArenaStringPtr as a string*. if (descriptor_->default_value_string().empty()) { - printer->Print(variables_, - "(*$name$_.UnsafeRawStringPointer())->clear();\n"); + printer->Print(variables_, "$name$_.UnsafeMutablePointer()->clear();\n"); } else { - printer->Print(variables_, - "(*$name$_.UnsafeRawStringPointer())->assign(*$default_variable$);\n"); + printer->Print( + variables_, + "$name$_.UnsafeMutablePointer()->assign(*$default_variable$);\n"); } } else { if (descriptor_->default_value_string().empty()) { @@ -426,7 +459,7 @@ GenerateCopyConstructorCode(io::Printer* printer) const { if (SupportsArenas(descriptor_) || descriptor_->containing_oneof() != NULL) { // TODO(gpike): improve this printer->Print(variables_, - "$name$_.Set($default_variable$, from.$name$(),\n" + "$name$_.Set$lite$($default_variable$, from.$name$(),\n" " GetArenaNoVirtual());\n"); } else { printer->Print(variables_, @@ -439,32 +472,21 @@ GenerateCopyConstructorCode(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$, arena);\n"); - } else { - printer->Print(variables_, - "$name$_.DestroyNoArena($default_variable$);\n"); - } + printer->Print(variables_, + "$name$_.DestroyNoArena($default_variable$);\n"); } void StringFieldGenerator:: GenerateDefaultInstanceAllocator(io::Printer* printer) const { if (!descriptor_->default_value_string().empty()) { - printer->Print(variables_, - "$classname$::$default_variable_name$.DefaultConstruct();\n" - "*$classname$::$default_variable_name$.get_mutable() = " - "::std::string($default$, $default_length$);\n"); - } -} - -void StringFieldGenerator:: -GenerateShutdownCode(io::Printer* printer) const { - if (!descriptor_->default_value_string().empty()) { - printer->Print(variables_, - "$classname$::$default_variable_name$.Shutdown();\n"); + printer->Print( + variables_, + "$ns$::$classname$::$default_variable_name$.DefaultConstruct();\n" + "*$ns$::$classname$::$default_variable_name$.get_mutable() = " + "::std::string($default$, $default_length$);\n" + "::google::protobuf::internal::OnShutdownDestroyString(\n" + " $ns$::$classname$::$default_variable_name$.get_mutable());\n" + ); } } @@ -477,16 +499,23 @@ GenerateMergeFromCodedStream(io::Printer* printer) const { if (descriptor_->type() == FieldDescriptor::TYPE_STRING) { GenerateUtf8CheckCodeForString( descriptor_, options_, true, variables_, - "this->$name$().data(), this->$name$().length(),\n", printer); + "this->$name$().data(), static_cast<int>(this->$name$().length()),\n", + printer); } } +bool StringFieldGenerator:: +MergeFromCodedStreamNeedsArena() const { + return false; +} + void StringFieldGenerator:: GenerateSerializeWithCachedSizes(io::Printer* printer) const { if (descriptor_->type() == FieldDescriptor::TYPE_STRING) { GenerateUtf8CheckCodeForString( descriptor_, options_, false, variables_, - "this->$name$().data(), this->$name$().length(),\n", printer); + "this->$name$().data(), static_cast<int>(this->$name$().length()),\n", + printer); } printer->Print(variables_, "::google::protobuf::internal::WireFormatLite::Write$declared_type$MaybeAliased(\n" @@ -498,7 +527,8 @@ GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const { if (descriptor_->type() == FieldDescriptor::TYPE_STRING) { GenerateUtf8CheckCodeForString( descriptor_, options_, false, variables_, - "this->$name$().data(), this->$name$().length(),\n", printer); + "this->$name$().data(), static_cast<int>(this->$name$().length()),\n", + printer); } printer->Print(variables_, "target =\n" @@ -527,108 +557,119 @@ StringOneofFieldGenerator(const FieldDescriptor* descriptor, StringOneofFieldGenerator::~StringOneofFieldGenerator() {} void StringOneofFieldGenerator:: -GenerateInlineAccessorDefinitions(io::Printer* printer, - bool is_inline) const { - std::map<string, string> variables(variables_); - variables["inline"] = is_inline ? "inline " : ""; +GenerateInlineAccessorDefinitions(io::Printer* printer) const { if (SupportsArenas(descriptor_)) { printer->Print( - variables, - "$inline$const ::std::string& $classname$::$name$() const {\n" + variables_, + "inline const ::std::string& $classname$::$name$() const {\n" " // @@protoc_insertion_point(field_get:$full_name$)\n" " if (has_$name$()) {\n" - " return $oneof_prefix$$name$_.Get();\n" + " return $field_member$.Get();\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" - " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n" + " $field_member$.UnsafeSetDefault($default_variable$);\n" " }\n" - " $oneof_prefix$$name$_.Set($default_variable$, value,\n" + " $field_member$.Set$lite$($default_variable$, value,\n" " GetArenaNoVirtual());\n" " // @@protoc_insertion_point(field_set:$full_name$)\n" "}\n" - "$inline$void $classname$::set_$name$(const char* value) {\n" + "#if LANG_CXX11\n" + "inline void $classname$::set_$name$(::std::string&& value) {\n" + " // @@protoc_insertion_point(field_set:$full_name$)\n" + " if (!has_$name$()) {\n" + " clear_$oneof_name$();\n" + " set_has_$name$();\n" + " $field_member$.UnsafeSetDefault($default_variable$);\n" + " }\n" + " $field_member$.Set$lite$(\n" + " $default_variable$, ::std::move(value), GetArenaNoVirtual());\n" + " // @@protoc_insertion_point(field_set_rvalue:$full_name$)\n" + "}\n" + "#endif\n" + "inline void $classname$::set_$name$(const char* value) {\n" " $null_check$" " if (!has_$name$()) {\n" " clear_$oneof_name$();\n" " set_has_$name$();\n" - " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n" + " $field_member$.UnsafeSetDefault($default_variable$);\n" " }\n" - " $oneof_prefix$$name$_.Set($default_variable$,\n" + " $field_member$.Set$lite$($default_variable$,\n" " $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" " clear_$oneof_name$();\n" " set_has_$name$();\n" - " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n" + " $field_member$.UnsafeSetDefault($default_variable$);\n" " }\n" - " $oneof_prefix$$name$_.Set($default_variable$, $string_piece$(\n" + " $field_member$.Set$lite$(\n" + " $default_variable$, $string_piece$(\n" " reinterpret_cast<const char*>(value), size),\n" " GetArenaNoVirtual());\n" " // @@protoc_insertion_point(field_set_pointer:$full_name$)\n" "}\n" - "$inline$::std::string* $classname$::mutable_$name$() {\n" + "inline ::std::string* $classname$::mutable_$name$() {\n" " if (!has_$name$()) {\n" " clear_$oneof_name$();\n" " set_has_$name$();\n" - " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n" + " $field_member$.UnsafeSetDefault($default_variable$);\n" " }\n" - " return $oneof_prefix$$name$_.Mutable($default_variable$,\n" + " return $field_member$.Mutable($default_variable$,\n" " 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" - " return $oneof_prefix$$name$_.Release($default_variable$,\n" + " return $field_member$.Release($default_variable$,\n" " GetArenaNoVirtual());\n" " } else {\n" " return NULL;\n" " }\n" "}\n" - "$inline$::std::string* $classname$::unsafe_arena_release_$name$() {\n" + "inline void $classname$::set_allocated_$name$(::std::string* $name$) {\n" + " if (!has_$name$()) {\n" + " $field_member$.UnsafeSetDefault($default_variable$);\n" + " }\n" + " clear_$oneof_name$();\n" + " if ($name$ != NULL) {\n" + " set_has_$name$();\n" + " $field_member$.SetAllocated($default_variable$, $name$,\n" + " GetArenaNoVirtual());\n" + " }\n" + " // @@protoc_insertion_point(field_set_allocated:$full_name$)\n" + "}\n" + "inline ::std::string* $classname$::unsafe_arena_release_$name$() {\n" " // " "@@protoc_insertion_point(field_unsafe_arena_release:$full_name$)\n" " GOOGLE_DCHECK(GetArenaNoVirtual() != NULL);\n" " if (has_$name$()) {\n" " clear_has_$oneof_name$();\n" - " return $oneof_prefix$$name$_.UnsafeArenaRelease(\n" + " return $field_member$.UnsafeArenaRelease(\n" " $default_variable$, GetArenaNoVirtual());\n" " } else {\n" " return NULL;\n" " }\n" "}\n" - "$inline$void $classname$::set_allocated_$name$(::std::string* $name$) {\n" - " if (!has_$name$()) {\n" - " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n" - " }\n" - " clear_$oneof_name$();\n" - " if ($name$ != NULL) {\n" - " set_has_$name$();\n" - " $oneof_prefix$$name$_.SetAllocated($default_variable$, $name$,\n" - " GetArenaNoVirtual());\n" - " }\n" - " // @@protoc_insertion_point(field_set_allocated:$full_name$)\n" - "}\n" - "$inline$void $classname$::unsafe_arena_set_allocated_$name$(" + "inline void $classname$::unsafe_arena_set_allocated_$name$(" "::std::string* $name$) {\n" " GOOGLE_DCHECK(GetArenaNoVirtual() != NULL);\n" " if (!has_$name$()) {\n" - " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n" + " $field_member$.UnsafeSetDefault($default_variable$);\n" " }\n" " clear_$oneof_name$();\n" " if ($name$) {\n" " set_has_$name$();\n" - " $oneof_prefix$$name$_.UnsafeArenaSetAllocated($default_variable$, " + " $field_member$.UnsafeArenaSetAllocated($default_variable$, " "$name$, GetArenaNoVirtual());\n" " }\n" " // @@protoc_insertion_point(field_unsafe_arena_set_allocated:" @@ -637,88 +678,85 @@ GenerateInlineAccessorDefinitions(io::Printer* printer, } else { // No-arena case. printer->Print( - variables, - "$inline$const ::std::string& $classname$::$name$() const {\n" + variables_, + "inline const ::std::string& $classname$::$name$() const {\n" " // @@protoc_insertion_point(field_get:$full_name$)\n" " if (has_$name$()) {\n" - " return $oneof_prefix$$name$_.GetNoArena();\n" + " return $field_member$.GetNoArena();\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" " set_has_$name$();\n" - " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n" + " $field_member$.UnsafeSetDefault($default_variable$);\n" " }\n" - " $oneof_prefix$$name$_.SetNoArena($default_variable$, value);\n" + " $field_member$.SetNoArena($default_variable$, value);\n" " // @@protoc_insertion_point(field_set:$full_name$)\n" "}\n" "#if LANG_CXX11\n" - "$inline$void $classname$::set_$name$(::std::string&& value) {\n" + "inline void $classname$::set_$name$(::std::string&& value) {\n" " // @@protoc_insertion_point(field_set:$full_name$)\n" " if (!has_$name$()) {\n" " clear_$oneof_name$();\n" " set_has_$name$();\n" - " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n" + " $field_member$.UnsafeSetDefault($default_variable$);\n" " }\n" - " $oneof_prefix$$name$_.SetNoArena(\n" - " $default_variable$, ::std::move(value));\n" + " $field_member$.SetNoArena($default_variable$, ::std::move(value));\n" " // @@protoc_insertion_point(field_set_rvalue:$full_name$)\n" "}\n" "#endif\n" - "$inline$void $classname$::set_$name$(const char* value) {\n" + "inline void $classname$::set_$name$(const char* value) {\n" " $null_check$" " if (!has_$name$()) {\n" " clear_$oneof_name$();\n" " set_has_$name$();\n" - " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n" + " $field_member$.UnsafeSetDefault($default_variable$);\n" " }\n" - " $oneof_prefix$$name$_.SetNoArena($default_variable$,\n" + " $field_member$.SetNoArena($default_variable$,\n" " $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" " set_has_$name$();\n" - " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n" + " $field_member$.UnsafeSetDefault($default_variable$);\n" " }\n" - " $oneof_prefix$$name$_.SetNoArena($default_variable$, " - "$string_piece$(\n" + " $field_member$.SetNoArena($default_variable$, $string_piece$(\n" " reinterpret_cast<const char*>(value), size));\n" " // @@protoc_insertion_point(field_set_pointer:$full_name$)\n" "}\n" - "$inline$::std::string* $classname$::mutable_$name$() {\n" + "inline ::std::string* $classname$::mutable_$name$() {\n" " if (!has_$name$()) {\n" " clear_$oneof_name$();\n" " set_has_$name$();\n" - " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n" + " $field_member$.UnsafeSetDefault($default_variable$);\n" " }\n" " // @@protoc_insertion_point(field_mutable:$full_name$)\n" - " return $oneof_prefix$$name$_.MutableNoArena($default_variable$);\n" + " return $field_member$.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" - " return $oneof_prefix$$name$_.ReleaseNoArena($default_variable$);\n" + " return $field_member$.ReleaseNoArena($default_variable$);\n" " } else {\n" " 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" + " $field_member$.UnsafeSetDefault($default_variable$);\n" " }\n" " clear_$oneof_name$();\n" " if ($name$ != NULL) {\n" " set_has_$name$();\n" - " $oneof_prefix$$name$_.SetAllocatedNoArena($default_variable$,\n" - " $name$);\n" + " $field_member$.SetAllocatedNoArena($default_variable$, $name$);\n" " }\n" " // @@protoc_insertion_point(field_set_allocated:$full_name$)\n" "}\n"); @@ -727,30 +765,13 @@ GenerateInlineAccessorDefinitions(io::Printer* printer, void StringOneofFieldGenerator:: GenerateClearingCode(io::Printer* printer) const { - std::map<string, string> variables(variables_); - if (dependent_field_) { - variables["this_message"] = DependentBaseDownCast(); - // This clearing code may be in the dependent base class. If the default - // value is an empty string, then the $default_variable$ is a global - // singleton. If the default is not empty, we need to down-cast to get the - // default value's global singleton instance. See SetStringVariables() for - // possible values of default_variable. - if (!descriptor_->default_value_string().empty()) { - variables["default_variable"] = "&" + DependentBaseDownCast() + - variables["default_variable_name"] + - ".get()"; - } - } else { - variables["this_message"] = ""; - } if (SupportsArenas(descriptor_)) { - printer->Print(variables, - "$this_message$$oneof_prefix$$name$_.Destroy($default_variable$,\n" - " $this_message$GetArenaNoVirtual());\n"); + printer->Print(variables_, + "$field_member$.Destroy($default_variable$,\n" + " GetArenaNoVirtual());\n"); } else { - printer->Print(variables, - "$this_message$$oneof_prefix$$name$_." - "DestroyNoArena($default_variable$);\n"); + printer->Print(variables_, + "$field_member$.DestroyNoArena($default_variable$);\n"); } } @@ -768,24 +789,16 @@ void StringOneofFieldGenerator:: GenerateConstructorCode(io::Printer* printer) const { printer->Print( variables_, - "_$classname$_default_instance_.$name$_.UnsafeSetDefault(\n" + "$ns$::_$classname$_default_instance_.$name$_.UnsafeSetDefault(\n" " $default_variable$);\n"); } void StringOneofFieldGenerator:: GenerateDestructorCode(io::Printer* printer) const { - if (SupportsArenas(descriptor_)) { - printer->Print(variables_, - "if (has_$name$()) {\n" - " $oneof_prefix$$name$_.Destroy($default_variable$,\n" - " GetArenaNoVirtual());\n" - "}\n"); - } else { - printer->Print(variables_, - "if (has_$name$()) {\n" - " $oneof_prefix$$name$_.DestroyNoArena($default_variable$);\n" - "}\n"); - } + printer->Print(variables_, + "if (has_$name$()) {\n" + " $field_member$.DestroyNoArena($default_variable$);\n" + "}\n"); } void StringOneofFieldGenerator:: @@ -797,7 +810,8 @@ GenerateMergeFromCodedStream(io::Printer* printer) const { if (descriptor_->type() == FieldDescriptor::TYPE_STRING) { GenerateUtf8CheckCodeForString( descriptor_, options_, true, variables_, - "this->$name$().data(), this->$name$().length(),\n", printer); + "this->$name$().data(), static_cast<int>(this->$name$().length()),\n", + printer); } } @@ -833,28 +847,62 @@ GenerateAccessorDeclarations(io::Printer* printer) const { } printer->Print(variables_, - "$deprecated_attr$const ::std::string& $name$(int index) const;\n" - "$deprecated_attr$::std::string* mutable_$name$(int index);\n" - "$deprecated_attr$void set_$name$(int index, const ::std::string& value);\n" - "#if LANG_CXX11\n" - "$deprecated_attr$void set_$name$(int index, ::std::string&& value);\n" - "#endif\n" - "$deprecated_attr$void set_$name$(int index, const char* value);\n" - "" - "$deprecated_attr$void set_$name$(" - "int index, const $pointer_type$* value, size_t size);\n" - "$deprecated_attr$::std::string* add_$name$();\n" - "$deprecated_attr$void add_$name$(const ::std::string& value);\n" - "#if LANG_CXX11\n" - "$deprecated_attr$void add_$name$(::std::string&& value);\n" - "#endif\n" - "$deprecated_attr$void add_$name$(const char* value);\n" - "$deprecated_attr$void add_$name$(const $pointer_type$* value, size_t size)" - ";\n" - "$deprecated_attr$const ::google::protobuf::RepeatedPtrField< ::std::string>& $name$() " - "const;\n" - "$deprecated_attr$::google::protobuf::RepeatedPtrField< ::std::string>* mutable_$name$()" + "$deprecated_attr$const ::std::string& $name$(int index) const;\n"); + printer->Annotate("name", descriptor_); + printer->Print( + variables_, + "$deprecated_attr$::std::string* ${$mutable_$name$$}$(int index);\n"); + printer->Annotate("{", "}", descriptor_); + printer->Print(variables_, + "$deprecated_attr$void ${$set_$name$$}$(int index, const " + "::std::string& value);\n"); + printer->Annotate("{", "}", descriptor_); + printer->Print( + variables_, + "#if LANG_CXX11\n" + "$deprecated_attr$void ${$set_$name$$}$(int index, ::std::string&& value);\n" + "#endif\n"); + printer->Annotate("{", "}", descriptor_); + printer->Print(variables_, + "$deprecated_attr$void ${$set_$name$$}$(int index, const " + "char* value);\n"); + printer->Annotate("{", "}", descriptor_); + printer->Print(variables_, + "" + "$deprecated_attr$void ${$set_$name$$}$(" + "int index, const $pointer_type$* value, size_t size);\n"); + printer->Annotate("{", "}", descriptor_); + printer->Print(variables_, + "$deprecated_attr$::std::string* ${$add_$name$$}$();\n"); + printer->Annotate("{", "}", descriptor_); + printer->Print( + variables_, + "$deprecated_attr$void ${$add_$name$$}$(const ::std::string& value);\n"); + printer->Annotate("{", "}", descriptor_); + printer->Print(variables_, + "#if LANG_CXX11\n" + "$deprecated_attr$void ${$add_$name$$}$(::std::string&& value);\n" + "#endif\n"); + printer->Annotate("{", "}", descriptor_); + printer->Print( + variables_, + "$deprecated_attr$void ${$add_$name$$}$(const char* value);\n"); + printer->Annotate("{", "}", descriptor_); + printer->Print(variables_, + "$deprecated_attr$void ${$add_$name$$}$(const $pointer_type$* " + "value, size_t size)" ";\n"); + printer->Annotate("{", "}", descriptor_); + printer->Print( + variables_, + "$deprecated_attr$const ::google::protobuf::RepeatedPtrField< ::std::string>& $name$() " + "const;\n"); + printer->Annotate("name", descriptor_); + printer->Print(variables_, + "$deprecated_attr$::google::protobuf::RepeatedPtrField< ::std::string>* " + "${$mutable_$name$$}$()" + ";\n"); + printer->Annotate("{", "}", descriptor_); if (unknown_ctype) { printer->Outdent(); @@ -864,71 +912,78 @@ GenerateAccessorDeclarations(io::Printer* printer) const { } void RepeatedStringFieldGenerator:: -GenerateInlineAccessorDefinitions(io::Printer* printer, - bool is_inline) const { - std::map<string, string> variables(variables_); - variables["inline"] = is_inline ? "inline " : ""; - printer->Print(variables, - "$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" +GenerateInlineAccessorDefinitions(io::Printer* printer) const { + if (options_.safe_boundary_check) { + printer->Print(variables_, + "inline const ::std::string& $classname$::$name$(int index) const {\n" + " // @@protoc_insertion_point(field_get:$full_name$)\n" + " return $name$_.InternalCheckedGet(\n" + " index, ::google::protobuf::internal::GetEmptyStringAlreadyInited());\n" + "}\n"); + } else { + printer->Print(variables_, + "inline const ::std::string& $classname$::$name$(int index) const {\n" + " // @@protoc_insertion_point(field_get:$full_name$)\n" + " return $name$_.Get(index);\n" + "}\n"); + } + printer->Print(variables_, + "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" "#if LANG_CXX11\n" - "$inline$void $classname$::set_$name$(int index, ::std::string&& value) {\n" + "inline void $classname$::set_$name$(int index, ::std::string&& value) {\n" " // @@protoc_insertion_point(field_set:$full_name$)\n" " $name$_.Mutable(index)->assign(std::move(value));\n" "}\n" "#endif\n" - "$inline$void $classname$::set_$name$(int index, const char* value) {\n" + "inline void $classname$::set_$name$(int index, const char* value) {\n" " $null_check$" " $name$_.Mutable(index)->assign(value);\n" " // @@protoc_insertion_point(field_set_char:$full_name$)\n" "}\n" - "$inline$void " + "inline void " "$classname$::set_$name$" "(int index, const $pointer_type$* value, size_t size) {\n" " $name$_.Mutable(index)->assign(\n" " reinterpret_cast<const char*>(value), size);\n" " // @@protoc_insertion_point(field_set_pointer:$full_name$)\n" "}\n" - "$inline$::std::string* $classname$::add_$name$() {\n" + "inline ::std::string* $classname$::add_$name$() {\n" " // @@protoc_insertion_point(field_add_mutable:$full_name$)\n" " return $name$_.Add();\n" "}\n" - "$inline$void $classname$::add_$name$(const ::std::string& value) {\n" + "inline void $classname$::add_$name$(const ::std::string& value) {\n" " $name$_.Add()->assign(value);\n" " // @@protoc_insertion_point(field_add:$full_name$)\n" "}\n" "#if LANG_CXX11\n" - "$inline$void $classname$::add_$name$(::std::string&& value) {\n" + "inline void $classname$::add_$name$(::std::string&& value) {\n" " $name$_.Add(std::move(value));\n" " // @@protoc_insertion_point(field_add:$full_name$)\n" "}\n" "#endif\n" - "$inline$void $classname$::add_$name$(const char* value) {\n" + "inline void $classname$::add_$name$(const char* value) {\n" " $null_check$" " $name$_.Add()->assign(value);\n" " // @@protoc_insertion_point(field_add_char:$full_name$)\n" "}\n" - "$inline$void " + "inline void " "$classname$::add_$name$(const $pointer_type$* value, size_t size) {\n" " $name$_.Add()->assign(reinterpret_cast<const char*>(value), size);\n" " // @@protoc_insertion_point(field_add_pointer:$full_name$)\n" "}\n" - "$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" @@ -947,7 +1002,8 @@ GenerateMergingCode(io::Printer* printer) const { void RepeatedStringFieldGenerator:: GenerateSwappingCode(io::Printer* printer) const { - printer->Print(variables_, "$name$_.InternalSwap(&other->$name$_);\n"); + printer->Print(variables_, + "$name$_.InternalSwap(CastToBase(&other->$name$_));\n"); } void RepeatedStringFieldGenerator:: @@ -969,7 +1025,7 @@ GenerateMergeFromCodedStream(io::Printer* printer) const { GenerateUtf8CheckCodeForString( descriptor_, options_, true, variables_, "this->$name$(this->$name$_size() - 1).data(),\n" - "this->$name$(this->$name$_size() - 1).length(),\n", + "static_cast<int>(this->$name$(this->$name$_size() - 1).length()),\n", printer); } } @@ -982,7 +1038,8 @@ GenerateSerializeWithCachedSizes(io::Printer* printer) const { if (descriptor_->type() == FieldDescriptor::TYPE_STRING) { GenerateUtf8CheckCodeForString( descriptor_, options_, false, variables_, - "this->$name$(i).data(), this->$name$(i).length(),\n", printer); + "this->$name$(i).data(), static_cast<int>(this->$name$(i).length()),\n", + printer); } printer->Outdent(); printer->Print(variables_, @@ -999,7 +1056,8 @@ GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const { if (descriptor_->type() == FieldDescriptor::TYPE_STRING) { GenerateUtf8CheckCodeForString( descriptor_, options_, false, variables_, - "this->$name$(i).data(), this->$name$(i).length(),\n", printer); + "this->$name$(i).data(), static_cast<int>(this->$name$(i).length()),\n", + printer); } printer->Outdent(); printer->Print(variables_, diff --git a/src/google/protobuf/compiler/cpp/cpp_string_field.h b/src/google/protobuf/compiler/cpp/cpp_string_field.h index af263c1a..0c6e9ced 100644 --- a/src/google/protobuf/compiler/cpp/cpp_string_field.h +++ b/src/google/protobuf/compiler/cpp/cpp_string_field.h @@ -54,8 +54,7 @@ class StringFieldGenerator : public FieldGenerator { void GeneratePrivateMembers(io::Printer* printer) const; void GenerateStaticMembers(io::Printer* printer) const; void GenerateAccessorDeclarations(io::Printer* printer) const; - void GenerateInlineAccessorDefinitions(io::Printer* printer, - bool is_inline) const; + void GenerateInlineAccessorDefinitions(io::Printer* printer) const; void GenerateNonInlineAccessorDefinitions(io::Printer* printer) const; void GenerateClearingCode(io::Printer* printer) const; void GenerateMessageClearingCode(io::Printer* printer) const; @@ -65,15 +64,17 @@ class StringFieldGenerator : public FieldGenerator { void GenerateCopyConstructorCode(io::Printer* printer) const; void GenerateDestructorCode(io::Printer* printer) const; void GenerateDefaultInstanceAllocator(io::Printer* printer) const; - void GenerateShutdownCode(io::Printer* printer) const; void GenerateMergeFromCodedStream(io::Printer* printer) const; void GenerateSerializeWithCachedSizes(io::Printer* printer) const; void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const; void GenerateByteSize(io::Printer* printer) const; + bool MergeFromCodedStreamNeedsArena() const; + protected: const FieldDescriptor* descriptor_; std::map<string, string> variables_; + const bool lite_; private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(StringFieldGenerator); @@ -86,8 +87,7 @@ class StringOneofFieldGenerator : public StringFieldGenerator { ~StringOneofFieldGenerator(); // implements FieldGenerator --------------------------------------- - void GenerateInlineAccessorDefinitions(io::Printer* printer, - bool is_inline) const; + void GenerateInlineAccessorDefinitions(io::Printer* printer) const; void GenerateClearingCode(io::Printer* printer) const; // StringFieldGenerator, from which we inherit, overrides this so we need to @@ -112,8 +112,7 @@ class RepeatedStringFieldGenerator : public FieldGenerator { // implements FieldGenerator --------------------------------------- void GeneratePrivateMembers(io::Printer* printer) const; void GenerateAccessorDeclarations(io::Printer* printer) const; - void GenerateInlineAccessorDefinitions(io::Printer* printer, - bool is_inline) const; + void GenerateInlineAccessorDefinitions(io::Printer* printer) const; void GenerateClearingCode(io::Printer* printer) const; void GenerateMergingCode(io::Printer* printer) const; void GenerateSwappingCode(io::Printer* printer) const; diff --git a/src/google/protobuf/compiler/cpp/cpp_test_bad_identifiers.proto b/src/google/protobuf/compiler/cpp/cpp_test_bad_identifiers.proto index 4e25b2ea..7fe98759 100644 --- a/src/google/protobuf/compiler/cpp/cpp_test_bad_identifiers.proto +++ b/src/google/protobuf/compiler/cpp/cpp_test_bad_identifiers.proto @@ -151,6 +151,10 @@ enum ConflictingEnum { // NO_PROTO3 message DummyMessage {} +// Message names that could conflict. +message Shutdown {} +message TableStruct {} + service TestConflictingMethodNames { rpc Closure(DummyMessage) returns (DummyMessage); } diff --git a/src/google/protobuf/compiler/cpp/cpp_unittest.cc b/src/google/protobuf/compiler/cpp/cpp_unittest.cc index e56964c7..2ad7ea4e 100644 --- a/src/google/protobuf/compiler/cpp/cpp_unittest.cc +++ b/src/google/protobuf/compiler/cpp/cpp_unittest.cc @@ -576,12 +576,73 @@ TEST(GeneratedMessageTest, SwapWithOther) { EXPECT_EQ(unittest::TestAllTypes::BAR, message2.repeated_nested_enum(1)); } -TEST(GeneratedMessageTest, CopyConstructor) { - unittest::TestAllTypes message1; +TEST(GeneratedMessageTest, ADLSwap) { + unittest::TestAllTypes message1, message2; TestUtil::SetAllFields(&message1); - unittest::TestAllTypes message2(message1); + // Note the address of one of the repeated fields, to verify it was swapped + // rather than copied. + const int32* addr = &message1.repeated_int32().Get(0); + + using std::swap; + swap(message1, message2); + TestUtil::ExpectAllFieldsSet(message2); + TestUtil::ExpectClear(message1); + + EXPECT_EQ(addr, &message2.repeated_int32().Get(0)); +} + +TEST(GeneratedMessageTest, CopyConstructor) { + // All set. + { + unittest::TestAllTypes message1; + TestUtil::SetAllFields(&message1); + + unittest::TestAllTypes message2(message1); + TestUtil::ExpectAllFieldsSet(message2); + } + + // None set. + { + unittest::TestAllTypes message1; + unittest::TestAllTypes message2(message1); + + EXPECT_FALSE(message1.has_optional_string()); + EXPECT_FALSE(message2.has_optional_string()); + EXPECT_EQ(&message1.optional_string(), + &message2.optional_string()); + + EXPECT_FALSE(message1.has_optional_bytes()); + EXPECT_FALSE(message2.has_optional_bytes()); + EXPECT_EQ(&message1.optional_bytes(), + &message2.optional_bytes()); + + EXPECT_FALSE(message1.has_optional_nested_message()); + EXPECT_FALSE(message2.has_optional_nested_message()); + EXPECT_EQ(&message1.optional_nested_message(), + &message2.optional_nested_message()); + + EXPECT_FALSE(message1.has_optional_foreign_message()); + EXPECT_FALSE(message2.has_optional_foreign_message()); + EXPECT_EQ(&message1.optional_foreign_message(), + &message2.optional_foreign_message()); + + EXPECT_FALSE(message1.has_optional_import_message()); + EXPECT_FALSE(message2.has_optional_import_message()); + EXPECT_EQ(&message1.optional_import_message(), + &message2.optional_import_message()); + + EXPECT_FALSE(message1.has_optional_public_import_message()); + EXPECT_FALSE(message2.has_optional_public_import_message()); + EXPECT_EQ(&message1.optional_public_import_message(), + &message2.optional_public_import_message()); + + EXPECT_FALSE(message1.has_optional_lazy_message()); + EXPECT_FALSE(message2.has_optional_lazy_message()); + EXPECT_EQ(&message1.optional_lazy_message(), + &message2.optional_lazy_message()); + } } TEST(GeneratedMessageTest, CopyConstructorWithArenas) { @@ -683,21 +744,6 @@ TEST(GeneratedMessageTest, NonEmptyMergeFrom) { TestUtil::ExpectAllFieldsSet(message1); } -#if !defined(PROTOBUF_TEST_NO_DESCRIPTORS) || \ - !defined(GOOGLE_PROTOBUF_NO_RTTI) -#ifdef PROTOBUF_HAS_DEATH_TEST -#ifndef NDEBUG - -TEST(GeneratedMessageTest, MergeFromSelf) { - unittest::TestAllTypes message; - EXPECT_DEATH(message.MergeFrom(message), "pb[.]cc.*Check failed:"); - EXPECT_DEATH(message.MergeFrom(implicit_cast<const Message&>(message)), - "pb[.]cc.*Check failed:"); -} - -#endif // NDEBUG -#endif // PROTOBUF_HAS_DEATH_TEST -#endif // !PROTOBUF_TEST_NO_DESCRIPTORS || !GOOGLE_PROTOBUF_NO_RTTI // Test the generated SerializeWithCachedSizesToArray(), TEST(GeneratedMessageTest, SerializationToArray) { @@ -949,75 +995,76 @@ TEST(GeneratedMessageTest, TestEmbedOptimizedForSize) { TEST(GeneratedMessageTest, TestSpaceUsed) { unittest::TestAllTypes message1; - // sizeof provides a lower bound on SpaceUsed(). - EXPECT_LE(sizeof(unittest::TestAllTypes), message1.SpaceUsed()); - const int empty_message_size = message1.SpaceUsed(); + // sizeof provides a lower bound on SpaceUsedLong(). + EXPECT_LE(sizeof(unittest::TestAllTypes), message1.SpaceUsedLong()); + const size_t empty_message_size = message1.SpaceUsedLong(); // Setting primitive types shouldn't affect the space used. message1.set_optional_int32(123); message1.set_optional_int64(12345); message1.set_optional_uint32(123); message1.set_optional_uint64(12345); - EXPECT_EQ(empty_message_size, message1.SpaceUsed()); + EXPECT_EQ(empty_message_size, message1.SpaceUsedLong()); // On some STL implementations, setting the string to a small value should - // only increase SpaceUsed() by the size of a string object, though this is - // not true everywhere. + // only increase SpaceUsedLong() by the size of a string object, though this + // is not true everywhere. message1.set_optional_string("abc"); - EXPECT_LE(empty_message_size + sizeof(string), message1.SpaceUsed()); + EXPECT_LE(empty_message_size + sizeof(string), message1.SpaceUsedLong()); // Setting a string to a value larger than the string object itself should - // increase SpaceUsed(), because it cannot store the value internally. + // increase SpaceUsedLong(), because it cannot store the value internally. message1.set_optional_string(string(sizeof(string) + 1, 'x')); int min_expected_increase = message1.optional_string().capacity() + sizeof(string); EXPECT_LE(empty_message_size + min_expected_increase, - message1.SpaceUsed()); + message1.SpaceUsedLong()); - int previous_size = message1.SpaceUsed(); + size_t previous_size = message1.SpaceUsedLong(); // Adding an optional message should increase the size by the size of the // nested message type. NestedMessage is simple enough (1 int field) that it // is equal to sizeof(NestedMessage) message1.mutable_optional_nested_message(); ASSERT_EQ(sizeof(unittest::TestAllTypes::NestedMessage), - message1.optional_nested_message().SpaceUsed()); + message1.optional_nested_message().SpaceUsedLong()); EXPECT_EQ(previous_size + sizeof(unittest::TestAllTypes::NestedMessage), - message1.SpaceUsed()); + message1.SpaceUsedLong()); } TEST(GeneratedMessageTest, TestOneofSpaceUsed) { unittest::TestOneof2 message1; - EXPECT_LE(sizeof(unittest::TestOneof2), message1.SpaceUsed()); + EXPECT_LE(sizeof(unittest::TestOneof2), message1.SpaceUsedLong()); - const int empty_message_size = message1.SpaceUsed(); + const size_t empty_message_size = message1.SpaceUsedLong(); // Setting primitive types shouldn't affect the space used. message1.set_foo_int(123); message1.set_bar_int(12345); - EXPECT_EQ(empty_message_size, message1.SpaceUsed()); + EXPECT_EQ(empty_message_size, message1.SpaceUsedLong()); - // Setting a string in oneof to a small value should only increase SpaceUsed() - // by the size of a string object. + // Setting a string in oneof to a small value should only increase + // SpaceUsedLong() by the size of a string object. message1.set_foo_string("abc"); - EXPECT_LE(empty_message_size + sizeof(string), message1.SpaceUsed()); + EXPECT_LE(empty_message_size + sizeof(string), message1.SpaceUsedLong()); // Setting a string in oneof to a value larger than the string object itself - // should increase SpaceUsed(), because it cannot store the value internally. + // should increase SpaceUsedLong(), because it cannot store the value + // internally. message1.set_foo_string(string(sizeof(string) + 1, 'x')); int min_expected_increase = message1.foo_string().capacity() + sizeof(string); EXPECT_LE(empty_message_size + min_expected_increase, - message1.SpaceUsed()); + message1.SpaceUsedLong()); // Setting a message in oneof should delete the other fields and increase the // size by the size of the nested message type. NestedMessage is simple enough // that it is equal to sizeof(NestedMessage) message1.mutable_foo_message(); ASSERT_EQ(sizeof(unittest::TestOneof2::NestedMessage), - message1.foo_message().SpaceUsed()); + message1.foo_message().SpaceUsedLong()); EXPECT_EQ(empty_message_size + sizeof(unittest::TestOneof2::NestedMessage), - message1.SpaceUsed()); + message1.SpaceUsedLong()); } #endif // !PROTOBUF_TEST_NO_DESCRIPTORS @@ -1340,7 +1387,7 @@ class GeneratedServiceTest : public testing::Test { foo_(descriptor_->FindMethodByName("Foo")), bar_(descriptor_->FindMethodByName("Bar")), stub_(&mock_channel_), - done_(NewPermanentCallback(&DoNothing)) {} + done_(::google::protobuf::NewPermanentCallback(&DoNothing)) {} virtual void SetUp() { ASSERT_TRUE(foo_ != NULL); diff --git a/src/google/protobuf/compiler/cpp/metadata_test.cc b/src/google/protobuf/compiler/cpp/metadata_test.cc index 03f6b12b..456784c6 100644 --- a/src/google/protobuf/compiler/cpp/metadata_test.cc +++ b/src/google/protobuf/compiler/cpp/metadata_test.cc @@ -35,10 +35,8 @@ #include <google/protobuf/compiler/cpp/cpp_helpers.h> #include <google/protobuf/compiler/cpp/cpp_generator.h> +#include <google/protobuf/compiler/annotation_test_util.h> #include <google/protobuf/compiler/command_line_interface.h> -#include <google/protobuf/io/zero_copy_stream.h> -#include <google/protobuf/io/zero_copy_stream_impl_lite.h> -#include <google/protobuf/io/printer.h> #include <google/protobuf/descriptor.pb.h> #include <google/protobuf/testing/file.h> @@ -47,37 +45,15 @@ #include <gtest/gtest.h> namespace google { +namespace atu = ::google::protobuf::compiler::annotation_test_util; + namespace protobuf { namespace compiler { namespace cpp { namespace { -// A CodeGenerator that captures the FileDescriptor it's passed as a -// FileDescriptorProto. -class DescriptorCapturingGenerator : public CodeGenerator { - public: - // Does not own file; file must outlive the Generator. - explicit DescriptorCapturingGenerator(FileDescriptorProto* file) - : file_(file) {} - - virtual bool Generate(const FileDescriptor* file, const string& parameter, - GeneratorContext* context, string* error) const { - file->CopyTo(file_); - return true; - } - - private: - FileDescriptorProto* file_; -}; - class CppMetadataTest : public ::testing::Test { public: - // Adds a file with name `filename` and content `data`. - void AddFile(const string& filename, const string& data) { - GOOGLE_CHECK_OK(File::SetContents(TestTempDir() + "/" + filename, data, - true)); - } - // Tries to capture a FileDescriptorProto, GeneratedCodeInfo, and output // code from the previously added file with name `filename`. Returns true on // success. If pb_h is non-null, expects a .pb.h and a .pb.h.meta (copied to @@ -87,26 +63,19 @@ class CppMetadataTest : public ::testing::Test { string* proto_h, GeneratedCodeInfo* proto_h_info, string* pb_cc) { google::protobuf::compiler::CommandLineInterface cli; - cli.SetInputsAreProtoPathRelative(true); - CppGenerator cpp_generator; - DescriptorCapturingGenerator capturing_generator(file); cli.RegisterGenerator("--cpp_out", &cpp_generator, ""); - cli.RegisterGenerator("--capture_out", &capturing_generator, ""); - - string proto_path = "-I" + TestTempDir(); string cpp_out = "--cpp_out=annotate_headers=true," "annotation_pragma_name=pragma_name," "annotation_guard_name=guard_name:" + TestTempDir(); - string capture_out = "--capture_out=" + TestTempDir(); - const char* argv[] = {"protoc", proto_path.c_str(), cpp_out.c_str(), - capture_out.c_str(), filename.c_str()}; + const bool result = + atu::RunProtoCompiler(filename, cpp_out, &cli, file); - if (cli.Run(5, argv) != 0) { - return false; + if (!result) { + return result; } string output_base = TestTempDir() + "/" + StripProto(filename); @@ -119,7 +88,7 @@ class CppMetadataTest : public ::testing::Test { if (pb_h != NULL && pb_h_info != NULL) { GOOGLE_CHECK_OK( File::GetContents(output_base + ".pb.h", pb_h, true)); - if (!DecodeMetadata(output_base + ".pb.h.meta", pb_h_info)) { + if (!atu::DecodeMetadata(output_base + ".pb.h.meta", pb_h_info)) { return false; } } @@ -127,23 +96,13 @@ class CppMetadataTest : public ::testing::Test { if (proto_h != NULL && proto_h_info != NULL) { GOOGLE_CHECK_OK(File::GetContents(output_base + ".proto.h", proto_h, true)); - if (!DecodeMetadata(output_base + ".proto.h.meta", proto_h_info)) { + if (!atu::DecodeMetadata(output_base + ".proto.h.meta", proto_h_info)) { return false; } } return true; } - - private: - // Decodes GeneratedCodeInfo stored in path and copies it to info. - // Returns true on success. - bool DecodeMetadata(const string& path, GeneratedCodeInfo* info) { - string data; - GOOGLE_CHECK_OK(File::GetContents(path, &data, true)); - io::ArrayInputStream input(data.data(), data.size()); - return info->ParseFromZeroCopyStream(&input); - } }; const char kSmallTestFile[] = @@ -152,48 +111,11 @@ const char kSmallTestFile[] = "enum Enum { VALUE = 0; }\n" "message Message { }\n"; -// Finds the Annotation for a given source file and path (or returns null if it -// couldn't). -const GeneratedCodeInfo::Annotation* FindAnnotationOnPath( - const GeneratedCodeInfo& info, const string& source_file, - const std::vector<int>& path) { - for (int i = 0; i < info.annotation_size(); ++i) { - const GeneratedCodeInfo::Annotation* annotation = &info.annotation(i); - if (annotation->source_file() != source_file || - annotation->path_size() != path.size()) { - continue; - } - int node = 0; - for (; node < path.size(); ++node) { - if (annotation->path(node) != path[node]) { - break; - } - } - if (node == path.size()) { - return annotation; - } - } - return NULL; -} - -// Returns true if the provided annotation covers a given substring in -// file_content. -bool AnnotationMatchesSubstring(const string& file_content, - const GeneratedCodeInfo::Annotation* annotation, - const string& expected_text) { - uint32 begin = annotation->begin(); - uint32 end = annotation->end(); - if (end < begin || end > file_content.size()) { - return false; - } - return file_content.substr(begin, end - begin) == expected_text; -} - TEST_F(CppMetadataTest, CapturesEnumNames) { FileDescriptorProto file; GeneratedCodeInfo info; string pb_h; - AddFile("test.proto", kSmallTestFile); + atu::AddFile("test.proto", kSmallTestFile); EXPECT_TRUE( CaptureMetadata("test.proto", &file, &pb_h, &info, NULL, NULL, NULL)); EXPECT_EQ("Enum", file.enum_type(0).name()); @@ -201,16 +123,16 @@ TEST_F(CppMetadataTest, CapturesEnumNames) { enum_path.push_back(FileDescriptorProto::kEnumTypeFieldNumber); enum_path.push_back(0); const GeneratedCodeInfo::Annotation* enum_annotation = - FindAnnotationOnPath(info, "test.proto", enum_path); + atu::FindAnnotationOnPath(info, "test.proto", enum_path); EXPECT_TRUE(NULL != enum_annotation); - EXPECT_TRUE(AnnotationMatchesSubstring(pb_h, enum_annotation, "Enum")); + EXPECT_TRUE(atu::AnnotationMatchesSubstring(pb_h, enum_annotation, "Enum")); } TEST_F(CppMetadataTest, AddsPragma) { FileDescriptorProto file; GeneratedCodeInfo info; string pb_h; - AddFile("test.proto", kSmallTestFile); + atu::AddFile("test.proto", kSmallTestFile); EXPECT_TRUE( CaptureMetadata("test.proto", &file, &pb_h, &info, NULL, NULL, NULL)); EXPECT_TRUE(pb_h.find("#ifdef guard_name") != string::npos); @@ -222,7 +144,7 @@ TEST_F(CppMetadataTest, CapturesMessageNames) { FileDescriptorProto file; GeneratedCodeInfo info; string pb_h; - AddFile("test.proto", kSmallTestFile); + atu::AddFile("test.proto", kSmallTestFile); EXPECT_TRUE( CaptureMetadata("test.proto", &file, &pb_h, &info, NULL, NULL, NULL)); EXPECT_EQ("Message", file.message_type(0).name()); @@ -230,9 +152,10 @@ TEST_F(CppMetadataTest, CapturesMessageNames) { message_path.push_back(FileDescriptorProto::kMessageTypeFieldNumber); message_path.push_back(0); const GeneratedCodeInfo::Annotation* message_annotation = - FindAnnotationOnPath(info, "test.proto", message_path); + atu::FindAnnotationOnPath(info, "test.proto", message_path); EXPECT_TRUE(NULL != message_annotation); - EXPECT_TRUE(AnnotationMatchesSubstring(pb_h, message_annotation, "Message")); + EXPECT_TRUE( + atu::AnnotationMatchesSubstring(pb_h, message_annotation, "Message")); } } // namespace diff --git a/src/google/protobuf/compiler/csharp/csharp_bootstrap_unittest.cc b/src/google/protobuf/compiler/csharp/csharp_bootstrap_unittest.cc index 4e44b578..8c38e52f 100644 --- a/src/google/protobuf/compiler/csharp/csharp_bootstrap_unittest.cc +++ b/src/google/protobuf/compiler/csharp/csharp_bootstrap_unittest.cc @@ -134,6 +134,14 @@ class GenerateAndTest { }; TEST(CsharpBootstrapTest, GeneratedCsharpDescriptorMatches) { + // Skip this whole test if the csharp directory doesn't exist (i.e., a C++11 + // only distribution). + string descriptor_file_name = + "../csharp/src/Google.Protobuf/Reflection/Descriptor.cs"; + if (!File::Exists(TestSourceDir() + "/" + descriptor_file_name)) { + return; + } + MockErrorCollector error_collector; DiskSourceTree source_tree; Importer importer(&source_tree, &error_collector); @@ -176,11 +184,6 @@ TEST(CsharpBootstrapTest, GeneratedCsharpDescriptorMatches) { "../csharp/src/Google.Protobuf/WellKnownTypes/Wrappers.cs"); generate_test.SetParameter(""); - source_tree.MapPath("", TestSourceDir() + "/../examples"); - generate_test.Run(importer.Import("addressbook.proto"), - "Addressbook.cs", - "../csharp/src/AddressBook/Addressbook.cs"); - source_tree.MapPath("", TestSourceDir() + "/../conformance"); generate_test.Run(importer.Import("conformance.proto"), "Conformance.cs", diff --git a/src/google/protobuf/compiler/csharp/csharp_doc_comment.cc b/src/google/protobuf/compiler/csharp/csharp_doc_comment.cc index 636a76a0..a21dc0a4 100644 --- a/src/google/protobuf/compiler/csharp/csharp_doc_comment.cc +++ b/src/google/protobuf/compiler/csharp/csharp_doc_comment.cc @@ -56,7 +56,7 @@ void WriteDocCommentBodyImpl(io::Printer* printer, SourceLocation location) { // node of a summary element, not part of an attribute. comments = StringReplace(comments, "&", "&", true); comments = StringReplace(comments, "<", "<", true); - vector<string> lines = Split(comments, "\n", false /* skip_empty */); + std::vector<string> lines = Split(comments, "\n", false /* skip_empty */); // TODO: We really should work out which part to put in the summary and which to put in the remarks... // but that needs to be part of a bigger effort to understand the markdown better anyway. printer->Print("/// <summary>\n"); diff --git a/src/google/protobuf/compiler/csharp/csharp_enum_field.cc b/src/google/protobuf/compiler/csharp/csharp_enum_field.cc index 67c0b596..9ceffa8c 100644 --- a/src/google/protobuf/compiler/csharp/csharp_enum_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_enum_field.cc @@ -89,6 +89,10 @@ EnumOneofFieldGenerator::EnumOneofFieldGenerator( EnumOneofFieldGenerator::~EnumOneofFieldGenerator() { } +void EnumOneofFieldGenerator::GenerateMergingCode(io::Printer* printer) { + printer->Print(variables_, "$property_name$ = other.$property_name$;\n"); +} + void EnumOneofFieldGenerator::GenerateParsingCode(io::Printer* printer) { // TODO(jonskeet): What about if we read the default value? printer->Print( diff --git a/src/google/protobuf/compiler/csharp/csharp_enum_field.h b/src/google/protobuf/compiler/csharp/csharp_enum_field.h index 9b7669ba..631632bc 100644 --- a/src/google/protobuf/compiler/csharp/csharp_enum_field.h +++ b/src/google/protobuf/compiler/csharp/csharp_enum_field.h @@ -64,6 +64,7 @@ class EnumOneofFieldGenerator : public PrimitiveOneofFieldGenerator { const Options *options); ~EnumOneofFieldGenerator(); + virtual void GenerateMergingCode(io::Printer* printer); virtual void GenerateParsingCode(io::Printer* printer); virtual void GenerateSerializationCode(io::Printer* printer); virtual void GenerateSerializedSizeCode(io::Printer* printer); diff --git a/src/google/protobuf/compiler/csharp/csharp_field_base.cc b/src/google/protobuf/compiler/csharp/csharp_field_base.cc index ebb8fbc2..ecf29ece 100644 --- a/src/google/protobuf/compiler/csharp/csharp_field_base.cc +++ b/src/google/protobuf/compiler/csharp/csharp_field_base.cc @@ -54,7 +54,7 @@ namespace compiler { namespace csharp { void FieldGeneratorBase::SetCommonFieldVariables( - map<string, string>* variables) { + std::map<string, string>* variables) { // Note: this will be valid even though the tag emitted for packed and unpacked versions of // repeated fields varies by wire format. The wire format is encoded in the bottom 3 bits, which // never effects the tag size. @@ -92,7 +92,7 @@ void FieldGeneratorBase::SetCommonFieldVariables( } void FieldGeneratorBase::SetCommonOneofFieldVariables( - map<string, string>* variables) { + std::map<string, string>* variables) { (*variables)["oneof_name"] = oneof_name(); (*variables)["has_property_check"] = oneof_name() + "Case_ == " + oneof_property_name() + diff --git a/src/google/protobuf/compiler/csharp/csharp_field_base.h b/src/google/protobuf/compiler/csharp/csharp_field_base.h index 4109f3ca..df26853b 100644 --- a/src/google/protobuf/compiler/csharp/csharp_field_base.h +++ b/src/google/protobuf/compiler/csharp/csharp_field_base.h @@ -66,14 +66,14 @@ class FieldGeneratorBase : public SourceGeneratorBase { protected: const FieldDescriptor* descriptor_; const int fieldOrdinal_; - map<string, string> variables_; + std::map<string, string> variables_; void AddDeprecatedFlag(io::Printer* printer); void AddNullCheck(io::Printer* printer); void AddNullCheck(io::Printer* printer, const std::string& name); void AddPublicMemberAttributes(io::Printer* printer); - void SetCommonOneofFieldVariables(map<string, string>* variables); + void SetCommonOneofFieldVariables(std::map<string, string>* variables); std::string oneof_property_name(); std::string oneof_name(); @@ -89,7 +89,7 @@ class FieldGeneratorBase : public SourceGeneratorBase { std::string capitalized_type_name(); private: - void SetCommonFieldVariables(map<string, string>* variables); + void SetCommonFieldVariables(std::map<string, string>* variables); std::string GetStringDefaultValueInternal(); std::string GetBytesDefaultValueInternal(); diff --git a/src/google/protobuf/compiler/csharp/csharp_generator.cc b/src/google/protobuf/compiler/csharp/csharp_generator.cc index c13ed65b..5418127f 100644 --- a/src/google/protobuf/compiler/csharp/csharp_generator.cc +++ b/src/google/protobuf/compiler/csharp/csharp_generator.cc @@ -64,7 +64,7 @@ bool Generator::Generate( GeneratorContext* generator_context, string* error) const { - vector<pair<string, string> > options; + std::vector<std::pair<string, string> > options; ParseGeneratorParameter(parameter, &options); // We only support proto3 - but we make an exception for descriptor.proto. diff --git a/src/google/protobuf/compiler/csharp/csharp_message.cc b/src/google/protobuf/compiler/csharp/csharp_message.cc index 0f00a438..17b4a071 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message.cc +++ b/src/google/protobuf/compiler/csharp/csharp_message.cc @@ -105,13 +105,13 @@ void MessageGenerator::AddDeprecatedFlag(io::Printer* printer) { } void MessageGenerator::Generate(io::Printer* printer) { - map<string, string> vars; + std::map<string, string> vars; vars["class_name"] = class_name(); vars["access_level"] = class_access_level(); WriteMessageDocComment(printer, descriptor_); AddDeprecatedFlag(printer); - + printer->Print( vars, "$access_level$ sealed partial class $class_name$ : pb::IMessage<$class_name$> {\n"); @@ -119,14 +119,17 @@ void MessageGenerator::Generate(io::Printer* printer) { // All static fields and properties printer->Print( - vars, - "private static readonly pb::MessageParser<$class_name$> _parser = new pb::MessageParser<$class_name$>(() => new $class_name$());\n"); + vars, + "private static readonly pb::MessageParser<$class_name$> _parser = new pb::MessageParser<$class_name$>(() => new $class_name$());\n"); + + printer->Print( + "private pb::UnknownFieldSet _unknownFields;\n"); WriteGeneratedCodeAttributes(printer); printer->Print( - vars, - "public static pb::MessageParser<$class_name$> Parser { get { return _parser; } }\n\n"); + vars, + "public static pb::MessageParser<$class_name$> Parser { get { return _parser; } }\n\n"); // Access the message descriptor via the relevant file descriptor or containing message descriptor. if (!descriptor_->containing_type()) { @@ -139,14 +142,14 @@ void MessageGenerator::Generate(io::Printer* printer) { WriteGeneratedCodeAttributes(printer); printer->Print( - vars, - "public static pbr::MessageDescriptor Descriptor {\n" - " get { return $descriptor_accessor$; }\n" - "}\n" - "\n"); + vars, + "public static pbr::MessageDescriptor Descriptor {\n" + " get { return $descriptor_accessor$; }\n" + "}\n" + "\n"); WriteGeneratedCodeAttributes(printer); printer->Print( - vars, + vars, "pbr::MessageDescriptor pb::IMessage.Descriptor {\n" " get { return Descriptor; }\n" "}\n" @@ -209,18 +212,18 @@ void MessageGenerator::Generate(io::Printer* printer) { printer->Print("}\n"); // TODO: Should we put the oneof .proto comments here? // It's unclear exactly where they should go. - printer->Print( - vars, - "private $property_name$OneofCase $name$Case_ = $property_name$OneofCase.None;\n"); - WriteGeneratedCodeAttributes(printer); - printer->Print( - vars, - "public $property_name$OneofCase $property_name$Case {\n" - " get { return $name$Case_; }\n" - "}\n\n"); - WriteGeneratedCodeAttributes(printer); - printer->Print( - vars, + printer->Print( + vars, + "private $property_name$OneofCase $name$Case_ = $property_name$OneofCase.None;\n"); + WriteGeneratedCodeAttributes(printer); + printer->Print( + vars, + "public $property_name$OneofCase $property_name$Case {\n" + " get { return $name$Case_; }\n" + "}\n\n"); + WriteGeneratedCodeAttributes(printer); + printer->Print( + vars, "public void Clear$property_name$() {\n" " $name$Case_ = $property_name$OneofCase.None;\n" " $name$_ = null;\n" @@ -280,7 +283,7 @@ bool MessageGenerator::HasNestedGeneratedTypes() } void MessageGenerator::GenerateCloningCode(io::Printer* printer) { - map<string, string> vars; + std::map<string, string> vars; WriteGeneratedCodeAttributes(printer); vars["class_name"] = class_name(); printer->Print( @@ -317,6 +320,9 @@ void MessageGenerator::GenerateCloningCode(io::Printer* printer) { printer->Outdent(); printer->Print("}\n\n"); } + // Clone unknown fields + printer->Print( + "_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);\n"); printer->Outdent(); printer->Print("}\n\n"); @@ -333,19 +339,19 @@ void MessageGenerator::GenerateFreezingCode(io::Printer* printer) { } void MessageGenerator::GenerateFrameworkMethods(io::Printer* printer) { - map<string, string> vars; + std::map<string, string> vars; vars["class_name"] = class_name(); // Equality - WriteGeneratedCodeAttributes(printer); + WriteGeneratedCodeAttributes(printer); printer->Print( vars, "public override bool Equals(object other) {\n" " return Equals(other as $class_name$);\n" "}\n\n"); - WriteGeneratedCodeAttributes(printer); - printer->Print( - vars, + WriteGeneratedCodeAttributes(printer); + printer->Print( + vars, "public bool Equals($class_name$ other) {\n" " if (ReferenceEquals(other, null)) {\n" " return false;\n" @@ -365,13 +371,13 @@ void MessageGenerator::GenerateFrameworkMethods(io::Printer* printer) { } printer->Outdent(); printer->Print( - " return true;\n" + " return Equals(_unknownFields, other._unknownFields);\n" "}\n\n"); // GetHashCode // Start with a non-zero value to easily distinguish between null and "empty" messages. - WriteGeneratedCodeAttributes(printer); - printer->Print( + WriteGeneratedCodeAttributes(printer); + printer->Print( "public override int GetHashCode() {\n" " int hash = 1;\n"); printer->Indent(); @@ -384,12 +390,16 @@ void MessageGenerator::GenerateFrameworkMethods(io::Printer* printer) { printer->Print("hash ^= (int) $name$Case_;\n", "name", UnderscoresToCamelCase(descriptor_->oneof_decl(i)->name(), false)); } - printer->Print("return hash;\n"); + printer->Print( + "if (_unknownFields != null) {\n" + " hash ^= _unknownFields.GetHashCode();\n" + "}\n" + "return hash;\n"); printer->Outdent(); printer->Print("}\n\n"); - WriteGeneratedCodeAttributes(printer); - printer->Print( + WriteGeneratedCodeAttributes(printer); + printer->Print( "public override string ToString() {\n" " return pb::JsonFormatter.ToDiagnosticString(this);\n" "}\n\n"); @@ -408,11 +418,17 @@ void MessageGenerator::GenerateMessageSerializationMethods(io::Printer* printer) generator->GenerateSerializationCode(printer); } + // Serialize unknown fields + printer->Print( + "if (_unknownFields != null) {\n" + " _unknownFields.WriteTo(output);\n" + "}\n"); + // TODO(jonskeet): Memoize size of frozen messages? printer->Outdent(); printer->Print( - "}\n" - "\n"); + "}\n" + "\n"); WriteGeneratedCodeAttributes(printer); printer->Print( "public int CalculateSize() {\n"); @@ -423,6 +439,12 @@ void MessageGenerator::GenerateMessageSerializationMethods(io::Printer* printer) CreateFieldGeneratorInternal(descriptor_->field(i))); generator->GenerateSerializedSizeCode(printer); } + + printer->Print( + "if (_unknownFields != null) {\n" + " size += _unknownFields.CalculateSize();\n" + "}\n"); + printer->Print("return size;\n"); printer->Outdent(); printer->Print("}\n\n"); @@ -432,7 +454,7 @@ void MessageGenerator::GenerateMergingMethods(io::Printer* printer) { // Note: These are separate from GenerateMessageSerializationMethods() // because they need to be generated even for messages that are optimized // for code size. - map<string, string> vars; + std::map<string, string> vars; vars["class_name"] = class_name(); WriteGeneratedCodeAttributes(printer); @@ -463,15 +485,24 @@ void MessageGenerator::GenerateMergingMethods(io::Printer* printer) { vars["field_property_name"] = GetPropertyName(field); printer->Print( vars, - "case $property_name$OneofCase.$field_property_name$:\n" - " $field_property_name$ = other.$field_property_name$;\n" - " break;\n"); + "case $property_name$OneofCase.$field_property_name$:\n"); + printer->Indent(); + scoped_ptr<FieldGeneratorBase> generator(CreateFieldGeneratorInternal(field)); + generator->GenerateMergingCode(printer); + printer->Print("break;\n"); + printer->Outdent(); } printer->Outdent(); printer->Print("}\n\n"); } + // Merge unknown fields. + printer->Print( + "_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);\n"); + printer->Outdent(); printer->Print("}\n\n"); + + WriteGeneratedCodeAttributes(printer); printer->Print("public void MergeFrom(pb::CodedInputStream input) {\n"); printer->Indent(); @@ -483,14 +514,14 @@ void MessageGenerator::GenerateMergingMethods(io::Printer* printer) { printer->Indent(); // Option messages need to store unknown fields so that options can be parsed later. if (IsDescriptorOptionMessage(descriptor_)) { - printer->Print( + printer->Print( "default:\n" " CustomOptions = CustomOptions.ReadOrSkipUnknownField(input);\n" " break;\n"); } else { printer->Print( "default:\n" - " input.SkipLastField();\n" // We're not storing the data, but we still need to consume it. + " _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);\n" " break;\n"); } for (int i = 0; i < fields_by_number().size(); i++) { diff --git a/src/google/protobuf/compiler/csharp/csharp_message_field.cc b/src/google/protobuf/compiler/csharp/csharp_message_field.cc index 438f3102..59b7edfb 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_message_field.cc @@ -171,6 +171,14 @@ void MessageOneofFieldGenerator::GenerateMembers(io::Printer* printer) { "}\n"); } +void MessageOneofFieldGenerator::GenerateMergingCode(io::Printer* printer) { + printer->Print(variables_, + "if ($property_name$ == null) {\n" + " $property_name$ = new $type_name$();\n" + "}\n" + "$property_name$.MergeFrom(other.$property_name$);\n"); +} + void MessageOneofFieldGenerator::GenerateParsingCode(io::Printer* printer) { // TODO(jonskeet): We may be able to do better than this printer->Print( diff --git a/src/google/protobuf/compiler/csharp/csharp_message_field.h b/src/google/protobuf/compiler/csharp/csharp_message_field.h index 7d614756..c41ee88a 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message_field.h +++ b/src/google/protobuf/compiler/csharp/csharp_message_field.h @@ -74,6 +74,7 @@ class MessageOneofFieldGenerator : public MessageFieldGenerator { virtual void GenerateCloningCode(io::Printer* printer); virtual void GenerateMembers(io::Printer* printer); + virtual void GenerateMergingCode(io::Printer* printer); virtual void WriteToString(io::Printer* printer); virtual void GenerateParsingCode(io::Printer* printer); diff --git a/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc b/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc index 169122e6..c3003e3d 100644 --- a/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc @@ -137,14 +137,22 @@ void PrimitiveFieldGenerator::GenerateSerializedSizeCode(io::Printer* printer) { } void PrimitiveFieldGenerator::WriteHash(io::Printer* printer) { - printer->Print( - variables_, - "if ($has_property_check$) hash ^= $property_name$.GetHashCode();\n"); + const char *text = "if ($has_property_check$) hash ^= $property_name$.GetHashCode();\n"; + if (descriptor_->type() == FieldDescriptor::TYPE_FLOAT) { + text = "if ($has_property_check$) hash ^= pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.GetHashCode($property_name$);\n"; + } else if (descriptor_->type() == FieldDescriptor::TYPE_DOUBLE) { + text = "if ($has_property_check$) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode($property_name$);\n"; + } + printer->Print(variables_, text); } void PrimitiveFieldGenerator::WriteEquals(io::Printer* printer) { - printer->Print( - variables_, - "if ($property_name$ != other.$property_name$) return false;\n"); + const char *text = "if ($property_name$ != other.$property_name$) return false;\n"; + if (descriptor_->type() == FieldDescriptor::TYPE_FLOAT) { + text = "if (!pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.Equals($property_name$, other.$property_name$)) return false;\n"; + } else if (descriptor_->type() == FieldDescriptor::TYPE_DOUBLE) { + text = "if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals($property_name$, other.$property_name$)) return false;\n"; + } + printer->Print(variables_, text); } void PrimitiveFieldGenerator::WriteToString(io::Printer* printer) { printer->Print( @@ -196,6 +204,10 @@ void PrimitiveOneofFieldGenerator::GenerateMembers(io::Printer* printer) { "}\n"); } +void PrimitiveOneofFieldGenerator::GenerateMergingCode(io::Printer* printer) { + printer->Print(variables_, "$property_name$ = other.$property_name$;\n"); +} + void PrimitiveOneofFieldGenerator::WriteToString(io::Printer* printer) { printer->Print(variables_, "PrintField(\"$descriptor_name$\", $has_property_check$, $oneof_name$_, writer);\n"); diff --git a/src/google/protobuf/compiler/csharp/csharp_primitive_field.h b/src/google/protobuf/compiler/csharp/csharp_primitive_field.h index 5f466fc4..ca7b8b3d 100644 --- a/src/google/protobuf/compiler/csharp/csharp_primitive_field.h +++ b/src/google/protobuf/compiler/csharp/csharp_primitive_field.h @@ -78,6 +78,7 @@ class PrimitiveOneofFieldGenerator : public PrimitiveFieldGenerator { virtual void GenerateCloningCode(io::Printer* printer); virtual void GenerateMembers(io::Printer* printer); + virtual void GenerateMergingCode(io::Printer* printer); virtual void WriteToString(io::Printer* printer); virtual void GenerateParsingCode(io::Printer* printer); diff --git a/src/google/protobuf/compiler/csharp/csharp_reflection_class.cc b/src/google/protobuf/compiler/csharp/csharp_reflection_class.cc index bac9aef7..5ddd616e 100644 --- a/src/google/protobuf/compiler/csharp/csharp_reflection_class.cc +++ b/src/google/protobuf/compiler/csharp/csharp_reflection_class.cc @@ -104,8 +104,10 @@ void ReflectionClassGenerator::Generate(io::Printer* printer) { void ReflectionClassGenerator::WriteIntroduction(io::Printer* printer) { printer->Print( - "// Generated by the protocol buffer compiler. DO NOT EDIT!\n" - "// source: $file_name$\n" + "// <auto-generated>\n" + "// Generated by the protocol buffer compiler. DO NOT EDIT!\n" + "// source: $file_name$\n" + "// </auto-generated>\n" "#pragma warning disable 1591, 0612, 3021\n" "#region Designer generated code\n" "\n" diff --git a/src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc b/src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc index 797d498e..047edf73 100644 --- a/src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc @@ -120,15 +120,25 @@ void WrapperFieldGenerator::GenerateSerializedSizeCode(io::Printer* printer) { } void WrapperFieldGenerator::WriteHash(io::Printer* printer) { - printer->Print( - variables_, - "if ($has_property_check$) hash ^= $property_name$.GetHashCode();\n"); + const char *text = "if ($has_property_check$) hash ^= $property_name$.GetHashCode();\n"; + if (descriptor_->message_type()->field(0)->type() == FieldDescriptor::TYPE_FLOAT) { + text = "if ($has_property_check$) hash ^= pbc::ProtobufEqualityComparers.BitwiseNullableSingleEqualityComparer.GetHashCode($property_name$);\n"; + } + else if (descriptor_->message_type()->field(0)->type() == FieldDescriptor::TYPE_DOUBLE) { + text = "if ($has_property_check$) hash ^= pbc::ProtobufEqualityComparers.BitwiseNullableDoubleEqualityComparer.GetHashCode($property_name$);\n"; + } + printer->Print(variables_, text); } void WrapperFieldGenerator::WriteEquals(io::Printer* printer) { - printer->Print( - variables_, - "if ($property_name$ != other.$property_name$) return false;\n"); + const char *text = "if ($property_name$ != other.$property_name$) return false;\n"; + if (descriptor_->message_type()->field(0)->type() == FieldDescriptor::TYPE_FLOAT) { + text = "if (!pbc::ProtobufEqualityComparers.BitwiseNullableSingleEqualityComparer.Equals($property_name$, other.$property_name$)) return false;\n"; + } + else if (descriptor_->message_type()->field(0)->type() == FieldDescriptor::TYPE_DOUBLE) { + text = "if (!pbc::ProtobufEqualityComparers.BitwiseNullableDoubleEqualityComparer.Equals($property_name$, other.$property_name$)) return false;\n"; + } + printer->Print(variables_, text); } void WrapperFieldGenerator::WriteToString(io::Printer* printer) { @@ -181,6 +191,10 @@ void WrapperOneofFieldGenerator::GenerateMembers(io::Printer* printer) { "}\n"); } +void WrapperOneofFieldGenerator::GenerateMergingCode(io::Printer* printer) { + printer->Print(variables_, "$property_name$ = other.$property_name$;\n"); +} + void WrapperOneofFieldGenerator::GenerateParsingCode(io::Printer* printer) { printer->Print( variables_, diff --git a/src/google/protobuf/compiler/csharp/csharp_wrapper_field.h b/src/google/protobuf/compiler/csharp/csharp_wrapper_field.h index 250dfd25..452531fb 100644 --- a/src/google/protobuf/compiler/csharp/csharp_wrapper_field.h +++ b/src/google/protobuf/compiler/csharp/csharp_wrapper_field.h @@ -75,6 +75,7 @@ class WrapperOneofFieldGenerator : public WrapperFieldGenerator { ~WrapperOneofFieldGenerator(); virtual void GenerateMembers(io::Printer* printer); + virtual void GenerateMergingCode(io::Printer* printer); virtual void GenerateParsingCode(io::Printer* printer); virtual void GenerateSerializationCode(io::Printer* printer); virtual void GenerateSerializedSizeCode(io::Printer* printer); diff --git a/src/google/protobuf/compiler/importer.cc b/src/google/protobuf/compiler/importer.cc index 844edc1c..a5341e0d 100644 --- a/src/google/protobuf/compiler/importer.cc +++ b/src/google/protobuf/compiler/importer.cc @@ -32,8 +32,9 @@ // Based on original Protocol Buffers design by // Sanjay Ghemawat, Jeff Dean, and others. + #ifdef _MSC_VER -#include <io.h> +#include <direct.h> #else #include <unistd.h> #endif @@ -54,16 +55,21 @@ #include <google/protobuf/io/tokenizer.h> #include <google/protobuf/io/zero_copy_stream_impl.h> #include <google/protobuf/stubs/strutil.h> +#include <google/protobuf/stubs/io_win32.h> + +#ifdef _WIN32 +#include <ctype.h> +#endif namespace google { namespace protobuf { namespace compiler { #ifdef _WIN32 -#ifndef F_OK -#define F_OK 00 // not defined by MSVC for whatever reason -#endif -#include <ctype.h> +// DO NOT include <io.h>, instead create functions in io_win32.{h,cc} and import +// them like we do below. +using google::protobuf::internal::win32::access; +using google::protobuf::internal::win32::open; #endif // Returns true if the text looks like a Windows-style absolute path, starting @@ -295,10 +301,8 @@ static string CanonicalizePath(string path) { } static inline bool ContainsParentReference(const string& path) { - return path == ".." || - HasPrefixString(path, "../") || - HasSuffixString(path, "/..") || - path.find("/../") != string::npos; + return path == ".." || HasPrefixString(path, "../") || + HasSuffixString(path, "/..") || path.find("/../") != string::npos; } // Maps a file from an old location to a new one. Typically, old_prefix is @@ -328,8 +332,7 @@ static bool ApplyMapping(const string& filename, // We do not allow the file name to use "..". return false; } - if (HasPrefixString(filename, "/") || - IsWindowsAbsolutePath(filename)) { + if (HasPrefixString(filename, "/") || IsWindowsAbsolutePath(filename)) { // This is an absolute path, so it isn't matched by the empty string. return false; } diff --git a/src/google/protobuf/compiler/java/java_context.cc b/src/google/protobuf/compiler/java/java_context.cc index b82fb3dd..0771d5e1 100644 --- a/src/google/protobuf/compiler/java/java_context.cc +++ b/src/google/protobuf/compiler/java/java_context.cc @@ -50,7 +50,7 @@ Context::Context(const FileDescriptor* file, const Options& options) Context::~Context() { } -ClassNameResolver* Context::GetNameResolver() { +ClassNameResolver* Context::GetNameResolver() const { return name_resolver_.get(); } @@ -154,7 +154,7 @@ void Context::InitializeFieldGeneratorInfoForFields( for (int i = 0; i < fields.size(); ++i) { const FieldDescriptor* field = fields[i]; FieldGeneratorInfo info; - info.name = UnderscoresToCamelCase(field); + info.name = CamelCaseFieldName(field); info.capitalized_name = UnderscoresToCapitalizedCamelCase(field); // For fields conflicting with some other fields, we append the field // number to their field names in generated code to avoid conflicts. diff --git a/src/google/protobuf/compiler/java/java_context.h b/src/google/protobuf/compiler/java/java_context.h index b22e7e3a..9a74c430 100644 --- a/src/google/protobuf/compiler/java/java_context.h +++ b/src/google/protobuf/compiler/java/java_context.h @@ -70,7 +70,7 @@ class Context { // Get the name resolver associated with this context. The resolver // can be used to map descriptors to Java class names. - ClassNameResolver* GetNameResolver(); + ClassNameResolver* GetNameResolver() const; // Get the FieldGeneratorInfo for a given field. const FieldGeneratorInfo* GetFieldGeneratorInfo( diff --git a/src/google/protobuf/compiler/java/java_enum.cc b/src/google/protobuf/compiler/java/java_enum.cc index b9ee00ff..d125ebe5 100644 --- a/src/google/protobuf/compiler/java/java_enum.cc +++ b/src/google/protobuf/compiler/java/java_enum.cc @@ -109,14 +109,16 @@ void EnumGenerator::Generate(io::Printer* printer) { printer->Print(vars, "$name$($index$, $number$),\n"); } + printer->Annotate("name", canonical_values_[i]); } if (SupportUnknownEnumValue(descriptor_->file())) { if (ordinal_is_index) { - printer->Print("UNRECOGNIZED(-1),\n"); + printer->Print("${$UNRECOGNIZED$}$(-1),\n", "{", "", "}", ""); } else { - printer->Print("UNRECOGNIZED(-1, -1),\n"); + printer->Print("${$UNRECOGNIZED$}$(-1, -1),\n", "{", "", "}", ""); } + printer->Annotate("{", "}", descriptor_); } printer->Print( @@ -133,15 +135,19 @@ void EnumGenerator::Generate(io::Printer* printer) { WriteEnumValueDocComment(printer, aliases_[i].value); printer->Print(vars, "public static final $classname$ $name$ = $canonical_name$;\n"); + printer->Annotate("name", aliases_[i].value); } for (int i = 0; i < descriptor_->value_count(); i++) { std::map<string, string> vars; vars["name"] = descriptor_->value(i)->name(); vars["number"] = SimpleItoa(descriptor_->value(i)->number()); + vars["{"] = ""; + vars["}"] = ""; WriteEnumValueDocComment(printer, descriptor_->value(i)); printer->Print(vars, - "public static final int $name$_VALUE = $number$;\n"); + "public static final int ${$$name$_VALUE$}$ = $number$;\n"); + printer->Annotate("{", "}", descriptor_->value(i)); } printer->Print("\n"); diff --git a/src/google/protobuf/compiler/java/java_enum_field.cc b/src/google/protobuf/compiler/java/java_enum_field.cc index 279b9da4..642cdd36 100644 --- a/src/google/protobuf/compiler/java/java_enum_field.cc +++ b/src/google/protobuf/compiler/java/java_enum_field.cc @@ -80,7 +80,7 @@ void SetEnumVariables(const FieldDescriptor* descriptor, // Use deprecated valueOf() method to be compatible with old generated code // for v2.5.0/v2.6.1. // TODO(xiaofeng): Use "forNumber" when we no longer support compatibility - // with v2.5.0/v2.6.1. + // with v2.5.0/v2.6.1, and remove the @SuppressWarnings annotations. (*variables)["for_number"] = "valueOf"; if (SupportFieldPresence(descriptor->file())) { @@ -183,23 +183,27 @@ GenerateMembers(io::Printer* printer) const { if (SupportFieldPresence(descriptor_->file())) { WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public boolean has$capitalized_name$() {\n" + "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return $get_has_field_bit_message$;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } if (SupportUnknownEnumValue(descriptor_->file())) { WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public int get$capitalized_name$Value() {\n" + "$deprecation$public int ${$get$capitalized_name$Value$}$() {\n" " return $name$_;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public $type$ get$capitalized_name$() {\n" + "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n" + " @SuppressWarnings(\"deprecation\")\n" " $type$ result = $type$.$for_number$($name$_);\n" " return result == null ? $unknown$ : result;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } void ImmutableEnumFieldGenerator:: @@ -209,33 +213,39 @@ GenerateBuilderMembers(io::Printer* printer) const { if (SupportFieldPresence(descriptor_->file())) { WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public boolean has$capitalized_name$() {\n" + "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return $get_has_field_bit_builder$;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } if (SupportUnknownEnumValue(descriptor_->file())) { WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public int get$capitalized_name$Value() {\n" + "$deprecation$public int ${$get$capitalized_name$Value$}$() {\n" " return $name$_;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder set$capitalized_name$Value(int value) {\n" + "$deprecation$public Builder " + "${$set$capitalized_name$Value$}$(int value) {\n" " $name$_ = value;\n" " $on_changed$\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public $type$ get$capitalized_name$() {\n" + "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n" + " @SuppressWarnings(\"deprecation\")\n" " $type$ result = $type$.$for_number$($name$_);\n" " return result == null ? $unknown$ : result;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder set$capitalized_name$($type$ value) {\n" + "$deprecation$public Builder ${$set$capitalized_name$$}$($type$ value) {\n" " if (value == null) {\n" " throw new NullPointerException();\n" " }\n" @@ -244,14 +254,16 @@ GenerateBuilderMembers(io::Printer* printer) const { " $on_changed$\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder clear$capitalized_name$() {\n" + "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n" " $clear_has_field_bit_builder$\n" " $name$_ = $default_number$;\n" " $on_changed$\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } void ImmutableEnumFieldGenerator:: @@ -310,13 +322,10 @@ GenerateParsingCode(io::Printer* printer) const { } else { printer->Print(variables_, "int rawValue = input.readEnum();\n" + " @SuppressWarnings(\"deprecation\")\n" "$type$ value = $type$.$for_number$(rawValue);\n" - "if (value == null) {\n"); - if (PreserveUnknownFields(descriptor_->containing_type())) { - printer->Print(variables_, - " unknownFields.mergeVarintField($number$, rawValue);\n"); - } - printer->Print(variables_, + "if (value == null) {\n" + " unknownFields.mergeVarintField($number$, rawValue);\n" "} else {\n" " $set_has_field_bit_message$\n" " $name$_ = rawValue;\n" @@ -386,30 +395,34 @@ GenerateMembers(io::Printer* printer) const { if (SupportFieldPresence(descriptor_->file())) { WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public boolean has$capitalized_name$() {\n" + "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return $has_oneof_case_message$;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } if (SupportUnknownEnumValue(descriptor_->file())) { WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public int get$capitalized_name$Value() {\n" + "$deprecation$public int ${$get$capitalized_name$Value$}$() {\n" " if ($has_oneof_case_message$) {\n" " return (java.lang.Integer) $oneof_name$_;\n" " }\n" " return $default_number$;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public $type$ get$capitalized_name$() {\n" + "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n" " if ($has_oneof_case_message$) {\n" + " @SuppressWarnings(\"deprecation\")\n" " $type$ result = $type$.$for_number$(\n" " (java.lang.Integer) $oneof_name$_);\n" " return result == null ? $unknown$ : result;\n" " }\n" " return $default$;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } void ImmutableEnumOneofFieldGenerator:: @@ -417,41 +430,47 @@ GenerateBuilderMembers(io::Printer* printer) const { if (SupportFieldPresence(descriptor_->file())) { WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public boolean has$capitalized_name$() {\n" + "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return $has_oneof_case_message$;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } if (SupportUnknownEnumValue(descriptor_->file())) { WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public int get$capitalized_name$Value() {\n" + "$deprecation$public int ${$get$capitalized_name$Value$}$() {\n" " if ($has_oneof_case_message$) {\n" " return ((java.lang.Integer) $oneof_name$_).intValue();\n" " }\n" " return $default_number$;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder set$capitalized_name$Value(int value) {\n" + "$deprecation$public Builder " + "${$set$capitalized_name$Value$}$(int value) {\n" " $set_oneof_case_message$;\n" " $oneof_name$_ = value;\n" " $on_changed$\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public $type$ get$capitalized_name$() {\n" + "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n" " if ($has_oneof_case_message$) {\n" + " @SuppressWarnings(\"deprecation\")\n" " $type$ result = $type$.$for_number$(\n" " (java.lang.Integer) $oneof_name$_);\n" " return result == null ? $unknown$ : result;\n" " }\n" " return $default$;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder set$capitalized_name$($type$ value) {\n" + "$deprecation$public Builder ${$set$capitalized_name$$}$($type$ value) {\n" " if (value == null) {\n" " throw new NullPointerException();\n" " }\n" @@ -460,9 +479,10 @@ GenerateBuilderMembers(io::Printer* printer) const { " $on_changed$\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder clear$capitalized_name$() {\n" + "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n" " if ($has_oneof_case_message$) {\n" " $clear_oneof_case_message$;\n" " $oneof_name$_ = null;\n" @@ -470,6 +490,7 @@ GenerateBuilderMembers(io::Printer* printer) const { " }\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } void ImmutableEnumOneofFieldGenerator:: @@ -501,13 +522,10 @@ GenerateParsingCode(io::Printer* printer) const { } else { printer->Print(variables_, "int rawValue = input.readEnum();\n" + "@SuppressWarnings(\"deprecation\")\n" "$type$ value = $type$.$for_number$(rawValue);\n" - "if (value == null) {\n"); - if (PreserveUnknownFields(descriptor_->containing_type())) { - printer->Print(variables_, - " unknownFields.mergeVarintField($number$, rawValue);\n"); - } - printer->Print(variables_, + "if (value == null) {\n" + " unknownFields.mergeVarintField($number$, rawValue);\n" "} else {\n" " $set_oneof_case_message$;\n" " $oneof_name$_ = rawValue;\n" @@ -614,6 +632,7 @@ GenerateMembers(io::Printer* printer) const { " new com.google.protobuf.Internal.ListAdapter.Converter<\n" " java.lang.Integer, $type$>() {\n" " public $type$ convert(java.lang.Integer from) {\n" + " @SuppressWarnings(\"deprecation\")\n" " $type$ result = $type$.$for_number$(from);\n" " return result == null ? $unknown$ : result;\n" " }\n" @@ -621,32 +640,38 @@ GenerateMembers(io::Printer* printer) const { PrintExtraFieldInfo(variables_, printer); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public java.util.List<$type$> get$capitalized_name$List() {\n" + "$deprecation$public java.util.List<$type$> " + "${$get$capitalized_name$List$}$() {\n" " return new com.google.protobuf.Internal.ListAdapter<\n" " java.lang.Integer, $type$>($name$_, $name$_converter_);\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public int get$capitalized_name$Count() {\n" + "$deprecation$public int ${$get$capitalized_name$Count$}$() {\n" " return $name$_.size();\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public $type$ get$capitalized_name$(int index) {\n" + "$deprecation$public $type$ ${$get$capitalized_name$$}$(int index) {\n" " return $name$_converter_.convert($name$_.get(index));\n" "}\n"); + printer->Annotate("{", "}", descriptor_); if (SupportUnknownEnumValue(descriptor_->file())) { WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "$deprecation$public java.util.List<java.lang.Integer>\n" - "get$capitalized_name$ValueList() {\n" + "${$get$capitalized_name$ValueList$}$() {\n" " return $name$_;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public int get$capitalized_name$Value(int index) {\n" + "$deprecation$public int ${$get$capitalized_name$Value$}$(int index) {\n" " return $name$_.get(index);\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } if (descriptor_->is_packed() && @@ -684,23 +709,27 @@ GenerateBuilderMembers(io::Printer* printer) const { // could hold on to the returned list and modify it after the message // has been built, thus mutating the message which is supposed to be // immutable. - "$deprecation$public java.util.List<$type$> get$capitalized_name$List() {\n" + "$deprecation$public java.util.List<$type$> " + "${$get$capitalized_name$List$}$() {\n" " return new com.google.protobuf.Internal.ListAdapter<\n" " java.lang.Integer, $type$>($name$_, $name$_converter_);\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public int get$capitalized_name$Count() {\n" + "$deprecation$public int ${$get$capitalized_name$Count$}$() {\n" " return $name$_.size();\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public $type$ get$capitalized_name$(int index) {\n" + "$deprecation$public $type$ ${$get$capitalized_name$$}$(int index) {\n" " return $name$_converter_.convert($name$_.get(index));\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder set$capitalized_name$(\n" + "$deprecation$public Builder ${$set$capitalized_name$$}$(\n" " int index, $type$ value) {\n" " if (value == null) {\n" " throw new NullPointerException();\n" @@ -710,9 +739,10 @@ GenerateBuilderMembers(io::Printer* printer) const { " $on_changed$\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder add$capitalized_name$($type$ value) {\n" + "$deprecation$public Builder ${$add$capitalized_name$$}$($type$ value) {\n" " if (value == null) {\n" " throw new NullPointerException();\n" " }\n" @@ -721,9 +751,10 @@ GenerateBuilderMembers(io::Printer* printer) const { " $on_changed$\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder addAll$capitalized_name$(\n" + "$deprecation$public Builder ${$addAll$capitalized_name$$}$(\n" " java.lang.Iterable<? extends $type$> values) {\n" " ensure$capitalized_name$IsMutable();\n" " for ($type$ value : values) {\n" @@ -732,47 +763,54 @@ GenerateBuilderMembers(io::Printer* printer) const { " $on_changed$\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder clear$capitalized_name$() {\n" + "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n" " $name$_ = java.util.Collections.emptyList();\n" " $clear_mutable_bit_builder$;\n" " $on_changed$\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); if (SupportUnknownEnumValue(descriptor_->file())) { WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "$deprecation$public java.util.List<java.lang.Integer>\n" - "get$capitalized_name$ValueList() {\n" + "${$get$capitalized_name$ValueList$}$() {\n" " return java.util.Collections.unmodifiableList($name$_);\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public int get$capitalized_name$Value(int index) {\n" + "$deprecation$public int ${$get$capitalized_name$Value$}$(int index) {\n" " return $name$_.get(index);\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder set$capitalized_name$Value(\n" + "$deprecation$public Builder ${$set$capitalized_name$Value$}$(\n" " int index, int value) {\n" " ensure$capitalized_name$IsMutable();\n" " $name$_.set(index, value);\n" " $on_changed$\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder add$capitalized_name$Value(int value) {\n" + "$deprecation$public Builder " + "${$add$capitalized_name$Value$}$(int value) {\n" " ensure$capitalized_name$IsMutable();\n" " $name$_.add(value);\n" " $on_changed$\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder addAll$capitalized_name$Value(\n" + "$deprecation$public Builder ${$addAll$capitalized_name$Value$}$(\n" " java.lang.Iterable<java.lang.Integer> values) {\n" " ensure$capitalized_name$IsMutable();\n" " for (int value : values) {\n" @@ -781,6 +819,7 @@ GenerateBuilderMembers(io::Printer* printer) const { " $on_changed$\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } } @@ -847,13 +886,10 @@ GenerateParsingCode(io::Printer* printer) const { } else { printer->Print(variables_, "int rawValue = input.readEnum();\n" + "@SuppressWarnings(\"deprecation\")\n" "$type$ value = $type$.$for_number$(rawValue);\n" - "if (value == null) {\n"); - if (PreserveUnknownFields(descriptor_->containing_type())) { - printer->Print(variables_, - " unknownFields.mergeVarintField($number$, rawValue);\n"); - } - printer->Print(variables_, + "if (value == null) {\n" + " unknownFields.mergeVarintField($number$, rawValue);\n" "} else {\n" " if (!$get_mutable_bit_parser$) {\n" " $name$_ = new java.util.ArrayList<java.lang.Integer>();\n" diff --git a/src/google/protobuf/compiler/java/java_enum_field_lite.cc b/src/google/protobuf/compiler/java/java_enum_field_lite.cc index 1eefdcfc..a4de1e23 100644 --- a/src/google/protobuf/compiler/java/java_enum_field_lite.cc +++ b/src/google/protobuf/compiler/java/java_enum_field_lite.cc @@ -165,23 +165,26 @@ GenerateMembers(io::Printer* printer) const { if (SupportFieldPresence(descriptor_->file())) { WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public boolean has$capitalized_name$() {\n" + "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return $get_has_field_bit_message$;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } if (SupportUnknownEnumValue(descriptor_->file())) { WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public int get$capitalized_name$Value() {\n" + "$deprecation$public int ${$get$capitalized_name$Value$}$() {\n" " return $name$_;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public $type$ get$capitalized_name$() {\n" + "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n" " $type$ result = $type$.forNumber($name$_);\n" " return result == null ? $unknown$ : result;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); // Generate private setters for the builder to proxy into. if (SupportUnknownEnumValue(descriptor_->file())) { @@ -214,43 +217,50 @@ GenerateBuilderMembers(io::Printer* printer) const { if (SupportFieldPresence(descriptor_->file())) { WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public boolean has$capitalized_name$() {\n" + "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return instance.has$capitalized_name$();\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } if (SupportUnknownEnumValue(descriptor_->file())) { WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public int get$capitalized_name$Value() {\n" + "$deprecation$public int ${$get$capitalized_name$Value$}$() {\n" " return instance.get$capitalized_name$Value();\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder set$capitalized_name$Value(int value) {\n" + "$deprecation$public Builder " + "${$set$capitalized_name$Value$}$(int value) {\n" " copyOnWrite();\n" " instance.set$capitalized_name$Value(value);\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public $type$ get$capitalized_name$() {\n" + "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n" " return instance.get$capitalized_name$();\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder set$capitalized_name$($type$ value) {\n" + "$deprecation$public Builder ${$set$capitalized_name$$}$($type$ value) {\n" " copyOnWrite();\n" " instance.set$capitalized_name$(value);\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder clear$capitalized_name$() {\n" + "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n" " copyOnWrite();\n" " instance.clear$capitalized_name$();\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } void ImmutableEnumFieldLiteGenerator:: @@ -296,12 +306,8 @@ GenerateParsingCode(io::Printer* printer) const { printer->Print(variables_, "int rawValue = input.readEnum();\n" "$type$ value = $type$.forNumber(rawValue);\n" - "if (value == null) {\n"); - if (PreserveUnknownFields(descriptor_->containing_type())) { - printer->Print(variables_, - " super.mergeVarintField($number$, rawValue);\n"); - } - printer->Print(variables_, + "if (value == null) {\n" + " super.mergeVarintField($number$, rawValue);\n" "} else {\n" " $set_has_field_bit_message$\n" " $name$_ = rawValue;\n" @@ -372,29 +378,32 @@ GenerateMembers(io::Printer* printer) const { if (SupportFieldPresence(descriptor_->file())) { WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public boolean has$capitalized_name$() {\n" + "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return $has_oneof_case_message$;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } if (SupportUnknownEnumValue(descriptor_->file())) { WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public int get$capitalized_name$Value() {\n" + "$deprecation$public int ${$get$capitalized_name$Value$}$() {\n" " if ($has_oneof_case_message$) {\n" " return (java.lang.Integer) $oneof_name$_;\n" " }\n" " return $default_number$;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public $type$ get$capitalized_name$() {\n" + "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n" " if ($has_oneof_case_message$) {\n" " $type$ result = $type$.forNumber((java.lang.Integer) $oneof_name$_);\n" " return result == null ? $unknown$ : result;\n" " }\n" " return $default$;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); // Generate private setters for the builder to proxy into. if (SupportUnknownEnumValue(descriptor_->file())) { @@ -430,43 +439,50 @@ GenerateBuilderMembers(io::Printer* printer) const { if (SupportFieldPresence(descriptor_->file())) { WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public boolean has$capitalized_name$() {\n" + "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return instance.has$capitalized_name$();\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } if (SupportUnknownEnumValue(descriptor_->file())) { WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public int get$capitalized_name$Value() {\n" + "$deprecation$public int ${$get$capitalized_name$Value$}$() {\n" " return instance.get$capitalized_name$Value();\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder set$capitalized_name$Value(int value) {\n" + "$deprecation$public Builder " + "${$set$capitalized_name$Value$}$(int value) {\n" " copyOnWrite();\n" " instance.set$capitalized_name$Value(value);\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public $type$ get$capitalized_name$() {\n" + "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n" " return instance.get$capitalized_name$();\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder set$capitalized_name$($type$ value) {\n" + "$deprecation$public Builder ${$set$capitalized_name$$}$($type$ value) {\n" " copyOnWrite();\n" " instance.set$capitalized_name$(value);\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder clear$capitalized_name$() {\n" + "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n" " copyOnWrite();\n" " instance.clear$capitalized_name$();\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } void ImmutableEnumOneofFieldLiteGenerator:: @@ -487,12 +503,8 @@ GenerateParsingCode(io::Printer* printer) const { printer->Print(variables_, "int rawValue = input.readEnum();\n" "$type$ value = $type$.forNumber(rawValue);\n" - "if (value == null) {\n"); - if (PreserveUnknownFields(descriptor_->containing_type())) { - printer->Print(variables_, - " super.mergeVarintField($number$, rawValue);\n"); - } - printer->Print(variables_, + "if (value == null) {\n" + " super.mergeVarintField($number$, rawValue);\n" "} else {\n" " $set_oneof_case_message$;\n" " $oneof_name$_ = rawValue;\n" @@ -607,35 +619,41 @@ GenerateMembers(io::Printer* printer) const { PrintExtraFieldInfo(variables_, printer); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public java.util.List<$type$> get$capitalized_name$List() {\n" + "$deprecation$public java.util.List<$type$> " + "${$get$capitalized_name$List$}$() {\n" " return new com.google.protobuf.Internal.ListAdapter<\n" " java.lang.Integer, $type$>($name$_, $name$_converter_);\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public int get$capitalized_name$Count() {\n" + "$deprecation$public int ${$get$capitalized_name$Count$}$() {\n" " return $name$_.size();\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public $type$ get$capitalized_name$(int index) {\n" + "$deprecation$public $type$ ${$get$capitalized_name$$}$(int index) {\n" " return $name$_converter_.convert($name$_.getInt(index));\n" "}\n"); + printer->Annotate("{", "}", descriptor_); if (SupportUnknownEnumValue(descriptor_->file())) { WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "$deprecation$public java.util.List<java.lang.Integer>\n" - "get$capitalized_name$ValueList() {\n" + "${$get$capitalized_name$ValueList$}$() {\n" " return $name$_;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public int get$capitalized_name$Value(int index) {\n" + "$deprecation$public int ${$get$capitalized_name$Value$}$(int index) {\n" " return $name$_.getInt(index);\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } - if (descriptor_->options().packed() && + if (descriptor_->is_packed() && context_->HasGeneratedMethods(descriptor_->containing_type())) { printer->Print(variables_, "private int $name$MemoizedSerializedSize;\n"); @@ -714,85 +732,99 @@ void RepeatedImmutableEnumFieldLiteGenerator:: GenerateBuilderMembers(io::Printer* printer) const { WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public java.util.List<$type$> get$capitalized_name$List() {\n" + "$deprecation$public java.util.List<$type$> " + "${$get$capitalized_name$List$}$() {\n" " return instance.get$capitalized_name$List();\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public int get$capitalized_name$Count() {\n" + "$deprecation$public int ${$get$capitalized_name$Count$}$() {\n" " return instance.get$capitalized_name$Count();\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public $type$ get$capitalized_name$(int index) {\n" + "$deprecation$public $type$ ${$get$capitalized_name$$}$(int index) {\n" " return instance.get$capitalized_name$(index);\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder set$capitalized_name$(\n" + "$deprecation$public Builder ${$set$capitalized_name$$}$(\n" " int index, $type$ value) {\n" " copyOnWrite();\n" " instance.set$capitalized_name$(index, value);\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder add$capitalized_name$($type$ value) {\n" + "$deprecation$public Builder ${$add$capitalized_name$$}$($type$ value) {\n" " copyOnWrite();\n" " instance.add$capitalized_name$(value);\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder addAll$capitalized_name$(\n" + "$deprecation$public Builder ${$addAll$capitalized_name$$}$(\n" " java.lang.Iterable<? extends $type$> values) {\n" " copyOnWrite();\n" " instance.addAll$capitalized_name$(values);" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder clear$capitalized_name$() {\n" + "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n" " copyOnWrite();\n" " instance.clear$capitalized_name$();\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); if (SupportUnknownEnumValue(descriptor_->file())) { WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "$deprecation$public java.util.List<java.lang.Integer>\n" - "get$capitalized_name$ValueList() {\n" + "${$get$capitalized_name$ValueList$}$() {\n" " return java.util.Collections.unmodifiableList(\n" " instance.get$capitalized_name$ValueList());\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public int get$capitalized_name$Value(int index) {\n" + "$deprecation$public int ${$get$capitalized_name$Value$}$(int index) {\n" " return instance.get$capitalized_name$Value(index);\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder set$capitalized_name$Value(\n" + "$deprecation$public Builder ${$set$capitalized_name$Value$}$(\n" " int index, int value) {\n" " copyOnWrite();\n" " instance.set$capitalized_name$Value(index, value);\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder add$capitalized_name$Value(int value) {\n" + "$deprecation$public Builder " + "${$add$capitalized_name$Value$}$(int value) {\n" " instance.add$capitalized_name$Value(value);\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder addAll$capitalized_name$Value(\n" + "$deprecation$public Builder ${$addAll$capitalized_name$Value$}$(\n" " java.lang.Iterable<java.lang.Integer> values) {\n" " copyOnWrite();\n" " instance.addAll$capitalized_name$Value(values);\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } } @@ -889,7 +921,7 @@ GenerateParsingDoneCode(io::Printer* printer) const { void RepeatedImmutableEnumFieldLiteGenerator:: GenerateSerializationCode(io::Printer* printer) const { - if (descriptor_->options().packed()) { + if (descriptor_->is_packed()) { printer->Print(variables_, "if (get$capitalized_name$List().size() > 0) {\n" " output.writeUInt32NoTag($tag$);\n" @@ -920,7 +952,7 @@ GenerateSerializedSizeCode(io::Printer* printer) const { "}\n"); printer->Print( "size += dataSize;\n"); - if (descriptor_->options().packed()) { + if (descriptor_->is_packed()) { printer->Print(variables_, "if (!get$capitalized_name$List().isEmpty()) {" " size += $tag_size$;\n" @@ -933,7 +965,7 @@ GenerateSerializedSizeCode(io::Printer* printer) const { } // cache the data size for packed fields. - if (descriptor_->options().packed()) { + if (descriptor_->is_packed()) { printer->Print(variables_, "$name$MemoizedSerializedSize = dataSize;\n"); } diff --git a/src/google/protobuf/compiler/java/java_enum_lite.cc b/src/google/protobuf/compiler/java/java_enum_lite.cc index 38b054e7..ab3b3323 100644 --- a/src/google/protobuf/compiler/java/java_enum_lite.cc +++ b/src/google/protobuf/compiler/java/java_enum_lite.cc @@ -93,10 +93,12 @@ void EnumLiteGenerator::Generate(io::Printer* printer) { } printer->Print(vars, "$name$($number$),\n"); + printer->Annotate("name", canonical_values_[i]); } if (SupportUnknownEnumValue(descriptor_->file())) { - printer->Print("UNRECOGNIZED(-1),\n"); + printer->Print("${$UNRECOGNIZED$}$(-1),\n", "{", "", "}", ""); + printer->Annotate("{", "}", descriptor_); } printer->Print( @@ -113,15 +115,19 @@ void EnumLiteGenerator::Generate(io::Printer* printer) { WriteEnumValueDocComment(printer, aliases_[i].value); printer->Print(vars, "public static final $classname$ $name$ = $canonical_name$;\n"); + printer->Annotate("name", aliases_[i].value); } for (int i = 0; i < descriptor_->value_count(); i++) { std::map<string, string> vars; vars["name"] = descriptor_->value(i)->name(); vars["number"] = SimpleItoa(descriptor_->value(i)->number()); + vars["{"] = ""; + vars["}"] = ""; WriteEnumValueDocComment(printer, descriptor_->value(i)); printer->Print(vars, - "public static final int $name$_VALUE = $number$;\n"); + "public static final int ${$$name$_VALUE$}$ = $number$;\n"); + printer->Annotate("{", "}", descriptor_->value(i)); } printer->Print("\n"); diff --git a/src/google/protobuf/compiler/java/java_extension.cc b/src/google/protobuf/compiler/java/java_extension.cc index cb237bf6..9b9be55b 100644 --- a/src/google/protobuf/compiler/java/java_extension.cc +++ b/src/google/protobuf/compiler/java/java_extension.cc @@ -75,7 +75,7 @@ void ExtensionGenerator::InitTemplateVars( vars["default"] = descriptor->is_repeated() ? "" : DefaultValue(descriptor, immutable, name_resolver); vars["type_constant"] = FieldTypeName(GetType(descriptor)); - vars["packed"] = descriptor->options().packed() ? "true" : "false"; + vars["packed"] = descriptor->is_packed() ? "true" : "false"; vars["enum_map"] = "null"; vars["prototype"] = "null"; diff --git a/src/google/protobuf/compiler/java/java_field.cc b/src/google/protobuf/compiler/java/java_field.cc index 04917296..1ab18629 100644 --- a/src/google/protobuf/compiler/java/java_field.cc +++ b/src/google/protobuf/compiler/java/java_field.cc @@ -45,8 +45,6 @@ #include <google/protobuf/compiler/java/java_enum_field.h> #include <google/protobuf/compiler/java/java_enum_field_lite.h> #include <google/protobuf/compiler/java/java_helpers.h> -#include <google/protobuf/compiler/java/java_lazy_message_field.h> -#include <google/protobuf/compiler/java/java_lazy_message_field_lite.h> #include <google/protobuf/compiler/java/java_map_field.h> #include <google/protobuf/compiler/java/java_map_field_lite.h> #include <google/protobuf/compiler/java/java_message_field.h> @@ -77,13 +75,8 @@ ImmutableFieldGenerator* MakeImmutableGenerator( return new ImmutableMapFieldGenerator( field, messageBitIndex, builderBitIndex, context); } else { - if (IsLazy(field, context->EnforceLite())) { - return new RepeatedImmutableLazyMessageFieldGenerator( - field, messageBitIndex, builderBitIndex, context); - } else { - return new RepeatedImmutableMessageFieldGenerator( - field, messageBitIndex, builderBitIndex, context); - } + return new RepeatedImmutableMessageFieldGenerator( + field, messageBitIndex, builderBitIndex, context); } case JAVATYPE_ENUM: return new RepeatedImmutableEnumFieldGenerator( @@ -99,13 +92,8 @@ ImmutableFieldGenerator* MakeImmutableGenerator( if (field->containing_oneof()) { switch (GetJavaType(field)) { case JAVATYPE_MESSAGE: - if (IsLazy(field, context->EnforceLite())) { - return new ImmutableLazyMessageOneofFieldGenerator( - field, messageBitIndex, builderBitIndex, context); - } else { - return new ImmutableMessageOneofFieldGenerator( - field, messageBitIndex, builderBitIndex, context); - } + return new ImmutableMessageOneofFieldGenerator( + field, messageBitIndex, builderBitIndex, context); case JAVATYPE_ENUM: return new ImmutableEnumOneofFieldGenerator( field, messageBitIndex, builderBitIndex, context); @@ -119,13 +107,8 @@ ImmutableFieldGenerator* MakeImmutableGenerator( } else { switch (GetJavaType(field)) { case JAVATYPE_MESSAGE: - if (IsLazy(field, context->EnforceLite())) { - return new ImmutableLazyMessageFieldGenerator( - field, messageBitIndex, builderBitIndex, context); - } else { - return new ImmutableMessageFieldGenerator( - field, messageBitIndex, builderBitIndex, context); - } + return new ImmutableMessageFieldGenerator( + field, messageBitIndex, builderBitIndex, context); case JAVATYPE_ENUM: return new ImmutableEnumFieldGenerator( field, messageBitIndex, builderBitIndex, context); @@ -150,13 +133,8 @@ ImmutableFieldLiteGenerator* MakeImmutableLiteGenerator( return new ImmutableMapFieldLiteGenerator( field, messageBitIndex, builderBitIndex, context); } else { - if (IsLazy(field, context->EnforceLite())) { - return new RepeatedImmutableLazyMessageFieldLiteGenerator( - field, messageBitIndex, builderBitIndex, context); - } else { - return new RepeatedImmutableMessageFieldLiteGenerator( - field, messageBitIndex, builderBitIndex, context); - } + return new RepeatedImmutableMessageFieldLiteGenerator( + field, messageBitIndex, builderBitIndex, context); } case JAVATYPE_ENUM: return new RepeatedImmutableEnumFieldLiteGenerator( @@ -172,13 +150,8 @@ ImmutableFieldLiteGenerator* MakeImmutableLiteGenerator( if (field->containing_oneof()) { switch (GetJavaType(field)) { case JAVATYPE_MESSAGE: - if (IsLazy(field, context->EnforceLite())) { - return new ImmutableLazyMessageOneofFieldLiteGenerator( - field, messageBitIndex, builderBitIndex, context); - } else { - return new ImmutableMessageOneofFieldLiteGenerator( - field, messageBitIndex, builderBitIndex, context); - } + return new ImmutableMessageOneofFieldLiteGenerator( + field, messageBitIndex, builderBitIndex, context); case JAVATYPE_ENUM: return new ImmutableEnumOneofFieldLiteGenerator( field, messageBitIndex, builderBitIndex, context); @@ -192,13 +165,8 @@ ImmutableFieldLiteGenerator* MakeImmutableLiteGenerator( } else { switch (GetJavaType(field)) { case JAVATYPE_MESSAGE: - if (IsLazy(field, context->EnforceLite())) { - return new ImmutableLazyMessageFieldLiteGenerator( - field, messageBitIndex, builderBitIndex, context); - } else { - return new ImmutableMessageFieldLiteGenerator( - field, messageBitIndex, builderBitIndex, context); - } + return new ImmutableMessageFieldLiteGenerator( + field, messageBitIndex, builderBitIndex, context); case JAVATYPE_ENUM: return new ImmutableEnumFieldLiteGenerator( field, messageBitIndex, builderBitIndex, context); @@ -293,10 +261,17 @@ void SetCommonFieldVariables(const FieldDescriptor* descriptor, std::map<string, string>* variables) { (*variables)["field_name"] = descriptor->name(); (*variables)["name"] = info->name; + (*variables)["classname"] = descriptor->containing_type()->name(); (*variables)["capitalized_name"] = info->capitalized_name; (*variables)["disambiguated_reason"] = info->disambiguated_reason; (*variables)["constant_name"] = FieldConstantName(descriptor); (*variables)["number"] = SimpleItoa(descriptor->number()); + // These variables are placeholders to pick out the beginning and ends of + // identifiers for annotations (when doing so with existing variables would + // be ambiguous or impossible). They should never be set to anything but the + // empty string. + (*variables)["{"] = ""; + (*variables)["}"] = ""; } void SetCommonOneofVariables(const FieldDescriptor* descriptor, diff --git a/src/google/protobuf/compiler/java/java_file.cc b/src/google/protobuf/compiler/java/java_file.cc index 0fda166d..21133a15 100644 --- a/src/google/protobuf/compiler/java/java_file.cc +++ b/src/google/protobuf/compiler/java/java_file.cc @@ -248,9 +248,12 @@ void FileGenerator::Generate(io::Printer* printer) { PrintGeneratedAnnotation( printer, '$', options_.annotate_code ? classname_ + ".java.pb.meta" : ""); printer->Print( - "public final class $classname$ {\n" + "$deprecation$public final class $classname$ {\n" " private $ctor$() {}\n", - "classname", classname_, "ctor", classname_); + "deprecation", file_->options().deprecated() ? + "@java.lang.Deprecated " : "", + "classname", classname_, + "ctor", classname_); printer->Annotate("classname", file_->name()); printer->Indent(); @@ -499,19 +502,57 @@ void FileGenerator::GenerateDescriptorInitializationCodeForMutable(io::Printer* // Try to load immutable messages' outer class. Its initialization code // will take care of interpreting custom options. printer->Print( - "try {\n" - // Note that we have to load the immutable class dynamically here as - // we want the mutable code to be independent from the immutable code - // at compile time. It is required to implement dual-compile for - // mutable and immutable API in blaze. - " java.lang.Class immutableClass = java.lang.Class.forName(\n" - " \"$immutable_classname$\");\n" - "} catch (java.lang.ClassNotFoundException e) {\n" - // The immutable class can not be found. Custom options are left - // as unknown fields. - // TODO(xiaofeng): inform the user with a warning? - "}\n", - "immutable_classname", name_resolver_->GetImmutableClassName(file_)); + "try {\n" + // Note that we have to load the immutable class dynamically here as + // we want the mutable code to be independent from the immutable code + // at compile time. It is required to implement dual-compile for + // mutable and immutable API in blaze. + " java.lang.Class immutableClass = java.lang.Class.forName(\n" + " \"$immutable_classname$\");\n" + "} catch (java.lang.ClassNotFoundException e) {\n", + "immutable_classname", name_resolver_->GetImmutableClassName(file_)); + printer->Indent(); + + // The immutable class can not be found. We try our best to collect all + // custom option extensions to interpret the custom options. + printer->Print( + "com.google.protobuf.ExtensionRegistry registry =\n" + " com.google.protobuf.ExtensionRegistry.newInstance();\n" + "com.google.protobuf.MessageLite defaultExtensionInstance = null;\n"); + FieldDescriptorSet::iterator it; + for (it = extensions.begin(); it != extensions.end(); it++) { + const FieldDescriptor* field = *it; + string scope; + if (field->extension_scope() != NULL) { + scope = name_resolver_->GetMutableClassName(field->extension_scope()) + + ".getDescriptor()"; + } else { + scope = FileJavaPackage(field->file(), true) + "." + + name_resolver_->GetDescriptorClassName(field->file()) + + ".descriptor"; + } + if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { + printer->Print( + "defaultExtensionInstance = com.google.protobuf.Internal\n" + " .getDefaultInstance(\"$class$\");\n" + "if (defaultExtensionInstance != null) {\n" + " registry.add(\n" + " $scope$.getExtensions().get($index$),\n" + " (com.google.protobuf.Message) defaultExtensionInstance);\n" + "}\n", + "scope", scope, "index", SimpleItoa(field->index()), "class", + name_resolver_->GetImmutableClassName(field->message_type())); + } else { + printer->Print("registry.add($scope$.getExtensions().get($index$));\n", + "scope", scope, "index", SimpleItoa(field->index())); + } + } + printer->Print( + "com.google.protobuf.Descriptors.FileDescriptor\n" + " .internalUpdateFileDescriptor(descriptor, registry);\n"); + + printer->Outdent(); + printer->Print("}\n"); } // Force descriptor initialization of all dependencies. diff --git a/src/google/protobuf/compiler/java/java_generator.cc b/src/google/protobuf/compiler/java/java_generator.cc index 02141210..84a3b90d 100644 --- a/src/google/protobuf/compiler/java/java_generator.cc +++ b/src/google/protobuf/compiler/java/java_generator.cc @@ -42,6 +42,7 @@ #include <google/protobuf/compiler/java/java_file.h> #include <google/protobuf/compiler/java/java_generator_factory.h> #include <google/protobuf/compiler/java/java_helpers.h> +#include <google/protobuf/compiler/java/java_name_resolver.h> #include <google/protobuf/compiler/java/java_options.h> #include <google/protobuf/compiler/java/java_shared_code_generator.h> #include <google/protobuf/io/printer.h> diff --git a/src/google/protobuf/compiler/java/java_helpers.cc b/src/google/protobuf/compiler/java/java_helpers.cc index 8469740f..dbb86b87 100644 --- a/src/google/protobuf/compiler/java/java_helpers.cc +++ b/src/google/protobuf/compiler/java/java_helpers.cc @@ -37,12 +37,15 @@ #include <limits> #include <vector> +#include <google/protobuf/stubs/stringprintf.h> #include <google/protobuf/compiler/java/java_helpers.h> #include <google/protobuf/compiler/java/java_name_resolver.h> #include <google/protobuf/descriptor.pb.h> #include <google/protobuf/wire_format.h> #include <google/protobuf/stubs/strutil.h> #include <google/protobuf/stubs/substitute.h> + + #include <google/protobuf/stubs/hash.h> // for hash<T *> namespace google { @@ -167,6 +170,14 @@ string UniqueFileScopeIdentifier(const Descriptor* descriptor) { return "static_" + StringReplace(descriptor->full_name(), ".", "_", true); } +string CamelCaseFieldName(const FieldDescriptor* field) { + string fieldName = UnderscoresToCamelCase(field); + if ('0' <= fieldName[0] && fieldName[0] <= '9') { + return '_' + fieldName; + } + return fieldName; +} + string StripProto(const string& filename) { if (HasSuffixString(filename, ".protodevel")) { return StripSuffixString(filename, ".protodevel"); @@ -773,6 +784,137 @@ bool HasRepeatedFields(const Descriptor* descriptor) { return false; } +// Encode an unsigned 32-bit value into a sequence of UTF-16 characters. +// +// If the value is in [0x0000, 0xD7FF], we encode it with a single character +// with the same numeric value. +// +// If the value is larger than 0xD7FF, we encode its lowest 13 bits into a +// character in the range [0xE000, 0xFFFF] by combining these 13 bits with +// 0xE000 using logic-or. Then we shift the value to the right by 13 bits, and +// encode the remaining value by repeating this same process until we get to +// a value in [0x0000, 0xD7FF] where we will encode it using a character with +// the same numeric value. +// +// Note that we only use code points in [0x0000, 0xD7FF] and [0xE000, 0xFFFF]. +// There will be no surrogate pairs in the encoded character sequence. +void WriteUInt32ToUtf16CharSequence(uint32 number, + std::vector<uint16>* output) { + // For values in [0x0000, 0xD7FF], only use one char to encode it. + if (number < 0xD800) { + output->push_back(static_cast<uint16>(number)); + return; + } + // Encode into multiple chars. All except the last char will be in the range + // [0xE000, 0xFFFF], and the last char will be in the range [0x0000, 0xD7FF]. + // Note that we don't use any value in range [0xD800, 0xDFFF] because they + // have to come in pairs and the encoding is just more space-efficient w/o + // them. + while (number >= 0xD800) { + // [0xE000, 0xFFFF] can represent 13 bits of info. + output->push_back(static_cast<uint16>(0xE000 | (number & 0x1FFF))); + number >>= 13; + } + output->push_back(static_cast<uint16>(number)); +} + +int GetExperimentalJavaFieldTypeForSingular(const FieldDescriptor* field) { + // j/c/g/protobuf/FieldType.java lists field types in a slightly different + // order from FieldDescriptor::Type so we can't do a simple cast. + // + // TODO(xiaofeng): Make j/c/g/protobuf/FieldType.java follow the same order. + int result = field->type(); + if (result == FieldDescriptor::TYPE_GROUP) { + return 17; + } else if (result < FieldDescriptor::TYPE_GROUP) { + return result - 1; + } else { + return result - 2; + } +} + +int GetExperimentalJavaFieldTypeForRepeated(const FieldDescriptor* field) { + if (field->type() == FieldDescriptor::TYPE_GROUP) { + return 49; + } else { + return GetExperimentalJavaFieldTypeForSingular(field) + 18; + } +} + +int GetExperimentalJavaFieldTypeForPacked(const FieldDescriptor* field) { + int result = field->type(); + if (result < FieldDescriptor::TYPE_STRING) { + return result + 34; + } else if (result > FieldDescriptor::TYPE_BYTES) { + return result + 30; + } else { + GOOGLE_LOG(FATAL) << field->full_name() << " can't be packed."; + return 0; + } +} + +int GetExperimentalJavaFieldType(const FieldDescriptor* field) { + static const int kMapFieldType = 50; + static const int kOneofFieldTypeOffset = 51; + static const int kRequiredBit = 0x100; + static const int kUtf8CheckBit = 0x200; + static const int kCheckInitialized = 0x400; + static const int kMapWithProto2EnumValue = 0x800; + int extra_bits = field->is_required() ? kRequiredBit : 0; + if (field->type() == FieldDescriptor::TYPE_STRING && CheckUtf8(field)) { + extra_bits |= kUtf8CheckBit; + } + if (field->is_required() || (GetJavaType(field) == JAVATYPE_MESSAGE && + HasRequiredFields(field->message_type()))) { + extra_bits |= kCheckInitialized; + } + + if (field->is_map()) { + if (SupportFieldPresence(field->file())) { + const FieldDescriptor* value = + field->message_type()->FindFieldByName("value"); + if (GetJavaType(value) == JAVATYPE_ENUM) { + extra_bits |= kMapWithProto2EnumValue; + } + } + return kMapFieldType | extra_bits; + } else if (field->is_packed()) { + return GetExperimentalJavaFieldTypeForPacked(field); + } else if (field->is_repeated()) { + return GetExperimentalJavaFieldTypeForRepeated(field) | extra_bits; + } else if (field->containing_oneof() != NULL) { + return (GetExperimentalJavaFieldTypeForSingular(field) + + kOneofFieldTypeOffset) | + extra_bits; + } else { + return GetExperimentalJavaFieldTypeForSingular(field) | extra_bits; + } +} + +// Escape a UTF-16 character to be embedded in a Java string. +void EscapeUtf16ToString(uint16 code, string* output) { + if (code == '\t') { + output->append("\\t"); + } else if (code == '\b') { + output->append("\\b"); + } else if (code == '\n') { + output->append("\\n"); + } else if (code == '\r') { + output->append("\\r"); + } else if (code == '\f') { + output->append("\\f"); + } else if (code == '\'') { + output->append("\\'"); + } else if (code == '\"') { + output->append("\\\""); + } else if (code == '\\') { + output->append("\\\\"); + } else if (code >= 0x20 && code <= 0x7f) { + output->push_back(static_cast<char>(code)); + } else { + output->append(StringPrintf("\\u%04x", code)); + } +} } // namespace java } // namespace compiler } // namespace protobuf diff --git a/src/google/protobuf/compiler/java/java_helpers.h b/src/google/protobuf/compiler/java/java_helpers.h index 829ec3d7..00d683db 100644 --- a/src/google/protobuf/compiler/java/java_helpers.h +++ b/src/google/protobuf/compiler/java/java_helpers.h @@ -74,6 +74,10 @@ string UnderscoresToCapitalizedCamelCase(const FieldDescriptor* field); // of lower-casing the first letter of the name.) string UnderscoresToCamelCase(const MethodDescriptor* method); +// Similar to UnderscoresToCamelCase, but guarentees that the result is a +// complete Java identifier by adding a _ if needed. +string CamelCaseFieldName(const FieldDescriptor* field); + // Get an identifier that uniquely identifies this type within the file. // This is used to declare static variables related to this type at the // outermost file scope. @@ -132,6 +136,13 @@ inline string ShortMutableJavaClassName(const Descriptor* descriptor) { return descriptor->name(); } +// Whether the given descriptor is for one of the core descriptor protos. We +// cannot currently use the new runtime with core protos since there is a +// bootstrapping problem with obtaining their descriptors. +inline bool IsDescriptorProto(const Descriptor* descriptor) { + return descriptor->file()->name() == "google/protobuf/descriptor.proto"; +} + // Whether we should generate multiple java files for messages. inline bool MultipleJavaFiles( @@ -242,15 +253,6 @@ inline bool HasGenericServices(const FileDescriptor *file, bool enforce_lite) { file->options().java_generic_services(); } -inline bool IsLazy(const FieldDescriptor* descriptor, bool enforce_lite) { - // Currently, the proto-lite version supports lazy field. - // TODO(niwasaki): Support lazy fields also for other proto runtimes. - if (HasDescriptorMethods(descriptor->file(), enforce_lite)) { - return false; - } - return descriptor->options().lazy(); -} - // Methods for shared bitfields. // Gets the name of the shared bitfield for the given index. @@ -372,14 +374,14 @@ inline bool IsMapField(const FieldDescriptor* descriptor) { return descriptor->is_map(); } -inline bool PreserveUnknownFields(const Descriptor* descriptor) { - return descriptor->file()->syntax() != FileDescriptor::SYNTAX_PROTO3; -} - inline bool IsAnyMessage(const Descriptor* descriptor) { return descriptor->full_name() == "google.protobuf.Any"; } +inline bool IsWrappersProtoFile(const FileDescriptor* descriptor) { + return descriptor->name() == "google/protobuf/wrappers.proto"; +} + inline bool CheckUtf8(const FieldDescriptor* descriptor) { return descriptor->file()->syntax() == FileDescriptor::SYNTAX_PROTO3 || descriptor->file()->options().java_string_check_utf8(); @@ -388,6 +390,30 @@ inline bool CheckUtf8(const FieldDescriptor* descriptor) { inline string GeneratedCodeVersionSuffix() { return "V3"; } + +inline bool EnableExperimentalRuntime(Context* context) { + return false; +} + +void WriteUInt32ToUtf16CharSequence(uint32 number, std::vector<uint16>* output); + +inline void WriteIntToUtf16CharSequence(int value, + std::vector<uint16>* output) { + WriteUInt32ToUtf16CharSequence(static_cast<uint32>(value), output); +} + +// Escape a UTF-16 character so it can be embedded in a Java string literal. +void EscapeUtf16ToString(uint16 code, string* output); + +// Only the lowest two bytes of the return value are used. The lowest byte +// is the integer value of a j/c/g/protobuf/FieldType enum. For the other +// byte: +// bit 0: whether the field is required. +// bit 1: whether the field requires UTF-8 validation. +// bit 2: whether the field needs isInitialized check. +// bit 3: whether the field is a map field with proto2 enum value. +// bits 4-7: unused +int GetExperimentalJavaFieldType(const FieldDescriptor* field); } // namespace java } // namespace compiler } // namespace protobuf diff --git a/src/google/protobuf/compiler/java/java_map_field.cc b/src/google/protobuf/compiler/java/java_map_field.cc index 608b5378..b22a2199 100644 --- a/src/google/protobuf/compiler/java/java_map_field.cc +++ b/src/google/protobuf/compiler/java/java_map_field.cc @@ -183,12 +183,14 @@ GenerateInterfaceMembers(io::Printer* printer) const { WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, - "$deprecation$int get$capitalized_name$Count();\n"); + "$deprecation$int ${$get$capitalized_name$Count$}$();\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, - "$deprecation$boolean contains$capitalized_name$(\n" + "$deprecation$boolean ${$contains$capitalized_name$$}$(\n" " $key_type$ key);\n"); + printer->Annotate("{", "}", descriptor_); if (GetJavaType(ValueField(descriptor_)) == JAVATYPE_ENUM) { printer->Print( variables_, @@ -197,23 +199,27 @@ GenerateInterfaceMembers(io::Printer* printer) const { " */\n" "@java.lang.Deprecated\n" "java.util.Map<$boxed_key_type$, $value_enum_type$>\n" - "get$capitalized_name$();\n"); + "${$get$capitalized_name$$}$();\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "$deprecation$java.util.Map<$boxed_key_type$, $value_enum_type$>\n" - "get$capitalized_name$Map();\n"); + "${$get$capitalized_name$Map$}$();\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, - "$deprecation$$value_enum_type$ get$capitalized_name$OrDefault(\n" + "$deprecation$$value_enum_type$ ${$get$capitalized_name$OrDefault$}$(\n" " $key_type$ key,\n" " $value_enum_type$ defaultValue);\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, - "$deprecation$$value_enum_type$ get$capitalized_name$OrThrow(\n" + "$deprecation$$value_enum_type$ ${$get$capitalized_name$OrThrow$}$(\n" " $key_type$ key);\n"); + printer->Annotate("{", "}", descriptor_); if (SupportUnknownEnumValue(descriptor_->file())) { printer->Print( variables_, @@ -222,25 +228,29 @@ GenerateInterfaceMembers(io::Printer* printer) const { " */\n" "@java.lang.Deprecated\n" "java.util.Map<$type_parameters$>\n" - "get$capitalized_name$Value();\n"); + "${$get$capitalized_name$Value$}$();\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "$deprecation$java.util.Map<$type_parameters$>\n" - "get$capitalized_name$ValueMap();\n"); + "${$get$capitalized_name$ValueMap$}$();\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "$deprecation$\n" - "$value_type$ get$capitalized_name$ValueOrDefault(\n" + "$value_type$ ${$get$capitalized_name$ValueOrDefault$}$(\n" " $key_type$ key,\n" " $value_type$ defaultValue);\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "$deprecation$\n" - "$value_type$ get$capitalized_name$ValueOrThrow(\n" + "$value_type$ ${$get$capitalized_name$ValueOrThrow$}$(\n" " $key_type$ key);\n"); + printer->Annotate("{", "}", descriptor_); } } else { printer->Print( @@ -250,25 +260,29 @@ GenerateInterfaceMembers(io::Printer* printer) const { " */\n" "@java.lang.Deprecated\n" "java.util.Map<$type_parameters$>\n" - "get$capitalized_name$();\n"); + "${$get$capitalized_name$$}$();\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "$deprecation$java.util.Map<$type_parameters$>\n" - "get$capitalized_name$Map();\n"); + "${$get$capitalized_name$Map$}$();\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "$deprecation$\n" - "$value_type$ get$capitalized_name$OrDefault(\n" + "$value_type$ ${$get$capitalized_name$OrDefault$}$(\n" " $key_type$ key,\n" " $value_type$ defaultValue);\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "$deprecation$\n" - "$value_type$ get$capitalized_name$OrThrow(\n" + "$value_type$ ${$get$capitalized_name$OrThrow$}$(\n" " $key_type$ key);\n"); + printer->Annotate("{", "}", descriptor_); } } @@ -349,23 +363,27 @@ GenerateBuilderMembers(io::Printer* printer) const { " return $name$_;\n" "}\n"); GenerateMapGetters(printer); - printer->Print(variables_, - "$deprecation$\n" - "public Builder clear$capitalized_name$() {\n" - " internalGetMutable$capitalized_name$().getMutableMap()\n" - " .clear();\n" - " return this;\n" - "}\n"); + printer->Print( + variables_, + "$deprecation$\n" + "public Builder ${$clear$capitalized_name$$}$() {\n" + " internalGetMutable$capitalized_name$().getMutableMap()\n" + " .clear();\n" + " return this;\n" + "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$\n" - "public Builder remove$capitalized_name$(\n" - " $key_type$ key) {\n" - " $key_null_check$\n" - " internalGetMutable$capitalized_name$().getMutableMap()\n" - " .remove(key);\n" - " return this;\n" - "}\n"); + printer->Print( + variables_, + "$deprecation$\n" + "public Builder ${$remove$capitalized_name$$}$(\n" + " $key_type$ key) {\n" + " $key_null_check$\n" + " internalGetMutable$capitalized_name$().getMutableMap()\n" + " .remove(key);\n" + " return this;\n" + "}\n"); + printer->Annotate("{", "}", descriptor_); if (GetJavaType(ValueField(descriptor_)) == JAVATYPE_ENUM) { printer->Print( variables_, @@ -374,13 +392,14 @@ GenerateBuilderMembers(io::Printer* printer) const { " */\n" "@java.lang.Deprecated\n" "public java.util.Map<$boxed_key_type$, $value_enum_type$>\n" - "getMutable$capitalized_name$() {\n" + "${$getMutable$capitalized_name$$}$() {\n" " return internalGetAdapted$capitalized_name$Map(\n" " internalGetMutable$capitalized_name$().getMutableMap());\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder put$capitalized_name$(\n" + "$deprecation$public Builder ${$put$capitalized_name$$}$(\n" " $key_type$ key,\n" " $value_enum_type$ value) {\n" " $key_null_check$\n" @@ -389,16 +408,18 @@ GenerateBuilderMembers(io::Printer* printer) const { " .put(key, $name$ValueConverter.doBackward(value));\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, - "$deprecation$public Builder putAll$capitalized_name$(\n" + "$deprecation$public Builder ${$putAll$capitalized_name$$}$(\n" " java.util.Map<$boxed_key_type$, $value_enum_type$> values) {\n" " internalGetAdapted$capitalized_name$Map(\n" " internalGetMutable$capitalized_name$().getMutableMap())\n" " .putAll(values);\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); if (SupportUnknownEnumValue(descriptor_->file())) { printer->Print( variables_, @@ -407,13 +428,14 @@ GenerateBuilderMembers(io::Printer* printer) const { " */\n" "@java.lang.Deprecated\n" "public java.util.Map<$boxed_key_type$, $boxed_value_type$>\n" - "getMutable$capitalized_name$Value() {\n" + "${$getMutable$capitalized_name$Value$}$() {\n" " return internalGetMutable$capitalized_name$().getMutableMap();\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, - "$deprecation$public Builder put$capitalized_name$Value(\n" + "$deprecation$public Builder ${$put$capitalized_name$Value$}$(\n" " $key_type$ key,\n" " $value_type$ value) {\n" " $key_null_check$\n" @@ -421,15 +443,17 @@ GenerateBuilderMembers(io::Printer* printer) const { " .put(key, value);\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, - "$deprecation$public Builder putAll$capitalized_name$Value(\n" + "$deprecation$public Builder ${$putAll$capitalized_name$Value$}$(\n" " java.util.Map<$boxed_key_type$, $boxed_value_type$> values) {\n" " internalGetMutable$capitalized_name$().getMutableMap()\n" " .putAll(values);\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } } else { printer->Print( @@ -439,30 +463,35 @@ GenerateBuilderMembers(io::Printer* printer) const { " */\n" "@java.lang.Deprecated\n" "public java.util.Map<$type_parameters$>\n" - "getMutable$capitalized_name$() {\n" + "${$getMutable$capitalized_name$$}$() {\n" " return internalGetMutable$capitalized_name$().getMutableMap();\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$" - "public Builder put$capitalized_name$(\n" - " $key_type$ key,\n" - " $value_type$ value) {\n" - " $key_null_check$\n" - " $value_null_check$\n" - " internalGetMutable$capitalized_name$().getMutableMap()\n" - " .put(key, value);\n" - " return this;\n" - "}\n"); + printer->Print( + variables_, + "$deprecation$" + "public Builder ${$put$capitalized_name$$}$(\n" + " $key_type$ key,\n" + " $value_type$ value) {\n" + " $key_null_check$\n" + " $value_null_check$\n" + " internalGetMutable$capitalized_name$().getMutableMap()\n" + " .put(key, value);\n" + " return this;\n" + "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$\n" - "public Builder putAll$capitalized_name$(\n" - " java.util.Map<$type_parameters$> values) {\n" - " internalGetMutable$capitalized_name$().getMutableMap()\n" - " .putAll(values);\n" - " return this;\n" - "}\n"); + printer->Print( + variables_, + "$deprecation$\n" + "public Builder ${$putAll$capitalized_name$$}$(\n" + " java.util.Map<$type_parameters$> values) {\n" + " internalGetMutable$capitalized_name$().getMutableMap()\n" + " .putAll(values);\n" + " return this;\n" + "}\n"); + printer->Annotate("{", "}", descriptor_); } } @@ -471,18 +500,20 @@ GenerateMapGetters(io::Printer* printer) const { printer->Print( variables_, "$deprecation$\n" - "public int get$capitalized_name$Count() {\n" + "public int ${$get$capitalized_name$Count$}$() {\n" " return internalGet$capitalized_name$().getMap().size();\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "$deprecation$\n" - "public boolean contains$capitalized_name$(\n" + "public boolean ${$contains$capitalized_name$$}$(\n" " $key_type$ key) {\n" " $key_null_check$\n" " return internalGet$capitalized_name$().getMap().containsKey(key);\n" "}\n"); + printer->Annotate("{", "}", descriptor_); if (GetJavaType(ValueField(descriptor_)) == JAVATYPE_ENUM) { printer->Print( variables_, @@ -491,22 +522,25 @@ GenerateMapGetters(io::Printer* printer) const { " */\n" "@java.lang.Deprecated\n" "public java.util.Map<$boxed_key_type$, $value_enum_type$>\n" - "get$capitalized_name$() {\n" + "${$get$capitalized_name$$}$() {\n" " return get$capitalized_name$Map();\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$\n" - "public java.util.Map<$boxed_key_type$, $value_enum_type$>\n" - "get$capitalized_name$Map() {\n" - " return internalGetAdapted$capitalized_name$Map(\n" - " internalGet$capitalized_name$().getMap());" - "}\n"); + printer->Print( + variables_, + "$deprecation$\n" + "public java.util.Map<$boxed_key_type$, $value_enum_type$>\n" + "${$get$capitalized_name$Map$}$() {\n" + " return internalGetAdapted$capitalized_name$Map(\n" + " internalGet$capitalized_name$().getMap());" + "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "$deprecation$\n" - "public $value_enum_type$ get$capitalized_name$OrDefault(\n" + "public $value_enum_type$ ${$get$capitalized_name$OrDefault$}$(\n" " $key_type$ key,\n" " $value_enum_type$ defaultValue) {\n" " $key_null_check$\n" @@ -516,11 +550,12 @@ GenerateMapGetters(io::Printer* printer) const { " ? $name$ValueConverter.doForward(map.get(key))\n" " : defaultValue;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "$deprecation$\n" - "public $value_enum_type$ get$capitalized_name$OrThrow(\n" + "public $value_enum_type$ ${$get$capitalized_name$OrThrow$}$(\n" " $key_type$ key) {\n" " $key_null_check$\n" " java.util.Map<$boxed_key_type$, $boxed_value_type$> map =\n" @@ -530,6 +565,7 @@ GenerateMapGetters(io::Printer* printer) const { " }\n" " return $name$ValueConverter.doForward(map.get(key));\n" "}\n"); + printer->Annotate("{", "}", descriptor_); if (SupportUnknownEnumValue(descriptor_->file())) { printer->Print( variables_, @@ -538,22 +574,24 @@ GenerateMapGetters(io::Printer* printer) const { " */\n" "@java.lang.Deprecated\n" "public java.util.Map<$boxed_key_type$, $boxed_value_type$>\n" - "get$capitalized_name$Value() {\n" + "${$get$capitalized_name$Value$}$() {\n" " return get$capitalized_name$ValueMap();\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "$deprecation$\n" "public java.util.Map<$boxed_key_type$, $boxed_value_type$>\n" - "get$capitalized_name$ValueMap() {\n" + "${$get$capitalized_name$ValueMap$}$() {\n" " return internalGet$capitalized_name$().getMap();\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "$deprecation$\n" - "public $value_type$ get$capitalized_name$ValueOrDefault(\n" + "public $value_type$ ${$get$capitalized_name$ValueOrDefault$}$(\n" " $key_type$ key,\n" " $value_type$ defaultValue) {\n" " $key_null_check$\n" @@ -561,11 +599,12 @@ GenerateMapGetters(io::Printer* printer) const { " internalGet$capitalized_name$().getMap();\n" " return map.containsKey(key) ? map.get(key) : defaultValue;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "$deprecation$\n" - "public $value_type$ get$capitalized_name$ValueOrThrow(\n" + "public $value_type$ ${$get$capitalized_name$ValueOrThrow$}$(\n" " $key_type$ key) {\n" " $key_null_check$\n" " java.util.Map<$boxed_key_type$, $boxed_value_type$> map =\n" @@ -575,6 +614,7 @@ GenerateMapGetters(io::Printer* printer) const { " }\n" " return map.get(key);\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } } else { printer->Print( @@ -583,21 +623,25 @@ GenerateMapGetters(io::Printer* printer) const { " * Use {@link #get$capitalized_name$Map()} instead.\n" " */\n" "@java.lang.Deprecated\n" - "public java.util.Map<$type_parameters$> get$capitalized_name$() {\n" + "public java.util.Map<$type_parameters$> " + "${$get$capitalized_name$$}$() {\n" " return get$capitalized_name$Map();\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "$deprecation$\n" - "public java.util.Map<$type_parameters$> get$capitalized_name$Map() {\n" + "public java.util.Map<$type_parameters$> " + "${$get$capitalized_name$Map$}$() {\n" " return internalGet$capitalized_name$().getMap();\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "$deprecation$\n" - "public $value_type$ get$capitalized_name$OrDefault(\n" + "public $value_type$ ${$get$capitalized_name$OrDefault$}$(\n" " $key_type$ key,\n" " $value_type$ defaultValue) {\n" " $key_null_check$\n" @@ -605,11 +649,12 @@ GenerateMapGetters(io::Printer* printer) const { " internalGet$capitalized_name$().getMap();\n" " return map.containsKey(key) ? map.get(key) : defaultValue;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "$deprecation$\n" - "public $value_type$ get$capitalized_name$OrThrow(\n" + "public $value_type$ ${$get$capitalized_name$OrThrow$}$(\n" " $key_type$ key) {\n" " $key_null_check$\n" " java.util.Map<$type_parameters$> map =\n" @@ -619,6 +664,7 @@ GenerateMapGetters(io::Printer* printer) const { " }\n" " return map.get(key);\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } } 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 073d1cfc..f19ec271 100644 --- a/src/google/protobuf/compiler/java/java_map_field_lite.cc +++ b/src/google/protobuf/compiler/java/java_map_field_lite.cc @@ -166,12 +166,14 @@ GenerateInterfaceMembers(io::Printer* printer) const { WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, - "$deprecation$int get$capitalized_name$Count();\n"); + "$deprecation$int ${$get$capitalized_name$Count$}$();\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, - "$deprecation$boolean contains$capitalized_name$(\n" + "$deprecation$boolean ${$contains$capitalized_name$$}$(\n" " $key_type$ key);\n"); + printer->Annotate("{", "}", descriptor_); if (GetJavaType(ValueField(descriptor_)) == JAVATYPE_ENUM) { printer->Print( variables_, @@ -180,23 +182,27 @@ GenerateInterfaceMembers(io::Printer* printer) const { " */\n" "@java.lang.Deprecated\n" "java.util.Map<$boxed_key_type$, $value_enum_type$>\n" - "get$capitalized_name$();\n"); + "${$get$capitalized_name$$}$();\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "$deprecation$java.util.Map<$boxed_key_type$, $value_enum_type$>\n" - "get$capitalized_name$Map();\n"); + "${$get$capitalized_name$Map$}$();\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, - "$deprecation$$value_enum_type$ get$capitalized_name$OrDefault(\n" + "$deprecation$$value_enum_type$ ${$get$capitalized_name$OrDefault$}$(\n" " $key_type$ key,\n" " $value_enum_type$ defaultValue);\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, - "$deprecation$$value_enum_type$ get$capitalized_name$OrThrow(\n" + "$deprecation$$value_enum_type$ ${$get$capitalized_name$OrThrow$}$(\n" " $key_type$ key);\n"); + printer->Annotate("{", "}", descriptor_); if (SupportUnknownEnumValue(descriptor_->file())) { printer->Print( variables_, @@ -205,25 +211,29 @@ GenerateInterfaceMembers(io::Printer* printer) const { " */\n" "@java.lang.Deprecated\n" "java.util.Map<$type_parameters$>\n" - "get$capitalized_name$Value();\n"); + "${$get$capitalized_name$Value$}$();\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "$deprecation$java.util.Map<$type_parameters$>\n" - "get$capitalized_name$ValueMap();\n"); + "${$get$capitalized_name$ValueMap$}$();\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "$deprecation$\n" - "$value_type$ get$capitalized_name$ValueOrDefault(\n" + "$value_type$ ${$get$capitalized_name$ValueOrDefault$}$(\n" " $key_type$ key,\n" " $value_type$ defaultValue);\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "$deprecation$\n" - "$value_type$ get$capitalized_name$ValueOrThrow(\n" + "$value_type$ ${$get$capitalized_name$ValueOrThrow$}$(\n" " $key_type$ key);\n"); + printer->Annotate("{", "}", descriptor_); } } else { printer->Print( @@ -233,25 +243,29 @@ GenerateInterfaceMembers(io::Printer* printer) const { " */\n" "@java.lang.Deprecated\n" "java.util.Map<$type_parameters$>\n" - "get$capitalized_name$();\n"); + "${$get$capitalized_name$$}$();\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "$deprecation$java.util.Map<$type_parameters$>\n" - "get$capitalized_name$Map();\n"); + "${$get$capitalized_name$Map$}$();\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "$deprecation$\n" - "$value_type$ get$capitalized_name$OrDefault(\n" + "$value_type$ ${$get$capitalized_name$OrDefault$}$(\n" " $key_type$ key,\n" " $value_type$ defaultValue);\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "$deprecation$\n" - "$value_type$ get$capitalized_name$OrThrow(\n" + "$value_type$ ${$get$capitalized_name$OrThrow$}$(\n" " $key_type$ key);\n"); + printer->Annotate("{", "}", descriptor_); } } @@ -288,18 +302,20 @@ GenerateMembers(io::Printer* printer) const { printer->Print( variables_, "$deprecation$\n" - "public int get$capitalized_name$Count() {\n" + "public int ${$get$capitalized_name$Count$}$() {\n" " return internalGet$capitalized_name$().size();\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "$deprecation$\n" - "public boolean contains$capitalized_name$(\n" + "public boolean ${$contains$capitalized_name$$}$(\n" " $key_type$ key) {\n" " $key_null_check$\n" " return internalGet$capitalized_name$().containsKey(key);\n" "}\n"); + printer->Annotate("{", "}", descriptor_); if (GetJavaType(ValueField(descriptor_)) == JAVATYPE_ENUM) { printer->Print( variables_, @@ -316,26 +332,28 @@ GenerateMembers(io::Printer* printer) const { " */\n" "@java.lang.Deprecated\n" "public java.util.Map<$boxed_key_type$, $value_enum_type$>\n" - "get$capitalized_name$() {\n" + "${$get$capitalized_name$$}$() {\n" " return get$capitalized_name$Map();\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "$deprecation$\n" "public java.util.Map<$boxed_key_type$, $value_enum_type$>\n" - "get$capitalized_name$Map() {\n" + "${$get$capitalized_name$Map$}$() {\n" " return java.util.Collections.unmodifiableMap(\n" " new com.google.protobuf.Internal.MapAdapter<\n" " $boxed_key_type$, $value_enum_type$, java.lang.Integer>(\n" " internalGet$capitalized_name$(),\n" " $name$ValueConverter));\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "$deprecation$\n" - "public $value_enum_type$ get$capitalized_name$OrDefault(\n" + "public $value_enum_type$ ${$get$capitalized_name$OrDefault$}$(\n" " $key_type$ key,\n" " $value_enum_type$ defaultValue) {\n" " $key_null_check$\n" @@ -345,11 +363,12 @@ GenerateMembers(io::Printer* printer) const { " ? $name$ValueConverter.doForward(map.get(key))\n" " : defaultValue;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "$deprecation$\n" - "public $value_enum_type$ get$capitalized_name$OrThrow(\n" + "public $value_enum_type$ ${$get$capitalized_name$OrThrow$}$(\n" " $key_type$ key) {\n" " $key_null_check$\n" " java.util.Map<$boxed_key_type$, $boxed_value_type$> map =\n" @@ -359,6 +378,7 @@ GenerateMembers(io::Printer* printer) const { " }\n" " return $name$ValueConverter.doForward(map.get(key));\n" "}\n"); + printer->Annotate("{", "}", descriptor_); if (SupportUnknownEnumValue(descriptor_->file())) { printer->Print( variables_, @@ -367,23 +387,25 @@ GenerateMembers(io::Printer* printer) const { " */\n" "@java.lang.Deprecated\n" "public java.util.Map<$boxed_key_type$, $boxed_value_type$>\n" - "get$capitalized_name$Value() {\n" + "${$get$capitalized_name$Value$}$() {\n" " return get$capitalized_name$ValueMap();\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "$deprecation$\n" "public java.util.Map<$boxed_key_type$, $boxed_value_type$>\n" - "get$capitalized_name$ValueMap() {\n" + "${$get$capitalized_name$ValueMap$}$() {\n" " return java.util.Collections.unmodifiableMap(\n" " internalGet$capitalized_name$());\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "$deprecation$\n" - "public $value_type$ get$capitalized_name$ValueOrDefault(\n" + "public $value_type$ ${$get$capitalized_name$ValueOrDefault$}$(\n" " $key_type$ key,\n" " $value_type$ defaultValue) {\n" " $key_null_check$\n" @@ -391,11 +413,12 @@ GenerateMembers(io::Printer* printer) const { " internalGet$capitalized_name$();\n" " return map.containsKey(key) ? map.get(key) : defaultValue;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "$deprecation$\n" - "public $value_type$ get$capitalized_name$ValueOrThrow(\n" + "public $value_type$ ${$get$capitalized_name$ValueOrThrow$}$(\n" " $key_type$ key) {\n" " $key_null_check$\n" " java.util.Map<$boxed_key_type$, $boxed_value_type$> map =\n" @@ -405,6 +428,7 @@ GenerateMembers(io::Printer* printer) const { " }\n" " return map.get(key);\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } } else { printer->Print( @@ -413,22 +437,26 @@ GenerateMembers(io::Printer* printer) const { " * Use {@link #get$capitalized_name$Map()} instead.\n" " */\n" "@java.lang.Deprecated\n" - "public java.util.Map<$type_parameters$> get$capitalized_name$() {\n" + "public java.util.Map<$type_parameters$> " + "${$get$capitalized_name$$}$() {\n" " return get$capitalized_name$Map();\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "$deprecation$\n" - "public java.util.Map<$type_parameters$> get$capitalized_name$Map() {\n" + "public java.util.Map<$type_parameters$> " + "${$get$capitalized_name$Map$}$() {\n" " return java.util.Collections.unmodifiableMap(\n" " internalGet$capitalized_name$());\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "$deprecation$\n" - "public $value_type$ get$capitalized_name$OrDefault(\n" + "public $value_type$ ${$get$capitalized_name$OrDefault$}$(\n" " $key_type$ key,\n" " $value_type$ defaultValue) {\n" " $key_null_check$\n" @@ -436,11 +464,12 @@ GenerateMembers(io::Printer* printer) const { " internalGet$capitalized_name$();\n" " return map.containsKey(key) ? map.get(key) : defaultValue;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "$deprecation$\n" - "public $value_type$ get$capitalized_name$OrThrow(\n" + "public $value_type$ ${$get$capitalized_name$OrThrow$}$(\n" " $key_type$ key) {\n" " $key_null_check$\n" " java.util.Map<$type_parameters$> map =\n" @@ -450,6 +479,7 @@ GenerateMembers(io::Printer* printer) const { " }\n" " return map.get(key);\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } // Generate private setters for the builder to proxy into. @@ -490,37 +520,41 @@ GenerateBuilderMembers(io::Printer* printer) const { printer->Print( variables_, "$deprecation$\n" - "public int get$capitalized_name$Count() {\n" + "public int ${$get$capitalized_name$Count$}$() {\n" " return instance.get$capitalized_name$Map().size();\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "$deprecation$\n" - "public boolean contains$capitalized_name$(\n" + "public boolean ${$contains$capitalized_name$$}$(\n" " $key_type$ key) {\n" " $key_null_check$\n" " return instance.get$capitalized_name$Map().containsKey(key);\n" "}\n"); + printer->Annotate("{", "}", descriptor_); printer->Print( variables_, "$deprecation$\n" - "public Builder clear$capitalized_name$() {\n" + "public Builder ${$clear$capitalized_name$$}$() {\n" " copyOnWrite();\n" " instance.getMutable$capitalized_name$Map().clear();\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "$deprecation$\n" - "public Builder remove$capitalized_name$(\n" + "public Builder ${$remove$capitalized_name$$}$(\n" " $key_type$ key) {\n" " $key_null_check$\n" " copyOnWrite();\n" " instance.getMutable$capitalized_name$Map().remove(key);\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); if (GetJavaType(ValueField(descriptor_)) == JAVATYPE_ENUM) { printer->Print( variables_, @@ -529,23 +563,25 @@ GenerateBuilderMembers(io::Printer* printer) const { " */\n" "@java.lang.Deprecated\n" "public java.util.Map<$boxed_key_type$, $value_enum_type$>\n" - "get$capitalized_name$() {\n" + "${$get$capitalized_name$$}$() {\n" " return get$capitalized_name$Map();\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "$deprecation$\n" "public java.util.Map<$boxed_key_type$, $value_enum_type$>\n" - "get$capitalized_name$Map() {\n" + "${$get$capitalized_name$Map$}$() {\n" " return java.util.Collections.unmodifiableMap(\n" " instance.get$capitalized_name$Map());\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "$deprecation$\n" - "public $value_enum_type$ get$capitalized_name$OrDefault(\n" + "public $value_enum_type$ ${$get$capitalized_name$OrDefault$}$(\n" " $key_type$ key,\n" " $value_enum_type$ defaultValue) {\n" " $key_null_check$\n" @@ -555,11 +591,12 @@ GenerateBuilderMembers(io::Printer* printer) const { " ? map.get(key)\n" " : defaultValue;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "$deprecation$\n" - "public $value_enum_type$ get$capitalized_name$OrThrow(\n" + "public $value_enum_type$ ${$get$capitalized_name$OrThrow$}$(\n" " $key_type$ key) {\n" " $key_null_check$\n" " java.util.Map<$boxed_key_type$, $value_enum_type$> map =\n" @@ -569,10 +606,11 @@ GenerateBuilderMembers(io::Printer* printer) const { " }\n" " return map.get(key);\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, - "$deprecation$public Builder put$capitalized_name$(\n" + "$deprecation$public Builder ${$put$capitalized_name$$}$(\n" " $key_type$ key,\n" " $value_enum_type$ value) {\n" " $key_null_check$\n" @@ -581,15 +619,17 @@ GenerateBuilderMembers(io::Printer* printer) const { " instance.getMutable$capitalized_name$Map().put(key, value);\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, - "$deprecation$public Builder putAll$capitalized_name$(\n" + "$deprecation$public Builder ${$putAll$capitalized_name$$}$(\n" " java.util.Map<$boxed_key_type$, $value_enum_type$> values) {\n" " copyOnWrite();\n" " instance.getMutable$capitalized_name$Map().putAll(values);\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); if (SupportUnknownEnumValue(descriptor_->file())) { printer->Print( variables_, @@ -598,23 +638,25 @@ GenerateBuilderMembers(io::Printer* printer) const { " */\n" "@java.lang.Deprecated\n" "public java.util.Map<$boxed_key_type$, $boxed_value_type$>\n" - "get$capitalized_name$Value() {\n" + "${$get$capitalized_name$Value$}$() {\n" " return get$capitalized_name$ValueMap();\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "$deprecation$\n" "public java.util.Map<$boxed_key_type$, $boxed_value_type$>\n" - "get$capitalized_name$ValueMap() {\n" + "${$get$capitalized_name$ValueMap$}$() {\n" " return java.util.Collections.unmodifiableMap(\n" " instance.get$capitalized_name$ValueMap());\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "$deprecation$\n" - "public $value_type$ get$capitalized_name$ValueOrDefault(\n" + "public $value_type$ ${$get$capitalized_name$ValueOrDefault$}$(\n" " $key_type$ key,\n" " $value_type$ defaultValue) {\n" " $key_null_check$\n" @@ -622,11 +664,12 @@ GenerateBuilderMembers(io::Printer* printer) const { " instance.get$capitalized_name$ValueMap();\n" " return map.containsKey(key) ? map.get(key) : defaultValue;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "$deprecation$\n" - "public $value_type$ get$capitalized_name$ValueOrThrow(\n" + "public $value_type$ ${$get$capitalized_name$ValueOrThrow$}$(\n" " $key_type$ key) {\n" " $key_null_check$\n" " java.util.Map<$boxed_key_type$, $boxed_value_type$> map =\n" @@ -636,10 +679,11 @@ GenerateBuilderMembers(io::Printer* printer) const { " }\n" " return map.get(key);\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, - "$deprecation$public Builder put$capitalized_name$Value(\n" + "$deprecation$public Builder ${$put$capitalized_name$Value$}$(\n" " $key_type$ key,\n" " $value_type$ value) {\n" " $key_null_check$\n" @@ -647,15 +691,17 @@ GenerateBuilderMembers(io::Printer* printer) const { " instance.getMutable$capitalized_name$ValueMap().put(key, value);\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, - "$deprecation$public Builder putAll$capitalized_name$Value(\n" + "$deprecation$public Builder ${$putAll$capitalized_name$Value$}$(\n" " java.util.Map<$boxed_key_type$, $boxed_value_type$> values) {\n" " copyOnWrite();\n" " instance.getMutable$capitalized_name$ValueMap().putAll(values);\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } } else { printer->Print( @@ -664,22 +710,26 @@ GenerateBuilderMembers(io::Printer* printer) const { " * Use {@link #get$capitalized_name$Map()} instead.\n" " */\n" "@java.lang.Deprecated\n" - "public java.util.Map<$type_parameters$> get$capitalized_name$() {\n" + "public java.util.Map<$type_parameters$> " + "${$get$capitalized_name$$}$() {\n" " return get$capitalized_name$Map();\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "$deprecation$" - "public java.util.Map<$type_parameters$> get$capitalized_name$Map() {\n" + "public java.util.Map<$type_parameters$> " + "${$get$capitalized_name$Map$}$() {\n" " return java.util.Collections.unmodifiableMap(\n" " instance.get$capitalized_name$Map());\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "$deprecation$\n" - "public $value_type$ get$capitalized_name$OrDefault(\n" + "public $value_type$ ${$get$capitalized_name$OrDefault$}$(\n" " $key_type$ key,\n" " $value_type$ defaultValue) {\n" " $key_null_check$\n" @@ -687,11 +737,12 @@ GenerateBuilderMembers(io::Printer* printer) const { " instance.get$capitalized_name$Map();\n" " return map.containsKey(key) ? map.get(key) : defaultValue;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "$deprecation$\n" - "public $value_type$ get$capitalized_name$OrThrow(\n" + "public $value_type$ ${$get$capitalized_name$OrThrow$}$(\n" " $key_type$ key) {\n" " $key_null_check$\n" " java.util.Map<$type_parameters$> map =\n" @@ -701,11 +752,12 @@ GenerateBuilderMembers(io::Printer* printer) const { " }\n" " return map.get(key);\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "$deprecation$" - "public Builder put$capitalized_name$(\n" + "public Builder ${$put$capitalized_name$$}$(\n" " $key_type$ key,\n" " $value_type$ value) {\n" " $key_null_check$\n" @@ -714,16 +766,18 @@ GenerateBuilderMembers(io::Printer* printer) const { " instance.getMutable$capitalized_name$Map().put(key, value);\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "$deprecation$" - "public Builder putAll$capitalized_name$(\n" + "public Builder ${$putAll$capitalized_name$$}$(\n" " java.util.Map<$type_parameters$> values) {\n" " copyOnWrite();\n" " instance.getMutable$capitalized_name$Map().putAll(values);\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } } diff --git a/src/google/protobuf/compiler/java/java_message.cc b/src/google/protobuf/compiler/java/java_message.cc index 6e3b4a75..8964f632 100644 --- a/src/google/protobuf/compiler/java/java_message.cc +++ b/src/google/protobuf/compiler/java/java_message.cc @@ -56,8 +56,9 @@ #include <google/protobuf/io/printer.h> #include <google/protobuf/descriptor.pb.h> #include <google/protobuf/wire_format.h> -#include <google/protobuf/stubs/strutil.h> #include <google/protobuf/stubs/substitute.h> +#include <google/protobuf/stubs/strutil.h> + namespace google { namespace protobuf { @@ -253,7 +254,7 @@ void ImmutableMessageGenerator::GenerateInterface(io::Printer* printer) { /* immutable = */ true, "OrBuilder"); if (descriptor_->extension_range_count() > 0) { printer->Print( - "$deprecation$public interface $classname$OrBuilder$idend$ extends\n" + "$deprecation$public interface ${$$classname$OrBuilder$}$ extends\n" " $extra_interfaces$\n" " com.google.protobuf.GeneratedMessage$ver$.\n" " ExtendableMessageOrBuilder<$classname$> {\n", @@ -261,19 +262,19 @@ void ImmutableMessageGenerator::GenerateInterface(io::Printer* printer) { "@java.lang.Deprecated " : "", "extra_interfaces", ExtraMessageOrBuilderInterfaces(descriptor_), "classname", descriptor_->name(), - "idend", "", "ver", GeneratedCodeVersionSuffix()); + "{", "", "}", "", "ver", GeneratedCodeVersionSuffix()); } else { printer->Print( - "$deprecation$public interface $classname$OrBuilder$idend$ extends\n" + "$deprecation$public interface ${$$classname$OrBuilder$}$ extends\n" " $extra_interfaces$\n" " com.google.protobuf.MessageOrBuilder {\n", "deprecation", descriptor_->options().deprecated() ? "@java.lang.Deprecated " : "", "extra_interfaces", ExtraMessageOrBuilderInterfaces(descriptor_), "classname", descriptor_->name(), - "idend", ""); + "{", "", "}", ""); } - printer->Annotate("classname", "idend", descriptor_); + printer->Annotate("{", "}", descriptor_); printer->Indent(); for (int i = 0; i < descriptor_->field_count(); i++) { @@ -345,6 +346,9 @@ void ImmutableMessageGenerator::Generate(io::Printer* printer) { "com.google.protobuf.GeneratedMessage$0.Builder<?>", GeneratedCodeVersionSuffix()); } + printer->Print( + "private static final long serialVersionUID = 0L;\n"); + printer->Indent(); // Using builder_type, instead of Builder, prevents the Builder class from // being loaded into PermGen space when the default instance is created. @@ -367,22 +371,19 @@ void ImmutableMessageGenerator::Generate(io::Printer* printer) { "}\n" "\n"); + printer->Print( "@java.lang.Override\n" "public final com.google.protobuf.UnknownFieldSet\n" - "getUnknownFields() {\n"); - if (PreserveUnknownFields(descriptor_)) { - printer->Print( - " return this.unknownFields;\n"); - } else { - printer->Print( - " return com.google.protobuf.UnknownFieldSet.getDefaultInstance();\n"); - } - printer->Print( + "getUnknownFields() {\n" + " return this.unknownFields;\n" "}\n"); if (context_->HasGeneratedMethods(descriptor_)) { - GenerateParsingConstructor(printer); + if (!EnableExperimentalRuntime(context_) || + IsDescriptorProto(descriptor_)) { + GenerateParsingConstructor(printer); + } } GenerateDescriptorMethods(printer); @@ -436,11 +437,10 @@ void ImmutableMessageGenerator::Generate(io::Printer* printer) { for (int j = 0; j < descriptor_->oneof_decl(i)->field_count(); j++) { const FieldDescriptor* field = descriptor_->oneof_decl(i)->field(j); printer->Print( - "$field_name$($field_number$),\n", - "field_name", - ToUpper(field->name()), - "field_number", - SimpleItoa(field->number())); + "$deprecation$$field_name$($field_number$),\n", + "deprecation", field->options().deprecated() ? "@java.lang.Deprecated " : "", + "field_name", ToUpper(field->name()), + "field_number", SimpleItoa(field->number())); } printer->Print( "$cap_oneof_name$_NOT_SET(0);\n", @@ -540,9 +540,21 @@ void ImmutableMessageGenerator::Generate(io::Printer* printer) { "\n", "classname", name_resolver_->GetImmutableClassName(descriptor_)); + // 'of' method for Wrappers + if (IsWrappersProtoFile(descriptor_->file())) { + printer->Print( + "public static $classname$ of($field_type$ value) {\n" + " return newBuilder().setValue(value).build();\n" + "}\n" + "\n", + "classname", name_resolver_->GetImmutableClassName(descriptor_), + "field_type", PrimitiveTypeName(GetJavaType(descriptor_->field(0)))); + } + GenerateParser(printer); printer->Print( + "@java.lang.Override\n" "public $classname$ getDefaultInstanceForType() {\n" " return DEFAULT_INSTANCE;\n" "}\n" @@ -576,107 +588,110 @@ GenerateMessageSerializationMethods(io::Printer* printer) { std::sort(sorted_extensions.begin(), sorted_extensions.end(), ExtensionRangeOrdering()); printer->Print( + "@java.lang.Override\n" "public void writeTo(com.google.protobuf.CodedOutputStream output)\n" " throws java.io.IOException {\n"); printer->Indent(); - if (HasPackedFields(descriptor_)) { - // writeTo(CodedOutputStream output) might be invoked without - // getSerializedSize() ever being called, but we need the memoized - // sizes in case this message has packed fields. Rather than emit checks for - // each packed field, just call getSerializedSize() up front. - // In most cases, getSerializedSize() will have already been called anyway - // by one of the wrapper writeTo() methods, making this call cheap. - printer->Print( - "getSerializedSize();\n"); - } - if (descriptor_->extension_range_count() > 0) { - if (descriptor_->options().message_set_wire_format()) { - printer->Print( - "com.google.protobuf.GeneratedMessage$ver$\n" - " .ExtendableMessage<$classname$>.ExtensionWriter\n" - " extensionWriter = newMessageSetExtensionWriter();\n", - "classname", name_resolver_->GetImmutableClassName(descriptor_), - "ver", GeneratedCodeVersionSuffix()); - } else { - printer->Print( - "com.google.protobuf.GeneratedMessage$ver$\n" - " .ExtendableMessage<$classname$>.ExtensionWriter\n" - " extensionWriter = newExtensionWriter();\n", - "classname", name_resolver_->GetImmutableClassName(descriptor_), - "ver", GeneratedCodeVersionSuffix()); + if (EnableExperimentalRuntime(context_) && !IsDescriptorProto(descriptor_)) { + printer->Print("writeToInternal(output);\n"); + } else { + if (HasPackedFields(descriptor_)) { + // writeTo(CodedOutputStream output) might be invoked without + // getSerializedSize() ever being called, but we need the memoized + // sizes in case this message has packed fields. Rather than emit checks + // for each packed field, just call getSerializedSize() up front. In most + // cases, getSerializedSize() will have already been called anyway by one + // of the wrapper writeTo() methods, making this call cheap. + printer->Print("getSerializedSize();\n"); } - } - // Merge the fields and the extension ranges, both sorted by field number. - for (int i = 0, j = 0; - i < descriptor_->field_count() || j < sorted_extensions.size(); - ) { - if (i == descriptor_->field_count()) { - GenerateSerializeOneExtensionRange(printer, sorted_extensions[j++]); - } else if (j == sorted_extensions.size()) { - GenerateSerializeOneField(printer, sorted_fields[i++]); - } else if (sorted_fields[i]->number() < sorted_extensions[j]->start) { - GenerateSerializeOneField(printer, sorted_fields[i++]); - } else { - GenerateSerializeOneExtensionRange(printer, sorted_extensions[j++]); + if (descriptor_->extension_range_count() > 0) { + if (descriptor_->options().message_set_wire_format()) { + printer->Print( + "com.google.protobuf.GeneratedMessage$ver$\n" + " .ExtendableMessage<$classname$>.ExtensionWriter\n" + " extensionWriter = newMessageSetExtensionWriter();\n", + "classname", name_resolver_->GetImmutableClassName(descriptor_), + "ver", GeneratedCodeVersionSuffix()); + } else { + printer->Print( + "com.google.protobuf.GeneratedMessage$ver$\n" + " .ExtendableMessage<$classname$>.ExtensionWriter\n" + " extensionWriter = newExtensionWriter();\n", + "classname", name_resolver_->GetImmutableClassName(descriptor_), + "ver", GeneratedCodeVersionSuffix()); + } + } + + // Merge the fields and the extension ranges, both sorted by field number. + for (int i = 0, j = 0; + i < descriptor_->field_count() || j < sorted_extensions.size();) { + if (i == descriptor_->field_count()) { + GenerateSerializeOneExtensionRange(printer, sorted_extensions[j++]); + } else if (j == sorted_extensions.size()) { + GenerateSerializeOneField(printer, sorted_fields[i++]); + } else if (sorted_fields[i]->number() < sorted_extensions[j]->start) { + GenerateSerializeOneField(printer, sorted_fields[i++]); + } else { + GenerateSerializeOneExtensionRange(printer, sorted_extensions[j++]); + } } - } - if (PreserveUnknownFields(descriptor_)) { if (descriptor_->options().message_set_wire_format()) { - printer->Print( - "unknownFields.writeAsMessageSetTo(output);\n"); + printer->Print("unknownFields.writeAsMessageSetTo(output);\n"); } else { - printer->Print( - "unknownFields.writeTo(output);\n"); + printer->Print("unknownFields.writeTo(output);\n"); } } printer->Outdent(); printer->Print( - "}\n" - "\n" - "public int getSerializedSize() {\n" - " int size = memoizedSize;\n" - " if (size != -1) return size;\n" - "\n" - " size = 0;\n"); + "}\n" + "\n" + "@java.lang.Override\n" + "public int getSerializedSize() {\n" + " int size = memoizedSize;\n" + " if (size != -1) return size;\n" + "\n"); printer->Indent(); + if (EnableExperimentalRuntime(context_) && !IsDescriptorProto(descriptor_)) { + printer->Print( + "memoizedSize = getSerializedSizeInternal();\n" + "return memoizedSize;\n"); + } else { - for (int i = 0; i < descriptor_->field_count(); i++) { - field_generators_.get(sorted_fields[i]).GenerateSerializedSizeCode(printer); - } + printer->Print("size = 0;\n"); - if (descriptor_->extension_range_count() > 0) { - if (descriptor_->options().message_set_wire_format()) { - printer->Print( - "size += extensionsSerializedSizeAsMessageSet();\n"); - } else { - printer->Print( - "size += extensionsSerializedSize();\n"); + for (int i = 0; i < descriptor_->field_count(); i++) { + field_generators_.get(sorted_fields[i]) + .GenerateSerializedSizeCode(printer); + } + + if (descriptor_->extension_range_count() > 0) { + if (descriptor_->options().message_set_wire_format()) { + printer->Print("size += extensionsSerializedSizeAsMessageSet();\n"); + } else { + printer->Print("size += extensionsSerializedSize();\n"); + } } - } - if (PreserveUnknownFields(descriptor_)) { if (descriptor_->options().message_set_wire_format()) { printer->Print( - "size += unknownFields.getSerializedSizeAsMessageSet();\n"); + "size += unknownFields.getSerializedSizeAsMessageSet();\n"); } else { - printer->Print( - "size += unknownFields.getSerializedSize();\n"); + printer->Print("size += unknownFields.getSerializedSize();\n"); } + + printer->Print( + "memoizedSize = size;\n" + "return size;\n"); } printer->Outdent(); printer->Print( - " memoizedSize = size;\n" - " return size;\n" "}\n" "\n"); - - printer->Print( - "private static final long serialVersionUID = 0L;\n"); } void ImmutableMessageGenerator:: @@ -776,6 +791,7 @@ void ImmutableMessageGenerator::GenerateSerializeOneExtensionRange( void ImmutableMessageGenerator::GenerateBuilder(io::Printer* printer) { // LITE_RUNTIME implements this at the GeneratedMessageLite level. printer->Print( + "@java.lang.Override\n" "public Builder newBuilderForType() { return newBuilder(); }\n"); printer->Print( @@ -785,6 +801,7 @@ void ImmutableMessageGenerator::GenerateBuilder(io::Printer* printer) { "public static Builder newBuilder($classname$ prototype) {\n" " return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);\n" "}\n" + "@java.lang.Override\n" "public Builder toBuilder() {\n" " return this == DEFAULT_INSTANCE\n" " ? new Builder() : new Builder().mergeFrom(this);\n" @@ -828,6 +845,7 @@ GenerateDescriptorMethods(io::Printer* printer) { if (!map_fields.empty()) { printer->Print( "@SuppressWarnings({\"rawtypes\"})\n" + "@java.lang.Override\n" "protected com.google.protobuf.MapField internalGetMapField(\n" " int number) {\n" " switch (number) {\n"); @@ -853,6 +871,7 @@ GenerateDescriptorMethods(io::Printer* printer) { "}\n"); } printer->Print( + "@java.lang.Override\n" "protected com.google.protobuf.GeneratedMessage$ver$.FieldAccessorTable\n" " internalGetFieldAccessorTable() {\n" " return $fileclass$.internal_$identifier$_fieldAccessorTable\n" @@ -876,6 +895,7 @@ void ImmutableMessageGenerator::GenerateIsInitialized( printer->Print( "private byte memoizedIsInitialized = -1;\n"); printer->Print( + "@java.lang.Override\n" "public final boolean isInitialized() {\n"); printer->Indent(); @@ -1078,13 +1098,11 @@ GenerateEqualsAndHashCode(io::Printer* printer) { printer->Print("}\n"); } - if (PreserveUnknownFields(descriptor_)) { - // Always consider unknown fields for equality. This will sometimes return - // false for non-canonical ordering when running in LITE_RUNTIME but it's - // the best we can do. - printer->Print( + // Always consider unknown fields for equality. This will sometimes return + // false for non-canonical ordering when running in LITE_RUNTIME but it's + // the best we can do. + printer->Print( "result = result && unknownFields.equals(other.unknownFields);\n"); - } if (descriptor_->extension_range_count() > 0) { printer->Print( "result = result &&\n" @@ -1211,7 +1229,10 @@ GenerateParsingConstructor(io::Printer* printer) { // Initialize all fields to default. printer->Print( - "this();\n"); + "this();\n" + "if (extensionRegistry == null) {\n" + " throw new java.lang.NullPointerException();\n" + "}\n"); // Use builder bits to track mutable repeated fields. int totalBuilderBits = 0; @@ -1226,11 +1247,9 @@ GenerateParsingConstructor(io::Printer* printer) { "bit_field_name", GetBitFieldName(i)); } - if (PreserveUnknownFields(descriptor_)) { - printer->Print( + printer->Print( "com.google.protobuf.UnknownFieldSet.Builder unknownFields =\n" " com.google.protobuf.UnknownFieldSet.newBuilder();\n"); - } printer->Print( "try {\n"); @@ -1247,28 +1266,9 @@ GenerateParsingConstructor(io::Printer* printer) { printer->Indent(); printer->Print( - "case 0:\n" // zero signals EOF / limit reached - " done = true;\n" - " break;\n"); - - if (PreserveUnknownFields(descriptor_)) { - printer->Print( - "default: {\n" - " if (!parseUnknownField(input, unknownFields,\n" - " extensionRegistry, tag)) {\n" - " done = true;\n" // it's an endgroup tag - " }\n" - " break;\n" - "}\n"); - } else { - printer->Print( - "default: {\n" - " if (!input.skipField(tag)) {\n" - " done = true;\n" // it's an endgroup tag - " }\n" - " break;\n" - "}\n"); - } + "case 0:\n" // zero signals EOF / limit reached + " done = true;\n" + " break;\n"); for (int i = 0; i < descriptor_->field_count(); i++) { const FieldDescriptor* field = sorted_fields[i]; @@ -1306,6 +1306,18 @@ GenerateParsingConstructor(io::Printer* printer) { } } + printer->Print( + "default: {\n" + " if (!parseUnknownField$suffix$(\n" + " input, unknownFields, extensionRegistry, tag)) {\n" + " done = true;\n" // it's an endgroup tag + " }\n" + " break;\n" + "}\n", + "suffix", + descriptor_->file()->syntax() == FileDescriptor::SYNTAX_PROTO3 ? "Proto3" + : ""); + printer->Outdent(); printer->Outdent(); printer->Print( @@ -1328,10 +1340,8 @@ GenerateParsingConstructor(io::Printer* printer) { field_generators_.get(field).GenerateParsingDoneCode(printer); } - if (PreserveUnknownFields(descriptor_)) { - // Make unknown fields immutable. - printer->Print("this.unknownFields = unknownFields.build();\n"); - } + // Make unknown fields immutable. + printer->Print("this.unknownFields = unknownFields.build();\n"); // Make extensions immutable. printer->Print( @@ -1355,15 +1365,24 @@ void ImmutableMessageGenerator::GenerateParser(io::Printer* printer) { "classname", descriptor_->name()); printer->Indent(); printer->Print( + "@java.lang.Override\n" "public $classname$ parsePartialFrom(\n" " com.google.protobuf.CodedInputStream input,\n" " com.google.protobuf.ExtensionRegistryLite extensionRegistry)\n" " throws com.google.protobuf.InvalidProtocolBufferException {\n", "classname", descriptor_->name()); - if (context_->HasGeneratedMethods(descriptor_)) { + if (EnableExperimentalRuntime(context_) && !IsDescriptorProto(descriptor_)) { + printer->Indent(); printer->Print( - " return new $classname$(input, extensionRegistry);\n", + "$classname$ msg = new $classname$();\n" + "msg.mergeFromInternal(input, extensionRegistry);\n" + "msg.makeImmutableInternal();\n" + "return msg;\n", "classname", descriptor_->name()); + printer->Outdent(); + } else if (context_->HasGeneratedMethods(descriptor_)) { + printer->Print(" return new $classname$(input, extensionRegistry);\n", + "classname", descriptor_->name()); } else { // When parsing constructor isn't generated, use builder to parse // messages. Note, will fallback to use reflection based mergeFieldFrom() diff --git a/src/google/protobuf/compiler/java/java_message_builder.cc b/src/google/protobuf/compiler/java/java_message_builder.cc index f5643abc..43c39b4a 100644 --- a/src/google/protobuf/compiler/java/java_message_builder.cc +++ b/src/google/protobuf/compiler/java/java_message_builder.cc @@ -54,8 +54,9 @@ #include <google/protobuf/io/printer.h> #include <google/protobuf/descriptor.pb.h> #include <google/protobuf/wire_format.h> -#include <google/protobuf/stubs/strutil.h> #include <google/protobuf/stubs/substitute.h> +#include <google/protobuf/stubs/strutil.h> + namespace google { namespace protobuf { @@ -171,36 +172,27 @@ Generate(io::Printer* printer) { .GenerateBuilderMembers(printer); } - if (!PreserveUnknownFields(descriptor_)) { - printer->Print( - "public final Builder setUnknownFields(\n" - " final com.google.protobuf.UnknownFieldSet unknownFields) {\n" - " return this;\n" - "}\n" - "\n" - "public final Builder mergeUnknownFields(\n" - " final com.google.protobuf.UnknownFieldSet unknownFields) {\n" - " return this;\n" - "}\n" - "\n"); - } else { + bool is_proto3 = + descriptor_->file()->syntax() == FileDescriptor::SYNTAX_PROTO3; // 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" - " return super.setUnknownFields(unknownFields);\n" - "}\n" - "\n" - "public final Builder mergeUnknownFields(\n" - " final com.google.protobuf.UnknownFieldSet unknownFields) {\n" - " return super.mergeUnknownFields(unknownFields);\n" - "}\n" - "\n"); - } + printer->Print( + "@java.lang.Override\n" + "public final Builder setUnknownFields(\n" + " final com.google.protobuf.UnknownFieldSet unknownFields) {\n" + " return super.setUnknownFields$suffix$(unknownFields);\n" + "}\n" + "\n" + "@java.lang.Override\n" + "public final Builder mergeUnknownFields(\n" + " final com.google.protobuf.UnknownFieldSet unknownFields) {\n" + " return super.mergeUnknownFields(unknownFields);\n" + "}\n" + "\n", + "suffix", is_proto3 ? "Proto3" : ""); printer->Print( "\n" @@ -287,6 +279,7 @@ GenerateDescriptorMethods(io::Printer* printer) { "}\n"); } printer->Print( + "@java.lang.Override\n" "protected com.google.protobuf.GeneratedMessage$ver$.FieldAccessorTable\n" " internalGetFieldAccessorTable() {\n" " return $fileclass$.internal_$identifier$_fieldAccessorTable\n" @@ -343,6 +336,7 @@ GenerateCommonBuilderMethods(io::Printer* printer) { "}\n"); printer->Print( + "@java.lang.Override\n" "public Builder clear() {\n" " super.clear();\n"); @@ -371,6 +365,7 @@ GenerateCommonBuilderMethods(io::Printer* printer) { "\n"); printer->Print( + "@java.lang.Override\n" "public com.google.protobuf.Descriptors.Descriptor\n" " getDescriptorForType() {\n" " return $fileclass$.internal_$identifier$_descriptor;\n" @@ -381,6 +376,7 @@ GenerateCommonBuilderMethods(io::Printer* printer) { // LITE runtime implements this in GeneratedMessageLite. printer->Print( + "@java.lang.Override\n" "public $classname$ getDefaultInstanceForType() {\n" " return $classname$.getDefaultInstance();\n" "}\n" @@ -388,6 +384,7 @@ GenerateCommonBuilderMethods(io::Printer* printer) { "classname", name_resolver_->GetImmutableClassName(descriptor_)); printer->Print( + "@java.lang.Override\n" "public $classname$ build() {\n" " $classname$ result = buildPartial();\n" " if (!result.isInitialized()) {\n" @@ -399,6 +396,7 @@ GenerateCommonBuilderMethods(io::Printer* printer) { "classname", name_resolver_->GetImmutableClassName(descriptor_)); printer->Print( + "@java.lang.Override\n" "public $classname$ buildPartial() {\n" " $classname$ result = new $classname$(this);\n", "classname", name_resolver_->GetImmutableClassName(descriptor_)); @@ -467,53 +465,63 @@ GenerateCommonBuilderMethods(io::Printer* printer) { // to subclass a different GeneratedMessage class (e.g., in v3.0.0 release // we changed all generated code to subclass GeneratedMessageV3). printer->Print( + "@java.lang.Override\n" "public Builder clone() {\n" " return (Builder) super.clone();\n" "}\n" + "@java.lang.Override\n" "public Builder setField(\n" " com.google.protobuf.Descriptors.FieldDescriptor field,\n" - " Object value) {\n" + " java.lang.Object value) {\n" " return (Builder) super.setField(field, value);\n" "}\n" + "@java.lang.Override\n" "public Builder clearField(\n" " com.google.protobuf.Descriptors.FieldDescriptor field) {\n" " return (Builder) super.clearField(field);\n" "}\n" + "@java.lang.Override\n" "public Builder clearOneof(\n" " com.google.protobuf.Descriptors.OneofDescriptor oneof) {\n" " return (Builder) super.clearOneof(oneof);\n" "}\n" + "@java.lang.Override\n" "public Builder setRepeatedField(\n" " com.google.protobuf.Descriptors.FieldDescriptor field,\n" - " int index, Object value) {\n" + " int index, java.lang.Object value) {\n" " return (Builder) super.setRepeatedField(field, index, value);\n" "}\n" + "@java.lang.Override\n" "public Builder addRepeatedField(\n" " com.google.protobuf.Descriptors.FieldDescriptor field,\n" - " Object value) {\n" + " java.lang.Object value) {\n" " return (Builder) super.addRepeatedField(field, value);\n" "}\n"); if (descriptor_->extension_range_count() > 0) { printer->Print( + "@java.lang.Override\n" "public <Type> Builder setExtension(\n" " com.google.protobuf.GeneratedMessage.GeneratedExtension<\n" " $classname$, Type> extension,\n" " Type value) {\n" " return (Builder) super.setExtension(extension, value);\n" "}\n" + "@java.lang.Override\n" "public <Type> Builder setExtension(\n" " com.google.protobuf.GeneratedMessage.GeneratedExtension<\n" " $classname$, java.util.List<Type>> extension,\n" " int index, Type value) {\n" " return (Builder) super.setExtension(extension, index, value);\n" "}\n" + "@java.lang.Override\n" "public <Type> Builder addExtension(\n" " com.google.protobuf.GeneratedMessage.GeneratedExtension<\n" " $classname$, java.util.List<Type>> extension,\n" " Type value) {\n" " return (Builder) super.addExtension(extension, value);\n" "}\n" + "@java.lang.Override\n" "public <Type> Builder clearExtension(\n" " com.google.protobuf.GeneratedMessage.GeneratedExtension<\n" " $classname$, ?> extension) {\n" @@ -526,6 +534,7 @@ GenerateCommonBuilderMethods(io::Printer* printer) { if (context_->HasGeneratedMethods(descriptor_)) { printer->Print( + "@java.lang.Override\n" "public Builder mergeFrom(com.google.protobuf.Message other) {\n" " if (other instanceof $classname$) {\n" " return mergeFrom(($classname$)other);\n" @@ -594,10 +603,8 @@ GenerateCommonBuilderMethods(io::Printer* printer) { " this.mergeExtensionFields(other);\n"); } - if (PreserveUnknownFields(descriptor_)) { - printer->Print( - " this.mergeUnknownFields(other.unknownFields);\n"); - } + printer->Print( + " this.mergeUnknownFields(other.unknownFields);\n"); printer->Print( " onChanged();\n"); @@ -614,6 +621,7 @@ GenerateCommonBuilderMethods(io::Printer* printer) { void MessageBuilderGenerator:: GenerateBuilderParsingMethods(io::Printer* printer) { printer->Print( + "@java.lang.Override\n" "public Builder mergeFrom(\n" " com.google.protobuf.CodedInputStream input,\n" " com.google.protobuf.ExtensionRegistryLite extensionRegistry)\n" @@ -639,6 +647,7 @@ GenerateBuilderParsingMethods(io::Printer* printer) { void MessageBuilderGenerator::GenerateIsInitialized( io::Printer* printer) { printer->Print( + "@java.lang.Override\n" "public final boolean isInitialized() {\n"); printer->Indent(); diff --git a/src/google/protobuf/compiler/java/java_message_field.cc b/src/google/protobuf/compiler/java/java_message_field.cc index ae84db1c..baa7f872 100644 --- a/src/google/protobuf/compiler/java/java_message_field.cc +++ b/src/google/protobuf/compiler/java/java_message_field.cc @@ -150,12 +150,9 @@ GenerateInterfaceMembers(io::Printer* printer) const { // interface so that builders can choose dynamically to either return a // message or a nested builder, so that asking for the interface doesn't // cause a message to ever be built. - if (SupportFieldPresence(descriptor_->file()) || - descriptor_->containing_oneof() == NULL) { - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$boolean has$capitalized_name$();\n"); - } + WriteFieldDocComment(printer, descriptor_); + printer->Print(variables_, + "$deprecation$boolean has$capitalized_name$();\n"); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "$deprecation$$type$ get$capitalized_name$();\n"); @@ -174,39 +171,45 @@ GenerateMembers(io::Printer* printer) const { if (SupportFieldPresence(descriptor_->file())) { WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public boolean has$capitalized_name$() {\n" + "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return $get_has_field_bit_message$;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public $type$ get$capitalized_name$() {\n" + "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n" " return $name$_ == null ? $type$.getDefaultInstance() : $name$_;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "$deprecation$public $type$OrBuilder " - "get$capitalized_name$OrBuilder() {\n" + "${$get$capitalized_name$OrBuilder$}$() {\n" " return $name$_ == null ? $type$.getDefaultInstance() : $name$_;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } else { WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public boolean has$capitalized_name$() {\n" + "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return $name$_ != null;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public $type$ get$capitalized_name$() {\n" + "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n" " return $name$_ == null ? $type$.getDefaultInstance() : $name$_;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "$deprecation$public $type$OrBuilder " - "get$capitalized_name$OrBuilder() {\n" + "${$get$capitalized_name$OrBuilder$}$() {\n" " return get$capitalized_name$();\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } } @@ -232,6 +235,7 @@ void ImmutableMessageFieldGenerator::PrintNestedBuilderFunction( const char* nested_builder_case, const char* trailing_code) const { printer->Print(variables_, method_prototype); + printer->Annotate("{", "}", descriptor_); printer->Print(" {\n"); printer->Indent(); PrintNestedBuilderCondition(printer, regular_case, nested_builder_case); @@ -267,20 +271,22 @@ GenerateBuilderMembers(io::Printer* printer) const { WriteFieldDocComment(printer, descriptor_); if (support_field_presence) { printer->Print(variables_, - "$deprecation$public boolean has$capitalized_name$() {\n" + "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return $get_has_field_bit_builder$;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } else { printer->Print(variables_, - "$deprecation$public boolean has$capitalized_name$() {\n" + "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return $name$Builder_ != null || $name$_ != null;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } // Field getField() WriteFieldDocComment(printer, descriptor_); PrintNestedBuilderFunction(printer, - "$deprecation$public $type$ get$capitalized_name$()", + "$deprecation$public $type$ ${$get$capitalized_name$$}$()", "return $name$_ == null ? $type$.getDefaultInstance() : $name$_;\n", "return $name$Builder_.getMessage();\n", NULL); @@ -288,7 +294,7 @@ GenerateBuilderMembers(io::Printer* printer) const { // Field.Builder setField(Field value) WriteFieldDocComment(printer, descriptor_); PrintNestedBuilderFunction(printer, - "$deprecation$public Builder set$capitalized_name$($type$ value)", + "$deprecation$public Builder ${$set$capitalized_name$$}$($type$ value)", "if (value == null) {\n" " throw new NullPointerException();\n" @@ -304,7 +310,7 @@ GenerateBuilderMembers(io::Printer* printer) const { // Field.Builder setField(Field.Builder builderForValue) WriteFieldDocComment(printer, descriptor_); PrintNestedBuilderFunction(printer, - "$deprecation$public Builder set$capitalized_name$(\n" + "$deprecation$public Builder ${$set$capitalized_name$$}$(\n" " $type$.Builder builderForValue)", "$name$_ = builderForValue.build();\n" @@ -318,7 +324,7 @@ GenerateBuilderMembers(io::Printer* printer) const { // Field.Builder mergeField(Field value) WriteFieldDocComment(printer, descriptor_); PrintNestedBuilderFunction(printer, - "$deprecation$public Builder merge$capitalized_name$($type$ value)", + "$deprecation$public Builder ${$merge$capitalized_name$$}$($type$ value)", support_field_presence ? "if ($get_has_field_bit_builder$ &&\n" @@ -346,7 +352,7 @@ GenerateBuilderMembers(io::Printer* printer) const { // Field.Builder clearField() WriteFieldDocComment(printer, descriptor_); PrintNestedBuilderFunction(printer, - "$deprecation$public Builder clear$capitalized_name$()", + "$deprecation$public Builder ${$clear$capitalized_name$$}$()", "$name$_ = null;\n" "$on_changed$\n", @@ -361,14 +367,17 @@ GenerateBuilderMembers(io::Printer* printer) const { WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public $type$.Builder get$capitalized_name$Builder() {\n" + "$deprecation$public $type$.Builder " + "${$get$capitalized_name$Builder$}$() {\n" " $set_has_field_bit_builder$\n" " $on_changed$\n" " return get$capitalized_name$FieldBuilder().getBuilder();\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public $type$OrBuilder get$capitalized_name$OrBuilder() {\n" + "$deprecation$public $type$OrBuilder " + "${$get$capitalized_name$OrBuilder$}$() {\n" " if ($name$Builder_ != null) {\n" " return $name$Builder_.getMessageOrBuilder();\n" " } else {\n" @@ -376,6 +385,7 @@ GenerateBuilderMembers(io::Printer* printer) const { " $type$.getDefaultInstance() : $name$_;\n" " }\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "private com.google.protobuf.SingleFieldBuilder$ver$<\n" @@ -530,30 +540,32 @@ ImmutableMessageOneofFieldGenerator:: void ImmutableMessageOneofFieldGenerator:: GenerateMembers(io::Printer* printer) const { PrintExtraFieldInfo(variables_, printer); - if (SupportFieldPresence(descriptor_->file())) { - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public boolean has$capitalized_name$() {\n" - " return $has_oneof_case_message$;\n" - "}\n"); - } WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public $type$ get$capitalized_name$() {\n" + "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" + " return $has_oneof_case_message$;\n" + "}\n"); + printer->Annotate("{", "}", descriptor_); + WriteFieldDocComment(printer, descriptor_); + printer->Print(variables_, + "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n" " if ($has_oneof_case_message$) {\n" " return ($type$) $oneof_name$_;\n" " }\n" " return $type$.getDefaultInstance();\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public $type$OrBuilder get$capitalized_name$OrBuilder() {\n" + "$deprecation$public $type$OrBuilder " + "${$get$capitalized_name$OrBuilder$}$() {\n" " if ($has_oneof_case_message$) {\n" " return ($type$) $oneof_name$_;\n" " }\n" " return $type$.getDefaultInstance();\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } void ImmutableMessageOneofFieldGenerator:: @@ -571,19 +583,18 @@ GenerateBuilderMembers(io::Printer* printer) const { // The comments above the methods below are based on a hypothetical // field of type "Field" called "Field". - if (SupportFieldPresence(descriptor_->file())) { - // boolean hasField() - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public boolean has$capitalized_name$() {\n" - " return $has_oneof_case_message$;\n" - "}\n"); - } + // boolean hasField() + WriteFieldDocComment(printer, descriptor_); + printer->Print(variables_, + "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" + " return $has_oneof_case_message$;\n" + "}\n"); + printer->Annotate("{", "}", descriptor_); // Field getField() WriteFieldDocComment(printer, descriptor_); PrintNestedBuilderFunction(printer, - "$deprecation$public $type$ get$capitalized_name$()", + "$deprecation$public $type$ ${$get$capitalized_name$$}$()", "if ($has_oneof_case_message$) {\n" " return ($type$) $oneof_name$_;\n" @@ -600,7 +611,7 @@ GenerateBuilderMembers(io::Printer* printer) const { // Field.Builder setField(Field value) WriteFieldDocComment(printer, descriptor_); PrintNestedBuilderFunction(printer, - "$deprecation$public Builder set$capitalized_name$($type$ value)", + "$deprecation$public Builder ${$set$capitalized_name$$}$($type$ value)", "if (value == null) {\n" " throw new NullPointerException();\n" @@ -616,7 +627,7 @@ GenerateBuilderMembers(io::Printer* printer) const { // Field.Builder setField(Field.Builder builderForValue) WriteFieldDocComment(printer, descriptor_); PrintNestedBuilderFunction(printer, - "$deprecation$public Builder set$capitalized_name$(\n" + "$deprecation$public Builder ${$set$capitalized_name$$}$(\n" " $type$.Builder builderForValue)", "$oneof_name$_ = builderForValue.build();\n" @@ -630,7 +641,7 @@ GenerateBuilderMembers(io::Printer* printer) const { // Field.Builder mergeField(Field value) WriteFieldDocComment(printer, descriptor_); PrintNestedBuilderFunction(printer, - "$deprecation$public Builder merge$capitalized_name$($type$ value)", + "$deprecation$public Builder ${$merge$capitalized_name$$}$($type$ value)", "if ($has_oneof_case_message$ &&\n" " $oneof_name$_ != $type$.getDefaultInstance()) {\n" @@ -652,7 +663,7 @@ GenerateBuilderMembers(io::Printer* printer) const { // Field.Builder clearField() WriteFieldDocComment(printer, descriptor_); PrintNestedBuilderFunction(printer, - "$deprecation$public Builder clear$capitalized_name$()", + "$deprecation$public Builder ${$clear$capitalized_name$$}$()", "if ($has_oneof_case_message$) {\n" " $clear_oneof_case_message$;\n" @@ -670,12 +681,15 @@ GenerateBuilderMembers(io::Printer* printer) const { WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public $type$.Builder get$capitalized_name$Builder() {\n" + "$deprecation$public $type$.Builder " + "${$get$capitalized_name$Builder$}$() {\n" " return get$capitalized_name$FieldBuilder().getBuilder();\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public $type$OrBuilder get$capitalized_name$OrBuilder() {\n" + "$deprecation$public $type$OrBuilder " + "${$get$capitalized_name$OrBuilder$}$() {\n" " if (($has_oneof_case_message$) && ($name$Builder_ != null)) {\n" " return $name$Builder_.getMessageOrBuilder();\n" " } else {\n" @@ -685,11 +699,12 @@ GenerateBuilderMembers(io::Printer* printer) const { " return $type$.getDefaultInstance();\n" " }\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "private com.google.protobuf.SingleFieldBuilder$ver$<\n" " $type$, $type$.Builder, $type$OrBuilder> \n" - " get$capitalized_name$FieldBuilder() {\n" + " ${$get$capitalized_name$FieldBuilder$}$() {\n" " if ($name$Builder_ == null) {\n" " if (!($has_oneof_case_message$)) {\n" " $oneof_name$_ = $type$.getDefaultInstance();\n" @@ -705,6 +720,7 @@ GenerateBuilderMembers(io::Printer* printer) const { " $on_changed$;\n" " return $name$Builder_;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } void ImmutableMessageOneofFieldGenerator:: @@ -833,31 +849,38 @@ GenerateMembers(io::Printer* printer) const { PrintExtraFieldInfo(variables_, printer); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public java.util.List<$type$> get$capitalized_name$List() {\n" + "$deprecation$public java.util.List<$type$> " + "${$get$capitalized_name$List$}$() {\n" " return $name$_;\n" // note: unmodifiable list "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "$deprecation$public java.util.List<? extends $type$OrBuilder> \n" - " get$capitalized_name$OrBuilderList() {\n" + " ${$get$capitalized_name$OrBuilderList$}$() {\n" " return $name$_;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public int get$capitalized_name$Count() {\n" + "$deprecation$public int ${$get$capitalized_name$Count$}$() {\n" " return $name$_.size();\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public $type$ get$capitalized_name$(int index) {\n" + "$deprecation$public $type$ ${$get$capitalized_name$$}$(int index) {\n" " return $name$_.get(index);\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public $type$OrBuilder get$capitalized_name$OrBuilder(\n" + "$deprecation$public $type$OrBuilder " + "${$get$capitalized_name$OrBuilder$}$(\n" " int index) {\n" " return $name$_.get(index);\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } @@ -883,6 +906,7 @@ void RepeatedImmutableMessageFieldGenerator::PrintNestedBuilderFunction( const char* nested_builder_case, const char* trailing_code) const { printer->Print(variables_, method_prototype); + printer->Annotate("{", "}", descriptor_); printer->Print(" {\n"); printer->Indent(); PrintNestedBuilderCondition(printer, regular_case, nested_builder_case); @@ -934,7 +958,8 @@ GenerateBuilderMembers(io::Printer* printer) const { // List<Field> getRepeatedFieldList() WriteFieldDocComment(printer, descriptor_); PrintNestedBuilderFunction(printer, - "$deprecation$public java.util.List<$type$> get$capitalized_name$List()", + "$deprecation$public java.util.List<$type$> " + "${$get$capitalized_name$List$}$()", "return java.util.Collections.unmodifiableList($name$_);\n", "return $name$Builder_.getMessageList();\n", @@ -944,7 +969,7 @@ GenerateBuilderMembers(io::Printer* printer) const { // int getRepeatedFieldCount() WriteFieldDocComment(printer, descriptor_); PrintNestedBuilderFunction(printer, - "$deprecation$public int get$capitalized_name$Count()", + "$deprecation$public int ${$get$capitalized_name$Count$}$()", "return $name$_.size();\n", "return $name$Builder_.getCount();\n", @@ -954,7 +979,7 @@ GenerateBuilderMembers(io::Printer* printer) const { // Field getRepeatedField(int index) WriteFieldDocComment(printer, descriptor_); PrintNestedBuilderFunction(printer, - "$deprecation$public $type$ get$capitalized_name$(int index)", + "$deprecation$public $type$ ${$get$capitalized_name$$}$(int index)", "return $name$_.get(index);\n", @@ -965,7 +990,7 @@ GenerateBuilderMembers(io::Printer* printer) const { // Builder setRepeatedField(int index, Field value) WriteFieldDocComment(printer, descriptor_); PrintNestedBuilderFunction(printer, - "$deprecation$public Builder set$capitalized_name$(\n" + "$deprecation$public Builder ${$set$capitalized_name$$}$(\n" " int index, $type$ value)", "if (value == null) {\n" " throw new NullPointerException();\n" @@ -979,7 +1004,7 @@ GenerateBuilderMembers(io::Printer* printer) const { // Builder setRepeatedField(int index, Field.Builder builderForValue) WriteFieldDocComment(printer, descriptor_); PrintNestedBuilderFunction(printer, - "$deprecation$public Builder set$capitalized_name$(\n" + "$deprecation$public Builder ${$set$capitalized_name$$}$(\n" " int index, $type$.Builder builderForValue)", "ensure$capitalized_name$IsMutable();\n" @@ -993,7 +1018,7 @@ GenerateBuilderMembers(io::Printer* printer) const { // Builder addRepeatedField(Field value) WriteFieldDocComment(printer, descriptor_); PrintNestedBuilderFunction(printer, - "$deprecation$public Builder add$capitalized_name$($type$ value)", + "$deprecation$public Builder ${$add$capitalized_name$$}$($type$ value)", "if (value == null) {\n" " throw new NullPointerException();\n" @@ -1010,7 +1035,7 @@ GenerateBuilderMembers(io::Printer* printer) const { // Builder addRepeatedField(int index, Field value) WriteFieldDocComment(printer, descriptor_); PrintNestedBuilderFunction(printer, - "$deprecation$public Builder add$capitalized_name$(\n" + "$deprecation$public Builder ${$add$capitalized_name$$}$(\n" " int index, $type$ value)", "if (value == null) {\n" @@ -1027,7 +1052,7 @@ GenerateBuilderMembers(io::Printer* printer) const { // Builder addRepeatedField(Field.Builder builderForValue) WriteFieldDocComment(printer, descriptor_); PrintNestedBuilderFunction(printer, - "$deprecation$public Builder add$capitalized_name$(\n" + "$deprecation$public Builder ${$add$capitalized_name$$}$(\n" " $type$.Builder builderForValue)", "ensure$capitalized_name$IsMutable();\n" @@ -1041,7 +1066,7 @@ GenerateBuilderMembers(io::Printer* printer) const { // Builder addRepeatedField(int index, Field.Builder builderForValue) WriteFieldDocComment(printer, descriptor_); PrintNestedBuilderFunction(printer, - "$deprecation$public Builder add$capitalized_name$(\n" + "$deprecation$public Builder ${$add$capitalized_name$$}$(\n" " int index, $type$.Builder builderForValue)", "ensure$capitalized_name$IsMutable();\n" @@ -1055,7 +1080,7 @@ GenerateBuilderMembers(io::Printer* printer) const { // Builder addAllRepeatedField(Iterable<Field> values) WriteFieldDocComment(printer, descriptor_); PrintNestedBuilderFunction(printer, - "$deprecation$public Builder addAll$capitalized_name$(\n" + "$deprecation$public Builder ${$addAll$capitalized_name$$}$(\n" " java.lang.Iterable<? extends $type$> values)", "ensure$capitalized_name$IsMutable();\n" @@ -1070,7 +1095,7 @@ GenerateBuilderMembers(io::Printer* printer) const { // Builder clearAllRepeatedField() WriteFieldDocComment(printer, descriptor_); PrintNestedBuilderFunction(printer, - "$deprecation$public Builder clear$capitalized_name$()", + "$deprecation$public Builder ${$clear$capitalized_name$$}$()", "$name$_ = java.util.Collections.emptyList();\n" "$clear_mutable_bit_builder$;\n" @@ -1083,7 +1108,7 @@ GenerateBuilderMembers(io::Printer* printer) const { // Builder removeRepeatedField(int index) WriteFieldDocComment(printer, descriptor_); PrintNestedBuilderFunction(printer, - "$deprecation$public Builder remove$capitalized_name$(int index)", + "$deprecation$public Builder ${$remove$capitalized_name$$}$(int index)", "ensure$capitalized_name$IsMutable();\n" "$name$_.remove(index);\n" @@ -1095,14 +1120,16 @@ GenerateBuilderMembers(io::Printer* printer) const { WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public $type$.Builder get$capitalized_name$Builder(\n" + "$deprecation$public $type$.Builder ${$get$capitalized_name$Builder$}$(\n" " int index) {\n" " return get$capitalized_name$FieldBuilder().getBuilder(index);\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public $type$OrBuilder get$capitalized_name$OrBuilder(\n" + "$deprecation$public $type$OrBuilder " + "${$get$capitalized_name$OrBuilder$}$(\n" " int index) {\n" " if ($name$Builder_ == null) {\n" " return $name$_.get(index);" @@ -1110,35 +1137,40 @@ GenerateBuilderMembers(io::Printer* printer) const { " return $name$Builder_.getMessageOrBuilder(index);\n" " }\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "$deprecation$public java.util.List<? extends $type$OrBuilder> \n" - " get$capitalized_name$OrBuilderList() {\n" + " ${$get$capitalized_name$OrBuilderList$}$() {\n" " if ($name$Builder_ != null) {\n" " return $name$Builder_.getMessageOrBuilderList();\n" " } else {\n" " return java.util.Collections.unmodifiableList($name$_);\n" " }\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public $type$.Builder add$capitalized_name$Builder() {\n" + "$deprecation$public $type$.Builder " + "${$add$capitalized_name$Builder$}$() {\n" " return get$capitalized_name$FieldBuilder().addBuilder(\n" " $type$.getDefaultInstance());\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public $type$.Builder add$capitalized_name$Builder(\n" + "$deprecation$public $type$.Builder ${$add$capitalized_name$Builder$}$(\n" " int index) {\n" " return get$capitalized_name$FieldBuilder().addBuilder(\n" " index, $type$.getDefaultInstance());\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "$deprecation$public java.util.List<$type$.Builder> \n" - " get$capitalized_name$BuilderList() {\n" + " ${$get$capitalized_name$BuilderList$}$() {\n" " return get$capitalized_name$FieldBuilder().getBuilderList();\n" "}\n" "private com.google.protobuf.RepeatedFieldBuilder$ver$<\n" @@ -1155,6 +1187,7 @@ GenerateBuilderMembers(io::Printer* printer) const { " }\n" " return $name$Builder_;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } void RepeatedImmutableMessageFieldGenerator:: 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 c71e9101..df3e80d4 100644 --- a/src/google/protobuf/compiler/java/java_message_field_lite.cc +++ b/src/google/protobuf/compiler/java/java_message_field_lite.cc @@ -129,16 +129,9 @@ int ImmutableMessageFieldLiteGenerator::GetNumBitsForBuilder() const { void ImmutableMessageFieldLiteGenerator:: GenerateInterfaceMembers(io::Printer* printer) const { - // TODO(jonp): In the future, consider having a method specific to the - // interface so that builders can choose dynamically to either return a - // message or a nested builder, so that asking for the interface doesn't - // cause a message to ever be built. - if (SupportFieldPresence(descriptor_->file()) || - descriptor_->containing_oneof() == NULL) { - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$boolean has$capitalized_name$();\n"); - } + WriteFieldDocComment(printer, descriptor_); + printer->Print(variables_, + "$deprecation$boolean has$capitalized_name$();\n"); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "$deprecation$$type$ get$capitalized_name$();\n"); @@ -154,25 +147,29 @@ GenerateMembers(io::Printer* printer) const { if (SupportFieldPresence(descriptor_->file())) { WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public boolean has$capitalized_name$() {\n" + "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return $get_has_field_bit_message$;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public $type$ get$capitalized_name$() {\n" + "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n" " return $name$_ == null ? $type$.getDefaultInstance() : $name$_;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } else { WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public boolean has$capitalized_name$() {\n" + "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return $name$_ != null;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public $type$ get$capitalized_name$() {\n" + "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n" " return $name$_ == null ? $type$.getDefaultInstance() : $name$_;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } // Field.Builder setField(Field value) @@ -226,53 +223,60 @@ GenerateBuilderMembers(io::Printer* printer) const { // boolean hasField() WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public boolean has$capitalized_name$() {\n" + "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return instance.has$capitalized_name$();\n" "}\n"); + printer->Annotate("{", "}", descriptor_); // Field getField() WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public $type$ get$capitalized_name$() {\n" + "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n" " return instance.get$capitalized_name$();\n" "}\n"); + printer->Annotate("{", "}", descriptor_); // Field.Builder setField(Field value) WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder set$capitalized_name$($type$ value) {\n" + "$deprecation$public Builder ${$set$capitalized_name$$}$($type$ value) {\n" " copyOnWrite();\n" " instance.set$capitalized_name$(value);\n" " return this;\n" " }\n"); + printer->Annotate("{", "}", descriptor_); // Field.Builder setField(Field.Builder builderForValue) WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder set$capitalized_name$(\n" + "$deprecation$public Builder ${$set$capitalized_name$$}$(\n" " $type$.Builder builderForValue) {\n" " copyOnWrite();\n" " instance.set$capitalized_name$(builderForValue);\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); // Field.Builder mergeField(Field value) WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder merge$capitalized_name$($type$ value) {\n" + "$deprecation$public Builder " + "${$merge$capitalized_name$$}$($type$ value) {\n" " copyOnWrite();\n" " instance.merge$capitalized_name$(value);\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); // Field.Builder clearField() WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder clear$capitalized_name$() {" + "$deprecation$public Builder ${$clear$capitalized_name$$}$() {" " copyOnWrite();\n" " instance.clear$capitalized_name$();\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } void ImmutableMessageFieldLiteGenerator:: @@ -390,21 +394,21 @@ ImmutableMessageOneofFieldLiteGenerator:: void ImmutableMessageOneofFieldLiteGenerator:: GenerateMembers(io::Printer* printer) const { PrintExtraFieldInfo(variables_, printer); - if (SupportFieldPresence(descriptor_->file())) { - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public boolean has$capitalized_name$() {\n" - " return $has_oneof_case_message$;\n" - "}\n"); - } WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public $type$ get$capitalized_name$() {\n" + "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" + " return $has_oneof_case_message$;\n" + "}\n"); + printer->Annotate("{", "}", descriptor_); + WriteFieldDocComment(printer, descriptor_); + printer->Print(variables_, + "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n" " if ($has_oneof_case_message$) {\n" " return ($type$) $oneof_name$_;\n" " }\n" " return $type$.getDefaultInstance();\n" "}\n"); + printer->Annotate("{", "}", descriptor_); // Field.Builder setField(Field value) WriteFieldDocComment(printer, descriptor_); @@ -457,58 +461,63 @@ GenerateBuilderMembers(io::Printer* printer) const { // The comments above the methods below are based on a hypothetical // field of type "Field" called "Field". - if (SupportFieldPresence(descriptor_->file())) { - // boolean hasField() - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public boolean has$capitalized_name$() {\n" - " return instance.has$capitalized_name$();\n" - "}\n"); - } + // boolean hasField() + WriteFieldDocComment(printer, descriptor_); + printer->Print(variables_, + "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" + " return instance.has$capitalized_name$();\n" + "}\n"); + printer->Annotate("{", "}", descriptor_); // Field getField() WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public $type$ get$capitalized_name$() {\n" + "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n" " return instance.get$capitalized_name$();\n" "}\n"); + printer->Annotate("{", "}", descriptor_); // Field.Builder setField(Field value) WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder set$capitalized_name$($type$ value) {\n" + "$deprecation$public Builder ${$set$capitalized_name$$}$($type$ value) {\n" " copyOnWrite();\n" " instance.set$capitalized_name$(value);\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); // Field.Builder setField(Field.Builder builderForValue) WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder set$capitalized_name$(\n" + "$deprecation$public Builder ${$set$capitalized_name$$}$(\n" " $type$.Builder builderForValue) {\n" " copyOnWrite();\n" " instance.set$capitalized_name$(builderForValue);\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); // Field.Builder mergeField(Field value) WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder merge$capitalized_name$($type$ value) {\n" + "$deprecation$public Builder " + "${$merge$capitalized_name$$}$($type$ value) {\n" " copyOnWrite();\n" " instance.merge$capitalized_name$(value);\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); // Field.Builder clearField() WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder clear$capitalized_name$() {\n" + "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n" " copyOnWrite();\n" " instance.clear$capitalized_name$();\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } void ImmutableMessageOneofFieldLiteGenerator:: @@ -615,31 +624,38 @@ GenerateMembers(io::Printer* printer) const { PrintExtraFieldInfo(variables_, printer); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public java.util.List<$type$> get$capitalized_name$List() {\n" + "$deprecation$public java.util.List<$type$> " + "${$get$capitalized_name$List$}$() {\n" " return $name$_;\n" // note: unmodifiable list "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "$deprecation$public java.util.List<? extends $type$OrBuilder> \n" - " get$capitalized_name$OrBuilderList() {\n" + " ${$get$capitalized_name$OrBuilderList$}$() {\n" " return $name$_;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public int get$capitalized_name$Count() {\n" + "$deprecation$public int ${$get$capitalized_name$Count$}$() {\n" " return $name$_.size();\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public $type$ get$capitalized_name$(int index) {\n" + "$deprecation$public $type$ ${$get$capitalized_name$$}$(int index) {\n" " return $name$_.get(index);\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public $type$OrBuilder get$capitalized_name$OrBuilder(\n" + "$deprecation$public $type$OrBuilder " + "${$get$capitalized_name$OrBuilder$}$(\n" " int index) {\n" " return $name$_.get(index);\n" "}\n"); + printer->Annotate("{", "}", descriptor_); printer->Print(variables_, "private void ensure$capitalized_name$IsMutable() {\n" @@ -745,110 +761,123 @@ GenerateBuilderMembers(io::Printer* printer) const { // List<Field> getRepeatedFieldList() WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public java.util.List<$type$> get$capitalized_name$List() {\n" + "$deprecation$public java.util.List<$type$> " + "${$get$capitalized_name$List$}$() {\n" " return java.util.Collections.unmodifiableList(\n" " instance.get$capitalized_name$List());\n" "}\n"); + printer->Annotate("{", "}", descriptor_); // int getRepeatedFieldCount() WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public int get$capitalized_name$Count() {\n" + "$deprecation$public int ${$get$capitalized_name$Count$}$() {\n" " return instance.get$capitalized_name$Count();\n" "}"); + printer->Annotate("{", "}", descriptor_); // Field getRepeatedField(int index) WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public $type$ get$capitalized_name$(int index) {\n" + "$deprecation$public $type$ ${$get$capitalized_name$$}$(int index) {\n" " return instance.get$capitalized_name$(index);\n" "}\n"); + printer->Annotate("{", "}", descriptor_); // Builder setRepeatedField(int index, Field value) WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder set$capitalized_name$(\n" + "$deprecation$public Builder ${$set$capitalized_name$$}$(\n" " int index, $type$ value) {\n" " copyOnWrite();\n" " instance.set$capitalized_name$(index, value);\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); // Builder setRepeatedField(int index, Field.Builder builderForValue) WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder set$capitalized_name$(\n" + "$deprecation$public Builder ${$set$capitalized_name$$}$(\n" " int index, $type$.Builder builderForValue) {\n" " copyOnWrite();\n" " instance.set$capitalized_name$(index, builderForValue);\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); // Builder addRepeatedField(Field value) WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder add$capitalized_name$($type$ value) {\n" + "$deprecation$public Builder ${$add$capitalized_name$$}$($type$ value) {\n" " copyOnWrite();\n" " instance.add$capitalized_name$(value);\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); // Builder addRepeatedField(int index, Field value) WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder add$capitalized_name$(\n" + "$deprecation$public Builder ${$add$capitalized_name$$}$(\n" " int index, $type$ value) {\n" " copyOnWrite();\n" " instance.add$capitalized_name$(index, value);\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); // Builder addRepeatedField(Field.Builder builderForValue) WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder add$capitalized_name$(\n" + "$deprecation$public Builder ${$add$capitalized_name$$}$(\n" " $type$.Builder builderForValue) {\n" " copyOnWrite();\n" " instance.add$capitalized_name$(builderForValue);\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); // Builder addRepeatedField(int index, Field.Builder builderForValue) WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder add$capitalized_name$(\n" + "$deprecation$public Builder ${$add$capitalized_name$$}$(\n" " int index, $type$.Builder builderForValue) {\n" " copyOnWrite();\n" " instance.add$capitalized_name$(index, builderForValue);\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); // Builder addAllRepeatedField(Iterable<Field> values) WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder addAll$capitalized_name$(\n" + "$deprecation$public Builder ${$addAll$capitalized_name$$}$(\n" " java.lang.Iterable<? extends $type$> values) {\n" " copyOnWrite();\n" " instance.addAll$capitalized_name$(values);\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); // Builder clearAllRepeatedField() WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder clear$capitalized_name$() {\n" + "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n" " copyOnWrite();\n" " instance.clear$capitalized_name$();\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); // Builder removeRepeatedField(int index) WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder remove$capitalized_name$(int index) {\n" + "$deprecation$public Builder ${$remove$capitalized_name$$}$(int index) {\n" " copyOnWrite();\n" " instance.remove$capitalized_name$(index);\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } void RepeatedImmutableMessageFieldLiteGenerator:: diff --git a/src/google/protobuf/compiler/java/java_message_lite.cc b/src/google/protobuf/compiler/java/java_message_lite.cc index 5007ecee..108504c7 100644 --- a/src/google/protobuf/compiler/java/java_message_lite.cc +++ b/src/google/protobuf/compiler/java/java_message_lite.cc @@ -56,8 +56,9 @@ #include <google/protobuf/io/printer.h> #include <google/protobuf/descriptor.pb.h> #include <google/protobuf/wire_format.h> -#include <google/protobuf/stubs/strutil.h> #include <google/protobuf/stubs/substitute.h> +#include <google/protobuf/stubs/strutil.h> + namespace google { namespace protobuf { @@ -68,6 +69,14 @@ using internal::WireFormat; using internal::WireFormatLite; namespace { +bool EnableExperimentalRuntimeForLite() { +#ifdef PROTOBUF_EXPERIMENT + return PROTOBUF_EXPERIMENT; +#else // PROTOBUF_EXPERIMENT + return false; +#endif // !PROTOBUF_EXPERIMENT +} + bool GenerateHasBits(const Descriptor* descriptor) { return SupportFieldPresence(descriptor->file()) || HasRepeatedFields(descriptor); @@ -124,7 +133,7 @@ void ImmutableMessageLiteGenerator::GenerateInterface(io::Printer* printer) { /* immutable = */ true, "OrBuilder"); if (descriptor_->extension_range_count() > 0) { printer->Print( - "$deprecation$public interface $classname$OrBuilder$idend$ extends \n" + "$deprecation$public interface ${$$classname$OrBuilder$}$ extends \n" " $extra_interfaces$\n" " com.google.protobuf.GeneratedMessageLite.\n" " ExtendableMessageOrBuilder<\n" @@ -133,19 +142,19 @@ void ImmutableMessageLiteGenerator::GenerateInterface(io::Printer* printer) { "@java.lang.Deprecated " : "", "extra_interfaces", ExtraMessageOrBuilderInterfaces(descriptor_), "classname", descriptor_->name(), - "idend", ""); + "{", "", "}", ""); } else { printer->Print( - "$deprecation$public interface $classname$OrBuilder$idend$ extends\n" + "$deprecation$public interface ${$$classname$OrBuilder$}$ extends\n" " $extra_interfaces$\n" " com.google.protobuf.MessageLiteOrBuilder {\n", "deprecation", descriptor_->options().deprecated() ? "@java.lang.Deprecated " : "", "extra_interfaces", ExtraMessageOrBuilderInterfaces(descriptor_), "classname", descriptor_->name(), - "idend", ""); + "{", "", "}", ""); } - printer->Annotate("classname", "idend", descriptor_); + printer->Annotate("{", "}", descriptor_); printer->Indent(); for (int i = 0; i < descriptor_->field_count(); i++) { @@ -331,41 +340,43 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) { printer->Print("\n"); } - GenerateMessageSerializationMethods(printer); + if (!EnableExperimentalRuntime(context_)) { + GenerateMessageSerializationMethods(printer); + } GenerateParseFromMethods(printer); GenerateBuilder(printer); if (HasRequiredFields(descriptor_)) { // Memoizes whether the protocol buffer is fully initialized (has all - // required fields). -1 means not yet computed. 0 means false and 1 means - // true. + // required fields). 0 means false, 1 means true, and all other values + // mean not yet computed. printer->Print( - "private byte memoizedIsInitialized = -1;\n"); + "private byte memoizedIsInitialized = 2;\n"); } printer->Print( - "@java.lang.SuppressWarnings({\"unchecked\", \"fallthrough\"})\n" - "protected final Object dynamicMethod(\n" - " com.google.protobuf.GeneratedMessageLite.MethodToInvoke method,\n" - " Object arg0, Object arg1) {\n" - " switch (method) {\n" - " case NEW_MUTABLE_INSTANCE: {\n" - " return new $classname$();\n" - " }\n", - "classname", name_resolver_->GetImmutableClassName(descriptor_)); + "@java.lang.SuppressWarnings({\"unchecked\", \"fallthrough\"})\n" + "protected final java.lang.Object dynamicMethod(\n" + " com.google.protobuf.GeneratedMessageLite.MethodToInvoke method,\n" + " java.lang.Object arg0, java.lang.Object arg1) {\n" + " switch (method) {\n" + " case NEW_MUTABLE_INSTANCE: {\n" + " return new $classname$();\n" + " }\n", + "classname", name_resolver_->GetImmutableClassName(descriptor_)); printer->Indent(); printer->Indent(); - printer->Print( - "case IS_INITIALIZED: {\n"); + printer->Print("case IS_INITIALIZED: {\n"); printer->Indent(); GenerateDynamicMethodIsInitialized(printer); printer->Outdent(); + printer->Print("}\n"); + printer->Print( - "}\n" "case MAKE_IMMUTABLE: {\n"); printer->Indent(); @@ -380,13 +391,15 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) { GenerateDynamicMethodNewBuilder(printer); printer->Outdent(); - printer->Print( - "}\n" - "case VISIT: {\n"); + if (!EnableExperimentalRuntimeForLite()) { + printer->Print( + "}\n" + "case VISIT: {\n"); - printer->Indent(); - GenerateDynamicMethodVisit(printer); - printer->Outdent(); + printer->Indent(); + GenerateDynamicMethodVisit(printer); + printer->Outdent(); + } printer->Print( "}\n" @@ -414,13 +427,33 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) { " }\n" " }\n" " }\n" - " return PARSER;\n" - "}\n", + " return PARSER;\n", "classname", name_resolver_->GetImmutableClassName(descriptor_)); printer->Outdent(); - printer->Outdent(); + if (HasRequiredFields(descriptor_)) { + printer->Print( + "}\n" + "case GET_MEMOIZED_IS_INITIALIZED: {\n" + " return memoizedIsInitialized;\n" + "}\n" + "case SET_MEMOIZED_IS_INITIALIZED: {\n" + " memoizedIsInitialized = (byte) (arg0 == null ? 0 : 1);\n" + " return null;\n" + "}\n"); + } else { + printer->Print( + "}\n" + "case GET_MEMOIZED_IS_INITIALIZED: {\n" + " return (byte) 1;\n" + "}\n" + "case SET_MEMOIZED_IS_INITIALIZED: {\n" + " return null;\n" + "}\n"); + } + + printer->Outdent(); printer->Print( " }\n" " throw new UnsupportedOperationException();\n" @@ -447,6 +480,17 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) { "}\n" "\n", "classname", descriptor_->name()); + if (EnableExperimentalRuntimeForLite()) { + // Register the default instance in a map. This map will be used by + // experimental runtime to lookup default instance given a class instance + // without using Java reflection. + printer->Print( + "static {\n" + " com.google.protobuf.GeneratedMessageLite.registerDefaultInstance(\n" + " $classname$.class, DEFAULT_INSTANCE);\n" + "}\n", + "classname", descriptor_->name()); + } printer->Print( "public static $classname$ getDefaultInstance() {\n" " return DEFAULT_INSTANCE;\n" @@ -454,6 +498,17 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) { "\n", "classname", name_resolver_->GetImmutableClassName(descriptor_)); + // 'of' method for Wrappers + if (IsWrappersProtoFile(descriptor_->file())) { + printer->Print( + "public static $classname$ of($field_type$ value) {\n" + " return newBuilder().setValue(value).build();\n" + "}\n" + "\n", + "classname", name_resolver_->GetImmutableClassName(descriptor_), + "field_type", PrimitiveTypeName(GetJavaType(descriptor_->field(0)))); + } + GenerateParser(printer); // Extensions must be declared after the DEFAULT_INSTANCE is initialized @@ -468,6 +523,7 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) { printer->Print("}\n\n"); } + // =================================================================== void ImmutableMessageLiteGenerator:: @@ -489,36 +545,34 @@ GenerateMessageSerializationMethods(io::Printer* printer) { if (HasPackedFields(descriptor_)) { // writeTo(CodedOutputStream output) might be invoked without // getSerializedSize() ever being called, but we need the memoized - // sizes in case this message has packed fields. Rather than emit checks for - // each packed field, just call getSerializedSize() up front. - // In most cases, getSerializedSize() will have already been called anyway - // by one of the wrapper writeTo() methods, making this call cheap. - printer->Print( - "getSerializedSize();\n"); + // sizes in case this message has packed fields. Rather than emit checks + // for each packed field, just call getSerializedSize() up front. In most + // cases, getSerializedSize() will have already been called anyway by one + // of the wrapper writeTo() methods, making this call cheap. + printer->Print("getSerializedSize();\n"); } if (descriptor_->extension_range_count() > 0) { if (descriptor_->options().message_set_wire_format()) { printer->Print( - "com.google.protobuf.GeneratedMessageLite\n" - " .ExtendableMessage<$classname$, $classname$.Builder>\n" - " .ExtensionWriter extensionWriter =\n" - " newMessageSetExtensionWriter();\n", - "classname", name_resolver_->GetImmutableClassName(descriptor_)); + "com.google.protobuf.GeneratedMessageLite\n" + " .ExtendableMessage<$classname$, $classname$.Builder>\n" + " .ExtensionWriter extensionWriter =\n" + " newMessageSetExtensionWriter();\n", + "classname", name_resolver_->GetImmutableClassName(descriptor_)); } else { printer->Print( - "com.google.protobuf.GeneratedMessageLite\n" - " .ExtendableMessage<$classname$, $classname$.Builder>\n" - " .ExtensionWriter extensionWriter =\n" - " newExtensionWriter();\n", - "classname", name_resolver_->GetImmutableClassName(descriptor_)); + "com.google.protobuf.GeneratedMessageLite\n" + " .ExtendableMessage<$classname$, $classname$.Builder>\n" + " .ExtensionWriter extensionWriter =\n" + " newExtensionWriter();\n", + "classname", name_resolver_->GetImmutableClassName(descriptor_)); } } // Merge the fields and the extension ranges, both sorted by field number. for (int i = 0, j = 0; - i < descriptor_->field_count() || j < sorted_extensions.size(); - ) { + i < descriptor_->field_count() || j < sorted_extensions.size();) { if (i == descriptor_->field_count()) { GenerateSerializeOneExtensionRange(printer, sorted_extensions[j++]); } else if (j == sorted_extensions.size()) { @@ -530,26 +584,23 @@ GenerateMessageSerializationMethods(io::Printer* printer) { } } - if (PreserveUnknownFields(descriptor_)) { - if (descriptor_->options().message_set_wire_format()) { - printer->Print( - "unknownFields.writeAsMessageSetTo(output);\n"); - } else { - printer->Print( - "unknownFields.writeTo(output);\n"); - } + if (descriptor_->options().message_set_wire_format()) { + printer->Print("unknownFields.writeAsMessageSetTo(output);\n"); + } else { + printer->Print("unknownFields.writeTo(output);\n"); } printer->Outdent(); printer->Print( - "}\n" - "\n" - "public int getSerializedSize() {\n" - " int size = memoizedSerializedSize;\n" - " if (size != -1) return size;\n" - "\n" - " size = 0;\n"); + "}\n" + "\n" + "public int getSerializedSize() {\n" + " int size = memoizedSerializedSize;\n" + " if (size != -1) return size;\n" + "\n"); printer->Indent(); + printer->Print( + "size = 0;\n"); for (int i = 0; i < descriptor_->field_count(); i++) { field_generators_.get(sorted_fields[i]).GenerateSerializedSizeCode(printer); @@ -557,28 +608,24 @@ GenerateMessageSerializationMethods(io::Printer* printer) { if (descriptor_->extension_range_count() > 0) { if (descriptor_->options().message_set_wire_format()) { - printer->Print( - "size += extensionsSerializedSizeAsMessageSet();\n"); + printer->Print("size += extensionsSerializedSizeAsMessageSet();\n"); } else { - printer->Print( - "size += extensionsSerializedSize();\n"); + printer->Print("size += extensionsSerializedSize();\n"); } } - if (PreserveUnknownFields(descriptor_)) { - if (descriptor_->options().message_set_wire_format()) { - printer->Print( - "size += unknownFields.getSerializedSizeAsMessageSet();\n"); - } else { - printer->Print( - "size += unknownFields.getSerializedSize();\n"); - } + if (descriptor_->options().message_set_wire_format()) { + printer->Print("size += unknownFields.getSerializedSizeAsMessageSet();\n"); + } else { + printer->Print("size += unknownFields.getSerializedSize();\n"); } + printer->Print( + "memoizedSerializedSize = size;\n" + "return size;\n"); + printer->Outdent(); printer->Print( - " memoizedSerializedSize = size;\n" - " return size;\n" "}\n" "\n"); } @@ -683,10 +730,10 @@ void ImmutableMessageLiteGenerator::GenerateSerializeOneExtensionRange( void ImmutableMessageLiteGenerator::GenerateBuilder(io::Printer* printer) { printer->Print( "public static Builder newBuilder() {\n" - " return DEFAULT_INSTANCE.toBuilder();\n" + " return (Builder) DEFAULT_INSTANCE.createBuilder();\n" "}\n" "public static Builder newBuilder($classname$ prototype) {\n" - " return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);\n" + " return (Builder) DEFAULT_INSTANCE.createBuilder(prototype);\n" "}\n" "\n", "classname", name_resolver_->GetImmutableClassName(descriptor_)); @@ -705,7 +752,10 @@ void ImmutableMessageLiteGenerator::GenerateDynamicMethodIsInitialized( return; } - // Don't directly compare to -1 to avoid an Android x86 JIT bug. + // TODO(xiaofeng): Remove this when b/64445758 is fixed. We don't need to + // check memoizedIsInitialized here because the caller does that already, + // but right now proguard proto shrinker asserts on the bytecode layout of + // this code so it can't be removed until proguard is updated. printer->Print( "byte isInitialized = memoizedIsInitialized;\n" "if (isInitialized == 1) return DEFAULT_INSTANCE;\n" @@ -723,9 +773,6 @@ void ImmutableMessageLiteGenerator::GenerateDynamicMethodIsInitialized( if (field->is_required()) { printer->Print( "if (!has$name$()) {\n" - " if (shouldMemoize) {\n" - " memoizedIsInitialized = 0;\n" - " }\n" " return null;\n" "}\n", "name", info->capitalized_name); @@ -742,9 +789,6 @@ void ImmutableMessageLiteGenerator::GenerateDynamicMethodIsInitialized( case FieldDescriptor::LABEL_REQUIRED: printer->Print( "if (!get$name$().isInitialized()) {\n" - " if (shouldMemoize) {\n" - " memoizedIsInitialized = 0;\n" - " }\n" " return null;\n" "}\n", "type", name_resolver_->GetImmutableClassName( @@ -768,9 +812,6 @@ void ImmutableMessageLiteGenerator::GenerateDynamicMethodIsInitialized( } printer->Print( " if (!get$name$().isInitialized()) {\n" - " if (shouldMemoize) {\n" - " memoizedIsInitialized = 0;\n" - " }\n" " return null;\n" " }\n" "}\n", @@ -781,9 +822,6 @@ void ImmutableMessageLiteGenerator::GenerateDynamicMethodIsInitialized( printer->Print( "for ($type$ item : get$name$Map().values()) {\n" " if (!item.isInitialized()) {\n" - " if (shouldMemoize) {\n" - " memoizedIsInitialized = 0;\n" - " }\n" " return null;\n" " }\n" "}\n", @@ -794,9 +832,6 @@ void ImmutableMessageLiteGenerator::GenerateDynamicMethodIsInitialized( printer->Print( "for (int i = 0; i < get$name$Count(); i++) {\n" " if (!get$name$(i).isInitialized()) {\n" - " if (shouldMemoize) {\n" - " memoizedIsInitialized = 0;\n" - " }\n" " return null;\n" " }\n" "}\n", @@ -812,17 +847,11 @@ void ImmutableMessageLiteGenerator::GenerateDynamicMethodIsInitialized( if (descriptor_->extension_range_count() > 0) { printer->Print( "if (!extensionsAreInitialized()) {\n" - " if (shouldMemoize) {\n" - " memoizedIsInitialized = 0;\n" - " }\n" " return null;\n" "}\n"); } printer->Print( - "if (shouldMemoize) memoizedIsInitialized = 1;\n"); - - printer->Print( "return DEFAULT_INSTANCE;\n" "\n"); } @@ -949,26 +978,70 @@ void ImmutableMessageLiteGenerator::GenerateDynamicMethodMergeFromStream( "com.google.protobuf.CodedInputStream input =\n" " (com.google.protobuf.CodedInputStream) arg0;\n" "com.google.protobuf.ExtensionRegistryLite extensionRegistry =\n" - " (com.google.protobuf.ExtensionRegistryLite) arg1;\n"); + " (com.google.protobuf.ExtensionRegistryLite) arg1;\n" + "if (extensionRegistry == null) {\n" + " throw new java.lang.NullPointerException();\n" + "}\n"); printer->Print( "try {\n"); printer->Indent(); - printer->Print( - "boolean done = false;\n" - "while (!done) {\n"); - printer->Indent(); + if (EnableExperimentalRuntime(context_)) { + printer->Print( + "mergeFromInternal(input, extensionRegistry);\n" + "return DEFAULT_INSTANCE;\n"); + } else { + printer->Print( + "boolean done = false;\n" + "while (!done) {\n"); + printer->Indent(); - printer->Print( - "int tag = input.readTag();\n" - "switch (tag) {\n"); - printer->Indent(); + printer->Print( + "int tag = input.readTag();\n" + "switch (tag) {\n"); + printer->Indent(); - printer->Print( - "case 0:\n" // zero signals EOF / limit reached - " done = true;\n" - " break;\n"); + printer->Print( + "case 0:\n" // zero signals EOF / limit reached + " done = true;\n" + " break;\n"); + + google::protobuf::scoped_array<const FieldDescriptor* > sorted_fields( + SortFieldsByNumber(descriptor_)); + for (int i = 0; i < descriptor_->field_count(); i++) { + const FieldDescriptor* field = sorted_fields[i]; + uint32 tag = WireFormatLite::MakeTag( + field->number(), WireFormat::WireTypeForFieldType(field->type())); + + printer->Print("case $tag$: {\n", "tag", + SimpleItoa(static_cast<int32>(tag))); + printer->Indent(); + + field_generators_.get(field).GenerateParsingCode(printer); + + printer->Outdent(); + printer->Print( + " break;\n" + "}\n"); + + if (field->is_packable()) { + // To make packed = true wire compatible, we generate parsing code from + // a packed version of this field regardless of + // field->options().packed(). + uint32 packed_tag = WireFormatLite::MakeTag( + field->number(), WireFormatLite::WIRETYPE_LENGTH_DELIMITED); + printer->Print("case $tag$: {\n", "tag", + SimpleItoa(static_cast<int32>(packed_tag))); + printer->Indent(); + + field_generators_.get(field).GenerateParsingCodeFromPacked(printer); + + printer->Outdent(); + printer->Print( + " break;\n" + "}\n"); + } + } - if (PreserveUnknownFields(descriptor_)) { if (descriptor_->extension_range_count() > 0) { if (descriptor_->options().message_set_wire_format()) { printer->Print( @@ -992,68 +1065,22 @@ void ImmutableMessageLiteGenerator::GenerateDynamicMethodMergeFromStream( } } else { printer->Print( - "default: {\n" - " if (!parseUnknownField(tag, input)) {\n" - " done = true;\n" // it's an endgroup tag - " }\n" - " break;\n" - "}\n"); + "default: {\n" + " if (!parseUnknownField(tag, input)) {\n" + " done = true;\n" // it's an endgroup tag + " }\n" + " break;\n" + "}\n"); } - } else { - printer->Print( - "default: {\n" - " if (!input.skipField(tag)) {\n" - " done = true;\n" // it's an endgroup tag - " }\n" - " break;\n" - "}\n"); - } - - google::protobuf::scoped_array<const FieldDescriptor * > sorted_fields( - SortFieldsByNumber(descriptor_)); - for (int i = 0; i < descriptor_->field_count(); i++) { - const FieldDescriptor* field = sorted_fields[i]; - uint32 tag = WireFormatLite::MakeTag(field->number(), - WireFormat::WireTypeForFieldType(field->type())); - - printer->Print( - "case $tag$: {\n", - "tag", SimpleItoa(static_cast<int32>(tag))); - printer->Indent(); - - field_generators_.get(field).GenerateParsingCode(printer); printer->Outdent(); + printer->Outdent(); printer->Print( - " break;\n" - "}\n"); - - if (field->is_packable()) { - // To make packed = true wire compatible, we generate parsing code from a - // packed version of this field regardless of field->options().packed(). - uint32 packed_tag = WireFormatLite::MakeTag(field->number(), - WireFormatLite::WIRETYPE_LENGTH_DELIMITED); - printer->Print( - "case $tag$: {\n", - "tag", SimpleItoa(static_cast<int32>(packed_tag))); - printer->Indent(); - - field_generators_.get(field).GenerateParsingCodeFromPacked(printer); - - printer->Outdent(); - printer->Print( - " break;\n" - "}\n"); - } + " }\n" // switch (tag) + "}\n"); // while (!done) } printer->Outdent(); - printer->Outdent(); - printer->Print( - " }\n" // switch (tag) - "}\n"); // while (!done) - - printer->Outdent(); printer->Print( "} catch (com.google.protobuf.InvalidProtocolBufferException e) {\n" " throw new RuntimeException(e.setUnfinishedMessage(this));\n" diff --git a/src/google/protobuf/compiler/java/java_name_resolver.cc b/src/google/protobuf/compiler/java/java_name_resolver.cc index bffe4f16..1673b4ee 100644 --- a/src/google/protobuf/compiler/java/java_name_resolver.cc +++ b/src/google/protobuf/compiler/java/java_name_resolver.cc @@ -33,6 +33,7 @@ #include <map> #include <string> + #include <google/protobuf/compiler/java/java_helpers.h> #include <google/protobuf/stubs/substitute.h> diff --git a/src/google/protobuf/compiler/java/java_options.h b/src/google/protobuf/compiler/java/java_options.h index 7bce1447..e4e7d5e2 100644 --- a/src/google/protobuf/compiler/java/java_options.h +++ b/src/google/protobuf/compiler/java/java_options.h @@ -59,10 +59,10 @@ struct Options { bool annotate_code; // Name of a file where we will write a list of generated .meta file names, // one per line. - string annotation_list_file; + std::string annotation_list_file; // Name of a file where we will write a list of generated file names, one // per line. - string output_list_file; + std::string output_list_file; }; } // namespace java diff --git a/src/google/protobuf/compiler/java/java_primitive_field.cc b/src/google/protobuf/compiler/java/java_primitive_field.cc index 840252e7..074a6be8 100644 --- a/src/google/protobuf/compiler/java/java_primitive_field.cc +++ b/src/google/protobuf/compiler/java/java_primitive_field.cc @@ -190,16 +190,18 @@ GenerateMembers(io::Printer* printer) const { if (SupportFieldPresence(descriptor_->file())) { WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public boolean has$capitalized_name$() {\n" + "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return $get_has_field_bit_message$;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public $type$ get$capitalized_name$() {\n" + "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n" " return $name$_;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } void ImmutablePrimitiveFieldGenerator:: @@ -210,31 +212,35 @@ GenerateBuilderMembers(io::Printer* printer) const { if (SupportFieldPresence(descriptor_->file())) { WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public boolean has$capitalized_name$() {\n" + "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return $get_has_field_bit_builder$;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public $type$ get$capitalized_name$() {\n" + "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n" " return $name$_;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder set$capitalized_name$($type$ value) {\n" + "$deprecation$public Builder ${$set$capitalized_name$$}$($type$ value) {\n" "$null_check$" " $set_has_field_bit_builder$\n" " $name$_ = value;\n" " $on_changed$\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder clear$capitalized_name$() {\n" + "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n" " $clear_has_field_bit_builder$\n"); + printer->Annotate("{", "}", descriptor_); JavaType type = GetJavaType(descriptor_); if (type == JAVATYPE_STRING || type == JAVATYPE_BYTES) { // The default value is not a simple literal so we want to avoid executing @@ -441,19 +447,21 @@ GenerateMembers(io::Printer* printer) const { if (SupportFieldPresence(descriptor_->file())) { WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public boolean has$capitalized_name$() {\n" + "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return $has_oneof_case_message$;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public $type$ get$capitalized_name$() {\n" + "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n" " if ($has_oneof_case_message$) {\n" " return ($boxed_type$) $oneof_name$_;\n" " }\n" " return $default$;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } @@ -462,33 +470,36 @@ GenerateBuilderMembers(io::Printer* printer) const { if (SupportFieldPresence(descriptor_->file())) { WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public boolean has$capitalized_name$() {\n" + "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return $has_oneof_case_message$;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public $type$ get$capitalized_name$() {\n" + "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n" " if ($has_oneof_case_message$) {\n" " return ($boxed_type$) $oneof_name$_;\n" " }\n" " return $default$;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder set$capitalized_name$($type$ value) {\n" + "$deprecation$public Builder ${$set$capitalized_name$$}$($type$ value) {\n" "$null_check$" " $set_oneof_case_message$;\n" " $oneof_name$_ = value;\n" " $on_changed$\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder clear$capitalized_name$() {\n" + "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n" " if ($has_oneof_case_message$) {\n" " $clear_oneof_case_message$;\n" " $oneof_name$_ = null;\n" @@ -496,6 +507,7 @@ GenerateBuilderMembers(io::Printer* printer) const { " }\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } void ImmutablePrimitiveOneofFieldGenerator:: @@ -604,19 +616,22 @@ GenerateMembers(io::Printer* printer) const { WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "$deprecation$public java.util.List<$boxed_type$>\n" - " get$capitalized_name$List() {\n" + " ${$get$capitalized_name$List$}$() {\n" " return $name$_;\n" // note: unmodifiable list "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public int get$capitalized_name$Count() {\n" + "$deprecation$public int ${$get$capitalized_name$Count$}$() {\n" " return $name$_.size();\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public $type$ get$capitalized_name$(int index) {\n" + "$deprecation$public $type$ ${$get$capitalized_name$$}$(int index) {\n" " return $name$_.get(index);\n" "}\n"); + printer->Annotate("{", "}", descriptor_); if (descriptor_->is_packed() && context_->HasGeneratedMethods(descriptor_->containing_type())) { @@ -654,22 +669,25 @@ GenerateBuilderMembers(io::Printer* printer) const { WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "$deprecation$public java.util.List<$boxed_type$>\n" - " get$capitalized_name$List() {\n" + " ${$get$capitalized_name$List$}$() {\n" " return java.util.Collections.unmodifiableList($name$_);\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public int get$capitalized_name$Count() {\n" + "$deprecation$public int ${$get$capitalized_name$Count$}$() {\n" " return $name$_.size();\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public $type$ get$capitalized_name$(int index) {\n" + "$deprecation$public $type$ ${$get$capitalized_name$$}$(int index) {\n" " return $name$_.get(index);\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder set$capitalized_name$(\n" + "$deprecation$public Builder ${$set$capitalized_name$$}$(\n" " int index, $type$ value) {\n" "$null_check$" " ensure$capitalized_name$IsMutable();\n" @@ -677,18 +695,20 @@ GenerateBuilderMembers(io::Printer* printer) const { " $on_changed$\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder add$capitalized_name$($type$ value) {\n" + "$deprecation$public Builder ${$add$capitalized_name$$}$($type$ value) {\n" "$null_check$" " ensure$capitalized_name$IsMutable();\n" " $name$_.add(value);\n" " $on_changed$\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder addAll$capitalized_name$(\n" + "$deprecation$public Builder ${$addAll$capitalized_name$$}$(\n" " java.lang.Iterable<? extends $boxed_type$> values) {\n" " ensure$capitalized_name$IsMutable();\n" " com.google.protobuf.AbstractMessageLite.Builder.addAll(\n" @@ -696,14 +716,16 @@ GenerateBuilderMembers(io::Printer* printer) const { " $on_changed$\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder clear$capitalized_name$() {\n" + "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n" " $name$_ = $empty_list$;\n" " $clear_mutable_bit_builder$;\n" " $on_changed$\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } void RepeatedImmutablePrimitiveFieldGenerator:: diff --git a/src/google/protobuf/compiler/java/java_primitive_field_lite.cc b/src/google/protobuf/compiler/java/java_primitive_field_lite.cc index 0e8e492f..f9293171 100644 --- a/src/google/protobuf/compiler/java/java_primitive_field_lite.cc +++ b/src/google/protobuf/compiler/java/java_primitive_field_lite.cc @@ -222,16 +222,18 @@ GenerateMembers(io::Printer* printer) const { if (SupportFieldPresence(descriptor_->file())) { WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public boolean has$capitalized_name$() {\n" + "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return $get_has_field_bit_message$;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public $type$ get$capitalized_name$() {\n" + "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n" " return $name$_;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, @@ -264,32 +266,36 @@ GenerateBuilderMembers(io::Printer* printer) const { if (SupportFieldPresence(descriptor_->file())) { WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public boolean has$capitalized_name$() {\n" + "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return instance.has$capitalized_name$();\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public $type$ get$capitalized_name$() {\n" + "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n" " return instance.get$capitalized_name$();\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder set$capitalized_name$($type$ value) {\n" + "$deprecation$public Builder ${$set$capitalized_name$$}$($type$ value) {\n" " copyOnWrite();\n" " instance.set$capitalized_name$(value);\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder clear$capitalized_name$() {\n" + "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n" " copyOnWrite();\n" " instance.clear$capitalized_name$();\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } void ImmutablePrimitiveFieldLiteGenerator:: @@ -482,19 +488,21 @@ GenerateMembers(io::Printer* printer) const { if (SupportFieldPresence(descriptor_->file())) { WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public boolean has$capitalized_name$() {\n" + "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return $has_oneof_case_message$;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public $type$ get$capitalized_name$() {\n" + "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n" " if ($has_oneof_case_message$) {\n" " return ($boxed_type$) $oneof_name$_;\n" " }\n" " return $default$;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, @@ -520,32 +528,36 @@ GenerateBuilderMembers(io::Printer* printer) const { if (SupportFieldPresence(descriptor_->file())) { WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public boolean has$capitalized_name$() {\n" + "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return instance.has$capitalized_name$();\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public $type$ get$capitalized_name$() {\n" + "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n" " return instance.get$capitalized_name$();\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder set$capitalized_name$($type$ value) {\n" + "$deprecation$public Builder ${$set$capitalized_name$$}$($type$ value) {\n" " copyOnWrite();\n" " instance.set$capitalized_name$(value);\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder clear$capitalized_name$() {\n" + "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n" " copyOnWrite();\n" " instance.clear$capitalized_name$();\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } void ImmutablePrimitiveOneofFieldLiteGenerator:: @@ -634,21 +646,24 @@ GenerateMembers(io::Printer* printer) const { WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "$deprecation$public java.util.List<$boxed_type$>\n" - " get$capitalized_name$List() {\n" + " ${$get$capitalized_name$List$}$() {\n" " return $name$_;\n" // note: unmodifiable list "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public int get$capitalized_name$Count() {\n" + "$deprecation$public int ${$get$capitalized_name$Count$}$() {\n" " return $name$_.size();\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public $type$ get$capitalized_name$(int index) {\n" + "$deprecation$public $type$ ${$get$capitalized_name$$}$(int index) {\n" " return $repeated_get$(index);\n" "}\n"); + printer->Annotate("{", "}", descriptor_); - if (descriptor_->options().packed() && + if (descriptor_->is_packed() && context_->HasGeneratedMethods(descriptor_->containing_type())) { printer->Print(variables_, "private int $name$MemoizedSerializedSize = -1;\n"); @@ -697,50 +712,57 @@ GenerateBuilderMembers(io::Printer* printer) const { WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "$deprecation$public java.util.List<$boxed_type$>\n" - " get$capitalized_name$List() {\n" + " ${$get$capitalized_name$List$}$() {\n" " return java.util.Collections.unmodifiableList(\n" " instance.get$capitalized_name$List());\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public int get$capitalized_name$Count() {\n" + "$deprecation$public int ${$get$capitalized_name$Count$}$() {\n" " return instance.get$capitalized_name$Count();\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public $type$ get$capitalized_name$(int index) {\n" + "$deprecation$public $type$ ${$get$capitalized_name$$}$(int index) {\n" " return instance.get$capitalized_name$(index);\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder set$capitalized_name$(\n" + "$deprecation$public Builder ${$set$capitalized_name$$}$(\n" " int index, $type$ value) {\n" " copyOnWrite();\n" " instance.set$capitalized_name$(index, value);\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder add$capitalized_name$($type$ value) {\n" + "$deprecation$public Builder ${$add$capitalized_name$$}$($type$ value) {\n" " copyOnWrite();\n" " instance.add$capitalized_name$(value);\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder addAll$capitalized_name$(\n" + "$deprecation$public Builder ${$addAll$capitalized_name$$}$(\n" " java.lang.Iterable<? extends $boxed_type$> values) {\n" " copyOnWrite();\n" " instance.addAll$capitalized_name$(values);\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder clear$capitalized_name$() {\n" + "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n" " copyOnWrite();\n" " instance.clear$capitalized_name$();\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } void RepeatedImmutablePrimitiveFieldLiteGenerator:: @@ -829,7 +851,7 @@ GenerateParsingDoneCode(io::Printer* printer) const { void RepeatedImmutablePrimitiveFieldLiteGenerator:: GenerateSerializationCode(io::Printer* printer) const { - if (descriptor_->options().packed()) { + if (descriptor_->is_packed()) { // We invoke getSerializedSize in writeTo for messages that have packed // fields in ImmutableMessageGenerator::GenerateMessageSerializationMethods. // That makes it safe to rely on the memoized size here. @@ -870,7 +892,7 @@ GenerateSerializedSizeCode(io::Printer* printer) const { printer->Print( "size += dataSize;\n"); - if (descriptor_->options().packed()) { + if (descriptor_->is_packed()) { printer->Print(variables_, "if (!get$capitalized_name$List().isEmpty()) {\n" " size += $tag_size$;\n" @@ -883,7 +905,7 @@ GenerateSerializedSizeCode(io::Printer* printer) const { } // cache the data size for packed fields. - if (descriptor_->options().packed()) { + if (descriptor_->is_packed()) { printer->Print(variables_, "$name$MemoizedSerializedSize = dataSize;\n"); } 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 7bd5ad7a..9a42aba9 100644 --- a/src/google/protobuf/compiler/java/java_shared_code_generator.cc +++ b/src/google/protobuf/compiler/java/java_shared_code_generator.cc @@ -140,13 +140,16 @@ void SharedCodeGenerator::GenerateDescriptors(io::Printer* printer) { "java.lang.String[] descriptorData = {\n"); printer->Indent(); - // Only write 40 bytes per line. + // Limit the number of bytes per line. static const int kBytesPerLine = 40; + // Limit the number of lines per string part. + static const int kLinesPerPart = 400; + // Every block of bytes, start a new string literal, in order to avoid the + // 64k length limit. Note that this value needs to be <64k. + static const int kBytesPerPart = kBytesPerLine * kLinesPerPart; for (int i = 0; i < file_data.size(); i += kBytesPerLine) { if (i > 0) { - // Every 400 lines, start a new string literal, in order to avoid the - // 64k length limit. - if (i % 400 == 0) { + if (i % kBytesPerPart == 0) { printer->Print(",\n"); } else { printer->Print(" +\n"); @@ -182,10 +185,16 @@ void SharedCodeGenerator::GenerateDescriptors(io::Printer* printer) { std::vector<std::pair<string, string> > dependencies; for (int i = 0; i < file_->dependency_count(); i++) { string filename = file_->dependency(i)->name(); - string classname = FileJavaPackage(file_->dependency(i)) + "." + - name_resolver_->GetDescriptorClassName( - file_->dependency(i)); - dependencies.push_back(std::make_pair(filename, classname)); + string package = FileJavaPackage(file_->dependency(i)); + string classname = name_resolver_->GetDescriptorClassName( + file_->dependency(i)); + string full_name; + if (package.empty()) { + full_name = classname; + } else { + full_name = package + "." + classname; + } + dependencies.push_back(std::make_pair(filename, full_name)); } // ----------------------------------------------------------------- diff --git a/src/google/protobuf/compiler/java/java_string_field.cc b/src/google/protobuf/compiler/java/java_string_field.cc index 5c2900ce..2b6e9381 100644 --- a/src/google/protobuf/compiler/java/java_string_field.cc +++ b/src/google/protobuf/compiler/java/java_string_field.cc @@ -217,14 +217,15 @@ GenerateMembers(io::Printer* printer) const { if (SupportFieldPresence(descriptor_->file())) { WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public boolean has$capitalized_name$() {\n" + "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return $get_has_field_bit_message$;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public java.lang.String get$capitalized_name$() {\n" + "$deprecation$public java.lang.String ${$get$capitalized_name$$}$() {\n" " java.lang.Object ref = $name$_;\n" " if (ref instanceof java.lang.String) {\n" " return (java.lang.String) ref;\n" @@ -232,6 +233,7 @@ GenerateMembers(io::Printer* printer) const { " com.google.protobuf.ByteString bs = \n" " (com.google.protobuf.ByteString) ref;\n" " java.lang.String s = bs.toStringUtf8();\n"); + printer->Annotate("{", "}", descriptor_); if (CheckUtf8(descriptor_)) { printer->Print(variables_, " $name$_ = s;\n"); @@ -248,7 +250,7 @@ GenerateMembers(io::Printer* printer) const { WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "$deprecation$public com.google.protobuf.ByteString\n" - " get$capitalized_name$Bytes() {\n" + " ${$get$capitalized_name$Bytes$}$() {\n" " java.lang.Object ref = $name$_;\n" " if (ref instanceof java.lang.String) {\n" " com.google.protobuf.ByteString b = \n" @@ -260,6 +262,7 @@ GenerateMembers(io::Printer* printer) const { " return (com.google.protobuf.ByteString) ref;\n" " }\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } void ImmutableStringFieldGenerator:: @@ -269,19 +272,21 @@ GenerateBuilderMembers(io::Printer* printer) const { if (SupportFieldPresence(descriptor_->file())) { WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public boolean has$capitalized_name$() {\n" + "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return $get_has_field_bit_builder$;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public java.lang.String get$capitalized_name$() {\n" + "$deprecation$public java.lang.String ${$get$capitalized_name$$}$() {\n" " java.lang.Object ref = $name$_;\n" " if (!(ref instanceof java.lang.String)) {\n" " com.google.protobuf.ByteString bs =\n" " (com.google.protobuf.ByteString) ref;\n" " java.lang.String s = bs.toStringUtf8();\n"); + printer->Annotate("{", "}", descriptor_); if (CheckUtf8(descriptor_)) { printer->Print(variables_, " $name$_ = s;\n"); @@ -301,7 +306,7 @@ GenerateBuilderMembers(io::Printer* printer) const { WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "$deprecation$public com.google.protobuf.ByteString\n" - " get$capitalized_name$Bytes() {\n" + " ${$get$capitalized_name$Bytes$}$() {\n" " java.lang.Object ref = $name$_;\n" " if (ref instanceof String) {\n" " com.google.protobuf.ByteString b = \n" @@ -313,10 +318,11 @@ GenerateBuilderMembers(io::Printer* printer) const { " return (com.google.protobuf.ByteString) ref;\n" " }\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder set$capitalized_name$(\n" + "$deprecation$public Builder ${$set$capitalized_name$$}$(\n" " java.lang.String value) {\n" "$null_check$" " $set_has_field_bit_builder$\n" @@ -324,10 +330,12 @@ GenerateBuilderMembers(io::Printer* printer) const { " $on_changed$\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder clear$capitalized_name$() {\n" + "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n" " $clear_has_field_bit_builder$\n"); + printer->Annotate("{", "}", descriptor_); // The default value is not a simple literal so we want to avoid executing // it multiple times. Instead, get the default out of the default instance. printer->Print(variables_, @@ -339,9 +347,10 @@ GenerateBuilderMembers(io::Printer* printer) const { WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder set$capitalized_name$Bytes(\n" + "$deprecation$public Builder ${$set$capitalized_name$Bytes$}$(\n" " com.google.protobuf.ByteString value) {\n" "$null_check$"); + printer->Annotate("{", "}", descriptor_); if (CheckUtf8(descriptor_)) { printer->Print(variables_, " checkByteStringIsUtf8(value);\n"); @@ -482,14 +491,15 @@ GenerateMembers(io::Printer* printer) const { if (SupportFieldPresence(descriptor_->file())) { WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public boolean has$capitalized_name$() {\n" + "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return $has_oneof_case_message$;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public java.lang.String get$capitalized_name$() {\n" + "$deprecation$public java.lang.String ${$get$capitalized_name$$}$() {\n" " java.lang.Object ref $default_init$;\n" " if ($has_oneof_case_message$) {\n" " ref = $oneof_name$_;\n" @@ -500,6 +510,7 @@ GenerateMembers(io::Printer* printer) const { " com.google.protobuf.ByteString bs = \n" " (com.google.protobuf.ByteString) ref;\n" " java.lang.String s = bs.toStringUtf8();\n"); + printer->Annotate("{", "}", descriptor_); if (CheckUtf8(descriptor_)) { printer->Print(variables_, " if ($has_oneof_case_message$) {\n" @@ -519,7 +530,7 @@ GenerateMembers(io::Printer* printer) const { printer->Print(variables_, "$deprecation$public com.google.protobuf.ByteString\n" - " get$capitalized_name$Bytes() {\n" + " ${$get$capitalized_name$Bytes$}$() {\n" " java.lang.Object ref $default_init$;\n" " if ($has_oneof_case_message$) {\n" " ref = $oneof_name$_;\n" @@ -536,6 +547,7 @@ GenerateMembers(io::Printer* printer) const { " return (com.google.protobuf.ByteString) ref;\n" " }\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } void ImmutableStringOneofFieldGenerator:: @@ -543,14 +555,15 @@ GenerateBuilderMembers(io::Printer* printer) const { if (SupportFieldPresence(descriptor_->file())) { WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public boolean has$capitalized_name$() {\n" + "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return $has_oneof_case_message$;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public java.lang.String get$capitalized_name$() {\n" + "$deprecation$public java.lang.String ${$get$capitalized_name$$}$() {\n" " java.lang.Object ref $default_init$;\n" " if ($has_oneof_case_message$) {\n" " ref = $oneof_name$_;\n" @@ -560,6 +573,7 @@ GenerateBuilderMembers(io::Printer* printer) const { " (com.google.protobuf.ByteString) ref;\n" " java.lang.String s = bs.toStringUtf8();\n" " if ($has_oneof_case_message$) {\n"); + printer->Annotate("{", "}", descriptor_); if (CheckUtf8(descriptor_)) { printer->Print(variables_, " $oneof_name$_ = s;\n"); @@ -580,7 +594,7 @@ GenerateBuilderMembers(io::Printer* printer) const { WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "$deprecation$public com.google.protobuf.ByteString\n" - " get$capitalized_name$Bytes() {\n" + " ${$get$capitalized_name$Bytes$}$() {\n" " java.lang.Object ref $default_init$;\n" " if ($has_oneof_case_message$) {\n" " ref = $oneof_name$_;\n" @@ -597,10 +611,11 @@ GenerateBuilderMembers(io::Printer* printer) const { " return (com.google.protobuf.ByteString) ref;\n" " }\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder set$capitalized_name$(\n" + "$deprecation$public Builder ${$set$capitalized_name$$}$(\n" " java.lang.String value) {\n" "$null_check$" " $set_oneof_case_message$;\n" @@ -608,9 +623,10 @@ GenerateBuilderMembers(io::Printer* printer) const { " $on_changed$\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder clear$capitalized_name$() {\n" + "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n" " if ($has_oneof_case_message$) {\n" " $clear_oneof_case_message$;\n" " $oneof_name$_ = null;\n" @@ -618,12 +634,14 @@ GenerateBuilderMembers(io::Printer* printer) const { " }\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder set$capitalized_name$Bytes(\n" + "$deprecation$public Builder ${$set$capitalized_name$Bytes$}$(\n" " com.google.protobuf.ByteString value) {\n" "$null_check$"); + printer->Annotate("{", "}", descriptor_); if (CheckUtf8(descriptor_)) { printer->Print(variables_, " checkByteStringIsUtf8(value);\n"); @@ -744,25 +762,30 @@ GenerateMembers(io::Printer* printer) const { WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "$deprecation$public com.google.protobuf.ProtocolStringList\n" - " get$capitalized_name$List() {\n" + " ${$get$capitalized_name$List$}$() {\n" " return $name$_;\n" // note: unmodifiable list "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public int get$capitalized_name$Count() {\n" + "$deprecation$public int ${$get$capitalized_name$Count$}$() {\n" " return $name$_.size();\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public java.lang.String get$capitalized_name$(int index) {\n" + "$deprecation$public java.lang.String " + "${$get$capitalized_name$$}$(int index) {\n" " return $name$_.get(index);\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "$deprecation$public com.google.protobuf.ByteString\n" - " get$capitalized_name$Bytes(int index) {\n" + " ${$get$capitalized_name$Bytes$}$(int index) {\n" " return $name$_.getByteString(index);\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } void RepeatedImmutableStringFieldGenerator:: @@ -794,28 +817,33 @@ GenerateBuilderMembers(io::Printer* printer) const { WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "$deprecation$public com.google.protobuf.ProtocolStringList\n" - " get$capitalized_name$List() {\n" + " ${$get$capitalized_name$List$}$() {\n" " return $name$_.getUnmodifiableView();\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public int get$capitalized_name$Count() {\n" + "$deprecation$public int ${$get$capitalized_name$Count$}$() {\n" " return $name$_.size();\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public java.lang.String get$capitalized_name$(int index) {\n" + "$deprecation$public java.lang.String " + "${$get$capitalized_name$$}$(int index) {\n" " return $name$_.get(index);\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "$deprecation$public com.google.protobuf.ByteString\n" - " get$capitalized_name$Bytes(int index) {\n" + " ${$get$capitalized_name$Bytes$}$(int index) {\n" " return $name$_.getByteString(index);\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder set$capitalized_name$(\n" + "$deprecation$public Builder ${$set$capitalized_name$$}$(\n" " int index, java.lang.String value) {\n" "$null_check$" " ensure$capitalized_name$IsMutable();\n" @@ -823,9 +851,10 @@ GenerateBuilderMembers(io::Printer* printer) const { " $on_changed$\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder add$capitalized_name$(\n" + "$deprecation$public Builder ${$add$capitalized_name$$}$(\n" " java.lang.String value) {\n" "$null_check$" " ensure$capitalized_name$IsMutable();\n" @@ -833,9 +862,10 @@ GenerateBuilderMembers(io::Printer* printer) const { " $on_changed$\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder addAll$capitalized_name$(\n" + "$deprecation$public Builder ${$addAll$capitalized_name$$}$(\n" " java.lang.Iterable<java.lang.String> values) {\n" " ensure$capitalized_name$IsMutable();\n" " com.google.protobuf.AbstractMessageLite.Builder.addAll(\n" @@ -843,20 +873,23 @@ GenerateBuilderMembers(io::Printer* printer) const { " $on_changed$\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder clear$capitalized_name$() {\n" + "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n" " $name$_ = $empty_list$;\n" " $clear_mutable_bit_builder$;\n" " $on_changed$\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder add$capitalized_name$Bytes(\n" + "$deprecation$public Builder ${$add$capitalized_name$Bytes$}$(\n" " com.google.protobuf.ByteString value) {\n" "$null_check$"); + printer->Annotate("{", "}", descriptor_); if (CheckUtf8(descriptor_)) { printer->Print(variables_, " checkByteStringIsUtf8(value);\n"); diff --git a/src/google/protobuf/compiler/java/java_string_field_lite.cc b/src/google/protobuf/compiler/java/java_string_field_lite.cc index 7e3ad1d0..adda307c 100644 --- a/src/google/protobuf/compiler/java/java_string_field_lite.cc +++ b/src/google/protobuf/compiler/java/java_string_field_lite.cc @@ -71,7 +71,7 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor, (*variables)["default"] = ImmutableDefaultValue(descriptor, name_resolver); (*variables)["default_init"] = "= " + ImmutableDefaultValue(descriptor, name_resolver); - (*variables)["capitalized_type"] = "String"; + (*variables)["capitalized_type"] = "java.lang.String"; (*variables)["tag"] = SimpleItoa(static_cast<int32>(WireFormat::MakeTag(descriptor))); (*variables)["tag_size"] = SimpleItoa( @@ -192,22 +192,25 @@ GenerateMembers(io::Printer* printer) const { if (SupportFieldPresence(descriptor_->file())) { WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public boolean has$capitalized_name$() {\n" + "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return $get_has_field_bit_message$;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public java.lang.String get$capitalized_name$() {\n" + "$deprecation$public java.lang.String ${$get$capitalized_name$$}$() {\n" " return $name$_;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "$deprecation$public com.google.protobuf.ByteString\n" - " get$capitalized_name$Bytes() {\n" + " ${$get$capitalized_name$Bytes$}$() {\n" " return com.google.protobuf.ByteString.copyFromUtf8($name$_);\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, @@ -246,48 +249,54 @@ GenerateBuilderMembers(io::Printer* printer) const { if (SupportFieldPresence(descriptor_->file())) { WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public boolean has$capitalized_name$() {\n" + "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return instance.has$capitalized_name$();\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public java.lang.String get$capitalized_name$() {\n" + "$deprecation$public java.lang.String ${$get$capitalized_name$$}$() {\n" " return instance.get$capitalized_name$();\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "$deprecation$public com.google.protobuf.ByteString\n" - " get$capitalized_name$Bytes() {\n" + " ${$get$capitalized_name$Bytes$}$() {\n" " return instance.get$capitalized_name$Bytes();\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder set$capitalized_name$(\n" + "$deprecation$public Builder ${$set$capitalized_name$$}$(\n" " java.lang.String value) {\n" " copyOnWrite();\n" " instance.set$capitalized_name$(value);\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder clear$capitalized_name$() {\n" + "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n" " copyOnWrite();\n" " instance.clear$capitalized_name$();\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder set$capitalized_name$Bytes(\n" + "$deprecation$public Builder ${$set$capitalized_name$Bytes$}$(\n" " com.google.protobuf.ByteString value) {\n" " copyOnWrite();\n" " instance.set$capitalized_name$Bytes(value);\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } void ImmutableStringFieldLiteGenerator:: @@ -324,7 +333,7 @@ void ImmutableStringFieldLiteGenerator:: GenerateParsingCode(io::Printer* printer) const { if (CheckUtf8(descriptor_)) { printer->Print(variables_, - "String s = input.readStringRequireUtf8();\n" + "java.lang.String s = input.readStringRequireUtf8();\n" "$set_has_field_bit_message$\n" "$name$_ = s;\n"); } else { @@ -333,7 +342,7 @@ GenerateParsingCode(io::Printer* printer) const { // spurious intermediary ByteString allocations, cutting overall allocations // in half. printer->Print(variables_, - "String s = input.readString();\n" + "java.lang.String s = input.readString();\n" "$set_has_field_bit_message$\n" "$name$_ = s;\n"); } @@ -410,54 +419,60 @@ GenerateMembers(io::Printer* printer) const { if (SupportFieldPresence(descriptor_->file())) { WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public boolean has$capitalized_name$() {\n" + "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return $has_oneof_case_message$;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public java.lang.String get$capitalized_name$() {\n" + "$deprecation$public java.lang.String ${$get$capitalized_name$$}$() {\n" " java.lang.String ref $default_init$;\n" " if ($has_oneof_case_message$) {\n" " ref = (java.lang.String) $oneof_name$_;\n" " }\n" " return ref;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "$deprecation$public com.google.protobuf.ByteString\n" - " get$capitalized_name$Bytes() {\n" + " ${$get$capitalized_name$Bytes$}$() {\n" " java.lang.String ref $default_init$;\n" " if ($has_oneof_case_message$) {\n" " ref = (java.lang.String) $oneof_name$_;\n" " }\n" " return com.google.protobuf.ByteString.copyFromUtf8(ref);\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "private void set$capitalized_name$(\n" + "private void ${$set$capitalized_name$$}$(\n" " java.lang.String value) {\n" "$null_check$" " $set_oneof_case_message$;\n" " $oneof_name$_ = value;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "private void clear$capitalized_name$() {\n" + "private void ${$clear$capitalized_name$$}$() {\n" " if ($has_oneof_case_message$) {\n" " $clear_oneof_case_message$;\n" " $oneof_name$_ = null;\n" " }\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "private void set$capitalized_name$Bytes(\n" + "private void ${$set$capitalized_name$Bytes$}$(\n" " com.google.protobuf.ByteString value) {\n" "$null_check$"); + printer->Annotate("{", "}", descriptor_); if (CheckUtf8(descriptor_)) { printer->Print(variables_, " checkByteStringIsUtf8(value);\n"); @@ -474,48 +489,54 @@ GenerateBuilderMembers(io::Printer* printer) const { if (SupportFieldPresence(descriptor_->file())) { WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public boolean has$capitalized_name$() {\n" + "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return instance.has$capitalized_name$();\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public java.lang.String get$capitalized_name$() {\n" + "$deprecation$public java.lang.String ${$get$capitalized_name$$}$() {\n" " return instance.get$capitalized_name$();\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "$deprecation$public com.google.protobuf.ByteString\n" - " get$capitalized_name$Bytes() {\n" + " ${$get$capitalized_name$Bytes$}$() {\n" " return instance.get$capitalized_name$Bytes();\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder set$capitalized_name$(\n" + "$deprecation$public Builder ${$set$capitalized_name$$}$(\n" " java.lang.String value) {\n" " copyOnWrite();\n" " instance.set$capitalized_name$(value);\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder clear$capitalized_name$() {\n" + "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n" " copyOnWrite();\n" " instance.clear$capitalized_name$();\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder set$capitalized_name$Bytes(\n" + "$deprecation$public Builder ${$set$capitalized_name$Bytes$}$(\n" " com.google.protobuf.ByteString value) {\n" " copyOnWrite();\n" " instance.set$capitalized_name$Bytes(value);\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } void ImmutableStringOneofFieldLiteGenerator:: @@ -529,7 +550,7 @@ void ImmutableStringOneofFieldLiteGenerator:: GenerateParsingCode(io::Printer* printer) const { if (CheckUtf8(descriptor_)) { printer->Print(variables_, - "String s = input.readStringRequireUtf8();\n" + "java.lang.String s = input.readStringRequireUtf8();\n" "$set_oneof_case_message$;\n" "$oneof_name$_ = s;\n"); } else { @@ -538,7 +559,7 @@ GenerateParsingCode(io::Printer* printer) const { // spurious intermediary ByteString allocations, cutting overall allocations // in half. printer->Print(variables_, - "String s = input.readString();\n" + "java.lang.String s = input.readString();\n" "$set_oneof_case_message$;\n" "$oneof_name$_ = s;\n"); } @@ -597,7 +618,7 @@ void RepeatedImmutableStringFieldLiteGenerator:: GenerateInterfaceMembers(io::Printer* printer) const { WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$java.util.List<String>\n" + "$deprecation$java.util.List<java.lang.String>\n" " get$capitalized_name$List();\n"); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, @@ -615,30 +636,37 @@ GenerateInterfaceMembers(io::Printer* printer) const { void RepeatedImmutableStringFieldLiteGenerator:: GenerateMembers(io::Printer* printer) const { printer->Print(variables_, - "private com.google.protobuf.Internal.ProtobufList<String> $name$_;\n"); + "private com.google.protobuf.Internal.ProtobufList<java.lang.String> " + "$name$_;\n"); PrintExtraFieldInfo(variables_, printer); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public java.util.List<String> get$capitalized_name$List() {\n" - " return $name$_;\n" // note: unmodifiable list + "$deprecation$public java.util.List<java.lang.String> " + "${$get$capitalized_name$List$}$() {\n" + " return $name$_;\n" // note: unmodifiable list "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public int get$capitalized_name$Count() {\n" + "$deprecation$public int ${$get$capitalized_name$Count$}$() {\n" " return $name$_.size();\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public java.lang.String get$capitalized_name$(int index) {\n" + "$deprecation$public java.lang.String " + "${$get$capitalized_name$$}$(int index) {\n" " return $name$_.get(index);\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "$deprecation$public com.google.protobuf.ByteString\n" - " get$capitalized_name$Bytes(int index) {\n" + " ${$get$capitalized_name$Bytes$}$(int index) {\n" " return com.google.protobuf.ByteString.copyFromUtf8(\n" " $name$_.get(index));\n" "}\n"); + printer->Annotate("{", "}", descriptor_); printer->Print(variables_, "private void ensure$capitalized_name$IsMutable() {\n" @@ -697,67 +725,77 @@ void RepeatedImmutableStringFieldLiteGenerator:: GenerateBuilderMembers(io::Printer* printer) const { WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public java.util.List<String>\n" - " get$capitalized_name$List() {\n" + "$deprecation$public java.util.List<java.lang.String>\n" + " ${$get$capitalized_name$List$}$() {\n" " return java.util.Collections.unmodifiableList(\n" " instance.get$capitalized_name$List());\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public int get$capitalized_name$Count() {\n" + "$deprecation$public int ${$get$capitalized_name$Count$}$() {\n" " return instance.get$capitalized_name$Count();\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public java.lang.String get$capitalized_name$(int index) {\n" + "$deprecation$public java.lang.String " + "${$get$capitalized_name$$}$(int index) {\n" " return instance.get$capitalized_name$(index);\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "$deprecation$public com.google.protobuf.ByteString\n" - " get$capitalized_name$Bytes(int index) {\n" + " ${$get$capitalized_name$Bytes$}$(int index) {\n" " return instance.get$capitalized_name$Bytes(index);\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder set$capitalized_name$(\n" + "$deprecation$public Builder ${$set$capitalized_name$$}$(\n" " int index, java.lang.String value) {\n" " copyOnWrite();\n" " instance.set$capitalized_name$(index, value);\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder add$capitalized_name$(\n" + "$deprecation$public Builder ${$add$capitalized_name$$}$(\n" " java.lang.String value) {\n" " copyOnWrite();\n" " instance.add$capitalized_name$(value);\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder addAll$capitalized_name$(\n" + "$deprecation$public Builder ${$addAll$capitalized_name$$}$(\n" " java.lang.Iterable<java.lang.String> values) {\n" " copyOnWrite();\n" " instance.addAll$capitalized_name$(values);\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder clear$capitalized_name$() {\n" + "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n" " copyOnWrite();\n" " instance.clear$capitalized_name$();\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$public Builder add$capitalized_name$Bytes(\n" + "$deprecation$public Builder ${$add$capitalized_name$Bytes$}$(\n" " com.google.protobuf.ByteString value) {\n" " copyOnWrite();\n" " instance.add$capitalized_name$Bytes(value);\n" " return this;\n" "}\n"); + printer->Annotate("{", "}", descriptor_); } void RepeatedImmutableStringFieldLiteGenerator:: @@ -787,14 +825,14 @@ void RepeatedImmutableStringFieldLiteGenerator:: GenerateParsingCode(io::Printer* printer) const { if (CheckUtf8(descriptor_)) { printer->Print(variables_, - "String s = input.readStringRequireUtf8();\n"); + "java.lang.String s = input.readStringRequireUtf8();\n"); } else { // Lite runtime should attempt to reduce allocations by attempting to // construct the string directly from the input stream buffer. This avoids // spurious intermediary ByteString allocations, cutting overall allocations // in half. printer->Print(variables_, - "String s = input.readString();\n"); + "java.lang.String s = input.readString();\n"); } printer->Print(variables_, "if (!$is_mutable$) {\n" @@ -868,7 +906,7 @@ GenerateHashCode(io::Printer* printer) const { } string RepeatedImmutableStringFieldLiteGenerator::GetBoxedType() const { - return "String"; + return "java.lang.String"; } } // namespace java diff --git a/src/google/protobuf/compiler/javanano/javanano_enum.h b/src/google/protobuf/compiler/javanano/javanano_enum.h index 10dd3648..82e098fc 100644 --- a/src/google/protobuf/compiler/javanano/javanano_enum.h +++ b/src/google/protobuf/compiler/javanano/javanano_enum.h @@ -68,13 +68,13 @@ class EnumGenerator { // considered equivalent. We treat the first defined constant for any // given numeric value as "canonical" and the rest as aliases of that // canonical value. - vector<const EnumValueDescriptor*> canonical_values_; + std::vector<const EnumValueDescriptor*> canonical_values_; struct Alias { const EnumValueDescriptor* value; const EnumValueDescriptor* canonical_value; }; - vector<Alias> aliases_; + std::vector<Alias> aliases_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumGenerator); }; diff --git a/src/google/protobuf/compiler/javanano/javanano_enum_field.cc b/src/google/protobuf/compiler/javanano/javanano_enum_field.cc index 7666db38..ea67a810 100644 --- a/src/google/protobuf/compiler/javanano/javanano_enum_field.cc +++ b/src/google/protobuf/compiler/javanano/javanano_enum_field.cc @@ -52,7 +52,7 @@ namespace { // TODO(kenton): Factor out a "SetCommonFieldVariables()" to get rid of // repeat code between this and the other field types. void SetEnumVariables(const Params& params, - const FieldDescriptor* descriptor, map<string, string>* variables) { + const FieldDescriptor* descriptor, std::map<string, string>* variables) { (*variables)["name"] = RenameJavaKeywords(UnderscoresToCamelCase(descriptor)); (*variables)["capitalized_name"] = @@ -83,7 +83,7 @@ void SetEnumVariables(const Params& params, } void LoadEnumValues(const Params& params, - const EnumDescriptor* enum_descriptor, vector<string>* canonical_values) { + const EnumDescriptor* enum_descriptor, std::vector<string>* canonical_values) { string enum_class_name = ClassName(params, enum_descriptor); for (int i = 0; i < enum_descriptor->value_count(); i++) { const EnumValueDescriptor* value = enum_descriptor->value(i); @@ -97,7 +97,7 @@ void LoadEnumValues(const Params& params, } void PrintCaseLabels( - io::Printer* printer, const vector<string>& canonical_values) { + io::Printer* printer, const std::vector<string>& canonical_values) { for (int i = 0; i < canonical_values.size(); i++) { printer->Print( " case $value$:\n", diff --git a/src/google/protobuf/compiler/javanano/javanano_enum_field.h b/src/google/protobuf/compiler/javanano/javanano_enum_field.h index b94790d6..8cd0e248 100644 --- a/src/google/protobuf/compiler/javanano/javanano_enum_field.h +++ b/src/google/protobuf/compiler/javanano/javanano_enum_field.h @@ -62,8 +62,8 @@ class EnumFieldGenerator : public FieldGenerator { private: const FieldDescriptor* descriptor_; - map<string, string> variables_; - vector<string> canonical_values_; + std::map<string, string> variables_; + std::vector<string> canonical_values_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumFieldGenerator); }; @@ -85,8 +85,8 @@ class AccessorEnumFieldGenerator : public FieldGenerator { private: const FieldDescriptor* descriptor_; - map<string, string> variables_; - vector<string> canonical_values_; + std::map<string, string> variables_; + std::vector<string> canonical_values_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(AccessorEnumFieldGenerator); }; @@ -112,8 +112,8 @@ class RepeatedEnumFieldGenerator : public FieldGenerator { void GenerateRepeatedDataSizeCode(io::Printer* printer) const; const FieldDescriptor* descriptor_; - map<string, string> variables_; - vector<string> canonical_values_; + std::map<string, string> variables_; + std::vector<string> canonical_values_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedEnumFieldGenerator); }; diff --git a/src/google/protobuf/compiler/javanano/javanano_extension.cc b/src/google/protobuf/compiler/javanano/javanano_extension.cc index 0b9d1d8d..4c61f915 100644 --- a/src/google/protobuf/compiler/javanano/javanano_extension.cc +++ b/src/google/protobuf/compiler/javanano/javanano_extension.cc @@ -78,7 +78,7 @@ const char* GetTypeConstantName(const FieldDescriptor::Type type) { } // namespace void SetVariables(const FieldDescriptor* descriptor, const Params params, - map<string, string>* variables) { + std::map<string, string>* variables) { (*variables)["extends"] = ClassName(params, descriptor->containing_type()); (*variables)["name"] = RenameJavaKeywords(UnderscoresToCamelCase(descriptor)); bool repeated = descriptor->is_repeated(); diff --git a/src/google/protobuf/compiler/javanano/javanano_extension.h b/src/google/protobuf/compiler/javanano/javanano_extension.h index 4843e296..f4e9eb2d 100644 --- a/src/google/protobuf/compiler/javanano/javanano_extension.h +++ b/src/google/protobuf/compiler/javanano/javanano_extension.h @@ -61,7 +61,7 @@ class ExtensionGenerator { private: const Params& params_; const FieldDescriptor* descriptor_; - map<string, string> variables_; + std::map<string, string> variables_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ExtensionGenerator); }; diff --git a/src/google/protobuf/compiler/javanano/javanano_field.cc b/src/google/protobuf/compiler/javanano/javanano_field.cc index 85257f3f..e31d1177 100644 --- a/src/google/protobuf/compiler/javanano/javanano_field.cc +++ b/src/google/protobuf/compiler/javanano/javanano_field.cc @@ -151,7 +151,7 @@ const FieldGenerator& FieldGeneratorMap::get( } void SetCommonOneofVariables(const FieldDescriptor* descriptor, - map<string, string>* variables) { + std::map<string, string>* variables) { (*variables)["oneof_name"] = UnderscoresToCamelCase(descriptor->containing_oneof()); (*variables)["oneof_capitalized_name"] = @@ -169,7 +169,7 @@ void SetCommonOneofVariables(const FieldDescriptor* descriptor, } void GenerateOneofFieldEquals(const FieldDescriptor* descriptor, - const map<string, string>& variables, + const std::map<string, string>& variables, io::Printer* printer) { if (GetJavaType(descriptor) == JAVATYPE_BYTES) { printer->Print(variables, @@ -190,7 +190,7 @@ void GenerateOneofFieldEquals(const FieldDescriptor* descriptor, } void GenerateOneofFieldHashCode(const FieldDescriptor* descriptor, - const map<string, string>& variables, + const std::map<string, string>& variables, io::Printer* printer) { if (GetJavaType(descriptor) == JAVATYPE_BYTES) { printer->Print(variables, diff --git a/src/google/protobuf/compiler/javanano/javanano_field.h b/src/google/protobuf/compiler/javanano/javanano_field.h index 57c221f4..347c888c 100644 --- a/src/google/protobuf/compiler/javanano/javanano_field.h +++ b/src/google/protobuf/compiler/javanano/javanano_field.h @@ -114,12 +114,12 @@ class FieldGeneratorMap { }; void SetCommonOneofVariables(const FieldDescriptor* descriptor, - map<string, string>* variables); + std::map<string, string>* variables); void GenerateOneofFieldEquals(const FieldDescriptor* descriptor, - const map<string, string>& variables, + const std::map<string, string>& variables, io::Printer* printer); void GenerateOneofFieldHashCode(const FieldDescriptor* descriptor, - const map<string, string>& variables, + const std::map<string, string>& variables, io::Printer* printer); } // namespace javanano diff --git a/src/google/protobuf/compiler/javanano/javanano_file.cc b/src/google/protobuf/compiler/javanano/javanano_file.cc index 17f7386e..7a661a42 100644 --- a/src/google/protobuf/compiler/javanano/javanano_file.cc +++ b/src/google/protobuf/compiler/javanano/javanano_file.cc @@ -59,7 +59,7 @@ bool UsesExtensions(const Message& message) { // We conservatively assume that unknown fields are extensions. if (reflection->GetUnknownFields(message).field_count() > 0) return true; - vector<const FieldDescriptor*> fields; + std::vector<const FieldDescriptor*> fields; reflection->ListFields(message, &fields); for (int i = 0; i < fields.size(); i++) { @@ -216,7 +216,7 @@ static void GenerateSibling(const string& package_dir, const string& java_package, const DescriptorClass* descriptor, GeneratorContext* output_directory, - vector<string>* file_list, + std::vector<string>* file_list, const Params& params) { string filename = package_dir + descriptor->name() + ".java"; file_list->push_back(filename); @@ -239,7 +239,7 @@ static void GenerateSibling(const string& package_dir, void FileGenerator::GenerateSiblings(const string& package_dir, GeneratorContext* output_directory, - vector<string>* file_list) { + std::vector<string>* file_list) { if (params_.java_multiple_files(file_->name())) { for (int i = 0; i < file_->message_type_count(); i++) { GenerateSibling<MessageGenerator>(package_dir, java_package_, diff --git a/src/google/protobuf/compiler/javanano/javanano_file.h b/src/google/protobuf/compiler/javanano/javanano_file.h index 217eafe2..4ad3868c 100644 --- a/src/google/protobuf/compiler/javanano/javanano_file.h +++ b/src/google/protobuf/compiler/javanano/javanano_file.h @@ -72,7 +72,7 @@ class FileGenerator { // service type). void GenerateSiblings(const string& package_dir, GeneratorContext* output_directory, - vector<string>* file_list); + std::vector<string>* file_list); const string& java_package() { return java_package_; } const string& classname() { return classname_; } diff --git a/src/google/protobuf/compiler/javanano/javanano_generator.cc b/src/google/protobuf/compiler/javanano/javanano_generator.cc index 7c3a0421..fd7151b1 100644 --- a/src/google/protobuf/compiler/javanano/javanano_generator.cc +++ b/src/google/protobuf/compiler/javanano/javanano_generator.cc @@ -94,7 +94,7 @@ bool JavaNanoGenerator::Generate(const FileDescriptor* file, const string& parameter, GeneratorContext* output_directory, string* error) const { - vector<pair<string, string> > options; + std::vector<std::pair<string, string> > options; ParseGeneratorParameter(parameter, &options); @@ -116,24 +116,24 @@ bool JavaNanoGenerator::Generate(const FileDescriptor* file, if (option_name == "output_list_file") { output_list_file = option_value; } else if (option_name == "java_package") { - vector<string> parts; - SplitStringUsing(option_value, "|", &parts); - if (parts.size() != 2) { - *error = "Bad java_package, expecting filename|PackageName found '" - + option_value + "'"; - return false; - } - params.set_java_package(parts[0], parts[1]); + std::vector<string> parts; + SplitStringUsing(option_value, "|", &parts); + if (parts.size() != 2) { + *error = "Bad java_package, expecting filename|PackageName found '" + + option_value + "'"; + return false; + } + params.set_java_package(parts[0], parts[1]); } else if (option_name == "java_outer_classname") { - vector<string> parts; - SplitStringUsing(option_value, "|", &parts); - if (parts.size() != 2) { - *error = "Bad java_outer_classname, " - "expecting filename|ClassName found '" - + option_value + "'"; - return false; - } - params.set_java_outer_classname(parts[0], parts[1]); + std::vector<string> parts; + SplitStringUsing(option_value, "|", &parts); + if (parts.size() != 2) { + *error = "Bad java_outer_classname, " + "expecting filename|ClassName found '" + + option_value + "'"; + return false; + } + params.set_java_outer_classname(parts[0], parts[1]); } else if (option_name == "store_unknown_fields") { params.set_store_unknown_fields(option_value == "true"); } else if (option_name == "java_multiple_files") { @@ -191,7 +191,7 @@ bool JavaNanoGenerator::Generate(const FileDescriptor* file, StringReplace(file_generator.java_package(), ".", "/", true); if (!package_dir.empty()) package_dir += "/"; - vector<string> all_files; + std::vector<string> all_files; if (IsOuterClassNeeded(params, file)) { string java_filename = package_dir; diff --git a/src/google/protobuf/compiler/javanano/javanano_helpers.cc b/src/google/protobuf/compiler/javanano/javanano_helpers.cc index 5018250c..1927ba12 100644 --- a/src/google/protobuf/compiler/javanano/javanano_helpers.cc +++ b/src/google/protobuf/compiler/javanano/javanano_helpers.cc @@ -567,7 +567,7 @@ string GenerateDifferentBit(int bit_index) { } void SetBitOperationVariables(const string name, - int bitIndex, map<string, string>* variables) { + int bitIndex, std::map<string, string>* variables) { (*variables)["get_" + name] = GenerateGetBit(bitIndex); (*variables)["set_" + name] = GenerateSetBit(bitIndex); (*variables)["clear_" + name] = GenerateClearBit(bitIndex); diff --git a/src/google/protobuf/compiler/javanano/javanano_helpers.h b/src/google/protobuf/compiler/javanano/javanano_helpers.h index 014c85ae..04b2d633 100644 --- a/src/google/protobuf/compiler/javanano/javanano_helpers.h +++ b/src/google/protobuf/compiler/javanano/javanano_helpers.h @@ -181,7 +181,7 @@ string GenerateDifferentBit(int bit_index); // the given name of the bit, to the appropriate Java expressions for the given // bit index. void SetBitOperationVariables(const string name, - int bitIndex, map<string, string>* variables); + int bitIndex, std::map<string, string>* variables); inline bool IsMapEntry(const Descriptor* descriptor) { // TODO(liujisi): Add an option to turn on maps for proto2 syntax as well. diff --git a/src/google/protobuf/compiler/javanano/javanano_map_field.cc b/src/google/protobuf/compiler/javanano/javanano_map_field.cc index 83b2b0ce..a4ab8858 100644 --- a/src/google/protobuf/compiler/javanano/javanano_map_field.cc +++ b/src/google/protobuf/compiler/javanano/javanano_map_field.cc @@ -84,7 +84,7 @@ const FieldDescriptor* ValueField(const FieldDescriptor* descriptor) { } void SetMapVariables(const Params& params, - const FieldDescriptor* descriptor, map<string, string>* variables) { + const FieldDescriptor* descriptor, std::map<string, string>* variables) { const FieldDescriptor* key = KeyField(descriptor); const FieldDescriptor* value = ValueField(descriptor); (*variables)["name"] = diff --git a/src/google/protobuf/compiler/javanano/javanano_map_field.h b/src/google/protobuf/compiler/javanano/javanano_map_field.h index c01bde38..81e5915d 100644 --- a/src/google/protobuf/compiler/javanano/javanano_map_field.h +++ b/src/google/protobuf/compiler/javanano/javanano_map_field.h @@ -58,7 +58,7 @@ class MapFieldGenerator : public FieldGenerator { private: const FieldDescriptor* descriptor_; - map<string, string> variables_; + std::map<string, string> variables_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MapFieldGenerator); }; diff --git a/src/google/protobuf/compiler/javanano/javanano_message.cc b/src/google/protobuf/compiler/javanano/javanano_message.cc index f81f7f9a..78421887 100644 --- a/src/google/protobuf/compiler/javanano/javanano_message.cc +++ b/src/google/protobuf/compiler/javanano/javanano_message.cc @@ -182,7 +182,7 @@ void MessageGenerator::Generate(io::Printer* printer) { } // oneof - map<string, string> vars; + std::map<string, string> vars; vars["message_name"] = descriptor_->name(); for (int i = 0; i < descriptor_->oneof_decl_count(); i++) { const OneofDescriptor* oneof_desc = descriptor_->oneof_decl(i); diff --git a/src/google/protobuf/compiler/javanano/javanano_message_field.cc b/src/google/protobuf/compiler/javanano/javanano_message_field.cc index d1d04b52..2ed8a3aa 100644 --- a/src/google/protobuf/compiler/javanano/javanano_message_field.cc +++ b/src/google/protobuf/compiler/javanano/javanano_message_field.cc @@ -54,7 +54,7 @@ namespace { // TODO(kenton): Factor out a "SetCommonFieldVariables()" to get rid of // repeat code between this and the other field types. void SetMessageVariables(const Params& params, - const FieldDescriptor* descriptor, map<string, string>* variables) { + const FieldDescriptor* descriptor, std::map<string, string>* variables) { (*variables)["name"] = RenameJavaKeywords(UnderscoresToCamelCase(descriptor)); (*variables)["capitalized_name"] = diff --git a/src/google/protobuf/compiler/javanano/javanano_message_field.h b/src/google/protobuf/compiler/javanano/javanano_message_field.h index e074735c..0ae8879b 100644 --- a/src/google/protobuf/compiler/javanano/javanano_message_field.h +++ b/src/google/protobuf/compiler/javanano/javanano_message_field.h @@ -62,7 +62,7 @@ class MessageFieldGenerator : public FieldGenerator { private: const FieldDescriptor* descriptor_; - map<string, string> variables_; + std::map<string, string> variables_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageFieldGenerator); }; @@ -85,7 +85,7 @@ class MessageOneofFieldGenerator : public FieldGenerator { private: const FieldDescriptor* descriptor_; - map<string, string> variables_; + std::map<string, string> variables_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageOneofFieldGenerator); }; @@ -108,7 +108,7 @@ class RepeatedMessageFieldGenerator : public FieldGenerator { private: const FieldDescriptor* descriptor_; - map<string, string> variables_; + std::map<string, string> variables_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedMessageFieldGenerator); }; diff --git a/src/google/protobuf/compiler/javanano/javanano_params.h b/src/google/protobuf/compiler/javanano/javanano_params.h index e3b4bb93..3594767d 100644 --- a/src/google/protobuf/compiler/javanano/javanano_params.h +++ b/src/google/protobuf/compiler/javanano/javanano_params.h @@ -47,8 +47,8 @@ enum eMultipleFiles { JAVANANO_MUL_UNSET, JAVANANO_MUL_FALSE, JAVANANO_MUL_TRUE // Parameters for used by the generators class Params { public: - typedef map<string, string> NameMap; - typedef set<string> NameSet; + typedef std::map<string, string> NameMap; + typedef std::set<string> NameSet; private: string empty_; string base_name_; diff --git a/src/google/protobuf/compiler/javanano/javanano_primitive_field.cc b/src/google/protobuf/compiler/javanano/javanano_primitive_field.cc index 978abf2c..66a0ff05 100644 --- a/src/google/protobuf/compiler/javanano/javanano_primitive_field.cc +++ b/src/google/protobuf/compiler/javanano/javanano_primitive_field.cc @@ -166,7 +166,7 @@ bool AllAscii(const string& text) { void SetPrimitiveVariables(const FieldDescriptor* descriptor, const Params params, - map<string, string>* variables) { + std::map<string, string>* variables) { (*variables)["name"] = RenameJavaKeywords(UnderscoresToCamelCase(descriptor)); (*variables)["capitalized_name"] = diff --git a/src/google/protobuf/compiler/javanano/javanano_primitive_field.h b/src/google/protobuf/compiler/javanano/javanano_primitive_field.h index a01981dd..d7d72d57 100644 --- a/src/google/protobuf/compiler/javanano/javanano_primitive_field.h +++ b/src/google/protobuf/compiler/javanano/javanano_primitive_field.h @@ -65,7 +65,7 @@ class PrimitiveFieldGenerator : public FieldGenerator { void GenerateSerializationConditional(io::Printer* printer) const; const FieldDescriptor* descriptor_; - map<string, string> variables_; + std::map<string, string> variables_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(PrimitiveFieldGenerator); }; @@ -89,7 +89,7 @@ class AccessorPrimitiveFieldGenerator : public FieldGenerator { private: const FieldDescriptor* descriptor_; - map<string, string> variables_; + std::map<string, string> variables_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(AccessorPrimitiveFieldGenerator); }; @@ -111,7 +111,7 @@ class PrimitiveOneofFieldGenerator : public FieldGenerator { private: const FieldDescriptor* descriptor_; - map<string, string> variables_; + std::map<string, string> variables_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(PrimitiveOneofFieldGenerator); }; @@ -137,7 +137,7 @@ class RepeatedPrimitiveFieldGenerator : public FieldGenerator { void GenerateRepeatedDataSizeCode(io::Printer* printer) const; const FieldDescriptor* descriptor_; - map<string, string> variables_; + std::map<string, string> variables_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedPrimitiveFieldGenerator); }; diff --git a/src/google/protobuf/compiler/js/js_generator.cc b/src/google/protobuf/compiler/js/js_generator.cc index 7c63e58f..fd2d3dfd 100755 --- a/src/google/protobuf/compiler/js/js_generator.cc +++ b/src/google/protobuf/compiler/js/js_generator.cc @@ -143,12 +143,16 @@ bool IsReserved(const string& ident) { return false; } +bool StrEndsWith(StringPiece sp, StringPiece x) { + return sp.size() >= x.size() && sp.substr(sp.size() - x.size()) == x; +} + // Returns a copy of |filename| with any trailing ".protodevel" or ".proto // suffix stripped. // TODO(haberman): Unify with copy in compiler/cpp/internal/helpers.cc. string StripProto(const string& filename) { - const char* suffix = HasSuffixString(filename, ".protodevel") - ? ".protodevel" : ".proto"; + const char* suffix = + StrEndsWith(filename, ".protodevel") ? ".protodevel" : ".proto"; return StripSuffixString(filename, suffix); } @@ -191,8 +195,9 @@ string ModuleAlias(const string& filename) { // We'll worry about this problem if/when we actually see it. This name isn't // exposed to users so we can change it later if we need to. string basename = StripProto(filename); - StripString(&basename, "-", '$'); - StripString(&basename, "/", '_'); + ReplaceCharacters(&basename, "-", '$'); + ReplaceCharacters(&basename, "/", '_'); + ReplaceCharacters(&basename, ".", '_'); return basename + "_pb"; } @@ -239,22 +244,35 @@ string GetPrefix(const GeneratorOptions& options, return prefix; } +// Returns the fully normalized JavaScript path prefix for the given +// message descriptor. +string GetMessagePathPrefix(const GeneratorOptions& options, + const Descriptor* descriptor) { + return GetPrefix( + options, descriptor->file(), + descriptor->containing_type()); +} + // Returns the fully normalized JavaScript path for the given // message descriptor. string GetMessagePath(const GeneratorOptions& options, const Descriptor* descriptor) { - return GetPrefix( - options, descriptor->file(), - descriptor->containing_type()) + descriptor->name(); + return GetMessagePathPrefix(options, descriptor) + descriptor->name(); +} + +// Returns the fully normalized JavaScript path prefix for the given +// enumeration descriptor. +string GetEnumPathPrefix(const GeneratorOptions& options, + const EnumDescriptor* enum_descriptor) { + return GetPrefix(options, enum_descriptor->file(), + enum_descriptor->containing_type()); } // Returns the fully normalized JavaScript path for the given // enumeration descriptor. string GetEnumPath(const GeneratorOptions& options, const EnumDescriptor* enum_descriptor) { - return GetPrefix( - options, enum_descriptor->file(), - enum_descriptor->containing_type()) + enum_descriptor->name(); + return GetEnumPathPrefix(options, enum_descriptor) + enum_descriptor->name(); } string MaybeCrossFileRef(const GeneratorOptions& options, @@ -756,8 +774,22 @@ string DoubleToString(double value) { return PostProcessFloat(result); } +// Return true if this is an integral field that should be represented as string +// in JS. +bool IsIntegralFieldWithStringJSType(const FieldDescriptor* field) { + switch (field->cpp_type()) { + case FieldDescriptor::CPPTYPE_INT64: + case FieldDescriptor::CPPTYPE_UINT64: + // The default value of JSType is JS_NORMAL, which behaves the same as + // JS_NUMBER. + return field->options().jstype() == google::protobuf::FieldOptions::JS_STRING; + default: + return false; + } +} + string MaybeNumberString(const FieldDescriptor* field, const string& orig) { - return orig; + return IsIntegralFieldWithStringJSType(field) ? ("\"" + orig + "\"") : orig; } string JSFieldDefault(const FieldDescriptor* field) { @@ -856,7 +888,7 @@ string ProtoTypeName(const GeneratorOptions& options, } string JSIntegerTypeName(const FieldDescriptor* field) { - return "number"; + return IsIntegralFieldWithStringJSType(field) ? "string" : "number"; } string JSStringTypeName(const GeneratorOptions& options, @@ -996,7 +1028,7 @@ string JSFieldTypeAnnotation(const GeneratorOptions& options, if (!IsPrimitive(jstype)) { jstype = "!" + jstype; } - jstype = "Array.<" + jstype + ">"; + jstype = "Array<" + jstype + ">"; } } @@ -1033,8 +1065,7 @@ string JSBinaryReaderMethodType(const FieldDescriptor* field) { if (name[0] >= 'a' && name[0] <= 'z') { name[0] = (name[0] - 'a') + 'A'; } - - return name; + return IsIntegralFieldWithStringJSType(field) ? (name + "String") : name; } string JSBinaryReadWriteMethodName(const FieldDescriptor* field, @@ -1064,6 +1095,40 @@ string JSReturnClause(const FieldDescriptor* desc) { return ""; } +string JSTypeTag(const FieldDescriptor* desc) { + switch (desc->type()) { + case FieldDescriptor::TYPE_DOUBLE: + case FieldDescriptor::TYPE_FLOAT: + return "Float"; + case FieldDescriptor::TYPE_INT32: + case FieldDescriptor::TYPE_UINT32: + case FieldDescriptor::TYPE_INT64: + case FieldDescriptor::TYPE_UINT64: + case FieldDescriptor::TYPE_FIXED32: + case FieldDescriptor::TYPE_FIXED64: + case FieldDescriptor::TYPE_SINT32: + case FieldDescriptor::TYPE_SINT64: + case FieldDescriptor::TYPE_SFIXED32: + case FieldDescriptor::TYPE_SFIXED64: + if (IsIntegralFieldWithStringJSType(desc)) { + return "StringInt"; + } else { + return "Int"; + } + case FieldDescriptor::TYPE_BOOL: + return "Boolean"; + case FieldDescriptor::TYPE_STRING: + return "String"; + case FieldDescriptor::TYPE_BYTES: + return "Bytes"; + case FieldDescriptor::TYPE_ENUM: + return "Enum"; + default: + assert(false); + } + return ""; +} + string JSReturnDoc(const GeneratorOptions& options, const FieldDescriptor* desc) { return ""; @@ -1244,13 +1309,6 @@ string FieldComments(const FieldDescriptor* field, BytesMode bytes_mode) { " * You should avoid comparisons like {@code val === true/false} in " "those cases.\n"; } - if (field->is_repeated()) { - comments += - " * If you change this array by adding, removing or replacing " - "elements, or if you\n" - " * replace the array itself, then you must call the setter to " - "update it.\n"; - } if (field->type() == FieldDescriptor::TYPE_BYTES && bytes_mode == BYTES_U8) { comments += " * Note that Uint8Array is not supported on all browsers.\n" @@ -1323,7 +1381,7 @@ bool IsExtendable(const Descriptor* desc) { // Returns the max index in the underlying data storage array beyond which the // extension object is used. string GetPivot(const Descriptor* desc) { - static const int kDefaultPivot = (1 << 29); // max field number (29 bits) + static const int kDefaultPivot = 500; // Find the max field number int max_field_number = 0; @@ -1335,7 +1393,7 @@ string GetPivot(const Descriptor* desc) { } int pivot = -1; - if (IsExtendable(desc)) { + if (IsExtendable(desc) || (max_field_number >= kDefaultPivot)) { pivot = ((max_field_number + 1) < kDefaultPivot) ? (max_field_number + 1) : kDefaultPivot; } @@ -1500,6 +1558,22 @@ bool GenerateJspbAllowedSet(const GeneratorOptions& options, return true; } +// Embeds base64 encoded GeneratedCodeInfo proto in a comment at the end of +// file. +void EmbedCodeAnnotations(const GeneratedCodeInfo& annotations, + io::Printer* printer) { + // Serialize annotations proto into base64 string. + string meta_content; + annotations.SerializeToString(&meta_content); + string meta_64; + Base64Escape(meta_content, &meta_64); + + // Print base64 encoded annotations at the end of output file in + // a comment. + printer->Print("\n// Below is base64 encoded GeneratedCodeInfo proto"); + printer->Print("\n// $encoded_proto$\n", "encoded_proto", meta_64); +} + } // anonymous namespace void Generator::GenerateHeader(const GeneratorOptions& options, @@ -1507,6 +1581,10 @@ void Generator::GenerateHeader(const GeneratorOptions& options, printer->Print("/**\n" " * @fileoverview\n" " * @enhanceable\n" + " * @suppress {messageConventions} JS Compiler reports an " + "error if a variable or\n" + " * field starts with 'MSG_' and isn't a translatable " + "message.\n" " * @public\n" " */\n" "// GENERATED CODE -- DO NOT EDIT!\n" @@ -1698,18 +1776,16 @@ void Generator::GenerateRequiresImpl(const GeneratorOptions& options, bool require_jspb, bool require_extension, bool require_map) const { if (require_jspb) { - printer->Print( - "goog.require('jspb.Message');\n" - "goog.require('jspb.BinaryReader');\n" - "goog.require('jspb.BinaryWriter');\n"); + required->insert("jspb.Message"); + required->insert("jspb.BinaryReader"); + required->insert("jspb.BinaryWriter"); } if (require_extension) { - printer->Print("goog.require('jspb.ExtensionFieldBinaryInfo');\n"); - printer->Print( - "goog.require('jspb.ExtensionFieldInfo');\n"); + required->insert("jspb.ExtensionFieldBinaryInfo"); + required->insert("jspb.ExtensionFieldInfo"); } if (require_map) { - printer->Print("goog.require('jspb.Map');\n"); + required->insert("jspb.Map"); } std::set<string>::iterator it; @@ -1883,8 +1959,10 @@ void Generator::GenerateClassConstructor(const GeneratorOptions& options, " * @extends {jspb.Message}\n" " * @constructor\n" " */\n" - "$classname$ = function(opt_data) {\n", - "classname", GetMessagePath(options, desc)); + "$classprefix$$classname$ = function(opt_data) {\n", + "classprefix", GetMessagePathPrefix(options, desc), + "classname", desc->name()); + printer->Annotate("classname", desc); string message_id = GetMessageId(desc); printer->Print( " jspb.Message.initialize(this, opt_data, $messageId$, $pivot$, " @@ -2037,6 +2115,7 @@ void Generator::GenerateClassToObject(const GeneratorOptions& options, " * http://goto/soy-param-migration\n" " * @param {!$classname$} msg The msg instance to transform.\n" " * @return {!Object}\n" + " * @suppress {unusedLocalVariables} f is only used for nested messages\n" " */\n" "$classname$.toObject = function(includeInstance, msg) {\n" " var f, obj = {", @@ -2125,7 +2204,8 @@ void Generator::GenerateFieldValueExpression(io::Printer* printer, "obj", obj_reference); } } else { - printer->Print("jspb.Message.getField($obj$, $index$)", + printer->Print("jspb.Message.get$cardinality$Field($obj$, $index$)", + "cardinality", field->is_repeated() ? "Repeated" : "", "index", JSFieldIndex(field), "obj", obj_reference); } @@ -2333,7 +2413,6 @@ void GenerateBytesWrapper(const GeneratorOptions& options, "defname", JSGetterName(options, field, BYTES_DEFAULT)); } - void Generator::GenerateClassField(const GeneratorOptions& options, io::Printer* printer, const FieldDescriptor* field) const { @@ -2365,12 +2444,13 @@ void Generator::GenerateClassField(const GeneratorOptions& options, "keytype", key_type, "valuetype", value_type); printer->Print( - "$class$.prototype.get$name$ = function(opt_noLazyCreate) {\n" + "$class$.prototype.$gettername$ = function(opt_noLazyCreate) {\n" " return /** @type {!jspb.Map<$keytype$,$valuetype$>} */ (\n", "class", GetMessagePath(options, field->containing_type()), - "name", JSGetterName(options, field), + "gettername", "get" + JSGetterName(options, field), "keytype", key_type, "valuetype", value_type); + printer->Annotate("gettername", field); printer->Print( " jspb.Message.getMapField(this, $index$, opt_noLazyCreate", "index", JSFieldIndex(field)); @@ -2409,7 +2489,7 @@ void Generator::GenerateClassField(const GeneratorOptions& options, /* force_present = */ false, /* singular_if_not_packed = */ false)); printer->Print( - "$class$.prototype.get$name$ = function() {\n" + "$class$.prototype.$gettername$ = function() {\n" " return /** @type{$type$} */ (\n" " jspb.Message.get$rpt$WrapperField(this, $wrapperclass$, " "$index$$required$));\n" @@ -2417,7 +2497,7 @@ void Generator::GenerateClassField(const GeneratorOptions& options, "\n" "\n", "class", GetMessagePath(options, field->containing_type()), - "name", JSGetterName(options, field), + "gettername", "get" + JSGetterName(options, field), "type", JSFieldTypeAnnotation(options, field, /* is_setter_argument = */ false, /* force_present = */ false, @@ -2427,9 +2507,10 @@ void Generator::GenerateClassField(const GeneratorOptions& options, "wrapperclass", SubmessageTypeRef(options, field), "required", (field->label() == FieldDescriptor::LABEL_REQUIRED ? ", 1" : "")); + printer->Annotate("gettername", field); printer->Print( "/** @param {$optionaltype$} value$returndoc$ */\n" - "$class$.prototype.set$name$ = function(value) {\n" + "$class$.prototype.$settername$ = function(value) {\n" " jspb.Message.set$oneoftag$$repeatedtag$WrapperField(", "optionaltype", JSFieldTypeAnnotation(options, field, @@ -2438,9 +2519,10 @@ void Generator::GenerateClassField(const GeneratorOptions& options, /* singular_if_not_packed = */ false), "returndoc", JSReturnDoc(options, field), "class", GetMessagePath(options, field->containing_type()), - "name", JSGetterName(options, field), + "settername", "set" + JSGetterName(options, field), "oneoftag", (field->containing_oneof() ? "Oneof" : ""), "repeatedtag", (field->is_repeated() ? "Repeated" : "")); + printer->Annotate("settername", field); printer->Print( "this, $index$$oneofgroup$, value);$returnvalue$\n" @@ -2463,7 +2545,7 @@ void Generator::GenerateClassField(const GeneratorOptions& options, // Simple (primitive) field, either singular or repeated. // TODO(b/26173701): Always use BYTES_DEFAULT for the getter return type; - // at this point we "lie" to non-binary users and tell the the return + // at this point we "lie" to non-binary users and tell the return // type is always base64 string, pending a LSC to migrate to typed getters. BytesMode bytes_mode = field->type() == FieldDescriptor::TYPE_BYTES && !options.binary ? @@ -2492,9 +2574,10 @@ void Generator::GenerateClassField(const GeneratorOptions& options, } printer->Print( - "$class$.prototype.get$name$ = function() {\n", + "$class$.prototype.$gettername$ = function() {\n", "class", GetMessagePath(options, field->containing_type()), - "name", JSGetterName(options, field)); + "gettername", "get" + JSGetterName(options, field)); + printer->Annotate("gettername", field); if (untyped) { printer->Print( @@ -2555,26 +2638,47 @@ void Generator::GenerateClassField(const GeneratorOptions& options, /* singular_if_not_packed = */ false), "returndoc", JSReturnDoc(options, field)); } - printer->Print( - "$class$.prototype.set$name$ = function(value) {\n" - " jspb.Message.set$oneoftag$Field(this, $index$", - "class", GetMessagePath(options, field->containing_type()), - "name", JSGetterName(options, field), - "oneoftag", (field->containing_oneof() ? "Oneof" : ""), - "index", JSFieldIndex(field)); - printer->Print( - "$oneofgroup$, $type$value$rptvalueinit$$typeclose$);$returnvalue$\n" - "};\n" - "\n" - "\n", - "type", - untyped ? "/** @type{string|number|boolean|Array|undefined} */(" : "", - "typeclose", untyped ? ")" : "", - "oneofgroup", - (field->containing_oneof() ? (", " + JSOneofArray(options, field)) - : ""), - "returnvalue", JSReturnClause(field), "rptvalueinit", - (field->is_repeated() ? " || []" : "")); + + if (field->file()->syntax() == FileDescriptor::SYNTAX_PROTO3 && + !field->is_repeated() && !field->is_map() && + !HasFieldPresence(options, field)) { + // Proto3 non-repeated and non-map fields without presence use the + // setProto3*Field function. + printer->Print( + "$class$.prototype.$settername$ = function(value) {\n" + " jspb.Message.setProto3$typetag$Field(this, $index$, " + "value);$returnvalue$\n" + "};\n" + "\n" + "\n", + "class", GetMessagePath(options, field->containing_type()), + "settername", "set" + JSGetterName(options, field), "typetag", + JSTypeTag(field), "index", JSFieldIndex(field), "returnvalue", + JSReturnClause(field)); + printer->Annotate("settername", field); + } else { + // Otherwise, use the regular setField function. + printer->Print( + "$class$.prototype.$settername$ = function(value) {\n" + " jspb.Message.set$oneoftag$Field(this, $index$", + "class", GetMessagePath(options, field->containing_type()), + "settername", "set" + JSGetterName(options, field), "oneoftag", + (field->containing_oneof() ? "Oneof" : ""), "index", + JSFieldIndex(field)); + printer->Annotate("settername", field); + printer->Print( + "$oneofgroup$, $type$value$rptvalueinit$$typeclose$);$returnvalue$\n" + "};\n" + "\n" + "\n", + "type", + untyped ? "/** @type{string|number|boolean|Array|undefined} */(" : "", + "typeclose", untyped ? ")" : "", "oneofgroup", + (field->containing_oneof() ? (", " + JSOneofArray(options, field)) + : ""), + "returnvalue", JSReturnClause(field), "rptvalueinit", + (field->is_repeated() ? " || []" : "")); + } if (untyped) { printer->Print( @@ -2594,41 +2698,46 @@ void Generator::GenerateClassField(const GeneratorOptions& options, // fields with presence. if (IsMap(options, field)) { printer->Print( - "$class$.prototype.clear$name$ = function() {\n" - " this.get$name$().clear();$returnvalue$\n" + "$class$.prototype.$clearername$ = function() {\n" + " this.$gettername$().clear();$returnvalue$\n" "};\n" "\n" "\n", "class", GetMessagePath(options, field->containing_type()), - "name", JSGetterName(options, field), + "clearername", "clear" + JSGetterName(options, field), + "gettername", "get" + JSGetterName(options, field), "returnvalue", JSReturnClause(field)); + printer->Annotate("clearername", 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" + "$class$.prototype.$clearername$ = function() {\n" + " this.$settername$($clearedvalue$);$returnvalue$\n" "};\n" "\n" "\n", "class", GetMessagePath(options, field->containing_type()), - "name", JSGetterName(options, field), + "clearername", "clear" + JSGetterName(options, field), + "settername", "set" + JSGetterName(options, field), "clearedvalue", (field->is_repeated() ? "[]" : "undefined"), "returnvalue", JSReturnClause(field)); + printer->Annotate("clearername", 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" + "$class$.prototype.$clearername$ = function() {\n" " jspb.Message.set$maybeoneof$Field(this, " "$index$$maybeoneofgroup$, ", "class", GetMessagePath(options, field->containing_type()), - "name", JSGetterName(options, field), + "clearername", "clear" + JSGetterName(options, field), "maybeoneof", (field->containing_oneof() ? "Oneof" : ""), "maybeoneofgroup", (field->containing_oneof() ? (", " + JSOneofArray(options, field)) : ""), "index", JSFieldIndex(field)); + printer->Annotate("clearername", field); printer->Print( "$clearedvalue$);$returnvalue$\n" "};\n" @@ -2644,14 +2753,15 @@ void Generator::GenerateClassField(const GeneratorOptions& options, " * Returns whether this field is set.\n" " * @return {!boolean}\n" " */\n" - "$class$.prototype.has$name$ = function() {\n" + "$class$.prototype.$hasername$ = function() {\n" " return jspb.Message.getField(this, $index$) != null;\n" "};\n" "\n" "\n", "class", GetMessagePath(options, field->containing_type()), - "name", JSGetterName(options, field), + "hasername", "has" + JSGetterName(options, field), "index", JSFieldIndex(field)); + printer->Annotate("hasername", field); } } @@ -2663,13 +2773,14 @@ void Generator::GenerateRepeatedPrimitiveHelperMethods( " * @param {!$optionaltype$} value\n" " * @param {number=} opt_index\n" " */\n" - "$class$.prototype.add$name$ = function(value, opt_index) {\n" + "$class$.prototype.$addername$ = function(value, opt_index) {\n" " jspb.Message.addToRepeatedField(this, $index$", - "class", GetMessagePath(options, field->containing_type()), - "name", JSGetterName(options, field, BYTES_DEFAULT, - /* drop_list = */ true), + "class", GetMessagePath(options, field->containing_type()), "addername", + "add" + JSGetterName(options, field, BYTES_DEFAULT, + /* drop_list = */ true), "optionaltype", JSTypeName(options, field, BYTES_DEFAULT), "index", JSFieldIndex(field)); + printer->Annotate("addername", field); printer->Print( "$oneofgroup$, $type$value$rptvalueinit$$typeclose$, opt_index);\n" "};\n" @@ -2727,7 +2838,7 @@ void Generator::GenerateClassExtensionFieldInfo(const GeneratorOptions& options, "so that it\n" " * works in OPTIMIZED mode.\n" " *\n" - " * @type {!Object.<number, jspb.ExtensionFieldInfo>}\n" + " * @type {!Object<number, jspb.ExtensionFieldInfo>}\n" " */\n" "$class$.extensions = {};\n" "\n", @@ -2748,7 +2859,7 @@ void Generator::GenerateClassExtensionFieldInfo(const GeneratorOptions& options, "so that it\n" " * works in OPTIMIZED mode.\n" " *\n" - " * @type {!Object.<number, jspb.ExtensionFieldBinaryInfo>}\n" + " * @type {!Object<number, jspb.ExtensionFieldBinaryInfo>}\n" " */\n" "$class$.extensionsBinary = {};\n" "\n", @@ -2910,6 +3021,7 @@ void Generator::GenerateClassSerializeBinary(const GeneratorOptions& options, " * format), writing to the given BinaryWriter.\n" " * @param {!$class$} message\n" " * @param {!jspb.BinaryWriter} writer\n" + " * @suppress {unusedLocalVariables} f is only used for nested messages\n" " */\n" "$class$.serializeBinaryToWriter = function(message, " "writer) {\n" @@ -2982,7 +3094,13 @@ void Generator::GenerateClassSerializeBinaryField( case FieldDescriptor::CPPTYPE_INT64: case FieldDescriptor::CPPTYPE_UINT32: case FieldDescriptor::CPPTYPE_UINT64: { - { + if (IsIntegralFieldWithStringJSType(field)) { + // We can use `parseInt` here even though it will not be precise for + // 64-bit quantities because we are only testing for zero/nonzero, + // and JS numbers (64-bit floating point values, i.e., doubles) are + // integer-precise in the range that includes zero. + printer->Print(" if (parseInt(f, 10) !== 0) {\n"); + } else { printer->Print(" if (f !== 0) {\n"); } break; @@ -3060,8 +3178,10 @@ void Generator::GenerateEnum(const GeneratorOptions& options, "/**\n" " * @enum {number}\n" " */\n" - "$name$ = {\n", - "name", GetEnumPath(options, enumdesc)); + "$enumprefix$$name$ = {\n", + "enumprefix", GetEnumPathPrefix(options, enumdesc), + "name", enumdesc->name()); + printer->Annotate("name", enumdesc); for (int i = 0; i < enumdesc->value_count(); i++) { const EnumValueDescriptor* value = enumdesc->value(i); @@ -3070,6 +3190,7 @@ void Generator::GenerateEnum(const GeneratorOptions& options, "name", ToEnumCase(value->name()), "value", SimpleItoa(value->number()), "comma", (i == enumdesc->value_count() - 1) ? "" : ","); + printer->Annotate("name", value); } printer->Print( @@ -3090,7 +3211,7 @@ void Generator::GenerateExtension(const GeneratorOptions& options, "/**\n" " * A tuple of {field number, class constructor} for the extension\n" " * field named `$name$`.\n" - " * @type {!jspb.ExtensionFieldInfo.<$extensionType$>}\n" + " * @type {!jspb.ExtensionFieldInfo<$extensionType$>}\n" " */\n" "$class$.$name$ = new jspb.ExtensionFieldInfo(\n", "name", JSObjectFieldName(options, field), @@ -3209,6 +3330,12 @@ bool GeneratorOptions::ParseFromOptions( return false; } one_output_file_per_input_file = true; + } else if (options[i].first == "annotate_code") { + if (!options[i].second.empty()) { + *error = "Unexpected option value for annotate_code"; + return false; + } + annotate_code = true; } else { // Assume any other option is an output directory, as long as it is a bare // `key` rather than a `key=value` option. @@ -3306,7 +3433,8 @@ void Generator::GenerateFile(const GeneratorOptions& options, printer->Print( "var $alias$ = require('$file$');\n", "alias", ModuleAlias(name), - "file", GetRootPath(file->name(), name) + GetJSFilename(options, name)); + "file", + GetRootPath(file->name(), name) + GetJSFilename(options, name)); } } @@ -3508,16 +3636,24 @@ bool Generator::GenerateAll(const std::vector<const FileDescriptor*>& files, options.output_dir + "/" + GetJSFilename(options, file->name()); google::protobuf::scoped_ptr<io::ZeroCopyOutputStream> output(context->Open(filename)); GOOGLE_CHECK(output.get()); - io::Printer printer(output.get(), '$'); + GeneratedCodeInfo annotations; + io::AnnotationProtoCollector<GeneratedCodeInfo> annotation_collector( + &annotations); + io::Printer printer(output.get(), '$', + options.annotate_code ? &annotation_collector : NULL); + GenerateFile(options, &printer, file); if (printer.failed()) { return false; } + + if (options.annotate_code) { + EmbedCodeAnnotations(annotations, &printer); + } } } - return true; } diff --git a/src/google/protobuf/compiler/js/js_generator.h b/src/google/protobuf/compiler/js/js_generator.h index 6e932d7f..3cc60e22 100755 --- a/src/google/protobuf/compiler/js/js_generator.h +++ b/src/google/protobuf/compiler/js/js_generator.h @@ -79,7 +79,8 @@ struct GeneratorOptions { library(""), error_on_name_conflict(false), extension(".js"), - one_output_file_per_input_file(false) {} + one_output_file_per_input_file(false), + annotate_code(false) {} bool ParseFromOptions( const std::vector< std::pair< string, string > >& options, @@ -118,6 +119,9 @@ struct GeneratorOptions { string extension; // Create a separate output file for each input file? bool one_output_file_per_input_file; + // If true, we should build .meta files that contain annotations for + // generated code. See GeneratedCodeInfo in descriptor.proto. + bool annotate_code; }; // CodeGenerator implementation which generates a JavaScript source file and diff --git a/src/google/protobuf/compiler/js/well_known_types/any.js b/src/google/protobuf/compiler/js/well_known_types/any.js index 22f18919..d7ca6e3a 100644 --- a/src/google/protobuf/compiler/js/well_known_types/any.js +++ b/src/google/protobuf/compiler/js/well_known_types/any.js @@ -69,7 +69,7 @@ proto.google.protobuf.Any.prototype.pack = function(serialized, name, * the binary data properly. * @param {string} name The expected type name of this message object. * @return {?T} If the name matched the expected name, returns the deserialized - * object, otherwise returns undefined. + * object, otherwise returns null. */ proto.google.protobuf.Any.prototype.unpack = function(deserialize, name) { if (this.getTypeName() == name) { diff --git a/src/google/protobuf/compiler/mock_code_generator.cc b/src/google/protobuf/compiler/mock_code_generator.cc index 0ddb99e5..7719ec3d 100644 --- a/src/google/protobuf/compiler/mock_code_generator.cc +++ b/src/google/protobuf/compiler/mock_code_generator.cc @@ -40,6 +40,7 @@ #endif #include <vector> + #include <google/protobuf/stubs/strutil.h> #include <google/protobuf/stubs/logging.h> @@ -52,16 +53,24 @@ #include <google/protobuf/io/zero_copy_stream.h> #include <google/protobuf/descriptor.pb.h> #include <google/protobuf/descriptor.h> +#include <google/protobuf/text_format.h> #include <google/protobuf/stubs/substitute.h> #include <gtest/gtest.h> +#ifdef major +#undef major +#endif +#ifdef minor +#undef minor +#endif + namespace google { namespace protobuf { namespace compiler { // Returns the list of the names of files in all_files in the form of a // comma-separated string. -string CommaSeparatedList(const std::vector<const FileDescriptor*> all_files) { +string CommaSeparatedList(const std::vector<const FileDescriptor*>& all_files) { std::vector<string> names; for (size_t i = 0; i < all_files.size(); i++) { names.push_back(all_files[i]->name()); @@ -129,11 +138,48 @@ void MockCodeGenerator::ExpectGenerated( } } +namespace { +void CheckSingleAnnotation(const string& expected_file, + const string& expected_text, + const string& file_content, + const GeneratedCodeInfo::Annotation& annotation) { + EXPECT_EQ(expected_file, annotation.source_file()); + ASSERT_GE(file_content.size(), annotation.begin()); + ASSERT_GE(file_content.size(), annotation.end()); + ASSERT_LE(annotation.begin(), annotation.end()); + EXPECT_EQ(expected_text.size(), annotation.end() - annotation.begin()); + EXPECT_EQ(expected_text, + file_content.substr(annotation.begin(), expected_text.size())); +} +} // anonymous namespace + +void MockCodeGenerator::CheckGeneratedAnnotations( + const string& name, const string& file, const string& output_directory) { + string file_content; + GOOGLE_CHECK_OK( + File::GetContents(output_directory + "/" + GetOutputFileName(name, file), + &file_content, true)); + string meta_content; + GOOGLE_CHECK_OK(File::GetContents( + output_directory + "/" + GetOutputFileName(name, file) + ".meta", + &meta_content, true)); + GeneratedCodeInfo annotations; + GOOGLE_CHECK(TextFormat::ParseFromString(meta_content, &annotations)); + ASSERT_EQ(3, annotations.annotation_size()); + CheckSingleAnnotation("first_annotation", "first", file_content, + annotations.annotation(0)); + CheckSingleAnnotation("second_annotation", "second", file_content, + annotations.annotation(1)); + CheckSingleAnnotation("third_annotation", "third", file_content, + annotations.annotation(2)); +} + bool MockCodeGenerator::Generate( const FileDescriptor* file, const string& parameter, GeneratorContext* context, string* error) const { + bool annotate = false; for (int i = 0; i < file->message_type_count(); i++) { if (HasPrefixString(file->message_type(i)->name(), "MockCodeGenerator_")) { string command = StripPrefixString(file->message_type(i)->name(), @@ -162,6 +208,8 @@ bool MockCodeGenerator::Generate( std::cerr << "Saw json_name: " << field_descriptor_proto.has_json_name() << std::endl; abort(); + } else if (command == "Annotate") { + annotate = true; } else if (command == "ShowVersionNumber") { Version compiler_version; context->GetCompilerVersion(&compiler_version); @@ -212,16 +260,40 @@ bool MockCodeGenerator::Generate( google::protobuf::scoped_ptr<io::ZeroCopyOutputStream> output( context->Open(GetOutputFileName(name_, file))); - io::Printer printer(output.get(), '$'); - printer.PrintRaw(GetOutputFileContent(name_, parameter, - file, context)); + GeneratedCodeInfo annotations; + io::AnnotationProtoCollector<GeneratedCodeInfo> annotation_collector( + &annotations); + io::Printer printer(output.get(), '$', + annotate ? &annotation_collector : NULL); + printer.PrintRaw(GetOutputFileContent(name_, parameter, file, context)); + string annotate_suffix = "_annotation"; + if (annotate) { + printer.Print("$p$", "p", "first"); + printer.Annotate("p", "first" + annotate_suffix); + } printer.PrintRaw(kFirstInsertionPoint); + if (annotate) { + printer.Print("$p$", "p", "second"); + printer.Annotate("p", "second" + annotate_suffix); + } printer.PrintRaw(kSecondInsertionPoint); + if (annotate) { + printer.Print("$p$", "p", "third"); + printer.Annotate("p", "third" + annotate_suffix); + } if (printer.failed()) { *error = "MockCodeGenerator detected write error."; return false; } + if (annotate) { + google::protobuf::scoped_ptr<io::ZeroCopyOutputStream> meta_output( + context->Open(GetOutputFileName(name_, file) + ".meta")); + if (!TextFormat::Print(annotations, meta_output.get())) { + *error = "MockCodeGenerator couldn't write .meta"; + return false; + } + } } return true; diff --git a/src/google/protobuf/compiler/mock_code_generator.h b/src/google/protobuf/compiler/mock_code_generator.h index e1665f88..cdd9138c 100644 --- a/src/google/protobuf/compiler/mock_code_generator.h +++ b/src/google/protobuf/compiler/mock_code_generator.h @@ -68,6 +68,8 @@ namespace compiler { // printing "Saw message type MockCodeGenerator_HasSourceCodeInfo: FOO." to // stderr, where FOO is "1" if the supplied FileDescriptorProto has source // code info, and "0" otherwise. +// MockCodeGenerator_Annotate: Generate() will add annotations to its output +// that can later be verified with CheckGeneratedAnnotations. class MockCodeGenerator : public CodeGenerator { public: MockCodeGenerator(const string& name); @@ -88,6 +90,12 @@ class MockCodeGenerator : public CodeGenerator { const string& parsed_file_list, const string& output_directory); + // Checks that the correct text ranges were annotated by the + // MockCodeGenerator_Annotate directive. + static void CheckGeneratedAnnotations(const string& name, + const string& file, + const string& output_directory); + // Get the name of the file which would be written by the given generator. static string GetOutputFileName(const string& generator_name, const FileDescriptor* file); diff --git a/src/google/protobuf/compiler/objectivec/objectivec_enum.cc b/src/google/protobuf/compiler/objectivec/objectivec_enum.cc index 02d60b3e..978e985c 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_enum.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_enum.cc @@ -149,7 +149,7 @@ void EnumGenerator::GenerateSource(io::Printer* printer) { printer->Print( "GPBEnumDescriptor *$name$_EnumDescriptor(void) {\n" - " static GPBEnumDescriptor *descriptor = NULL;\n" + " static _Atomic(GPBEnumDescriptor*) descriptor = nil;\n" " if (!descriptor) {\n", "name", name_); @@ -192,7 +192,8 @@ void EnumGenerator::GenerateSource(io::Printer* printer) { "extraTextFormatInfo", CEscape(text_format_decode_data.Data())); } printer->Print( - " if (!OSAtomicCompareAndSwapPtrBarrier(nil, worker, (void * volatile *)&descriptor)) {\n" + " GPBEnumDescriptor *expected = nil;\n" + " if (!atomic_compare_exchange_strong(&descriptor, &expected, worker)) {\n" " [worker release];\n" " }\n" " }\n" diff --git a/src/google/protobuf/compiler/objectivec/objectivec_enum.h b/src/google/protobuf/compiler/objectivec/objectivec_enum.h index 0b41cf73..f52e9e68 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_enum.h +++ b/src/google/protobuf/compiler/objectivec/objectivec_enum.h @@ -59,8 +59,8 @@ class EnumGenerator { private: const EnumDescriptor* descriptor_; - vector<const EnumValueDescriptor*> base_values_; - vector<const EnumValueDescriptor*> all_values_; + std::vector<const EnumValueDescriptor*> base_values_; + std::vector<const EnumValueDescriptor*> all_values_; const string name_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumGenerator); diff --git a/src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc b/src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc index 7a774a09..8899a13a 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc @@ -46,7 +46,7 @@ namespace objectivec { namespace { void SetEnumVariables(const FieldDescriptor* descriptor, - map<string, string>* variables) { + std::map<string, string>* variables) { string type = EnumName(descriptor->enum_type()); (*variables)["storage_type"] = type; // For non repeated fields, if it was defined in a different file, the @@ -118,7 +118,7 @@ void EnumFieldGenerator::GenerateCFunctionImplementations( } void EnumFieldGenerator::DetermineForwardDeclarations( - set<string>* fwd_decls) const { + std::set<string>* fwd_decls) const { SingleFieldGenerator::DetermineForwardDeclarations(fwd_decls); // If it is an enum defined in a different file, then we'll need a forward // declaration for it. When it is in our file, all the enums are output diff --git a/src/google/protobuf/compiler/objectivec/objectivec_enum_field.h b/src/google/protobuf/compiler/objectivec/objectivec_enum_field.h index 946faa81..ae56c069 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_enum_field.h +++ b/src/google/protobuf/compiler/objectivec/objectivec_enum_field.h @@ -47,7 +47,7 @@ class EnumFieldGenerator : public SingleFieldGenerator { public: virtual void GenerateCFunctionDeclarations(io::Printer* printer) const; virtual void GenerateCFunctionImplementations(io::Printer* printer) const; - virtual void DetermineForwardDeclarations(set<string>* fwd_decls) const; + virtual void DetermineForwardDeclarations(std::set<string>* fwd_decls) const; protected: EnumFieldGenerator(const FieldDescriptor* descriptor, const Options& options); diff --git a/src/google/protobuf/compiler/objectivec/objectivec_extension.cc b/src/google/protobuf/compiler/objectivec/objectivec_extension.cc index 73e4b86e..b788d0a3 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_extension.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_extension.cc @@ -59,7 +59,7 @@ ExtensionGenerator::ExtensionGenerator(const string& root_class_name, ExtensionGenerator::~ExtensionGenerator() {} void ExtensionGenerator::GenerateMembersHeader(io::Printer* printer) { - map<string, string> vars; + std::map<string, string> vars; vars["method_name"] = method_name_; SourceLocation location; if (descriptor_->GetSourceLocation(&location)) { @@ -77,7 +77,7 @@ void ExtensionGenerator::GenerateMembersHeader(io::Printer* printer) { void ExtensionGenerator::GenerateStaticVariablesInitialization( io::Printer* printer) { - map<string, string> vars; + std::map<string, string> vars; vars["root_class_and_method_name"] = root_class_and_method_name_; vars["extended_type"] = ClassName(descriptor_->containing_type()); vars["number"] = SimpleItoa(descriptor_->number()); diff --git a/src/google/protobuf/compiler/objectivec/objectivec_field.cc b/src/google/protobuf/compiler/objectivec/objectivec_field.cc index 9f7e84f2..b6123fad 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_field.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_field.cc @@ -49,7 +49,7 @@ namespace objectivec { namespace { void SetCommonFieldVariables(const FieldDescriptor* descriptor, - map<string, string>* variables) { + std::map<string, string>* variables) { string camel_case_name = FieldName(descriptor); string raw_field_name; if (descriptor->type() == FieldDescriptor::TYPE_GROUP) { @@ -178,7 +178,7 @@ void FieldGenerator::GenerateCFunctionImplementations( } void FieldGenerator::DetermineForwardDeclarations( - set<string>* fwd_decls) const { + std::set<string>* fwd_decls) const { // Nothing } diff --git a/src/google/protobuf/compiler/objectivec/objectivec_field.h b/src/google/protobuf/compiler/objectivec/objectivec_field.h index a3a4b1b6..6bd5db2e 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_field.h +++ b/src/google/protobuf/compiler/objectivec/objectivec_field.h @@ -67,7 +67,7 @@ class FieldGenerator { virtual void GenerateCFunctionImplementations(io::Printer* printer) const; // Exposed for subclasses, should always call it on the parent class also. - virtual void DetermineForwardDeclarations(set<string>* fwd_decls) const; + virtual void DetermineForwardDeclarations(std::set<string>* fwd_decls) const; // Used during generation, not intended to be extended by subclasses. void GenerateFieldDescription( @@ -100,7 +100,7 @@ class FieldGenerator { virtual bool WantsHasProperty(void) const = 0; const FieldDescriptor* descriptor_; - map<string, string> variables_; + std::map<string, string> variables_; private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FieldGenerator); diff --git a/src/google/protobuf/compiler/objectivec/objectivec_file.cc b/src/google/protobuf/compiler/objectivec/objectivec_file.cc index 7ad127bb..6f80a0de 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_file.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_file.cc @@ -56,6 +56,20 @@ const int32 GOOGLE_PROTOBUF_OBJC_VERSION = 30002; const char* kHeaderExtension = ".pbobjc.h"; +// Checks if a message contains any enums definitions (on the message or +// a nested message under it). +bool MessageContainsEnums(const Descriptor* message) { + if (message->enum_type_count() > 0) { + return true; + } + for (int i = 0; i < message->nested_type_count(); i++) { + if (MessageContainsEnums(message->nested_type(i))) { + return true; + } + } + return false; +} + // Checks if a message contains any extension definitions (on the message or // a nested message under it). bool MessageContainsExtensions(const Descriptor* message) { @@ -70,6 +84,20 @@ bool MessageContainsExtensions(const Descriptor* message) { return false; } +// Checks if the file contains any enum definitions (at the root or +// nested under a message). +bool FileContainsEnums(const FileDescriptor* file) { + if (file->enum_type_count() > 0) { + return true; + } + for (int i = 0; i < file->message_type_count(); i++) { + if (MessageContainsEnums(file->message_type(i))) { + return true; + } + } + return false; +} + // Checks if the file contains any extensions definitions (at the root or // nested under a message). bool FileContainsExtensions(const FileDescriptor* file) { @@ -88,9 +116,9 @@ bool FileContainsExtensions(const FileDescriptor* file) { // deps as visited and prunes them from the needed files list. void PruneFileAndDepsMarkingAsVisited( const FileDescriptor* file, - vector<const FileDescriptor*>* files, - set<const FileDescriptor*>* files_visited) { - vector<const FileDescriptor*>::iterator iter = + std::vector<const FileDescriptor*>* files, + std::set<const FileDescriptor*>* files_visited) { + std::vector<const FileDescriptor*>::iterator iter = std::find(files->begin(), files->end(), file); if (iter != files->end()) { files->erase(iter); @@ -104,8 +132,8 @@ void PruneFileAndDepsMarkingAsVisited( // Helper for CollectMinimalFileDepsContainingExtensions. void CollectMinimalFileDepsContainingExtensionsWorker( const FileDescriptor* file, - vector<const FileDescriptor*>* files, - set<const FileDescriptor*>* files_visited) { + std::vector<const FileDescriptor*>* files, + std::set<const FileDescriptor*>* files_visited) { if (files_visited->find(file) != files_visited->end()) { return; } @@ -137,8 +165,8 @@ void CollectMinimalFileDepsContainingExtensionsWorker( // specifically). void CollectMinimalFileDepsContainingExtensions( const FileDescriptor* file, - vector<const FileDescriptor*>* files) { - set<const FileDescriptor*> files_visited; + std::vector<const FileDescriptor*>* files) { + std::set<const FileDescriptor*> files_visited; for (int i = 0; i < file->dependency_count(); i++) { const FileDescriptor* dep = file->dependency(i); CollectMinimalFileDepsContainingExtensionsWorker(dep, files, @@ -229,12 +257,12 @@ void FileGenerator::GenerateHeader(io::Printer *printer) { "CF_EXTERN_C_BEGIN\n" "\n"); - set<string> fwd_decls; - for (vector<MessageGenerator *>::iterator iter = message_generators_.begin(); + std::set<string> fwd_decls; + for (std::vector<MessageGenerator *>::iterator iter = message_generators_.begin(); iter != message_generators_.end(); ++iter) { (*iter)->DetermineForwardDeclarations(&fwd_decls); } - for (set<string>::const_iterator i(fwd_decls.begin()); + for (std::set<string>::const_iterator i(fwd_decls.begin()); i != fwd_decls.end(); ++i) { printer->Print("$value$;\n", "value", *i); } @@ -247,12 +275,12 @@ void FileGenerator::GenerateHeader(io::Printer *printer) { "\n"); // need to write out all enums first - for (vector<EnumGenerator *>::iterator iter = enum_generators_.begin(); + for (std::vector<EnumGenerator *>::iterator iter = enum_generators_.begin(); iter != enum_generators_.end(); ++iter) { (*iter)->GenerateHeader(printer); } - for (vector<MessageGenerator *>::iterator iter = message_generators_.begin(); + for (std::vector<MessageGenerator *>::iterator iter = message_generators_.begin(); iter != message_generators_.end(); ++iter) { (*iter)->GenerateEnumHeader(printer); } @@ -283,7 +311,7 @@ void FileGenerator::GenerateHeader(io::Printer *printer) { "@interface $root_class_name$ (DynamicMethods)\n", "root_class_name", root_class_name_); - for (vector<ExtensionGenerator *>::iterator iter = + for (std::vector<ExtensionGenerator *>::iterator iter = extension_generators_.begin(); iter != extension_generators_.end(); ++iter) { (*iter)->GenerateMembersHeader(printer); @@ -292,7 +320,7 @@ void FileGenerator::GenerateHeader(io::Printer *printer) { printer->Print("@end\n\n"); } // extension_generators_.size() > 0 - for (vector<MessageGenerator *>::iterator iter = message_generators_.begin(); + for (std::vector<MessageGenerator *>::iterator iter = message_generators_.begin(); iter != message_generators_.end(); ++iter) { (*iter)->GenerateMessageHeader(printer); } @@ -311,7 +339,14 @@ void FileGenerator::GenerateSource(io::Printer *printer) { // #import the runtime support. PrintFileRuntimePreamble(printer, "GPBProtocolBuffers_RuntimeSupport.h"); - vector<const FileDescriptor*> deps_with_extensions; + // Enums use atomic in the generated code, so add the system import as needed. + if (FileContainsEnums(file_)) { + printer->Print( + "#import <stdatomic.h>\n" + "\n"); + } + + std::vector<const FileDescriptor*> deps_with_extensions; CollectMinimalFileDepsContainingExtensions(file_, &deps_with_extensions); { @@ -325,7 +360,7 @@ void FileGenerator::GenerateSource(io::Printer *printer) { // #import the headers for anything that a plain dependency of this proto // file (that means they were just an include, not a "public" include). - set<string> public_import_names; + std::set<string> public_import_names; for (int i = 0; i < file_->public_dependency_count(); i++) { public_import_names.insert(file_->public_dependency(i)->name()); } @@ -341,7 +376,7 @@ void FileGenerator::GenerateSource(io::Printer *printer) { // imported so it can get merged into the root's extensions registry. // See the Note by CollectMinimalFileDepsContainingExtensions before // changing this. - for (vector<const FileDescriptor *>::iterator iter = + for (std::vector<const FileDescriptor *>::iterator iter = deps_with_extensions.begin(); iter != deps_with_extensions.end(); ++iter) { if (!IsDirectDependency(*iter, file_)) { @@ -353,7 +388,7 @@ void FileGenerator::GenerateSource(io::Printer *printer) { } bool includes_oneof = false; - for (vector<MessageGenerator *>::iterator iter = message_generators_.begin(); + for (std::vector<MessageGenerator *>::iterator iter = message_generators_.begin(); iter != message_generators_.end(); ++iter) { if ((*iter)->IncludesOneOfDefinition()) { includes_oneof = true; @@ -406,12 +441,12 @@ void FileGenerator::GenerateSource(io::Printer *printer) { printer->Print( "static GPBExtensionDescription descriptions[] = {\n"); printer->Indent(); - for (vector<ExtensionGenerator *>::iterator iter = + for (std::vector<ExtensionGenerator *>::iterator iter = extension_generators_.begin(); iter != extension_generators_.end(); ++iter) { (*iter)->GenerateStaticVariablesInitialization(printer); } - for (vector<MessageGenerator *>::iterator iter = + for (std::vector<MessageGenerator *>::iterator iter = message_generators_.begin(); iter != message_generators_.end(); ++iter) { (*iter)->GenerateStaticVariablesInitialization(printer); @@ -435,7 +470,7 @@ void FileGenerator::GenerateSource(io::Printer *printer) { } else { printer->Print( "// Merge in the imports (direct or indirect) that defined extensions.\n"); - for (vector<const FileDescriptor *>::iterator iter = + for (std::vector<const FileDescriptor *>::iterator iter = deps_with_extensions.begin(); iter != deps_with_extensions.end(); ++iter) { const string root_class_name(FileClassName((*iter))); @@ -468,7 +503,7 @@ void FileGenerator::GenerateSource(io::Printer *printer) { // File descriptor only needed if there are messages to use it. if (message_generators_.size() > 0) { - map<string, string> vars; + std::map<string, string> vars; vars["root_class_name"] = root_class_name_; vars["package"] = file_->package(); vars["objc_prefix"] = FileClassPrefix(file_); @@ -511,11 +546,11 @@ void FileGenerator::GenerateSource(io::Printer *printer) { "\n"); } - for (vector<EnumGenerator *>::iterator iter = enum_generators_.begin(); + for (std::vector<EnumGenerator *>::iterator iter = enum_generators_.begin(); iter != enum_generators_.end(); ++iter) { (*iter)->GenerateSource(printer); } - for (vector<MessageGenerator *>::iterator iter = message_generators_.begin(); + for (std::vector<MessageGenerator *>::iterator iter = message_generators_.begin(); iter != message_generators_.end(); ++iter) { (*iter)->GenerateSource(printer); } diff --git a/src/google/protobuf/compiler/objectivec/objectivec_file.h b/src/google/protobuf/compiler/objectivec/objectivec_file.h index a60a6885..9c3f0071 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_file.h +++ b/src/google/protobuf/compiler/objectivec/objectivec_file.h @@ -67,9 +67,9 @@ class FileGenerator { const FileDescriptor* file_; string root_class_name_; - vector<EnumGenerator*> enum_generators_; - vector<MessageGenerator*> message_generators_; - vector<ExtensionGenerator*> extension_generators_; + std::vector<EnumGenerator*> enum_generators_; + std::vector<MessageGenerator*> message_generators_; + std::vector<ExtensionGenerator*> extension_generators_; const Options options_; diff --git a/src/google/protobuf/compiler/objectivec/objectivec_generator.cc b/src/google/protobuf/compiler/objectivec/objectivec_generator.cc index 36407467..760ff481 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_generator.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_generator.cc @@ -57,7 +57,7 @@ bool ObjectiveCGenerator::Generate(const FileDescriptor* file, return false; } -bool ObjectiveCGenerator::GenerateAll(const vector<const FileDescriptor*>& files, +bool ObjectiveCGenerator::GenerateAll(const std::vector<const FileDescriptor*>& files, const string& parameter, GeneratorContext* context, string* error) const { @@ -71,7 +71,7 @@ bool ObjectiveCGenerator::GenerateAll(const vector<const FileDescriptor*>& files Options generation_options; - vector<pair<string, string> > options; + std::vector<std::pair<string, string> > options; ParseGeneratorParameter(parameter, &options); for (int i = 0; i < options.size(); i++) { if (options[i].first == "expected_prefixes_path") { diff --git a/src/google/protobuf/compiler/objectivec/objectivec_generator.h b/src/google/protobuf/compiler/objectivec/objectivec_generator.h index b1723318..3e43f732 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_generator.h +++ b/src/google/protobuf/compiler/objectivec/objectivec_generator.h @@ -56,7 +56,7 @@ class LIBPROTOC_EXPORT ObjectiveCGenerator : public CodeGenerator { const string& parameter, GeneratorContext* context, string* error) const; - bool GenerateAll(const vector<const FileDescriptor*>& files, + bool GenerateAll(const std::vector<const FileDescriptor*>& files, const string& parameter, GeneratorContext* context, string* error) const; diff --git a/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc b/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc index 1ea2676a..5727dd56 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc @@ -28,9 +28,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#ifdef _MSC_VER -#include <io.h> -#else +#ifndef _MSC_VER #include <unistd.h> #endif #include <climits> @@ -49,8 +47,10 @@ #include <google/protobuf/io/printer.h> #include <google/protobuf/io/zero_copy_stream_impl.h> #include <google/protobuf/stubs/common.h> +#include <google/protobuf/stubs/io_win32.h> #include <google/protobuf/stubs/strutil.h> + // NOTE: src/google/protobuf/compiler/plugin.cc makes use of cerr for some // error cases, so it seems to be ok to use as a back door for errors. @@ -59,6 +59,16 @@ namespace protobuf { namespace compiler { namespace objectivec { +// <io.h> is transitively included in this file. Import the functions explicitly +// in this port namespace to avoid ambiguous definition. +namespace posix { +#ifdef _WIN32 +using ::google::protobuf::internal::win32::open; +#else +using ::open; +#endif +} // namespace port + Options::Options() { // Default is the value of the env for the package prefixes. const char* file_path = getenv("GPB_OBJC_EXPECTED_PACKAGE_PREFIXES"); @@ -90,7 +100,7 @@ bool ascii_isnewline(char c) { // Do not expose this outside of helpers, stick to having functions for specific // cases (ClassName(), FieldName()), so there is always consistent suffix rules. string UnderscoresToCamelCase(const string& input, bool first_capitalized) { - vector<string> values; + std::vector<string> values; string current; bool last_char_was_number = false; @@ -131,7 +141,7 @@ string UnderscoresToCamelCase(const string& input, bool first_capitalized) { string result; bool first_segment_forces_upper = false; - for (vector<string>::iterator i = values.begin(); i != values.end(); ++i) { + for (std::vector<string>::iterator i = values.begin(); i != values.end(); ++i) { string value = *i; bool all_upper = (kUpperSegments.count(value) > 0); if (all_upper && (result.length() == 0)) { @@ -196,7 +206,7 @@ const char* const kReservedWordList[] = { // method declared in protos. The main cases are methods // that take no arguments, or setFoo:/hasFoo: type methods. "clear", "data", "delimitedData", "descriptor", "extensionRegistry", - "extensionsCurrentlySet", "isInitialized", "serializedSize", + "extensionsCurrentlySet", "initialized", "isInitialized", "serializedSize", "sortedExtensionsInUse", "unknownFields", // MacTypes.h names @@ -854,7 +864,7 @@ bool HasNonZeroDefaultValue(const FieldDescriptor* field) { } string BuildFlagsString(const FlagType flag_type, - const vector<string>& strings) { + const std::vector<string>& strings) { if (strings.size() == 0) { return GetZeroEnumNameForFlagType(flag_type); } else if (strings.size() == 1) { @@ -876,7 +886,7 @@ string BuildCommentsString(const SourceLocation& location, const string& comments = location.leading_comments.empty() ? location.trailing_comments : location.leading_comments; - vector<string> lines; + std::vector<string> lines; SplitStringAllowEmpty(comments, "\n", &lines); while (!lines.empty() && lines.back().empty()) { lines.pop_back(); @@ -980,13 +990,13 @@ namespace { class ExpectedPrefixesCollector : public LineConsumer { public: - ExpectedPrefixesCollector(map<string, string>* inout_package_to_prefix_map) + ExpectedPrefixesCollector(std::map<string, string>* inout_package_to_prefix_map) : prefix_map_(inout_package_to_prefix_map) {} virtual bool ConsumeLine(const StringPiece& line, string* out_error); private: - map<string, string>* prefix_map_; + std::map<string, string>* prefix_map_; }; bool ExpectedPrefixesCollector::ConsumeLine( @@ -1009,7 +1019,7 @@ bool ExpectedPrefixesCollector::ConsumeLine( } bool LoadExpectedPackagePrefixes(const Options &generation_options, - map<string, string>* prefix_map, + std::map<string, string>* prefix_map, string* out_error) { if (generation_options.expected_prefixes_path.empty()) { return true; @@ -1023,7 +1033,7 @@ bool LoadExpectedPackagePrefixes(const Options &generation_options, bool ValidateObjCClassPrefix( const FileDescriptor* file, const string& expected_prefixes_path, - const map<string, string>& expected_package_prefixes, + const std::map<string, string>& expected_package_prefixes, string* out_error) { const string prefix = file->options().objc_class_prefix(); const string package = file->package(); @@ -1033,7 +1043,7 @@ bool ValidateObjCClassPrefix( // Check: Error - See if there was an expected prefix for the package and // report if it doesn't match (wrong or missing). - map<string, string>::const_iterator package_match = + std::map<string, string>::const_iterator package_match = expected_package_prefixes.find(package); if (package_match != expected_package_prefixes.end()) { // There was an entry, and... @@ -1082,7 +1092,7 @@ bool ValidateObjCClassPrefix( // Look for any other package that uses the same prefix. string other_package_for_prefix; - for (map<string, string>::const_iterator i = expected_package_prefixes.begin(); + for (std::map<string, string>::const_iterator i = expected_package_prefixes.begin(); i != expected_package_prefixes.end(); ++i) { if (i->second == prefix) { other_package_for_prefix = i->first; @@ -1146,11 +1156,11 @@ bool ValidateObjCClassPrefix( } // namespace -bool ValidateObjCClassPrefixes(const vector<const FileDescriptor*>& files, +bool ValidateObjCClassPrefixes(const std::vector<const FileDescriptor*>& files, const Options& generation_options, string* out_error) { // Load the expected package prefixes, if available, to validate against. - map<string, string> expected_package_prefixes; + std::map<string, string> expected_package_prefixes; if (!LoadExpectedPackagePrefixes(generation_options, &expected_package_prefixes, out_error)) { @@ -1177,7 +1187,7 @@ TextFormatDecodeData::~TextFormatDecodeData() { } void TextFormatDecodeData::AddString(int32 key, const string& input_for_decode, const string& desired_output) { - for (vector<DataEntry>::const_iterator i = entries_.begin(); + for (std::vector<DataEntry>::const_iterator i = entries_.begin(); i != entries_.end(); ++i) { if (i->first == key) { std::cerr << "error: duplicate key (" << key @@ -1201,7 +1211,7 @@ string TextFormatDecodeData::Data() const { io::CodedOutputStream output_stream(&data_outputstream); output_stream.WriteVarint32(num_entries()); - for (vector<DataEntry>::const_iterator i = entries_.begin(); + for (std::vector<DataEntry>::const_iterator i = entries_.begin(); i != entries_.end(); ++i) { output_stream.WriteVarint32(i->first); output_stream.WriteString(i->second); @@ -1464,7 +1474,7 @@ bool ParseSimpleFile( const string& path, LineConsumer* line_consumer, string* out_error) { int fd; do { - fd = open(path.c_str(), O_RDONLY); + fd = posix::open(path.c_str(), O_RDONLY); } while (fd < 0 && errno == EINTR); if (fd < 0) { *out_error = @@ -1519,7 +1529,7 @@ void ImportWriter::AddFile(const FileDescriptor* file, ParseFrameworkMappings(); } - map<string, string>::iterator proto_lookup = + std::map<string, string>::iterator proto_lookup = proto_file_to_framework_name_.find(file->name()); if (proto_lookup != proto_file_to_framework_name_.end()) { other_framework_imports_.push_back( @@ -1551,7 +1561,7 @@ void ImportWriter::Print(io::Printer* printer) const { printer->Print( "#if $cpp_symbol$\n", "cpp_symbol", cpp_symbol); - for (vector<string>::const_iterator iter = protobuf_framework_imports_.begin(); + for (std::vector<string>::const_iterator iter = protobuf_framework_imports_.begin(); iter != protobuf_framework_imports_.end(); ++iter) { printer->Print( " #import <$framework_name$/$header$>\n", @@ -1560,7 +1570,7 @@ void ImportWriter::Print(io::Printer* printer) const { } printer->Print( "#else\n"); - for (vector<string>::const_iterator iter = protobuf_non_framework_imports_.begin(); + for (std::vector<string>::const_iterator iter = protobuf_non_framework_imports_.begin(); iter != protobuf_non_framework_imports_.end(); ++iter) { printer->Print( " #import \"$header$\"\n", @@ -1577,10 +1587,10 @@ void ImportWriter::Print(io::Printer* printer) const { printer->Print("\n"); } - for (vector<string>::const_iterator iter = other_framework_imports_.begin(); + for (std::vector<string>::const_iterator iter = other_framework_imports_.begin(); iter != other_framework_imports_.end(); ++iter) { printer->Print( - " #import <$header$>\n", + "#import <$header$>\n", "header", *iter); } @@ -1592,10 +1602,10 @@ void ImportWriter::Print(io::Printer* printer) const { printer->Print("\n"); } - for (vector<string>::const_iterator iter = other_imports_.begin(); + for (std::vector<string>::const_iterator iter = other_imports_.begin(); iter != other_imports_.end(); ++iter) { printer->Print( - " #import \"$header$\"\n", + "#import \"$header$\"\n", "header", *iter); } } @@ -1640,7 +1650,7 @@ bool ImportWriter::ProtoFrameworkCollector::ConsumeLine( StringPiece proto_file(proto_file_list, start, offset - start); StringPieceTrimWhitespace(&proto_file); if (proto_file.size() != 0) { - map<string, string>::iterator existing_entry = + std::map<string, string>::iterator existing_entry = map_->find(proto_file.ToString()); if (existing_entry != map_->end()) { std::cerr << "warning: duplicate proto file reference, replacing framework entry for '" diff --git a/src/google/protobuf/compiler/objectivec/objectivec_helpers.h b/src/google/protobuf/compiler/objectivec/objectivec_helpers.h index c99262a1..f74607c8 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_helpers.h +++ b/src/google/protobuf/compiler/objectivec/objectivec_helpers.h @@ -190,7 +190,7 @@ string LIBPROTOC_EXPORT GPBGenericValueFieldName(const FieldDescriptor* field); string LIBPROTOC_EXPORT DefaultValue(const FieldDescriptor* field); bool LIBPROTOC_EXPORT HasNonZeroDefaultValue(const FieldDescriptor* field); -string LIBPROTOC_EXPORT BuildFlagsString(const FlagType type, const vector<string>& strings); +string LIBPROTOC_EXPORT BuildFlagsString(const FlagType type, const std::vector<string>& strings); // Builds HeaderDoc/appledoc style comments out of the comments in the .proto // file. @@ -210,7 +210,7 @@ bool LIBPROTOC_EXPORT IsProtobufLibraryBundledProtoFile(const FileDescriptor* fi // Checks the prefix for the given files and outputs any warnings as needed. If // there are flat out errors, then out_error is filled in with the first error // and the result is false. -bool LIBPROTOC_EXPORT ValidateObjCClassPrefixes(const vector<const FileDescriptor*>& files, +bool LIBPROTOC_EXPORT ValidateObjCClassPrefixes(const std::vector<const FileDescriptor*>& files, const Options& generation_options, string* out_error); @@ -233,7 +233,7 @@ class LIBPROTOC_EXPORT TextFormatDecodeData { GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(TextFormatDecodeData); typedef std::pair<int32, string> DataEntry; - vector<DataEntry> entries_; + std::vector<DataEntry> entries_; }; // Helper for parsing simple files. @@ -262,26 +262,26 @@ class LIBPROTOC_EXPORT ImportWriter { private: class ProtoFrameworkCollector : public LineConsumer { public: - ProtoFrameworkCollector(map<string, string>* inout_proto_file_to_framework_name) + ProtoFrameworkCollector(std::map<string, string>* inout_proto_file_to_framework_name) : map_(inout_proto_file_to_framework_name) {} virtual bool ConsumeLine(const StringPiece& line, string* out_error); private: - map<string, string>* map_; + std::map<string, string>* map_; }; void ParseFrameworkMappings(); const string generate_for_named_framework_; const string named_framework_to_proto_path_mappings_path_; - map<string, string> proto_file_to_framework_name_; + std::map<string, string> proto_file_to_framework_name_; bool need_to_parse_mapping_file_; - vector<string> protobuf_framework_imports_; - vector<string> protobuf_non_framework_imports_; - vector<string> other_framework_imports_; - vector<string> other_imports_; + std::vector<string> protobuf_framework_imports_; + std::vector<string> protobuf_non_framework_imports_; + std::vector<string> other_framework_imports_; + std::vector<string> other_imports_; }; } // namespace objectivec diff --git a/src/google/protobuf/compiler/objectivec/objectivec_map_field.cc b/src/google/protobuf/compiler/objectivec/objectivec_map_field.cc index 0bc9dc10..bcaf5709 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_map_field.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_map_field.cc @@ -162,7 +162,7 @@ void MapFieldGenerator::FinishInitialization(void) { } void MapFieldGenerator::DetermineForwardDeclarations( - set<string>* fwd_decls) const { + std::set<string>* fwd_decls) const { RepeatedFieldGenerator::DetermineForwardDeclarations(fwd_decls); const FieldDescriptor* value_descriptor = descriptor_->message_type()->FindFieldByName("value"); diff --git a/src/google/protobuf/compiler/objectivec/objectivec_map_field.h b/src/google/protobuf/compiler/objectivec/objectivec_map_field.h index bc68a682..6664d849 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_map_field.h +++ b/src/google/protobuf/compiler/objectivec/objectivec_map_field.h @@ -51,7 +51,7 @@ class MapFieldGenerator : public RepeatedFieldGenerator { MapFieldGenerator(const FieldDescriptor* descriptor, const Options& options); virtual ~MapFieldGenerator(); - virtual void DetermineForwardDeclarations(set<string>* fwd_decls) const; + virtual void DetermineForwardDeclarations(std::set<string>* fwd_decls) const; private: scoped_ptr<FieldGenerator> value_field_generator_; diff --git a/src/google/protobuf/compiler/objectivec/objectivec_message.cc b/src/google/protobuf/compiler/objectivec/objectivec_message.cc index 0a554a83..f1465c3e 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_message.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_message.cc @@ -220,20 +220,20 @@ MessageGenerator::~MessageGenerator() { void MessageGenerator::GenerateStaticVariablesInitialization( io::Printer* printer) { - for (vector<ExtensionGenerator*>::iterator iter = + for (std::vector<ExtensionGenerator*>::iterator iter = extension_generators_.begin(); iter != extension_generators_.end(); ++iter) { (*iter)->GenerateStaticVariablesInitialization(printer); } - for (vector<MessageGenerator*>::iterator iter = + for (std::vector<MessageGenerator*>::iterator iter = nested_message_generators_.begin(); iter != nested_message_generators_.end(); ++iter) { (*iter)->GenerateStaticVariablesInitialization(printer); } } -void MessageGenerator::DetermineForwardDeclarations(set<string>* fwd_decls) { +void MessageGenerator::DetermineForwardDeclarations(std::set<string>* fwd_decls) { if (!IsMapEntryMessage(descriptor_)) { for (int i = 0; i < descriptor_->field_count(); i++) { const FieldDescriptor* fieldDescriptor = descriptor_->field(i); @@ -242,7 +242,7 @@ void MessageGenerator::DetermineForwardDeclarations(set<string>* fwd_decls) { } } - for (vector<MessageGenerator*>::iterator iter = + for (std::vector<MessageGenerator*>::iterator iter = nested_message_generators_.begin(); iter != nested_message_generators_.end(); ++iter) { (*iter)->DetermineForwardDeclarations(fwd_decls); @@ -254,7 +254,7 @@ bool MessageGenerator::IncludesOneOfDefinition() const { return true; } - for (vector<MessageGenerator*>::const_iterator iter = + for (std::vector<MessageGenerator*>::const_iterator iter = nested_message_generators_.begin(); iter != nested_message_generators_.end(); ++iter) { if ((*iter)->IncludesOneOfDefinition()) { @@ -266,12 +266,12 @@ bool MessageGenerator::IncludesOneOfDefinition() const { } void MessageGenerator::GenerateEnumHeader(io::Printer* printer) { - for (vector<EnumGenerator*>::iterator iter = enum_generators_.begin(); + for (std::vector<EnumGenerator*>::iterator iter = enum_generators_.begin(); iter != enum_generators_.end(); ++iter) { (*iter)->GenerateHeader(printer); } - for (vector<MessageGenerator*>::iterator iter = + for (std::vector<MessageGenerator*>::iterator iter = nested_message_generators_.begin(); iter != nested_message_generators_.end(); ++iter) { (*iter)->GenerateEnumHeader(printer); @@ -280,13 +280,13 @@ void MessageGenerator::GenerateEnumHeader(io::Printer* printer) { void MessageGenerator::GenerateExtensionRegistrationSource( io::Printer* printer) { - for (vector<ExtensionGenerator*>::iterator iter = + for (std::vector<ExtensionGenerator*>::iterator iter = extension_generators_.begin(); iter != extension_generators_.end(); ++iter) { (*iter)->GenerateRegistrationSource(printer); } - for (vector<MessageGenerator*>::iterator iter = + for (std::vector<MessageGenerator*>::iterator iter = nested_message_generators_.begin(); iter != nested_message_generators_.end(); ++iter) { (*iter)->GenerateExtensionRegistrationSource(printer); @@ -296,7 +296,7 @@ void MessageGenerator::GenerateExtensionRegistrationSource( void MessageGenerator::GenerateMessageHeader(io::Printer* printer) { // This a a map entry message, just recurse and do nothing directly. if (IsMapEntryMessage(descriptor_)) { - for (vector<MessageGenerator*>::iterator iter = + for (std::vector<MessageGenerator*>::iterator iter = nested_message_generators_.begin(); iter != nested_message_generators_.end(); ++iter) { (*iter)->GenerateMessageHeader(printer); @@ -326,7 +326,7 @@ void MessageGenerator::GenerateMessageHeader(io::Printer* printer) { printer->Print("};\n\n"); } - for (vector<OneofGenerator*>::iterator iter = oneof_generators_.begin(); + for (std::vector<OneofGenerator*>::iterator iter = oneof_generators_.begin(); iter != oneof_generators_.end(); ++iter) { (*iter)->GenerateCaseEnum(printer); } @@ -345,7 +345,7 @@ void MessageGenerator::GenerateMessageHeader(io::Printer* printer) { "deprecated_attribute", deprecated_attribute_, "comments", message_comments); - vector<char> seen_oneofs(descriptor_->oneof_decl_count(), 0); + std::vector<char> seen_oneofs(descriptor_->oneof_decl_count(), 0); for (int i = 0; i < descriptor_->field_count(); i++) { const FieldDescriptor* field = descriptor_->field(i); if (field->containing_oneof() != NULL) { @@ -367,7 +367,7 @@ void MessageGenerator::GenerateMessageHeader(io::Printer* printer) { } if (!oneof_generators_.empty()) { - for (vector<OneofGenerator*>::iterator iter = oneof_generators_.begin(); + for (std::vector<OneofGenerator*>::iterator iter = oneof_generators_.begin(); iter != oneof_generators_.end(); ++iter) { (*iter)->GenerateClearFunctionDeclaration(printer); } @@ -377,7 +377,7 @@ void MessageGenerator::GenerateMessageHeader(io::Printer* printer) { if (descriptor_->extension_count() > 0) { printer->Print("@interface $classname$ (DynamicMethods)\n\n", "classname", class_name_); - for (vector<ExtensionGenerator*>::iterator iter = + for (std::vector<ExtensionGenerator*>::iterator iter = extension_generators_.begin(); iter != extension_generators_.end(); ++iter) { (*iter)->GenerateMembersHeader(printer); @@ -385,7 +385,7 @@ void MessageGenerator::GenerateMessageHeader(io::Printer* printer) { printer->Print("@end\n\n"); } - for (vector<MessageGenerator*>::iterator iter = + for (std::vector<MessageGenerator*>::iterator iter = nested_message_generators_.begin(); iter != nested_message_generators_.end(); ++iter) { (*iter)->GenerateMessageHeader(printer); @@ -410,7 +410,7 @@ void MessageGenerator::GenerateSource(io::Printer* printer) { printer->Print("@implementation $classname$\n\n", "classname", class_name_); - for (vector<OneofGenerator*>::iterator iter = oneof_generators_.begin(); + for (std::vector<OneofGenerator*>::iterator iter = oneof_generators_.begin(); iter != oneof_generators_.end(); ++iter) { (*iter)->GeneratePropertyImplementation(printer); } @@ -425,7 +425,7 @@ void MessageGenerator::GenerateSource(io::Printer* printer) { scoped_array<const FieldDescriptor*> size_order_fields( SortFieldsByStorageSize(descriptor_)); - vector<const Descriptor::ExtensionRange*> sorted_extensions; + std::vector<const Descriptor::ExtensionRange*> sorted_extensions; for (int i = 0; i < descriptor_->extension_range_count(); ++i) { sorted_extensions.push_back(descriptor_->extension_range(i)); } @@ -448,7 +448,7 @@ void MessageGenerator::GenerateSource(io::Printer* printer) { sizeof_has_storage = 1; } // Tell all the fields the oneof base. - for (vector<OneofGenerator*>::iterator iter = oneof_generators_.begin(); + for (std::vector<OneofGenerator*>::iterator iter = oneof_generators_.begin(); iter != oneof_generators_.end(); ++iter) { (*iter)->SetOneofIndexBase(sizeof_has_storage); } @@ -514,7 +514,7 @@ void MessageGenerator::GenerateSource(io::Printer* printer) { " };\n"); } - map<string, string> vars; + std::map<string, string> vars; vars["classname"] = class_name_; vars["rootclassname"] = root_classname_; vars["fields"] = has_fields ? "fields" : "NULL"; @@ -548,7 +548,7 @@ void MessageGenerator::GenerateSource(io::Printer* printer) { if (oneof_generators_.size() != 0) { printer->Print( " static const char *oneofs[] = {\n"); - for (vector<OneofGenerator*>::iterator iter = oneof_generators_.begin(); + for (std::vector<OneofGenerator*>::iterator iter = oneof_generators_.begin(); iter != oneof_generators_.end(); ++iter) { printer->Print( " \"$name$\",\n", @@ -623,18 +623,18 @@ void MessageGenerator::GenerateSource(io::Printer* printer) { .GenerateCFunctionImplementations(printer); } - for (vector<OneofGenerator*>::iterator iter = oneof_generators_.begin(); + for (std::vector<OneofGenerator*>::iterator iter = oneof_generators_.begin(); iter != oneof_generators_.end(); ++iter) { (*iter)->GenerateClearFunctionImplementation(printer); } } - for (vector<EnumGenerator*>::iterator iter = enum_generators_.begin(); + for (std::vector<EnumGenerator*>::iterator iter = enum_generators_.begin(); iter != enum_generators_.end(); ++iter) { (*iter)->GenerateSource(printer); } - for (vector<MessageGenerator*>::iterator iter = + for (std::vector<MessageGenerator*>::iterator iter = nested_message_generators_.begin(); iter != nested_message_generators_.end(); ++iter) { (*iter)->GenerateSource(printer); diff --git a/src/google/protobuf/compiler/objectivec/objectivec_message.h b/src/google/protobuf/compiler/objectivec/objectivec_message.h index 0fb78bc0..2de03f12 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_message.h +++ b/src/google/protobuf/compiler/objectivec/objectivec_message.h @@ -64,7 +64,7 @@ class MessageGenerator { void GenerateMessageHeader(io::Printer* printer); void GenerateSource(io::Printer* printer); void GenerateExtensionRegistrationSource(io::Printer* printer); - void DetermineForwardDeclarations(set<string>* fwd_decls); + void DetermineForwardDeclarations(std::set<string>* fwd_decls); // Checks if the message or a nested message includes a oneof definition. bool IncludesOneOfDefinition() const; @@ -86,10 +86,10 @@ class MessageGenerator { FieldGeneratorMap field_generators_; const string class_name_; const string deprecated_attribute_; - vector<ExtensionGenerator*> extension_generators_; - vector<EnumGenerator*> enum_generators_; - vector<MessageGenerator*> nested_message_generators_; - vector<OneofGenerator*> oneof_generators_; + std::vector<ExtensionGenerator*> extension_generators_; + std::vector<EnumGenerator*> enum_generators_; + std::vector<MessageGenerator*> nested_message_generators_; + std::vector<OneofGenerator*> oneof_generators_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageGenerator); }; diff --git a/src/google/protobuf/compiler/objectivec/objectivec_message_field.cc b/src/google/protobuf/compiler/objectivec/objectivec_message_field.cc index d6ccd6d1..699d25b3 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_message_field.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_message_field.cc @@ -45,7 +45,7 @@ namespace objectivec { namespace { void SetMessageVariables(const FieldDescriptor* descriptor, - map<string, string>* variables) { + std::map<string, string>* variables) { const string& message_type = ClassName(descriptor->message_type()); (*variables)["type"] = message_type; (*variables)["containing_class"] = ClassName(descriptor->containing_type()); @@ -67,7 +67,7 @@ MessageFieldGenerator::MessageFieldGenerator(const FieldDescriptor* descriptor, MessageFieldGenerator::~MessageFieldGenerator() {} void MessageFieldGenerator::DetermineForwardDeclarations( - set<string>* fwd_decls) const { + std::set<string>* fwd_decls) const { ObjCObjFieldGenerator::DetermineForwardDeclarations(fwd_decls); // Class name is already in "storage_type". fwd_decls->insert("@class " + variable("storage_type")); @@ -95,7 +95,7 @@ RepeatedMessageFieldGenerator::RepeatedMessageFieldGenerator( RepeatedMessageFieldGenerator::~RepeatedMessageFieldGenerator() {} void RepeatedMessageFieldGenerator::DetermineForwardDeclarations( - set<string>* fwd_decls) const { + std::set<string>* fwd_decls) const { RepeatedFieldGenerator::DetermineForwardDeclarations(fwd_decls); // Class name is already in "storage_type". fwd_decls->insert("@class " + variable("storage_type")); diff --git a/src/google/protobuf/compiler/objectivec/objectivec_message_field.h b/src/google/protobuf/compiler/objectivec/objectivec_message_field.h index d2dba153..50f4b6d4 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_message_field.h +++ b/src/google/protobuf/compiler/objectivec/objectivec_message_field.h @@ -51,7 +51,7 @@ class MessageFieldGenerator : public ObjCObjFieldGenerator { virtual bool WantsHasProperty(void) const; public: - virtual void DetermineForwardDeclarations(set<string>* fwd_decls) const; + virtual void DetermineForwardDeclarations(std::set<string>* fwd_decls) const; private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageFieldGenerator); @@ -67,7 +67,7 @@ class RepeatedMessageFieldGenerator : public RepeatedFieldGenerator { virtual ~RepeatedMessageFieldGenerator(); public: - virtual void DetermineForwardDeclarations(set<string>* fwd_decls) const; + virtual void DetermineForwardDeclarations(std::set<string>* fwd_decls) const; private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedMessageFieldGenerator); diff --git a/src/google/protobuf/compiler/objectivec/objectivec_oneof.h b/src/google/protobuf/compiler/objectivec/objectivec_oneof.h index 3d9df4db..ff353a6c 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_oneof.h +++ b/src/google/protobuf/compiler/objectivec/objectivec_oneof.h @@ -67,7 +67,7 @@ class OneofGenerator { private: const OneofDescriptor* descriptor_; - map<string, string> variables_; + std::map<string, string> variables_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(OneofGenerator); }; diff --git a/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc b/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc index d49350f4..aa8ac324 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc @@ -118,7 +118,7 @@ const char* PrimitiveArrayTypeName(const FieldDescriptor* descriptor) { } void SetPrimitiveVariables(const FieldDescriptor* descriptor, - map<string, string>* variables) { + std::map<string, string>* variables) { std::string primitive_name = PrimitiveTypeName(descriptor); (*variables)["type"] = primitive_name; (*variables)["storage_type"] = primitive_name; diff --git a/src/google/protobuf/compiler/parser.cc b/src/google/protobuf/compiler/parser.cc index 1a409566..03d05ad4 100644 --- a/src/google/protobuf/compiler/parser.cc +++ b/src/google/protobuf/compiler/parser.cc @@ -664,7 +664,7 @@ bool Parser::ParseMessageDefinition( namespace { -const int kMaxExtensionRangeSentinel = -1; +const int kMaxRangeSentinel = -1; bool IsMessageSetWireFormatMessage(const DescriptorProto& message) { const MessageOptions& options = message.options(); @@ -688,12 +688,27 @@ void AdjustExtensionRangesWithMaxEndNumber(DescriptorProto* message) { kint32max : FieldDescriptor::kMaxNumber + 1; for (int i = 0; i < message->extension_range_size(); ++i) { - if (message->extension_range(i).end() == kMaxExtensionRangeSentinel) { + if (message->extension_range(i).end() == kMaxRangeSentinel) { message->mutable_extension_range(i)->set_end(max_extension_number); } } } +// Modifies any reserved ranges that specified 'max' as the end of the +// reserved range, and sets them to the type-specific maximum. The actual max +// tag number can only be determined after all options have been parsed. +void AdjustReservedRangesWithMaxEndNumber(DescriptorProto* message) { + const bool is_message_set = IsMessageSetWireFormatMessage(*message); + const int max_field_number = is_message_set ? + kint32max : + FieldDescriptor::kMaxNumber + 1; + for (int i = 0; i < message->reserved_range_size(); ++i) { + if (message->reserved_range(i).end() == kMaxRangeSentinel) { + message->mutable_reserved_range(i)->set_end(max_field_number); + } + } +} + } // namespace bool Parser::ParseMessageBlock(DescriptorProto* message, @@ -717,6 +732,9 @@ bool Parser::ParseMessageBlock(DescriptorProto* message, if (message->extension_range_size() > 0) { AdjustExtensionRangesWithMaxEndNumber(message); } + if (message->reserved_range_size() > 0) { + AdjustReservedRangesWithMaxEndNumber(message); + } return true; } @@ -1429,6 +1447,8 @@ bool Parser::ParseExtensions(DescriptorProto* message, // Parse the declaration. DO(Consume("extensions")); + int old_range_size = message->extension_range_size(); + do { // Note that kExtensionRangeFieldNumber was already pushed by the parent. LocationRecorder location(extensions_location, @@ -1455,7 +1475,7 @@ bool Parser::ParseExtensions(DescriptorProto* message, // Set to the sentinel value - 1 since we increment the value below. // The actual value of the end of the range should be set with // AdjustExtensionRangesWithMaxEndNumber. - end = kMaxExtensionRangeSentinel - 1; + end = kMaxRangeSentinel - 1; } else { DO(ConsumeInteger(&end, "Expected integer.")); } @@ -1475,12 +1495,36 @@ bool Parser::ParseExtensions(DescriptorProto* message, range->set_end(end); } while (TryConsume(",")); + if (LookingAt("[")) { + LocationRecorder location( + extensions_location, + DescriptorProto::ExtensionRange::kOptionsFieldNumber); + + DO(Consume("[")); + + // Parse extension range options in the first range. + ExtensionRangeOptions* options = + message->mutable_extension_range(old_range_size)->mutable_options(); + do { + DO(ParseOption(options, location, containing_file, OPTION_ASSIGNMENT)); + } while (TryConsume(",")); + + DO(Consume("]")); + + // Then copy the extension range options to all of the other ranges we've + // parsed. + for (int i = old_range_size + 1; i < message->extension_range_size(); i++) { + message->mutable_extension_range(i)->mutable_options() + ->CopyFrom(*options); + } + } + DO(ConsumeEndOfDeclaration(";", &extensions_location)); return true; } -// This is similar to extension range parsing, except that "max" is not -// supported, and accepts field name literals. +// This is similar to extension range parsing, except that it accepts field +// name literals. bool Parser::ParseReserved(DescriptorProto* message, const LocationRecorder& message_location) { // Parse the declaration. @@ -1496,7 +1540,6 @@ bool Parser::ParseReserved(DescriptorProto* message, } } - bool Parser::ParseReservedNames(DescriptorProto* message, const LocationRecorder& parent_location) { do { @@ -1528,7 +1571,14 @@ bool Parser::ParseReservedNumbers(DescriptorProto* message, if (TryConsume("to")) { LocationRecorder end_location( location, DescriptorProto::ReservedRange::kEndFieldNumber); - DO(ConsumeInteger(&end, "Expected integer.")); + if (TryConsume("max")) { + // Set to the sentinel value - 1 since we increment the value below. + // The actual value of the end of the range should be set with + // AdjustExtensionRangesWithMaxEndNumber. + end = kMaxRangeSentinel - 1; + } else { + DO(ConsumeInteger(&end, "Expected integer.")); + } } else { LocationRecorder end_location( location, DescriptorProto::ReservedRange::kEndFieldNumber); @@ -1550,6 +1600,81 @@ bool Parser::ParseReservedNumbers(DescriptorProto* message, return true; } +bool Parser::ParseReserved(EnumDescriptorProto* message, + const LocationRecorder& message_location) { + // Parse the declaration. + DO(Consume("reserved")); + if (LookingAtType(io::Tokenizer::TYPE_STRING)) { + LocationRecorder location(message_location, + DescriptorProto::kReservedNameFieldNumber); + return ParseReservedNames(message, location); + } else { + LocationRecorder location(message_location, + DescriptorProto::kReservedRangeFieldNumber); + return ParseReservedNumbers(message, location); + } +} + +bool Parser::ParseReservedNames(EnumDescriptorProto* message, + const LocationRecorder& parent_location) { + do { + LocationRecorder location(parent_location, message->reserved_name_size()); + DO(ConsumeString(message->add_reserved_name(), "Expected enum value.")); + } while (TryConsume(",")); + DO(ConsumeEndOfDeclaration(";", &parent_location)); + return true; +} + +bool Parser::ParseReservedNumbers(EnumDescriptorProto* message, + const LocationRecorder& parent_location) { + bool first = true; + do { + LocationRecorder location(parent_location, message->reserved_range_size()); + + EnumDescriptorProto::EnumReservedRange* range = + message->add_reserved_range(); + int start, end; + io::Tokenizer::Token start_token; + { + LocationRecorder start_location( + location, EnumDescriptorProto::EnumReservedRange::kStartFieldNumber); + start_token = input_->current(); + DO(ConsumeSignedInteger(&start, (first ? + "Expected enum value or number range." : + "Expected enum number range."))); + } + + if (TryConsume("to")) { + LocationRecorder end_location( + location, EnumDescriptorProto::EnumReservedRange::kEndFieldNumber); + if (TryConsume("max")) { + // This is in the enum descriptor path, which doesn't have the message + // set duality to fix up, so it doesn't integrate with the sentinel. + + // Evaluate 'max' to INT_MAX - 1 so that incrementing to create the + // exclusive range end doesn't cause an overflow. + // Note, this prevents reserving the actual INT_MAX enum value. + end = INT_MAX; + } else { + DO(ConsumeSignedInteger(&end, "Expected integer.")); + } + } else { + LocationRecorder end_location( + location, EnumDescriptorProto::EnumReservedRange::kEndFieldNumber); + end_location.StartAt(start_token); + end_location.EndAt(start_token); + end = start; + } + + range->set_start(start); + range->set_end(end); + first = false; + } while (TryConsume(",")); + + DO(ConsumeEndOfDeclaration(";", &parent_location)); + return true; +} + bool Parser::ParseExtend(RepeatedPtrField<FieldDescriptorProto>* extensions, RepeatedPtrField<DescriptorProto>* messages, const LocationRecorder& parent_location, @@ -1730,6 +1855,8 @@ bool Parser::ParseEnumStatement(EnumDescriptorProto* enum_type, EnumDescriptorProto::kOptionsFieldNumber); return ParseOption(enum_type->mutable_options(), location, containing_file, OPTION_STATEMENT); + } else if (LookingAt("reserved")) { + return ParseReserved(enum_type, enum_location); } else { LocationRecorder location(enum_location, EnumDescriptorProto::kValueFieldNumber, enum_type->value_size()); @@ -2116,4 +2243,5 @@ void SourceLocationTable::Clear() { } // namespace compiler } // namespace protobuf + } // namespace google diff --git a/src/google/protobuf/compiler/parser.h b/src/google/protobuf/compiler/parser.h index dd8b6586..33b4c700 100644 --- a/src/google/protobuf/compiler/parser.h +++ b/src/google/protobuf/compiler/parser.h @@ -371,6 +371,12 @@ class LIBPROTOBUF_EXPORT Parser { const LocationRecorder& parent_location); bool ParseReservedNumbers(DescriptorProto* message, const LocationRecorder& parent_location); + bool ParseReserved(EnumDescriptorProto* message, + const LocationRecorder& message_location); + bool ParseReservedNames(EnumDescriptorProto* message, + const LocationRecorder& parent_location); + bool ParseReservedNumbers(EnumDescriptorProto* message, + const LocationRecorder& parent_location); // Parse an "extend" declaration. (See also comments for // ParseMessageField().) diff --git a/src/google/protobuf/compiler/parser_unittest.cc b/src/google/protobuf/compiler/parser_unittest.cc index d5e31325..9b59842e 100644 --- a/src/google/protobuf/compiler/parser_unittest.cc +++ b/src/google/protobuf/compiler/parser_unittest.cc @@ -663,7 +663,7 @@ TEST_F(ParseMessageTest, ReservedRange) { ExpectParsesTo( "message TestMessage {\n" " required int32 foo = 1;\n" - " reserved 2, 15, 9 to 11, 3;\n" + " reserved 2, 15, 9 to 11, 3, 20 to max;\n" "}\n", "message_type {" @@ -673,6 +673,29 @@ TEST_F(ParseMessageTest, ReservedRange) { " reserved_range { start:15 end:16 }" " reserved_range { start:9 end:12 }" " reserved_range { start:3 end:4 }" + " reserved_range { start:20 end:536870912 }" + "}"); +} + +TEST_F(ParseMessageTest, ReservedRangeOnMessageSet) { + ExpectParsesTo( + "message TestMessage {\n" + " option message_set_wire_format = true;\n" + " reserved 20 to max;\n" + "}\n", + + "message_type {" + " name: \"TestMessage\"" + " options {" + " uninterpreted_option {" + " name {" + " name_part: \"message_set_wire_format\"" + " is_extension: false" + " }" + " identifier_value: \"true\"" + " }" + " }" + " reserved_range { start:20 end:2147483647 }" "}"); } @@ -703,6 +726,30 @@ TEST_F(ParseMessageTest, ExtensionRange) { "}"); } +TEST_F(ParseMessageTest, ExtensionRangeWithOptions) { + ExpectParsesTo( + "message TestMessage {\n" + " extensions 10 to 19 [(i) = 5];\n" + "}\n", + + "message_type {" + " name: \"TestMessage\"" + " extension_range {" + " start:10" + " end:20" + " options {" + " uninterpreted_option {" + " name {" + " name_part: \"i\"" + " is_extension: true" + " }" + " positive_int_value: 5" + " }" + " }" + " }" + "}"); +} + TEST_F(ParseMessageTest, CompoundExtensionRange) { ExpectParsesTo( "message TestMessage {\n" @@ -719,6 +766,82 @@ TEST_F(ParseMessageTest, CompoundExtensionRange) { "}"); } +TEST_F(ParseMessageTest, CompoundExtensionRangeWithOptions) { + ExpectParsesTo( + "message TestMessage {\n" + " extensions 2, 15, 9 to 11, 100 to max, 3 [(i) = 5];\n" + "}\n", + + "message_type {" + " name: \"TestMessage\"" + " extension_range {" + " start:2" + " end:3" + " options {" + " uninterpreted_option {" + " name {" + " name_part: \"i\"" + " is_extension: true" + " }" + " positive_int_value: 5" + " }" + " }" + " }" + " extension_range {" + " start:15" + " end:16" + " options {" + " uninterpreted_option {" + " name {" + " name_part: \"i\"" + " is_extension: true" + " }" + " positive_int_value: 5" + " }" + " }" + " }" + " extension_range {" + " start:9" + " end:12" + " options {" + " uninterpreted_option {" + " name {" + " name_part: \"i\"" + " is_extension: true" + " }" + " positive_int_value: 5" + " }" + " }" + " }" + " extension_range {" + " start:100" + " end:536870912" + " options {" + " uninterpreted_option {" + " name {" + " name_part: \"i\"" + " is_extension: true" + " }" + " positive_int_value: 5" + " }" + " }" + " }" + " extension_range {" + " start:3" + " end:4" + " options {" + " uninterpreted_option {" + " name {" + " name_part: \"i\"" + " is_extension: true" + " }" + " positive_int_value: 5" + " }" + " }" + " }" + "}"); +} + TEST_F(ParseMessageTest, LargerMaxForMessageSetWireFormatMessages) { // Messages using the message_set_wire_format option can accept larger // extension numbers, as the numbers are not encoded as int32 field values @@ -871,6 +994,42 @@ TEST_F(ParseEnumTest, ValueOptions) { "}"); } +TEST_F(ParseEnumTest, ReservedRange) { + ExpectParsesTo( + "enum TestEnum {\n" + " FOO = 0;\n" + " reserved -2147483648, -6 to -4, -1 to 1, 2, 15, 9 to 11, 3, 20 to max;\n" + "}\n", + + "enum_type {" + " name: \"TestEnum\"" + " value { name:\"FOO\" number:0 }" + " reserved_range { start:-2147483648 end:-2147483648 }" + " reserved_range { start:-6 end:-4 }" + " reserved_range { start:-1 end:1 }" + " reserved_range { start:2 end:2 }" + " reserved_range { start:15 end:15 }" + " reserved_range { start:9 end:11 }" + " reserved_range { start:3 end:3 }" + " reserved_range { start:20 end:2147483647 }" + "}"); +} + +TEST_F(ParseEnumTest, ReservedNames) { + ExpectParsesTo( + "enum TestEnum {\n" + " FOO = 0;\n" + " reserved \"foo\", \"bar\";\n" + "}\n", + + "enum_type {" + " name: \"TestEnum\"" + " value { name:\"FOO\" number:0 }" + " reserved_name: \"foo\"" + " reserved_name: \"bar\"" + "}"); +} + // =================================================================== typedef ParserTest ParseServiceTest; @@ -1365,15 +1524,60 @@ TEST_F(ParseErrorTest, EnumValueMissingNumber) { "1:5: Missing numeric value for enum constant.\n"); } +TEST_F(ParseErrorTest, EnumReservedStandaloneMaxNotAllowed) { + ExpectHasErrors( + "enum TestEnum {\n" + " FOO = 1;\n" + " reserved max;\n" + "}\n", + "2:11: Expected enum value or number range.\n"); +} + +TEST_F(ParseErrorTest, EnumReservedMixNameAndNumber) { + ExpectHasErrors( + "enum TestEnum {\n" + " FOO = 1;\n" + " reserved 10, \"foo\";\n" + "}\n", + "2:15: Expected enum number range.\n"); +} + +TEST_F(ParseErrorTest, EnumReservedPositiveNumberOutOfRange) { + ExpectHasErrors( + "enum TestEnum {\n" + "FOO = 1;\n" + " reserved 2147483648;\n" + "}\n", + "2:11: Integer out of range.\n"); +} + +TEST_F(ParseErrorTest, EnumReservedNegativeNumberOutOfRange) { + ExpectHasErrors( + "enum TestEnum {\n" + "FOO = 1;\n" + " reserved -2147483649;\n" + "}\n", + "2:12: Integer out of range.\n"); +} + +TEST_F(ParseErrorTest, EnumReservedMissingQuotes) { + ExpectHasErrors( + "enum TestEnum {\n" + " FOO = 1;\n" + " reserved foo;\n" + "}\n", + "2:11: Expected enum value or number range.\n"); +} + // ------------------------------------------------------------------- // Reserved field number errors -TEST_F(ParseErrorTest, ReservedMaxNotAllowed) { +TEST_F(ParseErrorTest, ReservedStandaloneMaxNotAllowed) { ExpectHasErrors( "message Foo {\n" - " reserved 10 to max;\n" + " reserved max;\n" "}\n", - "1:17: Expected integer.\n"); + "1:11: Expected field name or number range.\n"); } TEST_F(ParseErrorTest, ReservedMixNameAndNumber) { @@ -1392,6 +1596,23 @@ TEST_F(ParseErrorTest, ReservedMissingQuotes) { "1:11: Expected field name or number range.\n"); } +TEST_F(ParseErrorTest, ReservedNegativeNumber) { + ExpectHasErrors( + "message Foo {\n" + " reserved -10;\n" + "}\n", + "1:11: Expected field name or number range.\n"); +} + +TEST_F(ParseErrorTest, ReservedNumberOutOfRange) { + ExpectHasErrors( + "message Foo {\n" + " reserved 2147483648;\n" + "}\n", + "1:11: Integer out of range.\n"); +} + + // ------------------------------------------------------------------- // Service errors diff --git a/src/google/protobuf/compiler/php/php_generator.cc b/src/google/protobuf/compiler/php/php_generator.cc index 78252817..eefdb196 100644 --- a/src/google/protobuf/compiler/php/php_generator.cc +++ b/src/google/protobuf/compiler/php/php_generator.cc @@ -49,8 +49,31 @@ const std::string kDescriptorMetadataFile = "GPBMetadata/Google/Protobuf/Internal/Descriptor.php"; const std::string kDescriptorDirName = "Google/Protobuf/Internal"; const std::string kDescriptorPackageName = "Google\\Protobuf\\Internal"; -const char* const kReservedNames[] = {"ARRAY", "Empty", "ECHO"}; -const int kReservedNamesSize = 3; +const char* const kReservedNames[] = { + "abstract", "and", "array", "as", "break", + "callable", "case", "catch", "class", "clone", + "const", "continue", "declare", "default", "die", + "do", "echo", "else", "elseif", "empty", + "enddeclare", "endfor", "endforeach", "endif", "endswitch", + "endwhile", "eval", "exit", "extends", "final", + "for", "foreach", "function", "global", "goto", + "if", "implements", "include", "include_once", "instanceof", + "insteadof", "interface", "isset", "list", "namespace", + "new", "or", "print", "private", "protected", + "public", "require", "require_once", "return", "static", + "switch", "throw", "trait", "try", "unset", + "use", "var", "while", "xor", "int", + "float", "bool", "string", "true", "false", + "null", "void", "iterable"}; +const char* const kValidConstantNames[] = { + "int", "float", "bool", "string", "true", + "false", "null", "void", "iterable", +}; +const int kReservedNamesSize = 73; +const int kValidConstantNamesSize = 9; +const int kFieldSetter = 1; +const int kFieldGetter = 2; +const int kFieldProperty = 3; namespace google { namespace protobuf { @@ -71,12 +94,18 @@ std::string EscapeDollor(const string& to_escape); std::string BinaryToHex(const string& binary); void Indent(io::Printer* printer); void Outdent(io::Printer* printer); -void GenerateMessageDocComment(io::Printer* printer, const Descriptor* message); -void GenerateFieldDocComment(io::Printer* printer, - const FieldDescriptor* field); -void GenerateEnumDocComment(io::Printer* printer, const EnumDescriptor* enum_); +void GenerateMessageDocComment(io::Printer* printer, const Descriptor* message, + int is_descriptor); +void GenerateFieldDocComment(io::Printer* printer, const FieldDescriptor* field, + int is_descriptor, int function_type); +void GenerateEnumDocComment(io::Printer* printer, const EnumDescriptor* enum_, + int is_descriptor); void GenerateEnumValueDocComment(io::Printer* printer, const EnumValueDescriptor* value); +void GenerateServiceDocComment(io::Printer* printer, + const ServiceDescriptor* service); +void GenerateServiceMethodDocComment(io::Printer* printer, + const MethodDescriptor* method); std::string RenameEmpty(const std::string& name) { if (name == "Empty") { @@ -116,8 +145,11 @@ std::string ClassNamePrefix(const string& classname, bool is_reserved = false; + string lower = classname; + transform(lower.begin(), lower.end(), lower.begin(), ::tolower); + for (int i = 0; i < kReservedNamesSize; i++) { - if (classname == kReservedNames[i]) { + if (lower == kReservedNames[i]) { is_reserved = true; break; } @@ -134,17 +166,36 @@ std::string ClassNamePrefix(const string& classname, return ""; } +std::string ConstantNamePrefix(const string& classname) { + bool is_reserved = false; -template <typename DescriptorType> -std::string FullClassName(const DescriptorType* desc, bool is_descriptor) { - string classname = desc->name(); - const Descriptor* containing = desc->containing_type(); - while (containing != NULL) { - classname = containing->name() + '_' + classname; - containing = containing->containing_type(); + string lower = classname; + transform(lower.begin(), lower.end(), lower.begin(), ::tolower); + + for (int i = 0; i < kReservedNamesSize; i++) { + if (lower == kReservedNames[i]) { + is_reserved = true; + break; + } + } + + for (int i = 0; i < kValidConstantNamesSize; i++) { + if (lower == kValidConstantNames[i]) { + is_reserved = false; + break; + } } - classname = ClassNamePrefix(classname, desc) + classname; + if (is_reserved) { + return "PB"; + } + + return ""; +} + +template <typename DescriptorType> +std::string NamespacedName(const string& classname, + const DescriptorType* desc, bool is_descriptor) { if (desc->file()->options().has_php_namespace()) { const string& php_namespace = desc->file()->options().php_namespace(); if (php_namespace != "") { @@ -162,6 +213,17 @@ std::string FullClassName(const DescriptorType* desc, bool is_descriptor) { } } +template <typename DescriptorType> +std::string FullClassName(const DescriptorType* desc, bool is_descriptor) { + string classname = GeneratedClassName(desc); + return NamespacedName(classname, desc, is_descriptor); +} + +std::string FullClassName(const ServiceDescriptor* desc, bool is_descriptor) { + string classname = GeneratedClassName(desc); + return NamespacedName(classname, desc, is_descriptor); +} + std::string PhpName(const std::string& full_name, bool is_descriptor) { if (is_descriptor) { return kDescriptorPackageName; @@ -267,6 +329,17 @@ std::string GeneratedEnumFileName(const EnumDescriptor* en, return result + ".php"; } +std::string GeneratedServiceFileName(const ServiceDescriptor* service, + bool is_descriptor) { + std::string result = FullClassName(service, is_descriptor) + "Interface"; + for (int i = 0; i < result.size(); i++) { + if (result[i] == '\\') { + result[i] = '/'; + } + } + return result + ".php"; +} + std::string IntToString(int32 value) { std::ostringstream os; os << value; @@ -306,6 +379,87 @@ std::string TypeName(const FieldDescriptor* field) { } } +std::string PhpSetterTypeName(const FieldDescriptor* field, bool is_descriptor) { + if (field->is_map()) { + return "array|\\Google\\Protobuf\\Internal\\MapField"; + } + string type; + switch (field->type()) { + case FieldDescriptor::TYPE_INT32: + case FieldDescriptor::TYPE_UINT32: + case FieldDescriptor::TYPE_SINT32: + case FieldDescriptor::TYPE_FIXED32: + case FieldDescriptor::TYPE_SFIXED32: + case FieldDescriptor::TYPE_ENUM: + type = "int"; + break; + case FieldDescriptor::TYPE_INT64: + case FieldDescriptor::TYPE_UINT64: + case FieldDescriptor::TYPE_SINT64: + case FieldDescriptor::TYPE_FIXED64: + case FieldDescriptor::TYPE_SFIXED64: + type = "int|string"; + break; + case FieldDescriptor::TYPE_DOUBLE: + case FieldDescriptor::TYPE_FLOAT: + type = "float"; + break; + case FieldDescriptor::TYPE_BOOL: + type = "bool"; + break; + case FieldDescriptor::TYPE_STRING: + case FieldDescriptor::TYPE_BYTES: + type = "string"; + break; + case FieldDescriptor::TYPE_MESSAGE: + type = "\\" + FullClassName(field->message_type(), is_descriptor); + break; + case FieldDescriptor::TYPE_GROUP: + return "null"; + default: assert(false); return ""; + } + if (field->is_repeated()) { + // accommodate for edge case with multiple types. + size_t start_pos = type.find("|"); + if (start_pos != std::string::npos) { + type.replace(start_pos, 1, "[]|"); + } + type += "[]|\\Google\\Protobuf\\Internal\\RepeatedField"; + } + return type; +} + +std::string PhpGetterTypeName(const FieldDescriptor* field, bool is_descriptor) { + if (field->is_map()) { + return "\\Google\\Protobuf\\Internal\\MapField"; + } + if (field->is_repeated()) { + return "\\Google\\Protobuf\\Internal\\RepeatedField"; + } + switch (field->type()) { + case FieldDescriptor::TYPE_INT32: + case FieldDescriptor::TYPE_UINT32: + case FieldDescriptor::TYPE_SINT32: + case FieldDescriptor::TYPE_FIXED32: + case FieldDescriptor::TYPE_SFIXED32: + case FieldDescriptor::TYPE_ENUM: return "int"; + case FieldDescriptor::TYPE_INT64: + case FieldDescriptor::TYPE_UINT64: + case FieldDescriptor::TYPE_SINT64: + case FieldDescriptor::TYPE_FIXED64: + case FieldDescriptor::TYPE_SFIXED64: return "int|string"; + case FieldDescriptor::TYPE_DOUBLE: + case FieldDescriptor::TYPE_FLOAT: return "float"; + case FieldDescriptor::TYPE_BOOL: return "bool"; + case FieldDescriptor::TYPE_STRING: + case FieldDescriptor::TYPE_BYTES: return "string"; + case FieldDescriptor::TYPE_MESSAGE: + return "\\" + FullClassName(field->message_type(), is_descriptor); + case FieldDescriptor::TYPE_GROUP: return "null"; + default: assert(false); return ""; + } +} + std::string EnumOrMessageSuffix( const FieldDescriptor* field, bool is_descriptor) { if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { @@ -390,7 +544,7 @@ void Outdent(io::Printer* printer) { void GenerateField(const FieldDescriptor* field, io::Printer* printer, bool is_descriptor) { if (field->is_repeated()) { - GenerateFieldDocComment(printer, field); + GenerateFieldDocComment(printer, field, is_descriptor, kFieldProperty); printer->Print( "private $^name^;\n", "name", field->name()); @@ -398,7 +552,7 @@ void GenerateField(const FieldDescriptor* field, io::Printer* printer, // Oneof fields are handled by GenerateOneofField. return; } else { - GenerateFieldDocComment(printer, field); + GenerateFieldDocComment(printer, field, is_descriptor, kFieldProperty); printer->Print( "private $^name^ = ^default^;\n", "name", field->name(), @@ -426,7 +580,7 @@ void GenerateFieldAccessor(const FieldDescriptor* field, bool is_descriptor, // Generate getter. if (oneof != NULL) { - GenerateFieldDocComment(printer, field); + GenerateFieldDocComment(printer, field, is_descriptor, kFieldGetter); printer->Print( "public function get^camel_name^()\n" "{\n" @@ -435,7 +589,7 @@ void GenerateFieldAccessor(const FieldDescriptor* field, bool is_descriptor, "camel_name", UnderscoresToCamelCase(field->name(), true), "number", IntToString(field->number())); } else { - GenerateFieldDocComment(printer, field); + GenerateFieldDocComment(printer, field, is_descriptor, kFieldGetter); printer->Print( "public function get^camel_name^()\n" "{\n" @@ -446,14 +600,11 @@ void GenerateFieldAccessor(const FieldDescriptor* field, bool is_descriptor, } // Generate setter. - GenerateFieldDocComment(printer, field); + GenerateFieldDocComment(printer, field, is_descriptor, kFieldSetter); printer->Print( - "public function set^camel_name^(^var^)\n" + "public function set^camel_name^($var)\n" "{\n", - "camel_name", UnderscoresToCamelCase(field->name(), true), - "var", (field->is_repeated() || - field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) ? - "&$var": "$var"); + "camel_name", UnderscoresToCamelCase(field->name(), true)); Indent(printer); @@ -570,13 +721,23 @@ void GenerateEnumToPool(const EnumDescriptor* en, io::Printer* printer) { const EnumValueDescriptor* value = en->value(i); printer->Print( "->value(\"^name^\", ^number^)\n", - "name", ClassNamePrefix(value->name(), en) + value->name(), + "name", ConstantNamePrefix(value->name()) + value->name(), "number", IntToString(value->number())); } printer->Print("->finalizeToPool();\n\n"); Outdent(printer); } +void GenerateServiceMethod(const MethodDescriptor* method, + io::Printer* printer) { + printer->Print( + "public function ^camel_name^(\\^request_name^ $request);\n\n", + "camel_name", UnderscoresToCamelCase(method->name(), false), + "request_name", FullClassName( + method->input_type(), false) + ); +} + void GenerateMessageToPool(const string& name_prefix, const Descriptor* message, io::Printer* printer) { // Don't generate MapEntry messages -- we use the PHP extension's native @@ -758,7 +919,7 @@ void GenerateUseDeclaration(bool is_descriptor, io::Printer* printer) { "use Google\\Protobuf\\Internal\\GPBType;\n" "use Google\\Protobuf\\Internal\\GPBWire;\n" "use Google\\Protobuf\\Internal\\RepeatedField;\n" - "use Google\\Protobuf\\Internal\\InputStream;\n\n" + "use Google\\Protobuf\\Internal\\InputStream;\n" "use Google\\Protobuf\\Internal\\GPBUtil;\n\n"); } } @@ -844,7 +1005,7 @@ void GenerateEnumFile(const FileDescriptor* file, const EnumDescriptor* en, "name", fullname.substr(0, lastindex)); } - GenerateEnumDocComment(&printer, en); + GenerateEnumDocComment(&printer, en, is_descriptor); if (lastindex != string::npos) { printer.Print( @@ -863,7 +1024,7 @@ void GenerateEnumFile(const FileDescriptor* file, const EnumDescriptor* en, const EnumValueDescriptor* value = en->value(i); GenerateEnumValueDocComment(&printer, value); printer.Print("const ^name^ = ^number^;\n", - "name", ClassNamePrefix(value->name(), en) + value->name(), + "name", ConstantNamePrefix(value->name()) + value->name(), "number", IntToString(value->number())); } @@ -905,7 +1066,7 @@ void GenerateMessageFile(const FileDescriptor* file, const Descriptor* message, GenerateUseDeclaration(is_descriptor, &printer); - GenerateMessageDocComment(&printer, message); + GenerateMessageDocComment(&printer, message, is_descriptor); if (lastindex != string::npos) { printer.Print( "class ^name^ extends \\Google\\Protobuf\\Internal\\Message\n" @@ -953,6 +1114,9 @@ void GenerateMessageFile(const FileDescriptor* file, const Descriptor* message, for (int i = 0; i < message->oneof_decl_count(); i++) { const OneofDescriptor* oneof = message->oneof_decl(i); printer.Print( + "/**\n" + " * @return string\n" + " */\n" "public function get^camel_name^()\n" "{\n" " return $this->whichOneof(\"^name^\");\n" @@ -975,6 +1139,58 @@ void GenerateMessageFile(const FileDescriptor* file, const Descriptor* message, } } +void GenerateServiceFile(const FileDescriptor* file, + const ServiceDescriptor* service, bool is_descriptor, + GeneratorContext* generator_context) { + std::string filename = GeneratedServiceFileName(service, is_descriptor); + scoped_ptr<io::ZeroCopyOutputStream> output( + generator_context->Open(filename)); + io::Printer printer(output.get(), '^'); + + GenerateHead(file, &printer); + + std::string fullname = FilenameToClassname(filename); + int lastindex = fullname.find_last_of("\\"); + + if (file->options().has_php_namespace()) { + const string& php_namespace = file->options().php_namespace(); + if (!php_namespace.empty()) { + printer.Print( + "namespace ^name^;\n\n", + "name", php_namespace); + } + } else if (!file->package().empty()) { + printer.Print( + "namespace ^name^;\n\n", + "name", fullname.substr(0, lastindex)); + } + + GenerateServiceDocComment(&printer, service); + + if (lastindex != string::npos) { + printer.Print( + "interface ^name^\n" + "{\n", + "name", fullname.substr(lastindex + 1)); + } else { + printer.Print( + "interface ^name^\n" + "{\n", + "name", fullname); + } + + Indent(&printer); + + for (int i = 0; i < service->method_count(); i++) { + const MethodDescriptor* method = service->method(i); + GenerateServiceMethodDocComment(&printer, method); + GenerateServiceMethod(method, &printer); + } + + Outdent(&printer); + printer.Print("}\n\n"); +} + void GenerateFile(const FileDescriptor* file, bool is_descriptor, GeneratorContext* generator_context) { GenerateMetadataFile(file, is_descriptor, generator_context); @@ -986,6 +1202,12 @@ void GenerateFile(const FileDescriptor* file, bool is_descriptor, GenerateEnumFile(file, file->enum_type(i), is_descriptor, generator_context); } + if (file->options().php_generic_services()) { + for (int i = 0; i < file->service_count(); i++) { + GenerateServiceFile(file, file->service(i), is_descriptor, + generator_context); + } + } } static string EscapePhpdoc(const string& input) { @@ -1019,22 +1241,6 @@ static string EscapePhpdoc(const string& input) { // does not have a corresponding @Deprecated annotation. result.append("@"); break; - case '<': - // Avoid interpretation as HTML. - result.append("<"); - break; - case '>': - // Avoid interpretation as HTML. - result.append(">"); - break; - case '&': - // Avoid interpretation as HTML. - result.append("&"); - break; - case '\\': - // Java interprets Unicode escape sequences anywhere! - result.append("\"); - break; default: result.push_back(c); break; @@ -1053,18 +1259,17 @@ static void GenerateDocCommentBodyForLocation( if (!comments.empty()) { // TODO(teboring): Ideally we should parse the comment text as Markdown and // write it back as HTML, but this requires a Markdown parser. For now - // we just use <pre> to get fixed-width text formatting. + // we just use the proto comments unchanged. // If the comment itself contains block comment start or end markers, // HTML-escape them so that they don't accidentally close the doc comment. comments = EscapePhpdoc(comments); - vector<string> lines = Split(comments, "\n"); + std::vector<string> lines = Split(comments, "\n"); while (!lines.empty() && lines.back().empty()) { lines.pop_back(); } - printer->Print(" * <pre>\n"); for (int i = 0; i < lines.size(); i++) { // Most lines should start with a space. Watch out for lines that start // with a /, since putting that right after the leading asterisk will @@ -1076,7 +1281,6 @@ static void GenerateDocCommentBodyForLocation( } } printer->Print( - " * </pre>\n" " *\n"); } } @@ -1102,17 +1306,28 @@ static string FirstLineOf(const string& value) { } void GenerateMessageDocComment(io::Printer* printer, - const Descriptor* message) { + const Descriptor* message, int is_descriptor) { printer->Print("/**\n"); GenerateDocCommentBody(printer, message); printer->Print( + " * Generated from protobuf message <code>^messagename^</code>\n" + " */\n", + "fullname", EscapePhpdoc(PhpName(message->full_name(), is_descriptor)), + "messagename", EscapePhpdoc(message->full_name())); +} + +void GenerateServiceDocComment(io::Printer* printer, + const ServiceDescriptor* service) { + printer->Print("/**\n"); + GenerateDocCommentBody(printer, service); + printer->Print( " * Protobuf type <code>^fullname^</code>\n" " */\n", - "fullname", EscapePhpdoc(message->full_name())); + "fullname", EscapePhpdoc(service->full_name())); } -void GenerateFieldDocComment(io::Printer* printer, - const FieldDescriptor* field) { +void GenerateFieldDocComment(io::Printer* printer, const FieldDescriptor* field, + int is_descriptor, int function_type) { // In theory we should have slightly different comments for setters, getters, // etc., but in practice everyone already knows the difference between these // so it's redundant information. @@ -1124,18 +1339,27 @@ void GenerateFieldDocComment(io::Printer* printer, printer->Print("/**\n"); GenerateDocCommentBody(printer, field); printer->Print( - " * <code>^def^</code>\n", + " * Generated from protobuf field <code>^def^</code>\n", "def", EscapePhpdoc(FirstLineOf(field->DebugString()))); + if (function_type == kFieldSetter) { + printer->Print(" * @param ^php_type^ $var\n", + "php_type", PhpSetterTypeName(field, is_descriptor)); + printer->Print(" * @return $this\n"); + } else if (function_type == kFieldGetter) { + printer->Print(" * @return ^php_type^\n", + "php_type", PhpGetterTypeName(field, is_descriptor)); + } printer->Print(" */\n"); } -void GenerateEnumDocComment(io::Printer* printer, const EnumDescriptor* enum_) { +void GenerateEnumDocComment(io::Printer* printer, const EnumDescriptor* enum_, + int is_descriptor) { printer->Print("/**\n"); GenerateDocCommentBody(printer, enum_); printer->Print( " * Protobuf enum <code>^fullname^</code>\n" " */\n", - "fullname", EscapePhpdoc(enum_->full_name())); + "fullname", EscapePhpdoc(PhpName(enum_->full_name(), is_descriptor))); } void GenerateEnumValueDocComment(io::Printer* printer, @@ -1143,11 +1367,28 @@ void GenerateEnumValueDocComment(io::Printer* printer, printer->Print("/**\n"); GenerateDocCommentBody(printer, value); printer->Print( - " * <code>^def^</code>\n" + " * Generated from protobuf enum <code>^def^</code>\n" " */\n", "def", EscapePhpdoc(FirstLineOf(value->DebugString()))); } +void GenerateServiceMethodDocComment(io::Printer* printer, + const MethodDescriptor* method) { + printer->Print("/**\n"); + GenerateDocCommentBody(printer, method); + printer->Print( + " * Method <code>^method_name^</code>\n" + " *\n", + "method_name", EscapePhpdoc(UnderscoresToCamelCase(method->name(), false))); + printer->Print( + " * @param \\^input_type^ $request\n", + "input_type", EscapePhpdoc(FullClassName(method->input_type(), false))); + printer->Print( + " * @return \\^return_type^\n" + " */\n", + "return_type", EscapePhpdoc(FullClassName(method->output_type(), false))); +} + bool Generator::Generate(const FileDescriptor* file, const string& parameter, GeneratorContext* generator_context, string* error) const { @@ -1171,6 +1412,31 @@ bool Generator::Generate(const FileDescriptor* file, const string& parameter, return true; } +std::string GeneratedClassName(const Descriptor* desc) { + std::string classname = desc->name(); + const Descriptor* containing = desc->containing_type(); + while (containing != NULL) { + classname = containing->name() + '_' + classname; + containing = containing->containing_type(); + } + return ClassNamePrefix(classname, desc) + classname; +} + +std::string GeneratedClassName(const EnumDescriptor* desc) { + std::string classname = desc->name(); + const Descriptor* containing = desc->containing_type(); + while (containing != NULL) { + classname = containing->name() + '_' + classname; + containing = containing->containing_type(); + } + return ClassNamePrefix(classname, desc) + classname; +} + +std::string GeneratedClassName(const ServiceDescriptor* desc) { + std::string classname = desc->name(); + return ClassNamePrefix(classname, desc) + classname; +} + } // namespace php } // namespace compiler } // namespace protobuf diff --git a/src/google/protobuf/compiler/php/php_generator.h b/src/google/protobuf/compiler/php/php_generator.h index ce2b000a..67e70bc7 100644 --- a/src/google/protobuf/compiler/php/php_generator.h +++ b/src/google/protobuf/compiler/php/php_generator.h @@ -32,6 +32,7 @@ #define GOOGLE_PROTOBUF_COMPILER_PHP_GENERATOR_H__ #include <google/protobuf/compiler/code_generator.h> +#include <google/protobuf/descriptor.h> #include <string> @@ -47,8 +48,16 @@ class LIBPROTOC_EXPORT Generator const string& parameter, GeneratorContext* generator_context, string* error) const; + }; +// To skip reserved keywords in php, some generated classname are prefixed. +// Other code generators may need following API to figure out the actual +// classname. +std::string GeneratedClassName(const google::protobuf::Descriptor* desc); +std::string GeneratedClassName(const google::protobuf::EnumDescriptor* desc); +std::string GeneratedClassName(const google::protobuf::ServiceDescriptor* desc); + } // namespace php } // namespace compiler } // namespace protobuf diff --git a/src/google/protobuf/compiler/plugin.cc b/src/google/protobuf/compiler/plugin.cc index 3848101d..bde3d798 100644 --- a/src/google/protobuf/compiler/plugin.cc +++ b/src/google/protobuf/compiler/plugin.cc @@ -36,14 +36,7 @@ #include <set> #ifdef _WIN32 -#include <io.h> #include <fcntl.h> -#ifndef STDIN_FILENO -#define STDIN_FILENO 0 -#endif -#ifndef STDOUT_FILENO -#define STDOUT_FILENO 1 -#endif #else #include <unistd.h> #endif @@ -54,12 +47,19 @@ #include <google/protobuf/compiler/code_generator.h> #include <google/protobuf/descriptor.h> #include <google/protobuf/io/zero_copy_stream_impl.h> +#include <google/protobuf/stubs/io_win32.h> namespace google { namespace protobuf { namespace compiler { +#if defined(_WIN32) +// DO NOT include <io.h>, instead create functions in io_win32.{h,cc} and import +// them like we do below. +using google::protobuf::internal::win32::setmode; +#endif + class GeneratorResponseContext : public GeneratorContext { public: GeneratorResponseContext( @@ -127,6 +127,7 @@ bool GenerateCode(const CodeGeneratorRequest& request, GeneratorResponseContext context( request.compiler_version(), response, parsed_files); + string error; bool succeeded = generator.GenerateAll( parsed_files, request.parameter(), &context, &error); @@ -150,8 +151,8 @@ int PluginMain(int argc, char* argv[], const CodeGenerator* generator) { } #ifdef _WIN32 - _setmode(STDIN_FILENO, _O_BINARY); - _setmode(STDOUT_FILENO, _O_BINARY); + setmode(STDIN_FILENO, _O_BINARY); + setmode(STDOUT_FILENO, _O_BINARY); #endif CodeGeneratorRequest request; diff --git a/src/google/protobuf/compiler/plugin.pb.cc b/src/google/protobuf/compiler/plugin.pb.cc index f7dc1b70..d13ad2b3 100644 --- a/src/google/protobuf/compiler/plugin.pb.cc +++ b/src/google/protobuf/compiler/plugin.pb.cc @@ -1,7 +1,6 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/protobuf/compiler/plugin.proto -#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION #include <google/protobuf/compiler/plugin.pb.h> #include <algorithm> @@ -15,111 +14,189 @@ #include <google/protobuf/generated_message_reflection.h> #include <google/protobuf/reflection_ops.h> #include <google/protobuf/wire_format.h> +// This is a temporary google only hack +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS +#include "third_party/protobuf/version.h" +#endif // @@protoc_insertion_point(includes) - namespace google { namespace protobuf { namespace compiler { -class VersionDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Version> { +class VersionDefaultTypeInternal { + public: + ::google::protobuf::internal::ExplicitlyConstructed<Version> + _instance; } _Version_default_instance_; -class CodeGeneratorRequestDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorRequest> { +class CodeGeneratorRequestDefaultTypeInternal { + public: + ::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorRequest> + _instance; } _CodeGeneratorRequest_default_instance_; -class CodeGeneratorResponse_FileDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorResponse_File> { +class CodeGeneratorResponse_FileDefaultTypeInternal { + public: + ::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorResponse_File> + _instance; } _CodeGeneratorResponse_File_default_instance_; -class CodeGeneratorResponseDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorResponse> { +class CodeGeneratorResponseDefaultTypeInternal { + public: + ::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorResponse> + _instance; } _CodeGeneratorResponse_default_instance_; - +} // namespace compiler +} // namespace protobuf +} // namespace google namespace protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto { +void InitDefaultsVersionImpl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); +#else + ::google::protobuf::internal::InitProtobufDefaults(); +#endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + { + void* ptr = &::google::protobuf::compiler::_Version_default_instance_; + new (ptr) ::google::protobuf::compiler::Version(); + ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); + } + ::google::protobuf::compiler::Version::InitAsDefaultInstance(); +} + +void InitDefaultsVersion() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsVersionImpl); +} -namespace { +void InitDefaultsCodeGeneratorRequestImpl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; -::google::protobuf::Metadata file_level_metadata[4]; +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); +#else + ::google::protobuf::internal::InitProtobufDefaults(); +#endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsFileDescriptorProto(); + protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::InitDefaultsVersion(); + { + void* ptr = &::google::protobuf::compiler::_CodeGeneratorRequest_default_instance_; + new (ptr) ::google::protobuf::compiler::CodeGeneratorRequest(); + ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); + } + ::google::protobuf::compiler::CodeGeneratorRequest::InitAsDefaultInstance(); +} -} // namespace +void InitDefaultsCodeGeneratorRequest() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsCodeGeneratorRequestImpl); +} -PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::ParseTableField - const TableStruct::entries[] = { - {0, 0, 0, ::google::protobuf::internal::kInvalidMask, 0, 0}, -}; +void InitDefaultsCodeGeneratorResponse_FileImpl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; -PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::AuxillaryParseTableField - const TableStruct::aux[] = { - ::google::protobuf::internal::AuxillaryParseTableField(), -}; -PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::ParseTable const - TableStruct::schema[] = { - { NULL, NULL, 0, -1, -1, false }, - { NULL, NULL, 0, -1, -1, false }, - { NULL, NULL, 0, -1, -1, false }, - { NULL, NULL, 0, -1, -1, false }, -}; +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); +#else + ::google::protobuf::internal::InitProtobufDefaults(); +#endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + { + void* ptr = &::google::protobuf::compiler::_CodeGeneratorResponse_File_default_instance_; + new (ptr) ::google::protobuf::compiler::CodeGeneratorResponse_File(); + ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); + } + ::google::protobuf::compiler::CodeGeneratorResponse_File::InitAsDefaultInstance(); +} + +void InitDefaultsCodeGeneratorResponse_File() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsCodeGeneratorResponse_FileImpl); +} + +void InitDefaultsCodeGeneratorResponseImpl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); +#else + ::google::protobuf::internal::InitProtobufDefaults(); +#endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::InitDefaultsCodeGeneratorResponse_File(); + { + void* ptr = &::google::protobuf::compiler::_CodeGeneratorResponse_default_instance_; + new (ptr) ::google::protobuf::compiler::CodeGeneratorResponse(); + ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); + } + ::google::protobuf::compiler::CodeGeneratorResponse::InitAsDefaultInstance(); +} + +void InitDefaultsCodeGeneratorResponse() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsCodeGeneratorResponseImpl); +} -const ::google::protobuf::uint32 TableStruct::offsets[] = { - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Version, _has_bits_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Version, _internal_metadata_), +::google::protobuf::Metadata file_level_metadata[4]; + +const ::google::protobuf::uint32 TableStruct::offsets[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::compiler::Version, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::compiler::Version, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Version, major_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Version, minor_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Version, patch_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Version, suffix_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::compiler::Version, major_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::compiler::Version, minor_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::compiler::Version, patch_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::compiler::Version, suffix_), 1, 2, 3, 0, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, _has_bits_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::compiler::CodeGeneratorRequest, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::compiler::CodeGeneratorRequest, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, file_to_generate_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, parameter_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, proto_file_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, compiler_version_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::compiler::CodeGeneratorRequest, file_to_generate_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::compiler::CodeGeneratorRequest, parameter_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::compiler::CodeGeneratorRequest, proto_file_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::compiler::CodeGeneratorRequest, compiler_version_), ~0u, 0, ~0u, 1, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse_File, _has_bits_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse_File, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::compiler::CodeGeneratorResponse_File, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::compiler::CodeGeneratorResponse_File, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse_File, name_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse_File, insertion_point_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse_File, content_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::compiler::CodeGeneratorResponse_File, name_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::compiler::CodeGeneratorResponse_File, insertion_point_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::compiler::CodeGeneratorResponse_File, content_), 0, 1, 2, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse, _has_bits_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::compiler::CodeGeneratorResponse, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::compiler::CodeGeneratorResponse, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse, error_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse, file_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::compiler::CodeGeneratorResponse, error_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::compiler::CodeGeneratorResponse, file_), 0, ~0u, }; - -static const ::google::protobuf::internal::MigrationSchema schemas[] = { - { 0, 9, sizeof(Version)}, - { 13, 22, sizeof(CodeGeneratorRequest)}, - { 26, 34, sizeof(CodeGeneratorResponse_File)}, - { 37, 44, sizeof(CodeGeneratorResponse)}, +static const ::google::protobuf::internal::MigrationSchema schemas[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { + { 0, 9, sizeof(::google::protobuf::compiler::Version)}, + { 13, 22, sizeof(::google::protobuf::compiler::CodeGeneratorRequest)}, + { 26, 34, sizeof(::google::protobuf::compiler::CodeGeneratorResponse_File)}, + { 37, 44, sizeof(::google::protobuf::compiler::CodeGeneratorResponse)}, }; static ::google::protobuf::Message const * const file_default_instances[] = { - reinterpret_cast<const ::google::protobuf::Message*>(&_Version_default_instance_), - reinterpret_cast<const ::google::protobuf::Message*>(&_CodeGeneratorRequest_default_instance_), - reinterpret_cast<const ::google::protobuf::Message*>(&_CodeGeneratorResponse_File_default_instance_), - reinterpret_cast<const ::google::protobuf::Message*>(&_CodeGeneratorResponse_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::compiler::_Version_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::compiler::_CodeGeneratorRequest_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::compiler::_CodeGeneratorResponse_File_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::compiler::_CodeGeneratorResponse_default_instance_), }; -namespace { - void protobuf_AssignDescriptors() { AddDescriptors(); ::google::protobuf::MessageFactory* factory = NULL; @@ -133,45 +210,15 @@ void protobuf_AssignDescriptorsOnce() { ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors); } -void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; +void protobuf_RegisterTypes(const ::std::string&) GOOGLE_PROTOBUF_ATTRIBUTE_COLD; void protobuf_RegisterTypes(const ::std::string&) { protobuf_AssignDescriptorsOnce(); ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 4); } -} // namespace - -void TableStruct::Shutdown() { - _Version_default_instance_.Shutdown(); - delete file_level_metadata[0].reflection; - _CodeGeneratorRequest_default_instance_.Shutdown(); - delete file_level_metadata[1].reflection; - _CodeGeneratorResponse_File_default_instance_.Shutdown(); - delete file_level_metadata[2].reflection; - _CodeGeneratorResponse_default_instance_.Shutdown(); - delete file_level_metadata[3].reflection; -} - -void TableStruct::InitDefaultsImpl() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - ::google::protobuf::internal::InitProtobufDefaults(); - ::google::protobuf::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); - _Version_default_instance_.DefaultConstruct(); - _CodeGeneratorRequest_default_instance_.DefaultConstruct(); - _CodeGeneratorResponse_File_default_instance_.DefaultConstruct(); - _CodeGeneratorResponse_default_instance_.DefaultConstruct(); - _CodeGeneratorRequest_default_instance_.get_mutable()->compiler_version_ = const_cast< ::google::protobuf::compiler::Version*>( - ::google::protobuf::compiler::Version::internal_default_instance()); -} - -void InitDefaults() { - static GOOGLE_PROTOBUF_DECLARE_ONCE(once); - ::google::protobuf::GoogleOnceInit(&once, &TableStruct::InitDefaultsImpl); -} void AddDescriptorsImpl() { InitDefaults(); - static const char descriptor[] = { + static const char descriptor[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { "\n%google/protobuf/compiler/plugin.proto\022" "\030google.protobuf.compiler\032 google/protob" "uf/descriptor.proto\"F\n\007Version\022\r\n\005major\030" @@ -193,26 +240,28 @@ void AddDescriptorsImpl() { descriptor, 638); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/compiler/plugin.proto", &protobuf_RegisterTypes); - ::google::protobuf::protobuf_google_2fprotobuf_2fdescriptor_2eproto::AddDescriptors(); - ::google::protobuf::internal::OnShutdown(&TableStruct::Shutdown); + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::AddDescriptors(); } void AddDescriptors() { static GOOGLE_PROTOBUF_DECLARE_ONCE(once); ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl); } -// Force AddDescriptors() to be called at static initialization time. +// Force AddDescriptors() to be called at dynamic initialization time. struct StaticDescriptorInitializer { StaticDescriptorInitializer() { AddDescriptors(); } } static_descriptor_initializer; - } // namespace protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto - +namespace google { +namespace protobuf { +namespace compiler { // =================================================================== +void Version::InitAsDefaultInstance() { +} #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int Version::kMajorFieldNumber; const int Version::kMinorFieldNumber; @@ -223,7 +272,7 @@ const int Version::kSuffixFieldNumber; Version::Version() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { - protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::InitDefaultsVersion(); } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.compiler.Version) @@ -239,16 +288,17 @@ Version::Version(const Version& from) suffix_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.suffix_); } ::memcpy(&major_, &from.major_, - reinterpret_cast<char*>(&patch_) - - reinterpret_cast<char*>(&major_) + sizeof(patch_)); + static_cast<size_t>(reinterpret_cast<char*>(&patch_) - + reinterpret_cast<char*>(&major_)) + sizeof(patch_)); // @@protoc_insertion_point(copy_constructor:google.protobuf.compiler.Version) } void Version::SharedCtor() { _cached_size_ = 0; suffix_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - ::memset(&major_, 0, reinterpret_cast<char*>(&patch_) - - reinterpret_cast<char*>(&major_) + sizeof(patch_)); + ::memset(&major_, 0, static_cast<size_t>( + reinterpret_cast<char*>(&patch_) - + reinterpret_cast<char*>(&major_)) + sizeof(patch_)); } Version::~Version() { @@ -266,32 +316,31 @@ void Version::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* Version::descriptor() { - protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; + ::protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::protobuf_AssignDescriptorsOnce(); + return ::protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const Version& Version::default_instance() { - protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::InitDefaultsVersion(); return *internal_default_instance(); } -Version* Version::New(::google::protobuf::Arena* arena) const { - Version* n = new Version; - if (arena != NULL) { - arena->Own(n); - } - return n; -} void Version::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.compiler.Version) - if (has_suffix()) { + ::google::protobuf::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + cached_has_bits = _has_bits_[0]; + if (cached_has_bits & 0x00000001u) { GOOGLE_DCHECK(!suffix_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); - (*suffix_.UnsafeRawStringPointer())->clear(); + suffix_.UnsafeMutablePointer()->clear(); } - if (_has_bits_[0 / 32] & 14u) { - ::memset(&major_, 0, reinterpret_cast<char*>(&patch_) - - reinterpret_cast<char*>(&major_) + sizeof(patch_)); + if (cached_has_bits & 14u) { + ::memset(&major_, 0, static_cast<size_t>( + reinterpret_cast<char*>(&patch_) - + reinterpret_cast<char*>(&major_)) + sizeof(patch_)); } _has_bits_.Clear(); _internal_metadata_.Clear(); @@ -310,7 +359,7 @@ bool Version::MergePartialFromCodedStream( // optional int32 major = 1; case 1: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(8u)) { + static_cast< ::google::protobuf::uint8>(8u /* 8 & 0xFF */)) { set_has_major(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -324,7 +373,7 @@ bool Version::MergePartialFromCodedStream( // optional int32 minor = 2; case 2: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(16u)) { + static_cast< ::google::protobuf::uint8>(16u /* 16 & 0xFF */)) { set_has_minor(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -338,7 +387,7 @@ bool Version::MergePartialFromCodedStream( // optional int32 patch = 3; case 3: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(24u)) { + static_cast< ::google::protobuf::uint8>(24u /* 24 & 0xFF */)) { set_has_patch(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -352,11 +401,11 @@ bool Version::MergePartialFromCodedStream( // optional string suffix = 4; case 4: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(34u)) { + static_cast< ::google::protobuf::uint8>(34u /* 34 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_suffix())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->suffix().data(), this->suffix().length(), + this->suffix().data(), static_cast<int>(this->suffix().length()), ::google::protobuf::internal::WireFormat::PARSE, "google.protobuf.compiler.Version.suffix"); } else { @@ -367,13 +416,11 @@ bool Version::MergePartialFromCodedStream( default: { handle_unusual: - if (tag == 0 || - ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + if (tag == 0) { goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); + input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } @@ -412,7 +459,7 @@ void Version::SerializeWithCachedSizes( // optional string suffix = 4; if (cached_has_bits & 0x00000001u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->suffix().data(), this->suffix().length(), + this->suffix().data(), static_cast<int>(this->suffix().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.compiler.Version.suffix"); ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( @@ -421,13 +468,14 @@ void Version::SerializeWithCachedSizes( if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); + _internal_metadata_.unknown_fields(), output); } // @@protoc_insertion_point(serialize_end:google.protobuf.compiler.Version) } ::google::protobuf::uint8* Version::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.compiler.Version) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -451,7 +499,7 @@ void Version::SerializeWithCachedSizes( // optional string suffix = 4; if (cached_has_bits & 0x00000001u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->suffix().data(), this->suffix().length(), + this->suffix().data(), static_cast<int>(this->suffix().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.compiler.Version.suffix"); target = @@ -461,7 +509,7 @@ void Version::SerializeWithCachedSizes( if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); + _internal_metadata_.unknown_fields(), target); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.compiler.Version) return target; @@ -474,7 +522,7 @@ size_t Version::ByteSizeLong() const { if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); + _internal_metadata_.unknown_fields()); } if (_has_bits_[0 / 32] & 15u) { // optional string suffix = 4; @@ -577,162 +625,31 @@ void Version::Swap(Version* other) { InternalSwap(other); } void Version::InternalSwap(Version* other) { + using std::swap; suffix_.Swap(&other->suffix_); - std::swap(major_, other->major_); - std::swap(minor_, other->minor_); - std::swap(patch_, other->patch_); - std::swap(_has_bits_[0], other->_has_bits_[0]); + swap(major_, other->major_); + swap(minor_, other->minor_); + swap(patch_, other->patch_); + swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); - std::swap(_cached_size_, other->_cached_size_); + swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata Version::GetMetadata() const { protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::file_level_metadata[kIndexInFileMessages]; + return ::protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::file_level_metadata[kIndexInFileMessages]; } -#if PROTOBUF_INLINE_NOT_IN_HEADERS -// Version - -// optional int32 major = 1; -bool Version::has_major() const { - return (_has_bits_[0] & 0x00000002u) != 0; -} -void Version::set_has_major() { - _has_bits_[0] |= 0x00000002u; -} -void Version::clear_has_major() { - _has_bits_[0] &= ~0x00000002u; -} -void Version::clear_major() { - major_ = 0; - clear_has_major(); -} -::google::protobuf::int32 Version::major() const { - // @@protoc_insertion_point(field_get:google.protobuf.compiler.Version.major) - return major_; -} -void Version::set_major(::google::protobuf::int32 value) { - set_has_major(); - major_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.compiler.Version.major) -} - -// optional int32 minor = 2; -bool Version::has_minor() const { - return (_has_bits_[0] & 0x00000004u) != 0; -} -void Version::set_has_minor() { - _has_bits_[0] |= 0x00000004u; -} -void Version::clear_has_minor() { - _has_bits_[0] &= ~0x00000004u; -} -void Version::clear_minor() { - minor_ = 0; - clear_has_minor(); -} -::google::protobuf::int32 Version::minor() const { - // @@protoc_insertion_point(field_get:google.protobuf.compiler.Version.minor) - return minor_; -} -void Version::set_minor(::google::protobuf::int32 value) { - set_has_minor(); - minor_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.compiler.Version.minor) -} -// optional int32 patch = 3; -bool Version::has_patch() const { - return (_has_bits_[0] & 0x00000008u) != 0; -} -void Version::set_has_patch() { - _has_bits_[0] |= 0x00000008u; -} -void Version::clear_has_patch() { - _has_bits_[0] &= ~0x00000008u; -} -void Version::clear_patch() { - patch_ = 0; - clear_has_patch(); -} -::google::protobuf::int32 Version::patch() const { - // @@protoc_insertion_point(field_get:google.protobuf.compiler.Version.patch) - return patch_; -} -void Version::set_patch(::google::protobuf::int32 value) { - set_has_patch(); - patch_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.compiler.Version.patch) -} +// =================================================================== -// optional string suffix = 4; -bool Version::has_suffix() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -void Version::set_has_suffix() { - _has_bits_[0] |= 0x00000001u; -} -void Version::clear_has_suffix() { - _has_bits_[0] &= ~0x00000001u; -} -void Version::clear_suffix() { - suffix_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - clear_has_suffix(); -} -const ::std::string& Version::suffix() const { - // @@protoc_insertion_point(field_get:google.protobuf.compiler.Version.suffix) - return suffix_.GetNoArena(); -} -void Version::set_suffix(const ::std::string& value) { - set_has_suffix(); - suffix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.compiler.Version.suffix) -} -#if LANG_CXX11 -void Version::set_suffix(::std::string&& value) { - set_has_suffix(); - suffix_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.Version.suffix) +void CodeGeneratorRequest::InitAsDefaultInstance() { + ::google::protobuf::compiler::_CodeGeneratorRequest_default_instance_._instance.get_mutable()->compiler_version_ = const_cast< ::google::protobuf::compiler::Version*>( + ::google::protobuf::compiler::Version::internal_default_instance()); } -#endif -void Version::set_suffix(const char* value) { - GOOGLE_DCHECK(value != NULL); - set_has_suffix(); - suffix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); - // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.Version.suffix) -} -void Version::set_suffix(const char* value, size_t size) { - set_has_suffix(); - suffix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.Version.suffix) -} -::std::string* Version::mutable_suffix() { - set_has_suffix(); - // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.Version.suffix) - return suffix_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -::std::string* Version::release_suffix() { - // @@protoc_insertion_point(field_release:google.protobuf.compiler.Version.suffix) - clear_has_suffix(); - return suffix_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -void Version::set_allocated_suffix(::std::string* suffix) { - if (suffix != NULL) { - set_has_suffix(); - } else { - clear_has_suffix(); - } - suffix_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), suffix); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.Version.suffix) +void CodeGeneratorRequest::clear_proto_file() { + proto_file_.Clear(); } - -#endif // PROTOBUF_INLINE_NOT_IN_HEADERS - -// =================================================================== - #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int CodeGeneratorRequest::kFileToGenerateFieldNumber; const int CodeGeneratorRequest::kParameterFieldNumber; @@ -743,7 +660,7 @@ const int CodeGeneratorRequest::kCompilerVersionFieldNumber; CodeGeneratorRequest::CodeGeneratorRequest() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { - protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::InitDefaultsCodeGeneratorRequest(); } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.compiler.CodeGeneratorRequest) @@ -781,9 +698,7 @@ CodeGeneratorRequest::~CodeGeneratorRequest() { void CodeGeneratorRequest::SharedDtor() { parameter_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != internal_default_instance()) { - delete compiler_version_; - } + if (this != internal_default_instance()) delete compiler_version_; } void CodeGeneratorRequest::SetCachedSize(int size) const { @@ -792,35 +707,33 @@ void CodeGeneratorRequest::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* CodeGeneratorRequest::descriptor() { - protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; + ::protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::protobuf_AssignDescriptorsOnce(); + return ::protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const CodeGeneratorRequest& CodeGeneratorRequest::default_instance() { - protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::InitDefaultsCodeGeneratorRequest(); return *internal_default_instance(); } -CodeGeneratorRequest* CodeGeneratorRequest::New(::google::protobuf::Arena* arena) const { - CodeGeneratorRequest* n = new CodeGeneratorRequest; - if (arena != NULL) { - arena->Own(n); - } - return n; -} void CodeGeneratorRequest::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.compiler.CodeGeneratorRequest) + ::google::protobuf::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + file_to_generate_.Clear(); proto_file_.Clear(); - if (_has_bits_[0 / 32] & 3u) { - if (has_parameter()) { + cached_has_bits = _has_bits_[0]; + if (cached_has_bits & 3u) { + if (cached_has_bits & 0x00000001u) { GOOGLE_DCHECK(!parameter_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); - (*parameter_.UnsafeRawStringPointer())->clear(); + parameter_.UnsafeMutablePointer()->clear(); } - if (has_compiler_version()) { + if (cached_has_bits & 0x00000002u) { GOOGLE_DCHECK(compiler_version_ != NULL); - compiler_version_->::google::protobuf::compiler::Version::Clear(); + compiler_version_->Clear(); } } _has_bits_.Clear(); @@ -840,12 +753,12 @@ bool CodeGeneratorRequest::MergePartialFromCodedStream( // repeated string file_to_generate = 1; case 1: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(10u)) { + static_cast< ::google::protobuf::uint8>(10u /* 10 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->add_file_to_generate())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->file_to_generate(this->file_to_generate_size() - 1).data(), - this->file_to_generate(this->file_to_generate_size() - 1).length(), + static_cast<int>(this->file_to_generate(this->file_to_generate_size() - 1).length()), ::google::protobuf::internal::WireFormat::PARSE, "google.protobuf.compiler.CodeGeneratorRequest.file_to_generate"); } else { @@ -857,11 +770,11 @@ bool CodeGeneratorRequest::MergePartialFromCodedStream( // optional string parameter = 2; case 2: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(18u)) { + static_cast< ::google::protobuf::uint8>(18u /* 18 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_parameter())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->parameter().data(), this->parameter().length(), + this->parameter().data(), static_cast<int>(this->parameter().length()), ::google::protobuf::internal::WireFormat::PARSE, "google.protobuf.compiler.CodeGeneratorRequest.parameter"); } else { @@ -873,8 +786,8 @@ bool CodeGeneratorRequest::MergePartialFromCodedStream( // optional .google.protobuf.compiler.Version compiler_version = 3; case 3: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(26u)) { - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + static_cast< ::google::protobuf::uint8>(26u /* 26 & 0xFF */)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, mutable_compiler_version())); } else { goto handle_unusual; @@ -885,8 +798,8 @@ bool CodeGeneratorRequest::MergePartialFromCodedStream( // repeated .google.protobuf.FileDescriptorProto proto_file = 15; case 15: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(122u)) { - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + static_cast< ::google::protobuf::uint8>(122u /* 122 & 0xFF */)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, add_proto_file())); } else { goto handle_unusual; @@ -896,13 +809,11 @@ bool CodeGeneratorRequest::MergePartialFromCodedStream( default: { handle_unusual: - if (tag == 0 || - ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + if (tag == 0) { goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); + input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } @@ -925,7 +836,7 @@ void CodeGeneratorRequest::SerializeWithCachedSizes( // repeated string file_to_generate = 1; for (int i = 0, n = this->file_to_generate_size(); i < n; i++) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->file_to_generate(i).data(), this->file_to_generate(i).length(), + this->file_to_generate(i).data(), static_cast<int>(this->file_to_generate(i).length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.compiler.CodeGeneratorRequest.file_to_generate"); ::google::protobuf::internal::WireFormatLite::WriteString( @@ -936,7 +847,7 @@ void CodeGeneratorRequest::SerializeWithCachedSizes( // optional string parameter = 2; if (cached_has_bits & 0x00000001u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->parameter().data(), this->parameter().length(), + this->parameter().data(), static_cast<int>(this->parameter().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.compiler.CodeGeneratorRequest.parameter"); ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( @@ -946,24 +857,28 @@ void CodeGeneratorRequest::SerializeWithCachedSizes( // optional .google.protobuf.compiler.Version compiler_version = 3; if (cached_has_bits & 0x00000002u) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 3, *this->compiler_version_, output); + 3, *compiler_version_, output); } // repeated .google.protobuf.FileDescriptorProto proto_file = 15; - for (unsigned int i = 0, n = this->proto_file_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->proto_file_size()); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 15, this->proto_file(i), output); + 15, + this->proto_file(static_cast<int>(i)), + output); } if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); + _internal_metadata_.unknown_fields(), output); } // @@protoc_insertion_point(serialize_end:google.protobuf.compiler.CodeGeneratorRequest) } ::google::protobuf::uint8* CodeGeneratorRequest::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.compiler.CodeGeneratorRequest) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -971,7 +886,7 @@ void CodeGeneratorRequest::SerializeWithCachedSizes( // repeated string file_to_generate = 1; for (int i = 0, n = this->file_to_generate_size(); i < n; i++) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->file_to_generate(i).data(), this->file_to_generate(i).length(), + this->file_to_generate(i).data(), static_cast<int>(this->file_to_generate(i).length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.compiler.CodeGeneratorRequest.file_to_generate"); target = ::google::protobuf::internal::WireFormatLite:: @@ -982,7 +897,7 @@ void CodeGeneratorRequest::SerializeWithCachedSizes( // optional string parameter = 2; if (cached_has_bits & 0x00000001u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->parameter().data(), this->parameter().length(), + this->parameter().data(), static_cast<int>(this->parameter().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.compiler.CodeGeneratorRequest.parameter"); target = @@ -993,20 +908,21 @@ void CodeGeneratorRequest::SerializeWithCachedSizes( // optional .google.protobuf.compiler.Version compiler_version = 3; if (cached_has_bits & 0x00000002u) { target = ::google::protobuf::internal::WireFormatLite:: - InternalWriteMessageNoVirtualToArray( - 3, *this->compiler_version_, deterministic, target); + InternalWriteMessageToArray( + 3, *compiler_version_, deterministic, target); } // repeated .google.protobuf.FileDescriptorProto proto_file = 15; - for (unsigned int i = 0, n = this->proto_file_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->proto_file_size()); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: - InternalWriteMessageNoVirtualToArray( - 15, this->proto_file(i), deterministic, target); + InternalWriteMessageToArray( + 15, this->proto_file(static_cast<int>(i)), deterministic, target); } if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); + _internal_metadata_.unknown_fields(), target); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.compiler.CodeGeneratorRequest) return target; @@ -1019,7 +935,7 @@ size_t CodeGeneratorRequest::ByteSizeLong() const { if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); + _internal_metadata_.unknown_fields()); } // repeated string file_to_generate = 1; total_size += 1 * @@ -1031,12 +947,12 @@ size_t CodeGeneratorRequest::ByteSizeLong() const { // repeated .google.protobuf.FileDescriptorProto proto_file = 15; { - unsigned int count = this->proto_file_size(); + unsigned int count = static_cast<unsigned int>(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)); + ::google::protobuf::internal::WireFormatLite::MessageSize( + this->proto_file(static_cast<int>(i))); } } @@ -1051,8 +967,8 @@ size_t CodeGeneratorRequest::ByteSizeLong() const { // optional .google.protobuf.compiler.Version compiler_version = 3; if (has_compiler_version()) { total_size += 1 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - *this->compiler_version_); + ::google::protobuf::internal::WireFormatLite::MessageSize( + *compiler_version_); } } @@ -1123,234 +1039,26 @@ void CodeGeneratorRequest::Swap(CodeGeneratorRequest* other) { InternalSwap(other); } void CodeGeneratorRequest::InternalSwap(CodeGeneratorRequest* other) { - file_to_generate_.InternalSwap(&other->file_to_generate_); - proto_file_.InternalSwap(&other->proto_file_); + using std::swap; + file_to_generate_.InternalSwap(CastToBase(&other->file_to_generate_)); + CastToBase(&proto_file_)->InternalSwap(CastToBase(&other->proto_file_)); parameter_.Swap(&other->parameter_); - std::swap(compiler_version_, other->compiler_version_); - std::swap(_has_bits_[0], other->_has_bits_[0]); + swap(compiler_version_, other->compiler_version_); + swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); - std::swap(_cached_size_, other->_cached_size_); + swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata CodeGeneratorRequest::GetMetadata() const { protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::file_level_metadata[kIndexInFileMessages]; + return ::protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::file_level_metadata[kIndexInFileMessages]; } -#if PROTOBUF_INLINE_NOT_IN_HEADERS -// CodeGeneratorRequest - -// repeated string file_to_generate = 1; -int CodeGeneratorRequest::file_to_generate_size() const { - return file_to_generate_.size(); -} -void CodeGeneratorRequest::clear_file_to_generate() { - file_to_generate_.Clear(); -} -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) { - // @@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) { - // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) - file_to_generate_.Mutable(index)->assign(value); -} -#if LANG_CXX11 -void CodeGeneratorRequest::set_file_to_generate(int index, ::std::string&& value) { - // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) - file_to_generate_.Mutable(index)->assign(std::move(value)); -} -#endif -void CodeGeneratorRequest::set_file_to_generate(int index, const char* value) { - GOOGLE_DCHECK(value != NULL); - 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) { - file_to_generate_.Mutable(index)->assign( - reinterpret_cast<const char*>(value), size); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) -} -::std::string* CodeGeneratorRequest::add_file_to_generate() { - // @@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) { - file_to_generate_.Add()->assign(value); - // @@protoc_insertion_point(field_add:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) -} -#if LANG_CXX11 -void CodeGeneratorRequest::add_file_to_generate(::std::string&& value) { - file_to_generate_.Add(std::move(value)); - // @@protoc_insertion_point(field_add:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) -} -#endif -void CodeGeneratorRequest::add_file_to_generate(const char* value) { - GOOGLE_DCHECK(value != NULL); - 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) { - file_to_generate_.Add()->assign(reinterpret_cast<const char*>(value), size); - // @@protoc_insertion_point(field_add_pointer:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) -} -const ::google::protobuf::RepeatedPtrField< ::std::string>& -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>* -CodeGeneratorRequest::mutable_file_to_generate() { - // @@protoc_insertion_point(field_mutable_list:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) - return &file_to_generate_; -} - -// optional string parameter = 2; -bool CodeGeneratorRequest::has_parameter() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -void CodeGeneratorRequest::set_has_parameter() { - _has_bits_[0] |= 0x00000001u; -} -void CodeGeneratorRequest::clear_has_parameter() { - _has_bits_[0] &= ~0x00000001u; -} -void CodeGeneratorRequest::clear_parameter() { - parameter_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - clear_has_parameter(); -} -const ::std::string& CodeGeneratorRequest::parameter() const { - // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorRequest.parameter) - return parameter_.GetNoArena(); -} -void CodeGeneratorRequest::set_parameter(const ::std::string& value) { - set_has_parameter(); - parameter_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorRequest.parameter) -} -#if LANG_CXX11 -void CodeGeneratorRequest::set_parameter(::std::string&& value) { - set_has_parameter(); - parameter_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.CodeGeneratorRequest.parameter) -} -#endif -void CodeGeneratorRequest::set_parameter(const char* value) { - GOOGLE_DCHECK(value != NULL); - 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) { - set_has_parameter(); - parameter_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorRequest.parameter) -} -::std::string* CodeGeneratorRequest::mutable_parameter() { - 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() { - // @@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) { - if (parameter != NULL) { - set_has_parameter(); - } else { - clear_has_parameter(); - } - parameter_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), parameter); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorRequest.parameter) -} - -// repeated .google.protobuf.FileDescriptorProto proto_file = 15; -int CodeGeneratorRequest::proto_file_size() const { - return proto_file_.size(); -} -void CodeGeneratorRequest::clear_proto_file() { - proto_file_.Clear(); -} -const ::google::protobuf::FileDescriptorProto& CodeGeneratorRequest::proto_file(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorRequest.proto_file) - return proto_file_.Get(index); -} -::google::protobuf::FileDescriptorProto* CodeGeneratorRequest::mutable_proto_file(int index) { - // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorRequest.proto_file) - return proto_file_.Mutable(index); -} -::google::protobuf::FileDescriptorProto* CodeGeneratorRequest::add_proto_file() { - // @@protoc_insertion_point(field_add:google.protobuf.compiler.CodeGeneratorRequest.proto_file) - return proto_file_.Add(); -} -::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto >* -CodeGeneratorRequest::mutable_proto_file() { - // @@protoc_insertion_point(field_mutable_list:google.protobuf.compiler.CodeGeneratorRequest.proto_file) - return &proto_file_; -} -const ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto >& -CodeGeneratorRequest::proto_file() const { - // @@protoc_insertion_point(field_list:google.protobuf.compiler.CodeGeneratorRequest.proto_file) - return proto_file_; -} - -// optional .google.protobuf.compiler.Version compiler_version = 3; -bool CodeGeneratorRequest::has_compiler_version() const { - return (_has_bits_[0] & 0x00000002u) != 0; -} -void CodeGeneratorRequest::set_has_compiler_version() { - _has_bits_[0] |= 0x00000002u; -} -void CodeGeneratorRequest::clear_has_compiler_version() { - _has_bits_[0] &= ~0x00000002u; -} -void CodeGeneratorRequest::clear_compiler_version() { - if (compiler_version_ != NULL) compiler_version_->::google::protobuf::compiler::Version::Clear(); - clear_has_compiler_version(); -} -const ::google::protobuf::compiler::Version& CodeGeneratorRequest::compiler_version() const { - // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorRequest.compiler_version) - return compiler_version_ != NULL ? *compiler_version_ - : *::google::protobuf::compiler::Version::internal_default_instance(); -} -::google::protobuf::compiler::Version* CodeGeneratorRequest::mutable_compiler_version() { - set_has_compiler_version(); - if (compiler_version_ == NULL) { - compiler_version_ = new ::google::protobuf::compiler::Version; - } - // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorRequest.compiler_version) - return compiler_version_; -} -::google::protobuf::compiler::Version* CodeGeneratorRequest::release_compiler_version() { - // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorRequest.compiler_version) - clear_has_compiler_version(); - ::google::protobuf::compiler::Version* temp = compiler_version_; - compiler_version_ = NULL; - return temp; -} -void CodeGeneratorRequest::set_allocated_compiler_version(::google::protobuf::compiler::Version* compiler_version) { - delete compiler_version_; - compiler_version_ = compiler_version; - if (compiler_version) { - set_has_compiler_version(); - } else { - clear_has_compiler_version(); - } - // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorRequest.compiler_version) -} - -#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== +void CodeGeneratorResponse_File::InitAsDefaultInstance() { +} #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int CodeGeneratorResponse_File::kNameFieldNumber; const int CodeGeneratorResponse_File::kInsertionPointFieldNumber; @@ -1360,7 +1068,7 @@ const int CodeGeneratorResponse_File::kContentFieldNumber; CodeGeneratorResponse_File::CodeGeneratorResponse_File() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { - protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::InitDefaultsCodeGeneratorResponse_File(); } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.compiler.CodeGeneratorResponse.File) @@ -1410,37 +1118,35 @@ void CodeGeneratorResponse_File::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* CodeGeneratorResponse_File::descriptor() { - protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; + ::protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::protobuf_AssignDescriptorsOnce(); + return ::protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const CodeGeneratorResponse_File& CodeGeneratorResponse_File::default_instance() { - protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::InitDefaultsCodeGeneratorResponse_File(); return *internal_default_instance(); } -CodeGeneratorResponse_File* CodeGeneratorResponse_File::New(::google::protobuf::Arena* arena) const { - CodeGeneratorResponse_File* n = new CodeGeneratorResponse_File; - if (arena != NULL) { - arena->Own(n); - } - return n; -} void CodeGeneratorResponse_File::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.compiler.CodeGeneratorResponse.File) - if (_has_bits_[0 / 32] & 7u) { - if (has_name()) { + ::google::protobuf::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + cached_has_bits = _has_bits_[0]; + if (cached_has_bits & 7u) { + if (cached_has_bits & 0x00000001u) { GOOGLE_DCHECK(!name_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); - (*name_.UnsafeRawStringPointer())->clear(); + name_.UnsafeMutablePointer()->clear(); } - if (has_insertion_point()) { + if (cached_has_bits & 0x00000002u) { GOOGLE_DCHECK(!insertion_point_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); - (*insertion_point_.UnsafeRawStringPointer())->clear(); + insertion_point_.UnsafeMutablePointer()->clear(); } - if (has_content()) { + if (cached_has_bits & 0x00000004u) { GOOGLE_DCHECK(!content_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); - (*content_.UnsafeRawStringPointer())->clear(); + content_.UnsafeMutablePointer()->clear(); } } _has_bits_.Clear(); @@ -1460,11 +1166,11 @@ bool CodeGeneratorResponse_File::MergePartialFromCodedStream( // optional string name = 1; case 1: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(10u)) { + static_cast< ::google::protobuf::uint8>(10u /* 10 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->name().data(), this->name().length(), + this->name().data(), static_cast<int>(this->name().length()), ::google::protobuf::internal::WireFormat::PARSE, "google.protobuf.compiler.CodeGeneratorResponse.File.name"); } else { @@ -1476,11 +1182,11 @@ bool CodeGeneratorResponse_File::MergePartialFromCodedStream( // optional string insertion_point = 2; case 2: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(18u)) { + static_cast< ::google::protobuf::uint8>(18u /* 18 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_insertion_point())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->insertion_point().data(), this->insertion_point().length(), + this->insertion_point().data(), static_cast<int>(this->insertion_point().length()), ::google::protobuf::internal::WireFormat::PARSE, "google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point"); } else { @@ -1492,11 +1198,11 @@ bool CodeGeneratorResponse_File::MergePartialFromCodedStream( // optional string content = 15; case 15: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(122u)) { + static_cast< ::google::protobuf::uint8>(122u /* 122 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_content())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->content().data(), this->content().length(), + this->content().data(), static_cast<int>(this->content().length()), ::google::protobuf::internal::WireFormat::PARSE, "google.protobuf.compiler.CodeGeneratorResponse.File.content"); } else { @@ -1507,13 +1213,11 @@ bool CodeGeneratorResponse_File::MergePartialFromCodedStream( default: { handle_unusual: - if (tag == 0 || - ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + if (tag == 0) { goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); + input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } @@ -1537,7 +1241,7 @@ void CodeGeneratorResponse_File::SerializeWithCachedSizes( // optional string name = 1; if (cached_has_bits & 0x00000001u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->name().data(), this->name().length(), + this->name().data(), static_cast<int>(this->name().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.compiler.CodeGeneratorResponse.File.name"); ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( @@ -1547,7 +1251,7 @@ void CodeGeneratorResponse_File::SerializeWithCachedSizes( // optional string insertion_point = 2; if (cached_has_bits & 0x00000002u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->insertion_point().data(), this->insertion_point().length(), + this->insertion_point().data(), static_cast<int>(this->insertion_point().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point"); ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( @@ -1557,7 +1261,7 @@ void CodeGeneratorResponse_File::SerializeWithCachedSizes( // optional string content = 15; if (cached_has_bits & 0x00000004u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->content().data(), this->content().length(), + this->content().data(), static_cast<int>(this->content().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.compiler.CodeGeneratorResponse.File.content"); ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( @@ -1566,13 +1270,14 @@ void CodeGeneratorResponse_File::SerializeWithCachedSizes( if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); + _internal_metadata_.unknown_fields(), output); } // @@protoc_insertion_point(serialize_end:google.protobuf.compiler.CodeGeneratorResponse.File) } ::google::protobuf::uint8* CodeGeneratorResponse_File::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.compiler.CodeGeneratorResponse.File) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -1581,7 +1286,7 @@ void CodeGeneratorResponse_File::SerializeWithCachedSizes( // optional string name = 1; if (cached_has_bits & 0x00000001u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->name().data(), this->name().length(), + this->name().data(), static_cast<int>(this->name().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.compiler.CodeGeneratorResponse.File.name"); target = @@ -1592,7 +1297,7 @@ void CodeGeneratorResponse_File::SerializeWithCachedSizes( // optional string insertion_point = 2; if (cached_has_bits & 0x00000002u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->insertion_point().data(), this->insertion_point().length(), + this->insertion_point().data(), static_cast<int>(this->insertion_point().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point"); target = @@ -1603,7 +1308,7 @@ void CodeGeneratorResponse_File::SerializeWithCachedSizes( // optional string content = 15; if (cached_has_bits & 0x00000004u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->content().data(), this->content().length(), + this->content().data(), static_cast<int>(this->content().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.compiler.CodeGeneratorResponse.File.content"); target = @@ -1613,7 +1318,7 @@ void CodeGeneratorResponse_File::SerializeWithCachedSizes( if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); + _internal_metadata_.unknown_fields(), target); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.compiler.CodeGeneratorResponse.File) return target; @@ -1626,7 +1331,7 @@ size_t CodeGeneratorResponse_File::ByteSizeLong() const { if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); + _internal_metadata_.unknown_fields()); } if (_has_bits_[0 / 32] & 7u) { // optional string name = 1; @@ -1720,215 +1425,25 @@ void CodeGeneratorResponse_File::Swap(CodeGeneratorResponse_File* other) { InternalSwap(other); } void CodeGeneratorResponse_File::InternalSwap(CodeGeneratorResponse_File* other) { + using std::swap; name_.Swap(&other->name_); insertion_point_.Swap(&other->insertion_point_); content_.Swap(&other->content_); - std::swap(_has_bits_[0], other->_has_bits_[0]); + swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); - std::swap(_cached_size_, other->_cached_size_); + swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata CodeGeneratorResponse_File::GetMetadata() const { protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::file_level_metadata[kIndexInFileMessages]; -} - -#if PROTOBUF_INLINE_NOT_IN_HEADERS -// CodeGeneratorResponse_File - -// optional string name = 1; -bool CodeGeneratorResponse_File::has_name() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -void CodeGeneratorResponse_File::set_has_name() { - _has_bits_[0] |= 0x00000001u; -} -void CodeGeneratorResponse_File::clear_has_name() { - _has_bits_[0] &= ~0x00000001u; -} -void CodeGeneratorResponse_File::clear_name() { - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - clear_has_name(); -} -const ::std::string& CodeGeneratorResponse_File::name() const { - // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.name) - return name_.GetNoArena(); -} -void CodeGeneratorResponse_File::set_name(const ::std::string& value) { - set_has_name(); - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.name) -} -#if LANG_CXX11 -void CodeGeneratorResponse_File::set_name(::std::string&& value) { - set_has_name(); - name_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.CodeGeneratorResponse.File.name) -} -#endif -void CodeGeneratorResponse_File::set_name(const char* value) { - GOOGLE_DCHECK(value != NULL); - set_has_name(); - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); - // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorResponse.File.name) -} -void CodeGeneratorResponse_File::set_name(const char* value, size_t size) { - set_has_name(); - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorResponse.File.name) -} -::std::string* CodeGeneratorResponse_File::mutable_name() { - set_has_name(); - // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorResponse.File.name) - return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -::std::string* CodeGeneratorResponse_File::release_name() { - // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.File.name) - clear_has_name(); - return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -void CodeGeneratorResponse_File::set_allocated_name(::std::string* name) { - if (name != NULL) { - set_has_name(); - } else { - clear_has_name(); - } - name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.name) -} - -// optional string insertion_point = 2; -bool CodeGeneratorResponse_File::has_insertion_point() const { - return (_has_bits_[0] & 0x00000002u) != 0; -} -void CodeGeneratorResponse_File::set_has_insertion_point() { - _has_bits_[0] |= 0x00000002u; -} -void CodeGeneratorResponse_File::clear_has_insertion_point() { - _has_bits_[0] &= ~0x00000002u; -} -void CodeGeneratorResponse_File::clear_insertion_point() { - insertion_point_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - clear_has_insertion_point(); -} -const ::std::string& CodeGeneratorResponse_File::insertion_point() const { - // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) - return insertion_point_.GetNoArena(); -} -void CodeGeneratorResponse_File::set_insertion_point(const ::std::string& value) { - set_has_insertion_point(); - insertion_point_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) -} -#if LANG_CXX11 -void CodeGeneratorResponse_File::set_insertion_point(::std::string&& value) { - set_has_insertion_point(); - insertion_point_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) -} -#endif -void CodeGeneratorResponse_File::set_insertion_point(const char* value) { - GOOGLE_DCHECK(value != NULL); - set_has_insertion_point(); - insertion_point_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); - // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) -} -void CodeGeneratorResponse_File::set_insertion_point(const char* value, size_t size) { - set_has_insertion_point(); - insertion_point_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) -} -::std::string* CodeGeneratorResponse_File::mutable_insertion_point() { - set_has_insertion_point(); - // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) - return insertion_point_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -::std::string* CodeGeneratorResponse_File::release_insertion_point() { - // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) - clear_has_insertion_point(); - return insertion_point_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -void CodeGeneratorResponse_File::set_allocated_insertion_point(::std::string* insertion_point) { - if (insertion_point != NULL) { - set_has_insertion_point(); - } else { - clear_has_insertion_point(); - } - insertion_point_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), insertion_point); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) + return ::protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::file_level_metadata[kIndexInFileMessages]; } -// optional string content = 15; -bool CodeGeneratorResponse_File::has_content() const { - return (_has_bits_[0] & 0x00000004u) != 0; -} -void CodeGeneratorResponse_File::set_has_content() { - _has_bits_[0] |= 0x00000004u; -} -void CodeGeneratorResponse_File::clear_has_content() { - _has_bits_[0] &= ~0x00000004u; -} -void CodeGeneratorResponse_File::clear_content() { - content_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - clear_has_content(); -} -const ::std::string& CodeGeneratorResponse_File::content() const { - // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.content) - return content_.GetNoArena(); -} -void CodeGeneratorResponse_File::set_content(const ::std::string& value) { - set_has_content(); - content_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.content) -} -#if LANG_CXX11 -void CodeGeneratorResponse_File::set_content(::std::string&& value) { - set_has_content(); - content_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.CodeGeneratorResponse.File.content) -} -#endif -void CodeGeneratorResponse_File::set_content(const char* value) { - GOOGLE_DCHECK(value != NULL); - set_has_content(); - content_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); - // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorResponse.File.content) -} -void CodeGeneratorResponse_File::set_content(const char* value, size_t size) { - set_has_content(); - content_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorResponse.File.content) -} -::std::string* CodeGeneratorResponse_File::mutable_content() { - set_has_content(); - // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorResponse.File.content) - return content_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -::std::string* CodeGeneratorResponse_File::release_content() { - // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.File.content) - clear_has_content(); - return content_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -void CodeGeneratorResponse_File::set_allocated_content(::std::string* content) { - if (content != NULL) { - set_has_content(); - } else { - clear_has_content(); - } - content_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), content); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.content) -} - -#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== +void CodeGeneratorResponse::InitAsDefaultInstance() { +} #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int CodeGeneratorResponse::kErrorFieldNumber; const int CodeGeneratorResponse::kFileFieldNumber; @@ -1937,7 +1452,7 @@ const int CodeGeneratorResponse::kFileFieldNumber; CodeGeneratorResponse::CodeGeneratorResponse() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { - protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::InitDefaultsCodeGeneratorResponse(); } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.compiler.CodeGeneratorResponse) @@ -1976,29 +1491,27 @@ void CodeGeneratorResponse::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* CodeGeneratorResponse::descriptor() { - protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; + ::protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::protobuf_AssignDescriptorsOnce(); + return ::protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const CodeGeneratorResponse& CodeGeneratorResponse::default_instance() { - protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::InitDefaultsCodeGeneratorResponse(); return *internal_default_instance(); } -CodeGeneratorResponse* CodeGeneratorResponse::New(::google::protobuf::Arena* arena) const { - CodeGeneratorResponse* n = new CodeGeneratorResponse; - if (arena != NULL) { - arena->Own(n); - } - return n; -} void CodeGeneratorResponse::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.compiler.CodeGeneratorResponse) + ::google::protobuf::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + file_.Clear(); - if (has_error()) { + cached_has_bits = _has_bits_[0]; + if (cached_has_bits & 0x00000001u) { GOOGLE_DCHECK(!error_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); - (*error_.UnsafeRawStringPointer())->clear(); + error_.UnsafeMutablePointer()->clear(); } _has_bits_.Clear(); _internal_metadata_.Clear(); @@ -2017,11 +1530,11 @@ bool CodeGeneratorResponse::MergePartialFromCodedStream( // optional string error = 1; case 1: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(10u)) { + static_cast< ::google::protobuf::uint8>(10u /* 10 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_error())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->error().data(), this->error().length(), + this->error().data(), static_cast<int>(this->error().length()), ::google::protobuf::internal::WireFormat::PARSE, "google.protobuf.compiler.CodeGeneratorResponse.error"); } else { @@ -2033,8 +1546,8 @@ bool CodeGeneratorResponse::MergePartialFromCodedStream( // repeated .google.protobuf.compiler.CodeGeneratorResponse.File file = 15; case 15: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(122u)) { - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + static_cast< ::google::protobuf::uint8>(122u /* 122 & 0xFF */)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, add_file())); } else { goto handle_unusual; @@ -2044,13 +1557,11 @@ bool CodeGeneratorResponse::MergePartialFromCodedStream( default: { handle_unusual: - if (tag == 0 || - ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + if (tag == 0) { goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); + input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } @@ -2074,7 +1585,7 @@ void CodeGeneratorResponse::SerializeWithCachedSizes( // optional string error = 1; if (cached_has_bits & 0x00000001u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->error().data(), this->error().length(), + this->error().data(), static_cast<int>(this->error().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.compiler.CodeGeneratorResponse.error"); ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( @@ -2082,20 +1593,24 @@ void CodeGeneratorResponse::SerializeWithCachedSizes( } // repeated .google.protobuf.compiler.CodeGeneratorResponse.File file = 15; - for (unsigned int i = 0, n = this->file_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->file_size()); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 15, this->file(i), output); + 15, + this->file(static_cast<int>(i)), + output); } if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); + _internal_metadata_.unknown_fields(), output); } // @@protoc_insertion_point(serialize_end:google.protobuf.compiler.CodeGeneratorResponse) } ::google::protobuf::uint8* CodeGeneratorResponse::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.compiler.CodeGeneratorResponse) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -2104,7 +1619,7 @@ void CodeGeneratorResponse::SerializeWithCachedSizes( // optional string error = 1; if (cached_has_bits & 0x00000001u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->error().data(), this->error().length(), + this->error().data(), static_cast<int>(this->error().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.compiler.CodeGeneratorResponse.error"); target = @@ -2113,15 +1628,16 @@ void CodeGeneratorResponse::SerializeWithCachedSizes( } // repeated .google.protobuf.compiler.CodeGeneratorResponse.File file = 15; - for (unsigned int i = 0, n = this->file_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->file_size()); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: - InternalWriteMessageNoVirtualToArray( - 15, this->file(i), deterministic, target); + InternalWriteMessageToArray( + 15, this->file(static_cast<int>(i)), deterministic, target); } if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); + _internal_metadata_.unknown_fields(), target); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.compiler.CodeGeneratorResponse) return target; @@ -2134,16 +1650,16 @@ size_t CodeGeneratorResponse::ByteSizeLong() const { if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); + _internal_metadata_.unknown_fields()); } // repeated .google.protobuf.compiler.CodeGeneratorResponse.File file = 15; { - unsigned int count = this->file_size(); + unsigned int count = static_cast<unsigned int>(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)); + ::google::protobuf::internal::WireFormatLite::MessageSize( + this->file(static_cast<int>(i))); } } @@ -2213,119 +1729,38 @@ void CodeGeneratorResponse::Swap(CodeGeneratorResponse* other) { InternalSwap(other); } void CodeGeneratorResponse::InternalSwap(CodeGeneratorResponse* other) { - file_.InternalSwap(&other->file_); + using std::swap; + CastToBase(&file_)->InternalSwap(CastToBase(&other->file_)); error_.Swap(&other->error_); - std::swap(_has_bits_[0], other->_has_bits_[0]); + swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); - std::swap(_cached_size_, other->_cached_size_); + swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata CodeGeneratorResponse::GetMetadata() const { protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::file_level_metadata[kIndexInFileMessages]; + return ::protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::file_level_metadata[kIndexInFileMessages]; } -#if PROTOBUF_INLINE_NOT_IN_HEADERS -// CodeGeneratorResponse -// optional string error = 1; -bool CodeGeneratorResponse::has_error() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -void CodeGeneratorResponse::set_has_error() { - _has_bits_[0] |= 0x00000001u; -} -void CodeGeneratorResponse::clear_has_error() { - _has_bits_[0] &= ~0x00000001u; -} -void CodeGeneratorResponse::clear_error() { - error_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - clear_has_error(); -} -const ::std::string& CodeGeneratorResponse::error() const { - // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.error) - return error_.GetNoArena(); -} -void CodeGeneratorResponse::set_error(const ::std::string& value) { - set_has_error(); - error_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.error) -} -#if LANG_CXX11 -void CodeGeneratorResponse::set_error(::std::string&& value) { - set_has_error(); - error_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.CodeGeneratorResponse.error) -} -#endif -void CodeGeneratorResponse::set_error(const char* value) { - GOOGLE_DCHECK(value != NULL); - 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) { - set_has_error(); - error_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorResponse.error) -} -::std::string* CodeGeneratorResponse::mutable_error() { - 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() { - // @@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) { - if (error != NULL) { - set_has_error(); - } else { - clear_has_error(); - } - error_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), error); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.error) -} - -// repeated .google.protobuf.compiler.CodeGeneratorResponse.File file = 15; -int CodeGeneratorResponse::file_size() const { - return file_.size(); -} -void CodeGeneratorResponse::clear_file() { - file_.Clear(); -} -const ::google::protobuf::compiler::CodeGeneratorResponse_File& CodeGeneratorResponse::file(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.file) - return file_.Get(index); -} -::google::protobuf::compiler::CodeGeneratorResponse_File* CodeGeneratorResponse::mutable_file(int index) { - // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorResponse.file) - return file_.Mutable(index); +// @@protoc_insertion_point(namespace_scope) +} // namespace compiler +} // namespace protobuf +} // namespace google +namespace google { +namespace protobuf { +template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::compiler::Version* Arena::Create< ::google::protobuf::compiler::Version >(Arena* arena) { + return Arena::CreateInternal< ::google::protobuf::compiler::Version >(arena); } -::google::protobuf::compiler::CodeGeneratorResponse_File* CodeGeneratorResponse::add_file() { - // @@protoc_insertion_point(field_add:google.protobuf.compiler.CodeGeneratorResponse.file) - return file_.Add(); +template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::compiler::CodeGeneratorRequest* Arena::Create< ::google::protobuf::compiler::CodeGeneratorRequest >(Arena* arena) { + return Arena::CreateInternal< ::google::protobuf::compiler::CodeGeneratorRequest >(arena); } -::google::protobuf::RepeatedPtrField< ::google::protobuf::compiler::CodeGeneratorResponse_File >* -CodeGeneratorResponse::mutable_file() { - // @@protoc_insertion_point(field_mutable_list:google.protobuf.compiler.CodeGeneratorResponse.file) - return &file_; +template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::compiler::CodeGeneratorResponse_File* Arena::Create< ::google::protobuf::compiler::CodeGeneratorResponse_File >(Arena* arena) { + return Arena::CreateInternal< ::google::protobuf::compiler::CodeGeneratorResponse_File >(arena); } -const ::google::protobuf::RepeatedPtrField< ::google::protobuf::compiler::CodeGeneratorResponse_File >& -CodeGeneratorResponse::file() const { - // @@protoc_insertion_point(field_list:google.protobuf.compiler.CodeGeneratorResponse.file) - return file_; +template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::compiler::CodeGeneratorResponse* Arena::Create< ::google::protobuf::compiler::CodeGeneratorResponse >(Arena* arena) { + return Arena::CreateInternal< ::google::protobuf::compiler::CodeGeneratorResponse >(arena); } - -#endif // PROTOBUF_INLINE_NOT_IN_HEADERS - -// @@protoc_insertion_point(namespace_scope) - -} // namespace compiler } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/compiler/plugin.pb.h b/src/google/protobuf/compiler/plugin.pb.h index 4f8befb6..a6c1300e 100644 --- a/src/google/protobuf/compiler/plugin.pb.h +++ b/src/google/protobuf/compiler/plugin.pb.h @@ -1,19 +1,19 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/protobuf/compiler/plugin.proto -#ifndef PROTOBUF_google_2fprotobuf_2fcompiler_2fplugin_2eproto__INCLUDED -#define PROTOBUF_google_2fprotobuf_2fcompiler_2fplugin_2eproto__INCLUDED +#ifndef PROTOBUF_google_2fprotobuf_2fcompiler_2fplugin_2eproto_INCLUDED +#define PROTOBUF_google_2fprotobuf_2fcompiler_2fplugin_2eproto_INCLUDED #include <string> #include <google/protobuf/stubs/common.h> -#if GOOGLE_PROTOBUF_VERSION < 3003000 +#if GOOGLE_PROTOBUF_VERSION < 3005000 #error This file was generated by a newer version of protoc which is #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3003000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION +#if 3005001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. @@ -37,83 +37,35 @@ #ifdef minor #undef minor #endif + +namespace protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto { +// Internal implementation detail -- do not use these members. +struct LIBPROTOC_EXPORT TableStruct { + static const ::google::protobuf::internal::ParseTableField entries[]; + static const ::google::protobuf::internal::AuxillaryParseTableField aux[]; + static const ::google::protobuf::internal::ParseTable schema[4]; + static const ::google::protobuf::internal::FieldMetadata field_metadata[]; + static const ::google::protobuf::internal::SerializationTable serialization_table[]; + static const ::google::protobuf::uint32 offsets[]; +}; +void LIBPROTOC_EXPORT AddDescriptors(); +void LIBPROTOC_EXPORT InitDefaultsVersionImpl(); +void LIBPROTOC_EXPORT InitDefaultsVersion(); +void LIBPROTOC_EXPORT InitDefaultsCodeGeneratorRequestImpl(); +void LIBPROTOC_EXPORT InitDefaultsCodeGeneratorRequest(); +void LIBPROTOC_EXPORT InitDefaultsCodeGeneratorResponse_FileImpl(); +void LIBPROTOC_EXPORT InitDefaultsCodeGeneratorResponse_File(); +void LIBPROTOC_EXPORT InitDefaultsCodeGeneratorResponseImpl(); +void LIBPROTOC_EXPORT InitDefaultsCodeGeneratorResponse(); +inline void LIBPROTOC_EXPORT InitDefaults() { + InitDefaultsVersion(); + InitDefaultsCodeGeneratorRequest(); + InitDefaultsCodeGeneratorResponse_File(); + InitDefaultsCodeGeneratorResponse(); +} +} // namespace protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto namespace google { namespace protobuf { -class DescriptorProto; -class DescriptorProtoDefaultTypeInternal; -LIBPROTOC_EXPORT extern DescriptorProtoDefaultTypeInternal _DescriptorProto_default_instance_; -class DescriptorProto_ExtensionRange; -class DescriptorProto_ExtensionRangeDefaultTypeInternal; -LIBPROTOC_EXPORT extern DescriptorProto_ExtensionRangeDefaultTypeInternal _DescriptorProto_ExtensionRange_default_instance_; -class DescriptorProto_ReservedRange; -class DescriptorProto_ReservedRangeDefaultTypeInternal; -LIBPROTOC_EXPORT extern DescriptorProto_ReservedRangeDefaultTypeInternal _DescriptorProto_ReservedRange_default_instance_; -class EnumDescriptorProto; -class EnumDescriptorProtoDefaultTypeInternal; -LIBPROTOC_EXPORT extern EnumDescriptorProtoDefaultTypeInternal _EnumDescriptorProto_default_instance_; -class EnumOptions; -class EnumOptionsDefaultTypeInternal; -LIBPROTOC_EXPORT extern EnumOptionsDefaultTypeInternal _EnumOptions_default_instance_; -class EnumValueDescriptorProto; -class EnumValueDescriptorProtoDefaultTypeInternal; -LIBPROTOC_EXPORT extern EnumValueDescriptorProtoDefaultTypeInternal _EnumValueDescriptorProto_default_instance_; -class EnumValueOptions; -class EnumValueOptionsDefaultTypeInternal; -LIBPROTOC_EXPORT extern EnumValueOptionsDefaultTypeInternal _EnumValueOptions_default_instance_; -class FieldDescriptorProto; -class FieldDescriptorProtoDefaultTypeInternal; -LIBPROTOC_EXPORT extern FieldDescriptorProtoDefaultTypeInternal _FieldDescriptorProto_default_instance_; -class FieldOptions; -class FieldOptionsDefaultTypeInternal; -LIBPROTOC_EXPORT extern FieldOptionsDefaultTypeInternal _FieldOptions_default_instance_; -class FileDescriptorProto; -class FileDescriptorProtoDefaultTypeInternal; -LIBPROTOC_EXPORT extern FileDescriptorProtoDefaultTypeInternal _FileDescriptorProto_default_instance_; -class FileDescriptorSet; -class FileDescriptorSetDefaultTypeInternal; -LIBPROTOC_EXPORT extern FileDescriptorSetDefaultTypeInternal _FileDescriptorSet_default_instance_; -class FileOptions; -class FileOptionsDefaultTypeInternal; -LIBPROTOC_EXPORT extern FileOptionsDefaultTypeInternal _FileOptions_default_instance_; -class GeneratedCodeInfo; -class GeneratedCodeInfoDefaultTypeInternal; -LIBPROTOC_EXPORT extern GeneratedCodeInfoDefaultTypeInternal _GeneratedCodeInfo_default_instance_; -class GeneratedCodeInfo_Annotation; -class GeneratedCodeInfo_AnnotationDefaultTypeInternal; -LIBPROTOC_EXPORT extern GeneratedCodeInfo_AnnotationDefaultTypeInternal _GeneratedCodeInfo_Annotation_default_instance_; -class MessageOptions; -class MessageOptionsDefaultTypeInternal; -LIBPROTOC_EXPORT extern MessageOptionsDefaultTypeInternal _MessageOptions_default_instance_; -class MethodDescriptorProto; -class MethodDescriptorProtoDefaultTypeInternal; -LIBPROTOC_EXPORT extern MethodDescriptorProtoDefaultTypeInternal _MethodDescriptorProto_default_instance_; -class MethodOptions; -class MethodOptionsDefaultTypeInternal; -LIBPROTOC_EXPORT extern MethodOptionsDefaultTypeInternal _MethodOptions_default_instance_; -class OneofDescriptorProto; -class OneofDescriptorProtoDefaultTypeInternal; -LIBPROTOC_EXPORT extern OneofDescriptorProtoDefaultTypeInternal _OneofDescriptorProto_default_instance_; -class OneofOptions; -class OneofOptionsDefaultTypeInternal; -LIBPROTOC_EXPORT extern OneofOptionsDefaultTypeInternal _OneofOptions_default_instance_; -class ServiceDescriptorProto; -class ServiceDescriptorProtoDefaultTypeInternal; -LIBPROTOC_EXPORT extern ServiceDescriptorProtoDefaultTypeInternal _ServiceDescriptorProto_default_instance_; -class ServiceOptions; -class ServiceOptionsDefaultTypeInternal; -LIBPROTOC_EXPORT extern ServiceOptionsDefaultTypeInternal _ServiceOptions_default_instance_; -class SourceCodeInfo; -class SourceCodeInfoDefaultTypeInternal; -LIBPROTOC_EXPORT extern SourceCodeInfoDefaultTypeInternal _SourceCodeInfo_default_instance_; -class SourceCodeInfo_Location; -class SourceCodeInfo_LocationDefaultTypeInternal; -LIBPROTOC_EXPORT extern SourceCodeInfo_LocationDefaultTypeInternal _SourceCodeInfo_Location_default_instance_; -class UninterpretedOption; -class UninterpretedOptionDefaultTypeInternal; -LIBPROTOC_EXPORT extern UninterpretedOptionDefaultTypeInternal _UninterpretedOption_default_instance_; -class UninterpretedOption_NamePart; -class UninterpretedOption_NamePartDefaultTypeInternal; -LIBPROTOC_EXPORT extern UninterpretedOption_NamePartDefaultTypeInternal _UninterpretedOption_NamePart_default_instance_; namespace compiler { class CodeGeneratorRequest; class CodeGeneratorRequestDefaultTypeInternal; @@ -130,25 +82,18 @@ LIBPROTOC_EXPORT extern VersionDefaultTypeInternal _Version_default_instance_; } // namespace compiler } // namespace protobuf } // namespace google - +namespace google { +namespace protobuf { +template<> LIBPROTOC_EXPORT ::google::protobuf::compiler::CodeGeneratorRequest* Arena::Create< ::google::protobuf::compiler::CodeGeneratorRequest>(Arena*); +template<> LIBPROTOC_EXPORT ::google::protobuf::compiler::CodeGeneratorResponse* Arena::Create< ::google::protobuf::compiler::CodeGeneratorResponse>(Arena*); +template<> LIBPROTOC_EXPORT ::google::protobuf::compiler::CodeGeneratorResponse_File* Arena::Create< ::google::protobuf::compiler::CodeGeneratorResponse_File>(Arena*); +template<> LIBPROTOC_EXPORT ::google::protobuf::compiler::Version* Arena::Create< ::google::protobuf::compiler::Version>(Arena*); +} // namespace protobuf +} // namespace google namespace google { namespace protobuf { namespace compiler { -namespace protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto { -// Internal implementation detail -- do not call these. -struct LIBPROTOC_EXPORT TableStruct { - static const ::google::protobuf::internal::ParseTableField entries[]; - static const ::google::protobuf::internal::AuxillaryParseTableField aux[]; - static const ::google::protobuf::internal::ParseTable schema[]; - static const ::google::protobuf::uint32 offsets[]; - static void InitDefaultsImpl(); - static void Shutdown(); -}; -void LIBPROTOC_EXPORT AddDescriptors(); -void LIBPROTOC_EXPORT InitDefaults(); -} // namespace protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto - // =================================================================== class LIBPROTOC_EXPORT Version : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.Version) */ { @@ -162,11 +107,24 @@ class LIBPROTOC_EXPORT Version : public ::google::protobuf::Message /* @@protoc_ CopyFrom(from); return *this; } + #if LANG_CXX11 + Version(Version&& from) noexcept + : Version() { + *this = ::std::move(from); + } + inline Version& operator=(Version&& from) noexcept { + if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + #endif inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { return _internal_metadata_.unknown_fields(); } - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { return _internal_metadata_.mutable_unknown_fields(); } @@ -174,6 +132,7 @@ class LIBPROTOC_EXPORT Version : public ::google::protobuf::Message /* @@protoc_ static const ::google::protobuf::Descriptor* descriptor(); static const Version& default_instance(); + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY static inline const Version* internal_default_instance() { return reinterpret_cast<const Version*>( &_Version_default_instance_); @@ -182,12 +141,19 @@ class LIBPROTOC_EXPORT Version : public ::google::protobuf::Message /* @@protoc_ 0; void Swap(Version* other); + friend void swap(Version& a, Version& b) { + a.Swap(&b); + } // implements Message ---------------------------------------------- - inline Version* New() const PROTOBUF_FINAL { return New(NULL); } + inline Version* New() const PROTOBUF_FINAL { + return ::google::protobuf::Arena::Create<Version>(NULL); + } - Version* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + Version* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL { + return ::google::protobuf::Arena::Create<Version>(arena); + } void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const Version& from); @@ -277,7 +243,8 @@ class LIBPROTOC_EXPORT Version : public ::google::protobuf::Message /* @@protoc_ ::google::protobuf::int32 major_; ::google::protobuf::int32 minor_; ::google::protobuf::int32 patch_; - friend struct protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::TableStruct; + friend struct ::protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::TableStruct; + friend void ::protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::InitDefaultsVersionImpl(); }; // ------------------------------------------------------------------- @@ -292,11 +259,24 @@ class LIBPROTOC_EXPORT CodeGeneratorRequest : public ::google::protobuf::Message CopyFrom(from); return *this; } + #if LANG_CXX11 + CodeGeneratorRequest(CodeGeneratorRequest&& from) noexcept + : CodeGeneratorRequest() { + *this = ::std::move(from); + } + inline CodeGeneratorRequest& operator=(CodeGeneratorRequest&& from) noexcept { + if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + #endif inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { return _internal_metadata_.unknown_fields(); } - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { return _internal_metadata_.mutable_unknown_fields(); } @@ -304,6 +284,7 @@ class LIBPROTOC_EXPORT CodeGeneratorRequest : public ::google::protobuf::Message static const ::google::protobuf::Descriptor* descriptor(); static const CodeGeneratorRequest& default_instance(); + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY static inline const CodeGeneratorRequest* internal_default_instance() { return reinterpret_cast<const CodeGeneratorRequest*>( &_CodeGeneratorRequest_default_instance_); @@ -312,12 +293,19 @@ class LIBPROTOC_EXPORT CodeGeneratorRequest : public ::google::protobuf::Message 1; void Swap(CodeGeneratorRequest* other); + friend void swap(CodeGeneratorRequest& a, CodeGeneratorRequest& b) { + a.Swap(&b); + } // implements Message ---------------------------------------------- - inline CodeGeneratorRequest* New() const PROTOBUF_FINAL { return New(NULL); } + inline CodeGeneratorRequest* New() const PROTOBUF_FINAL { + return ::google::protobuf::Arena::Create<CodeGeneratorRequest>(NULL); + } - CodeGeneratorRequest* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + CodeGeneratorRequest* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL { + return ::google::protobuf::Arena::Create<CodeGeneratorRequest>(arena); + } void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const CodeGeneratorRequest& from); @@ -379,11 +367,11 @@ class LIBPROTOC_EXPORT CodeGeneratorRequest : public ::google::protobuf::Message int proto_file_size() const; void clear_proto_file(); static const int kProtoFileFieldNumber = 15; - const ::google::protobuf::FileDescriptorProto& proto_file(int index) const; ::google::protobuf::FileDescriptorProto* mutable_proto_file(int index); - ::google::protobuf::FileDescriptorProto* add_proto_file(); ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto >* mutable_proto_file(); + const ::google::protobuf::FileDescriptorProto& proto_file(int index) const; + ::google::protobuf::FileDescriptorProto* add_proto_file(); const ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto >& proto_file() const; @@ -407,8 +395,8 @@ class LIBPROTOC_EXPORT CodeGeneratorRequest : public ::google::protobuf::Message void clear_compiler_version(); static const int kCompilerVersionFieldNumber = 3; const ::google::protobuf::compiler::Version& compiler_version() const; - ::google::protobuf::compiler::Version* mutable_compiler_version(); ::google::protobuf::compiler::Version* release_compiler_version(); + ::google::protobuf::compiler::Version* mutable_compiler_version(); void set_allocated_compiler_version(::google::protobuf::compiler::Version* compiler_version); // @@protoc_insertion_point(class_scope:google.protobuf.compiler.CodeGeneratorRequest) @@ -425,7 +413,8 @@ class LIBPROTOC_EXPORT CodeGeneratorRequest : public ::google::protobuf::Message ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto > proto_file_; ::google::protobuf::internal::ArenaStringPtr parameter_; ::google::protobuf::compiler::Version* compiler_version_; - friend struct protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::TableStruct; + friend struct ::protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::TableStruct; + friend void ::protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::InitDefaultsCodeGeneratorRequestImpl(); }; // ------------------------------------------------------------------- @@ -440,11 +429,24 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse_File : public ::google::protobuf::M CopyFrom(from); return *this; } + #if LANG_CXX11 + CodeGeneratorResponse_File(CodeGeneratorResponse_File&& from) noexcept + : CodeGeneratorResponse_File() { + *this = ::std::move(from); + } + inline CodeGeneratorResponse_File& operator=(CodeGeneratorResponse_File&& from) noexcept { + if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + #endif inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { return _internal_metadata_.unknown_fields(); } - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { return _internal_metadata_.mutable_unknown_fields(); } @@ -452,6 +454,7 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse_File : public ::google::protobuf::M static const ::google::protobuf::Descriptor* descriptor(); static const CodeGeneratorResponse_File& default_instance(); + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY static inline const CodeGeneratorResponse_File* internal_default_instance() { return reinterpret_cast<const CodeGeneratorResponse_File*>( &_CodeGeneratorResponse_File_default_instance_); @@ -460,12 +463,19 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse_File : public ::google::protobuf::M 2; void Swap(CodeGeneratorResponse_File* other); + friend void swap(CodeGeneratorResponse_File& a, CodeGeneratorResponse_File& b) { + a.Swap(&b); + } // implements Message ---------------------------------------------- - inline CodeGeneratorResponse_File* New() const PROTOBUF_FINAL { return New(NULL); } + inline CodeGeneratorResponse_File* New() const PROTOBUF_FINAL { + return ::google::protobuf::Arena::Create<CodeGeneratorResponse_File>(NULL); + } - CodeGeneratorResponse_File* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + CodeGeneratorResponse_File* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL { + return ::google::protobuf::Arena::Create<CodeGeneratorResponse_File>(arena); + } void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const CodeGeneratorResponse_File& from); @@ -561,7 +571,8 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse_File : public ::google::protobuf::M ::google::protobuf::internal::ArenaStringPtr name_; ::google::protobuf::internal::ArenaStringPtr insertion_point_; ::google::protobuf::internal::ArenaStringPtr content_; - friend struct protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::TableStruct; + friend struct ::protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::TableStruct; + friend void ::protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::InitDefaultsCodeGeneratorResponse_FileImpl(); }; // ------------------------------------------------------------------- @@ -576,11 +587,24 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse : public ::google::protobuf::Messag CopyFrom(from); return *this; } + #if LANG_CXX11 + CodeGeneratorResponse(CodeGeneratorResponse&& from) noexcept + : CodeGeneratorResponse() { + *this = ::std::move(from); + } + inline CodeGeneratorResponse& operator=(CodeGeneratorResponse&& from) noexcept { + if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + #endif inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { return _internal_metadata_.unknown_fields(); } - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { return _internal_metadata_.mutable_unknown_fields(); } @@ -588,6 +612,7 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse : public ::google::protobuf::Messag static const ::google::protobuf::Descriptor* descriptor(); static const CodeGeneratorResponse& default_instance(); + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY static inline const CodeGeneratorResponse* internal_default_instance() { return reinterpret_cast<const CodeGeneratorResponse*>( &_CodeGeneratorResponse_default_instance_); @@ -596,12 +621,19 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse : public ::google::protobuf::Messag 3; void Swap(CodeGeneratorResponse* other); + friend void swap(CodeGeneratorResponse& a, CodeGeneratorResponse& b) { + a.Swap(&b); + } // implements Message ---------------------------------------------- - inline CodeGeneratorResponse* New() const PROTOBUF_FINAL { return New(NULL); } + inline CodeGeneratorResponse* New() const PROTOBUF_FINAL { + return ::google::protobuf::Arena::Create<CodeGeneratorResponse>(NULL); + } - CodeGeneratorResponse* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + CodeGeneratorResponse* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL { + return ::google::protobuf::Arena::Create<CodeGeneratorResponse>(arena); + } void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const CodeGeneratorResponse& from); @@ -643,11 +675,11 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse : public ::google::protobuf::Messag int file_size() const; void clear_file(); static const int kFileFieldNumber = 15; - const ::google::protobuf::compiler::CodeGeneratorResponse_File& file(int index) const; ::google::protobuf::compiler::CodeGeneratorResponse_File* mutable_file(int index); - ::google::protobuf::compiler::CodeGeneratorResponse_File* add_file(); ::google::protobuf::RepeatedPtrField< ::google::protobuf::compiler::CodeGeneratorResponse_File >* mutable_file(); + const ::google::protobuf::compiler::CodeGeneratorResponse_File& file(int index) const; + ::google::protobuf::compiler::CodeGeneratorResponse_File* add_file(); const ::google::protobuf::RepeatedPtrField< ::google::protobuf::compiler::CodeGeneratorResponse_File >& file() const; @@ -676,14 +708,18 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse : public ::google::protobuf::Messag mutable int _cached_size_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::compiler::CodeGeneratorResponse_File > file_; ::google::protobuf::internal::ArenaStringPtr error_; - friend struct protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::TableStruct; + friend struct ::protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::TableStruct; + friend void ::protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::InitDefaultsCodeGeneratorResponseImpl(); }; // =================================================================== // =================================================================== -#if !PROTOBUF_INLINE_NOT_IN_HEADERS +#ifdef __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif // __GNUC__ // Version // optional int32 major = 1; @@ -961,26 +997,23 @@ inline void CodeGeneratorRequest::set_allocated_parameter(::std::string* paramet inline int CodeGeneratorRequest::proto_file_size() const { return proto_file_.size(); } -inline void CodeGeneratorRequest::clear_proto_file() { - proto_file_.Clear(); -} -inline const ::google::protobuf::FileDescriptorProto& CodeGeneratorRequest::proto_file(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorRequest.proto_file) - return proto_file_.Get(index); -} inline ::google::protobuf::FileDescriptorProto* CodeGeneratorRequest::mutable_proto_file(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorRequest.proto_file) return proto_file_.Mutable(index); } -inline ::google::protobuf::FileDescriptorProto* CodeGeneratorRequest::add_proto_file() { - // @@protoc_insertion_point(field_add:google.protobuf.compiler.CodeGeneratorRequest.proto_file) - return proto_file_.Add(); -} inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto >* CodeGeneratorRequest::mutable_proto_file() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.compiler.CodeGeneratorRequest.proto_file) return &proto_file_; } +inline const ::google::protobuf::FileDescriptorProto& CodeGeneratorRequest::proto_file(int index) const { + // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorRequest.proto_file) + return proto_file_.Get(index); +} +inline ::google::protobuf::FileDescriptorProto* CodeGeneratorRequest::add_proto_file() { + // @@protoc_insertion_point(field_add:google.protobuf.compiler.CodeGeneratorRequest.proto_file) + return proto_file_.Add(); +} inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto >& CodeGeneratorRequest::proto_file() const { // @@protoc_insertion_point(field_list:google.protobuf.compiler.CodeGeneratorRequest.proto_file) @@ -998,21 +1031,14 @@ inline void CodeGeneratorRequest::clear_has_compiler_version() { _has_bits_[0] &= ~0x00000002u; } inline void CodeGeneratorRequest::clear_compiler_version() { - if (compiler_version_ != NULL) compiler_version_->::google::protobuf::compiler::Version::Clear(); + if (compiler_version_ != NULL) compiler_version_->Clear(); clear_has_compiler_version(); } inline const ::google::protobuf::compiler::Version& CodeGeneratorRequest::compiler_version() const { + const ::google::protobuf::compiler::Version* p = compiler_version_; // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorRequest.compiler_version) - return compiler_version_ != NULL ? *compiler_version_ - : *::google::protobuf::compiler::Version::internal_default_instance(); -} -inline ::google::protobuf::compiler::Version* CodeGeneratorRequest::mutable_compiler_version() { - set_has_compiler_version(); - if (compiler_version_ == NULL) { - compiler_version_ = new ::google::protobuf::compiler::Version; - } - // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorRequest.compiler_version) - return compiler_version_; + return p != NULL ? *p : *reinterpret_cast<const ::google::protobuf::compiler::Version*>( + &::google::protobuf::compiler::_Version_default_instance_); } inline ::google::protobuf::compiler::Version* CodeGeneratorRequest::release_compiler_version() { // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorRequest.compiler_version) @@ -1021,14 +1047,31 @@ inline ::google::protobuf::compiler::Version* CodeGeneratorRequest::release_comp compiler_version_ = NULL; return temp; } +inline ::google::protobuf::compiler::Version* CodeGeneratorRequest::mutable_compiler_version() { + set_has_compiler_version(); + if (compiler_version_ == NULL) { + compiler_version_ = ::google::protobuf::Arena::Create< ::google::protobuf::compiler::Version >( + GetArenaNoVirtual()); + } + // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorRequest.compiler_version) + return compiler_version_; +} inline void CodeGeneratorRequest::set_allocated_compiler_version(::google::protobuf::compiler::Version* compiler_version) { - delete compiler_version_; - compiler_version_ = compiler_version; + ::google::protobuf::Arena* message_arena = GetArenaNoVirtual(); + if (message_arena == NULL) { + delete compiler_version_; + } if (compiler_version) { + ::google::protobuf::Arena* submessage_arena = NULL; + if (message_arena != submessage_arena) { + compiler_version = ::google::protobuf::internal::GetOwnedMessage( + message_arena, compiler_version, submessage_arena); + } set_has_compiler_version(); } else { clear_has_compiler_version(); } + compiler_version_ = compiler_version; // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorRequest.compiler_version) } @@ -1299,30 +1342,32 @@ inline int CodeGeneratorResponse::file_size() const { inline void CodeGeneratorResponse::clear_file() { file_.Clear(); } -inline const ::google::protobuf::compiler::CodeGeneratorResponse_File& CodeGeneratorResponse::file(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.file) - return file_.Get(index); -} inline ::google::protobuf::compiler::CodeGeneratorResponse_File* CodeGeneratorResponse::mutable_file(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorResponse.file) return file_.Mutable(index); } -inline ::google::protobuf::compiler::CodeGeneratorResponse_File* CodeGeneratorResponse::add_file() { - // @@protoc_insertion_point(field_add:google.protobuf.compiler.CodeGeneratorResponse.file) - return file_.Add(); -} inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::compiler::CodeGeneratorResponse_File >* CodeGeneratorResponse::mutable_file() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.compiler.CodeGeneratorResponse.file) return &file_; } +inline const ::google::protobuf::compiler::CodeGeneratorResponse_File& CodeGeneratorResponse::file(int index) const { + // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.file) + return file_.Get(index); +} +inline ::google::protobuf::compiler::CodeGeneratorResponse_File* CodeGeneratorResponse::add_file() { + // @@protoc_insertion_point(field_add:google.protobuf.compiler.CodeGeneratorResponse.file) + return file_.Add(); +} inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::compiler::CodeGeneratorResponse_File >& CodeGeneratorResponse::file() const { // @@protoc_insertion_point(field_list:google.protobuf.compiler.CodeGeneratorResponse.file) return file_; } -#endif // !PROTOBUF_INLINE_NOT_IN_HEADERS +#ifdef __GNUC__ + #pragma GCC diagnostic pop +#endif // __GNUC__ // ------------------------------------------------------------------- // ------------------------------------------------------------------- @@ -1332,11 +1377,10 @@ CodeGeneratorResponse::file() const { // @@protoc_insertion_point(namespace_scope) - } // namespace compiler } // namespace protobuf } // namespace google // @@protoc_insertion_point(global_scope) -#endif // PROTOBUF_google_2fprotobuf_2fcompiler_2fplugin_2eproto__INCLUDED +#endif // PROTOBUF_google_2fprotobuf_2fcompiler_2fplugin_2eproto_INCLUDED diff --git a/src/google/protobuf/compiler/plugin.proto b/src/google/protobuf/compiler/plugin.proto index f04dc73c..5b557452 100644 --- a/src/google/protobuf/compiler/plugin.proto +++ b/src/google/protobuf/compiler/plugin.proto @@ -91,6 +91,7 @@ message CodeGeneratorRequest { // The version number of protocol compiler. optional Version compiler_version = 3; + } // The plugin writes an encoded CodeGeneratorResponse to stdout. diff --git a/src/google/protobuf/compiler/profile.pb.cc b/src/google/protobuf/compiler/profile.pb.cc deleted file mode 100644 index c185e4f9..00000000 --- a/src/google/protobuf/compiler/profile.pb.cc +++ /dev/null @@ -1,1442 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/protobuf/compiler/profile.proto - -#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION -#include <google/protobuf/compiler/profile.pb.h> - -#include <algorithm> - -#include <google/protobuf/stubs/common.h> -#include <google/protobuf/stubs/port.h> -#include <google/protobuf/stubs/once.h> -#include <google/protobuf/io/coded_stream.h> -#include <google/protobuf/wire_format_lite_inl.h> -#include <google/protobuf/descriptor.h> -#include <google/protobuf/generated_message_reflection.h> -#include <google/protobuf/reflection_ops.h> -#include <google/protobuf/wire_format.h> -// @@protoc_insertion_point(includes) - -namespace google { -namespace protobuf { -namespace compiler { -class FieldAccessInfoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<FieldAccessInfo> { -} _FieldAccessInfo_default_instance_; -class MessageAccessInfoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<MessageAccessInfo> { -} _MessageAccessInfo_default_instance_; -class AccessInfoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<AccessInfo> { -} _AccessInfo_default_instance_; - -namespace protobuf_google_2fprotobuf_2fcompiler_2fprofile_2eproto { - - -namespace { - -::google::protobuf::Metadata file_level_metadata[3]; - -} // namespace - -PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::ParseTableField - const TableStruct::entries[] = { - {0, 0, 0, ::google::protobuf::internal::kInvalidMask, 0, 0}, -}; - -PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::AuxillaryParseTableField - const TableStruct::aux[] = { - ::google::protobuf::internal::AuxillaryParseTableField(), -}; -PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::ParseTable const - TableStruct::schema[] = { - { NULL, NULL, 0, -1, -1, false }, - { NULL, NULL, 0, -1, -1, false }, - { NULL, NULL, 0, -1, -1, false }, -}; - -const ::google::protobuf::uint32 TableStruct::offsets[] = { - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldAccessInfo, _has_bits_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldAccessInfo, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldAccessInfo, name_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldAccessInfo, getters_count_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldAccessInfo, setters_count_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldAccessInfo, configs_count_), - 0, - 1, - 2, - 3, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageAccessInfo, _has_bits_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageAccessInfo, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageAccessInfo, name_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageAccessInfo, count_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageAccessInfo, field_), - 0, - 1, - ~0u, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(AccessInfo, _has_bits_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(AccessInfo, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(AccessInfo, message_), - ~0u, -}; - -static const ::google::protobuf::internal::MigrationSchema schemas[] = { - { 0, 9, sizeof(FieldAccessInfo)}, - { 13, 21, sizeof(MessageAccessInfo)}, - { 24, 30, sizeof(AccessInfo)}, -}; - -static ::google::protobuf::Message const * const file_default_instances[] = { - reinterpret_cast<const ::google::protobuf::Message*>(&_FieldAccessInfo_default_instance_), - reinterpret_cast<const ::google::protobuf::Message*>(&_MessageAccessInfo_default_instance_), - reinterpret_cast<const ::google::protobuf::Message*>(&_AccessInfo_default_instance_), -}; - -namespace { - -void protobuf_AssignDescriptors() { - AddDescriptors(); - ::google::protobuf::MessageFactory* factory = NULL; - AssignDescriptors( - "google/protobuf/compiler/profile.proto", schemas, file_default_instances, TableStruct::offsets, factory, - file_level_metadata, NULL, NULL); -} - -void protobuf_AssignDescriptorsOnce() { - static GOOGLE_PROTOBUF_DECLARE_ONCE(once); - ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors); -} - -void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; -void protobuf_RegisterTypes(const ::std::string&) { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 3); -} - -} // namespace - -void TableStruct::Shutdown() { - _FieldAccessInfo_default_instance_.Shutdown(); - delete file_level_metadata[0].reflection; - _MessageAccessInfo_default_instance_.Shutdown(); - delete file_level_metadata[1].reflection; - _AccessInfo_default_instance_.Shutdown(); - delete file_level_metadata[2].reflection; -} - -void TableStruct::InitDefaultsImpl() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - ::google::protobuf::internal::InitProtobufDefaults(); - _FieldAccessInfo_default_instance_.DefaultConstruct(); - _MessageAccessInfo_default_instance_.DefaultConstruct(); - _AccessInfo_default_instance_.DefaultConstruct(); -} - -void InitDefaults() { - static GOOGLE_PROTOBUF_DECLARE_ONCE(once); - ::google::protobuf::GoogleOnceInit(&once, &TableStruct::InitDefaultsImpl); -} -void AddDescriptorsImpl() { - InitDefaults(); - static const char descriptor[] = { - "\n&google/protobuf/compiler/profile.proto" - "\022\030google.protobuf.compiler\"d\n\017FieldAcces" - "sInfo\022\014\n\004name\030\001 \001(\t\022\025\n\rgetters_count\030\002 \001" - "(\004\022\025\n\rsetters_count\030\003 \001(\004\022\025\n\rconfigs_cou" - "nt\030\004 \001(\004\"j\n\021MessageAccessInfo\022\014\n\004name\030\001 " - "\001(\t\022\r\n\005count\030\002 \001(\004\0228\n\005field\030\003 \003(\0132).goog" - "le.protobuf.compiler.FieldAccessInfo\"J\n\n" - "AccessInfo\022<\n\007message\030\001 \003(\0132+.google.pro" - "tobuf.compiler.MessageAccessInfo" - }; - ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( - descriptor, 352); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( - "google/protobuf/compiler/profile.proto", &protobuf_RegisterTypes); - ::google::protobuf::internal::OnShutdown(&TableStruct::Shutdown); -} - -void AddDescriptors() { - static GOOGLE_PROTOBUF_DECLARE_ONCE(once); - ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl); -} -// Force AddDescriptors() to be called at static initialization time. -struct StaticDescriptorInitializer { - StaticDescriptorInitializer() { - AddDescriptors(); - } -} static_descriptor_initializer; - -} // namespace protobuf_google_2fprotobuf_2fcompiler_2fprofile_2eproto - - -// =================================================================== - -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const int FieldAccessInfo::kNameFieldNumber; -const int FieldAccessInfo::kGettersCountFieldNumber; -const int FieldAccessInfo::kSettersCountFieldNumber; -const int FieldAccessInfo::kConfigsCountFieldNumber; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 - -FieldAccessInfo::FieldAccessInfo() - : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { - protobuf_google_2fprotobuf_2fcompiler_2fprofile_2eproto::InitDefaults(); - } - SharedCtor(); - // @@protoc_insertion_point(constructor:google.protobuf.compiler.FieldAccessInfo) -} -FieldAccessInfo::FieldAccessInfo(const FieldAccessInfo& from) - : ::google::protobuf::Message(), - _internal_metadata_(NULL), - _has_bits_(from._has_bits_), - _cached_size_(0) { - _internal_metadata_.MergeFrom(from._internal_metadata_); - name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (from.has_name()) { - name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); - } - ::memcpy(&getters_count_, &from.getters_count_, - reinterpret_cast<char*>(&configs_count_) - - reinterpret_cast<char*>(&getters_count_) + sizeof(configs_count_)); - // @@protoc_insertion_point(copy_constructor:google.protobuf.compiler.FieldAccessInfo) -} - -void FieldAccessInfo::SharedCtor() { - _cached_size_ = 0; - name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - ::memset(&getters_count_, 0, reinterpret_cast<char*>(&configs_count_) - - reinterpret_cast<char*>(&getters_count_) + sizeof(configs_count_)); -} - -FieldAccessInfo::~FieldAccessInfo() { - // @@protoc_insertion_point(destructor:google.protobuf.compiler.FieldAccessInfo) - SharedDtor(); -} - -void FieldAccessInfo::SharedDtor() { - name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} - -void FieldAccessInfo::SetCachedSize(int size) const { - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); -} -const ::google::protobuf::Descriptor* FieldAccessInfo::descriptor() { - protobuf_google_2fprotobuf_2fcompiler_2fprofile_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fcompiler_2fprofile_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; -} - -const FieldAccessInfo& FieldAccessInfo::default_instance() { - protobuf_google_2fprotobuf_2fcompiler_2fprofile_2eproto::InitDefaults(); - return *internal_default_instance(); -} - -FieldAccessInfo* FieldAccessInfo::New(::google::protobuf::Arena* arena) const { - FieldAccessInfo* n = new FieldAccessInfo; - if (arena != NULL) { - arena->Own(n); - } - return n; -} - -void FieldAccessInfo::Clear() { -// @@protoc_insertion_point(message_clear_start:google.protobuf.compiler.FieldAccessInfo) - if (has_name()) { - GOOGLE_DCHECK(!name_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); - (*name_.UnsafeRawStringPointer())->clear(); - } - if (_has_bits_[0 / 32] & 14u) { - ::memset(&getters_count_, 0, reinterpret_cast<char*>(&configs_count_) - - reinterpret_cast<char*>(&getters_count_) + sizeof(configs_count_)); - } - _has_bits_.Clear(); - _internal_metadata_.Clear(); -} - -bool FieldAccessInfo::MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure - ::google::protobuf::uint32 tag; - // @@protoc_insertion_point(parse_start:google.protobuf.compiler.FieldAccessInfo) - for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); - tag = p.first; - if (!p.second) goto handle_unusual; - switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional string name = 1; - case 1: { - if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(10u)) { - DO_(::google::protobuf::internal::WireFormatLite::ReadString( - input, this->mutable_name())); - ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->name().data(), this->name().length(), - ::google::protobuf::internal::WireFormat::PARSE, - "google.protobuf.compiler.FieldAccessInfo.name"); - } else { - goto handle_unusual; - } - break; - } - - // optional uint64 getters_count = 2; - case 2: { - if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(16u)) { - set_has_getters_count(); - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - ::google::protobuf::uint64, ::google::protobuf::internal::WireFormatLite::TYPE_UINT64>( - input, &getters_count_))); - } else { - goto handle_unusual; - } - break; - } - - // optional uint64 setters_count = 3; - case 3: { - if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(24u)) { - set_has_setters_count(); - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - ::google::protobuf::uint64, ::google::protobuf::internal::WireFormatLite::TYPE_UINT64>( - input, &setters_count_))); - } else { - goto handle_unusual; - } - break; - } - - // optional uint64 configs_count = 4; - case 4: { - if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(32u)) { - set_has_configs_count(); - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - ::google::protobuf::uint64, ::google::protobuf::internal::WireFormatLite::TYPE_UINT64>( - input, &configs_count_))); - } else { - goto handle_unusual; - } - break; - } - - default: { - handle_unusual: - if (tag == 0 || - ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - goto success; - } - DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); - break; - } - } - } -success: - // @@protoc_insertion_point(parse_success:google.protobuf.compiler.FieldAccessInfo) - return true; -failure: - // @@protoc_insertion_point(parse_failure:google.protobuf.compiler.FieldAccessInfo) - return false; -#undef DO_ -} - -void FieldAccessInfo::SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const { - // @@protoc_insertion_point(serialize_start:google.protobuf.compiler.FieldAccessInfo) - ::google::protobuf::uint32 cached_has_bits = 0; - (void) cached_has_bits; - - cached_has_bits = _has_bits_[0]; - // optional string name = 1; - if (cached_has_bits & 0x00000001u) { - ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->name().data(), this->name().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE, - "google.protobuf.compiler.FieldAccessInfo.name"); - ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( - 1, this->name(), output); - } - - // optional uint64 getters_count = 2; - if (cached_has_bits & 0x00000002u) { - ::google::protobuf::internal::WireFormatLite::WriteUInt64(2, this->getters_count(), output); - } - - // optional uint64 setters_count = 3; - if (cached_has_bits & 0x00000004u) { - ::google::protobuf::internal::WireFormatLite::WriteUInt64(3, this->setters_count(), output); - } - - // optional uint64 configs_count = 4; - if (cached_has_bits & 0x00000008u) { - ::google::protobuf::internal::WireFormatLite::WriteUInt64(4, this->configs_count(), output); - } - - if (_internal_metadata_.have_unknown_fields()) { - ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); - } - // @@protoc_insertion_point(serialize_end:google.protobuf.compiler.FieldAccessInfo) -} - -::google::protobuf::uint8* FieldAccessInfo::InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* target) const { - // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.compiler.FieldAccessInfo) - ::google::protobuf::uint32 cached_has_bits = 0; - (void) cached_has_bits; - - cached_has_bits = _has_bits_[0]; - // optional string name = 1; - if (cached_has_bits & 0x00000001u) { - ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->name().data(), this->name().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE, - "google.protobuf.compiler.FieldAccessInfo.name"); - target = - ::google::protobuf::internal::WireFormatLite::WriteStringToArray( - 1, this->name(), target); - } - - // optional uint64 getters_count = 2; - if (cached_has_bits & 0x00000002u) { - target = ::google::protobuf::internal::WireFormatLite::WriteUInt64ToArray(2, this->getters_count(), target); - } - - // optional uint64 setters_count = 3; - if (cached_has_bits & 0x00000004u) { - target = ::google::protobuf::internal::WireFormatLite::WriteUInt64ToArray(3, this->setters_count(), target); - } - - // optional uint64 configs_count = 4; - if (cached_has_bits & 0x00000008u) { - target = ::google::protobuf::internal::WireFormatLite::WriteUInt64ToArray(4, this->configs_count(), target); - } - - if (_internal_metadata_.have_unknown_fields()) { - target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); - } - // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.compiler.FieldAccessInfo) - return target; -} - -size_t FieldAccessInfo::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:google.protobuf.compiler.FieldAccessInfo) - size_t total_size = 0; - - if (_internal_metadata_.have_unknown_fields()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } - if (_has_bits_[0 / 32] & 15u) { - // optional string name = 1; - if (has_name()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->name()); - } - - // optional uint64 getters_count = 2; - if (has_getters_count()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::UInt64Size( - this->getters_count()); - } - - // optional uint64 setters_count = 3; - if (has_setters_count()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::UInt64Size( - this->setters_count()); - } - - // optional uint64 configs_count = 4; - if (has_configs_count()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::UInt64Size( - this->configs_count()); - } - - } - int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = cached_size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); - return total_size; -} - -void FieldAccessInfo::MergeFrom(const ::google::protobuf::Message& from) { -// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.compiler.FieldAccessInfo) - GOOGLE_DCHECK_NE(&from, this); - const FieldAccessInfo* source = - ::google::protobuf::internal::DynamicCastToGenerated<const FieldAccessInfo>( - &from); - if (source == NULL) { - // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.compiler.FieldAccessInfo) - ::google::protobuf::internal::ReflectionOps::Merge(from, this); - } else { - // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.compiler.FieldAccessInfo) - MergeFrom(*source); - } -} - -void FieldAccessInfo::MergeFrom(const FieldAccessInfo& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.FieldAccessInfo) - GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom(from._internal_metadata_); - ::google::protobuf::uint32 cached_has_bits = 0; - (void) cached_has_bits; - - cached_has_bits = from._has_bits_[0]; - if (cached_has_bits & 15u) { - if (cached_has_bits & 0x00000001u) { - set_has_name(); - name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); - } - if (cached_has_bits & 0x00000002u) { - getters_count_ = from.getters_count_; - } - if (cached_has_bits & 0x00000004u) { - setters_count_ = from.setters_count_; - } - if (cached_has_bits & 0x00000008u) { - configs_count_ = from.configs_count_; - } - _has_bits_[0] |= cached_has_bits; - } -} - -void FieldAccessInfo::CopyFrom(const ::google::protobuf::Message& from) { -// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.compiler.FieldAccessInfo) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -void FieldAccessInfo::CopyFrom(const FieldAccessInfo& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.compiler.FieldAccessInfo) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool FieldAccessInfo::IsInitialized() const { - return true; -} - -void FieldAccessInfo::Swap(FieldAccessInfo* other) { - if (other == this) return; - InternalSwap(other); -} -void FieldAccessInfo::InternalSwap(FieldAccessInfo* other) { - name_.Swap(&other->name_); - std::swap(getters_count_, other->getters_count_); - std::swap(setters_count_, other->setters_count_); - std::swap(configs_count_, other->configs_count_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _internal_metadata_.Swap(&other->_internal_metadata_); - std::swap(_cached_size_, other->_cached_size_); -} - -::google::protobuf::Metadata FieldAccessInfo::GetMetadata() const { - protobuf_google_2fprotobuf_2fcompiler_2fprofile_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fcompiler_2fprofile_2eproto::file_level_metadata[kIndexInFileMessages]; -} - -#if PROTOBUF_INLINE_NOT_IN_HEADERS -// FieldAccessInfo - -// optional string name = 1; -bool FieldAccessInfo::has_name() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -void FieldAccessInfo::set_has_name() { - _has_bits_[0] |= 0x00000001u; -} -void FieldAccessInfo::clear_has_name() { - _has_bits_[0] &= ~0x00000001u; -} -void FieldAccessInfo::clear_name() { - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - clear_has_name(); -} -const ::std::string& FieldAccessInfo::name() const { - // @@protoc_insertion_point(field_get:google.protobuf.compiler.FieldAccessInfo.name) - return name_.GetNoArena(); -} -void FieldAccessInfo::set_name(const ::std::string& value) { - set_has_name(); - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.compiler.FieldAccessInfo.name) -} -#if LANG_CXX11 -void FieldAccessInfo::set_name(::std::string&& value) { - set_has_name(); - name_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.FieldAccessInfo.name) -} -#endif -void FieldAccessInfo::set_name(const char* value) { - GOOGLE_DCHECK(value != NULL); - set_has_name(); - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); - // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.FieldAccessInfo.name) -} -void FieldAccessInfo::set_name(const char* value, size_t size) { - set_has_name(); - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.FieldAccessInfo.name) -} -::std::string* FieldAccessInfo::mutable_name() { - set_has_name(); - // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.FieldAccessInfo.name) - return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -::std::string* FieldAccessInfo::release_name() { - // @@protoc_insertion_point(field_release:google.protobuf.compiler.FieldAccessInfo.name) - clear_has_name(); - return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -void FieldAccessInfo::set_allocated_name(::std::string* name) { - if (name != NULL) { - set_has_name(); - } else { - clear_has_name(); - } - name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.FieldAccessInfo.name) -} - -// optional uint64 getters_count = 2; -bool FieldAccessInfo::has_getters_count() const { - return (_has_bits_[0] & 0x00000002u) != 0; -} -void FieldAccessInfo::set_has_getters_count() { - _has_bits_[0] |= 0x00000002u; -} -void FieldAccessInfo::clear_has_getters_count() { - _has_bits_[0] &= ~0x00000002u; -} -void FieldAccessInfo::clear_getters_count() { - getters_count_ = GOOGLE_ULONGLONG(0); - clear_has_getters_count(); -} -::google::protobuf::uint64 FieldAccessInfo::getters_count() const { - // @@protoc_insertion_point(field_get:google.protobuf.compiler.FieldAccessInfo.getters_count) - return getters_count_; -} -void FieldAccessInfo::set_getters_count(::google::protobuf::uint64 value) { - set_has_getters_count(); - getters_count_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.compiler.FieldAccessInfo.getters_count) -} - -// optional uint64 setters_count = 3; -bool FieldAccessInfo::has_setters_count() const { - return (_has_bits_[0] & 0x00000004u) != 0; -} -void FieldAccessInfo::set_has_setters_count() { - _has_bits_[0] |= 0x00000004u; -} -void FieldAccessInfo::clear_has_setters_count() { - _has_bits_[0] &= ~0x00000004u; -} -void FieldAccessInfo::clear_setters_count() { - setters_count_ = GOOGLE_ULONGLONG(0); - clear_has_setters_count(); -} -::google::protobuf::uint64 FieldAccessInfo::setters_count() const { - // @@protoc_insertion_point(field_get:google.protobuf.compiler.FieldAccessInfo.setters_count) - return setters_count_; -} -void FieldAccessInfo::set_setters_count(::google::protobuf::uint64 value) { - set_has_setters_count(); - setters_count_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.compiler.FieldAccessInfo.setters_count) -} - -// optional uint64 configs_count = 4; -bool FieldAccessInfo::has_configs_count() const { - return (_has_bits_[0] & 0x00000008u) != 0; -} -void FieldAccessInfo::set_has_configs_count() { - _has_bits_[0] |= 0x00000008u; -} -void FieldAccessInfo::clear_has_configs_count() { - _has_bits_[0] &= ~0x00000008u; -} -void FieldAccessInfo::clear_configs_count() { - configs_count_ = GOOGLE_ULONGLONG(0); - clear_has_configs_count(); -} -::google::protobuf::uint64 FieldAccessInfo::configs_count() const { - // @@protoc_insertion_point(field_get:google.protobuf.compiler.FieldAccessInfo.configs_count) - return configs_count_; -} -void FieldAccessInfo::set_configs_count(::google::protobuf::uint64 value) { - set_has_configs_count(); - configs_count_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.compiler.FieldAccessInfo.configs_count) -} - -#endif // PROTOBUF_INLINE_NOT_IN_HEADERS - -// =================================================================== - -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const int MessageAccessInfo::kNameFieldNumber; -const int MessageAccessInfo::kCountFieldNumber; -const int MessageAccessInfo::kFieldFieldNumber; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 - -MessageAccessInfo::MessageAccessInfo() - : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { - protobuf_google_2fprotobuf_2fcompiler_2fprofile_2eproto::InitDefaults(); - } - SharedCtor(); - // @@protoc_insertion_point(constructor:google.protobuf.compiler.MessageAccessInfo) -} -MessageAccessInfo::MessageAccessInfo(const MessageAccessInfo& from) - : ::google::protobuf::Message(), - _internal_metadata_(NULL), - _has_bits_(from._has_bits_), - _cached_size_(0), - field_(from.field_) { - _internal_metadata_.MergeFrom(from._internal_metadata_); - name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (from.has_name()) { - name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); - } - count_ = from.count_; - // @@protoc_insertion_point(copy_constructor:google.protobuf.compiler.MessageAccessInfo) -} - -void MessageAccessInfo::SharedCtor() { - _cached_size_ = 0; - name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - count_ = GOOGLE_ULONGLONG(0); -} - -MessageAccessInfo::~MessageAccessInfo() { - // @@protoc_insertion_point(destructor:google.protobuf.compiler.MessageAccessInfo) - SharedDtor(); -} - -void MessageAccessInfo::SharedDtor() { - name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} - -void MessageAccessInfo::SetCachedSize(int size) const { - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); -} -const ::google::protobuf::Descriptor* MessageAccessInfo::descriptor() { - protobuf_google_2fprotobuf_2fcompiler_2fprofile_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fcompiler_2fprofile_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; -} - -const MessageAccessInfo& MessageAccessInfo::default_instance() { - protobuf_google_2fprotobuf_2fcompiler_2fprofile_2eproto::InitDefaults(); - return *internal_default_instance(); -} - -MessageAccessInfo* MessageAccessInfo::New(::google::protobuf::Arena* arena) const { - MessageAccessInfo* n = new MessageAccessInfo; - if (arena != NULL) { - arena->Own(n); - } - return n; -} - -void MessageAccessInfo::Clear() { -// @@protoc_insertion_point(message_clear_start:google.protobuf.compiler.MessageAccessInfo) - field_.Clear(); - if (has_name()) { - GOOGLE_DCHECK(!name_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); - (*name_.UnsafeRawStringPointer())->clear(); - } - count_ = GOOGLE_ULONGLONG(0); - _has_bits_.Clear(); - _internal_metadata_.Clear(); -} - -bool MessageAccessInfo::MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure - ::google::protobuf::uint32 tag; - // @@protoc_insertion_point(parse_start:google.protobuf.compiler.MessageAccessInfo) - for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); - tag = p.first; - if (!p.second) goto handle_unusual; - switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional string name = 1; - case 1: { - if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(10u)) { - DO_(::google::protobuf::internal::WireFormatLite::ReadString( - input, this->mutable_name())); - ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->name().data(), this->name().length(), - ::google::protobuf::internal::WireFormat::PARSE, - "google.protobuf.compiler.MessageAccessInfo.name"); - } else { - goto handle_unusual; - } - break; - } - - // optional uint64 count = 2; - case 2: { - if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(16u)) { - set_has_count(); - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - ::google::protobuf::uint64, ::google::protobuf::internal::WireFormatLite::TYPE_UINT64>( - input, &count_))); - } else { - goto handle_unusual; - } - break; - } - - // repeated .google.protobuf.compiler.FieldAccessInfo field = 3; - case 3: { - if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(26u)) { - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( - input, add_field())); - } else { - goto handle_unusual; - } - break; - } - - default: { - handle_unusual: - if (tag == 0 || - ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - goto success; - } - DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); - break; - } - } - } -success: - // @@protoc_insertion_point(parse_success:google.protobuf.compiler.MessageAccessInfo) - return true; -failure: - // @@protoc_insertion_point(parse_failure:google.protobuf.compiler.MessageAccessInfo) - return false; -#undef DO_ -} - -void MessageAccessInfo::SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const { - // @@protoc_insertion_point(serialize_start:google.protobuf.compiler.MessageAccessInfo) - ::google::protobuf::uint32 cached_has_bits = 0; - (void) cached_has_bits; - - cached_has_bits = _has_bits_[0]; - // optional string name = 1; - if (cached_has_bits & 0x00000001u) { - ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->name().data(), this->name().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE, - "google.protobuf.compiler.MessageAccessInfo.name"); - ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( - 1, this->name(), output); - } - - // optional uint64 count = 2; - if (cached_has_bits & 0x00000002u) { - ::google::protobuf::internal::WireFormatLite::WriteUInt64(2, this->count(), output); - } - - // repeated .google.protobuf.compiler.FieldAccessInfo field = 3; - for (unsigned int i = 0, n = this->field_size(); i < n; i++) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 3, this->field(i), output); - } - - if (_internal_metadata_.have_unknown_fields()) { - ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); - } - // @@protoc_insertion_point(serialize_end:google.protobuf.compiler.MessageAccessInfo) -} - -::google::protobuf::uint8* MessageAccessInfo::InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* target) const { - // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.compiler.MessageAccessInfo) - ::google::protobuf::uint32 cached_has_bits = 0; - (void) cached_has_bits; - - cached_has_bits = _has_bits_[0]; - // optional string name = 1; - if (cached_has_bits & 0x00000001u) { - ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->name().data(), this->name().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE, - "google.protobuf.compiler.MessageAccessInfo.name"); - target = - ::google::protobuf::internal::WireFormatLite::WriteStringToArray( - 1, this->name(), target); - } - - // optional uint64 count = 2; - if (cached_has_bits & 0x00000002u) { - target = ::google::protobuf::internal::WireFormatLite::WriteUInt64ToArray(2, this->count(), target); - } - - // repeated .google.protobuf.compiler.FieldAccessInfo field = 3; - for (unsigned int i = 0, n = this->field_size(); i < n; i++) { - target = ::google::protobuf::internal::WireFormatLite:: - InternalWriteMessageNoVirtualToArray( - 3, this->field(i), deterministic, target); - } - - if (_internal_metadata_.have_unknown_fields()) { - target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); - } - // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.compiler.MessageAccessInfo) - return target; -} - -size_t MessageAccessInfo::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:google.protobuf.compiler.MessageAccessInfo) - size_t total_size = 0; - - if (_internal_metadata_.have_unknown_fields()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } - // repeated .google.protobuf.compiler.FieldAccessInfo field = 3; - { - 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)); - } - } - - if (_has_bits_[0 / 32] & 3u) { - // optional string name = 1; - if (has_name()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->name()); - } - - // optional uint64 count = 2; - if (has_count()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::UInt64Size( - this->count()); - } - - } - int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = cached_size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); - return total_size; -} - -void MessageAccessInfo::MergeFrom(const ::google::protobuf::Message& from) { -// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.compiler.MessageAccessInfo) - GOOGLE_DCHECK_NE(&from, this); - const MessageAccessInfo* source = - ::google::protobuf::internal::DynamicCastToGenerated<const MessageAccessInfo>( - &from); - if (source == NULL) { - // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.compiler.MessageAccessInfo) - ::google::protobuf::internal::ReflectionOps::Merge(from, this); - } else { - // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.compiler.MessageAccessInfo) - MergeFrom(*source); - } -} - -void MessageAccessInfo::MergeFrom(const MessageAccessInfo& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.MessageAccessInfo) - GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom(from._internal_metadata_); - ::google::protobuf::uint32 cached_has_bits = 0; - (void) cached_has_bits; - - field_.MergeFrom(from.field_); - cached_has_bits = from._has_bits_[0]; - if (cached_has_bits & 3u) { - if (cached_has_bits & 0x00000001u) { - set_has_name(); - name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); - } - if (cached_has_bits & 0x00000002u) { - count_ = from.count_; - } - _has_bits_[0] |= cached_has_bits; - } -} - -void MessageAccessInfo::CopyFrom(const ::google::protobuf::Message& from) { -// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.compiler.MessageAccessInfo) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -void MessageAccessInfo::CopyFrom(const MessageAccessInfo& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.compiler.MessageAccessInfo) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool MessageAccessInfo::IsInitialized() const { - return true; -} - -void MessageAccessInfo::Swap(MessageAccessInfo* other) { - if (other == this) return; - InternalSwap(other); -} -void MessageAccessInfo::InternalSwap(MessageAccessInfo* other) { - field_.InternalSwap(&other->field_); - name_.Swap(&other->name_); - std::swap(count_, other->count_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _internal_metadata_.Swap(&other->_internal_metadata_); - std::swap(_cached_size_, other->_cached_size_); -} - -::google::protobuf::Metadata MessageAccessInfo::GetMetadata() const { - protobuf_google_2fprotobuf_2fcompiler_2fprofile_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fcompiler_2fprofile_2eproto::file_level_metadata[kIndexInFileMessages]; -} - -#if PROTOBUF_INLINE_NOT_IN_HEADERS -// MessageAccessInfo - -// optional string name = 1; -bool MessageAccessInfo::has_name() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -void MessageAccessInfo::set_has_name() { - _has_bits_[0] |= 0x00000001u; -} -void MessageAccessInfo::clear_has_name() { - _has_bits_[0] &= ~0x00000001u; -} -void MessageAccessInfo::clear_name() { - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - clear_has_name(); -} -const ::std::string& MessageAccessInfo::name() const { - // @@protoc_insertion_point(field_get:google.protobuf.compiler.MessageAccessInfo.name) - return name_.GetNoArena(); -} -void MessageAccessInfo::set_name(const ::std::string& value) { - set_has_name(); - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.compiler.MessageAccessInfo.name) -} -#if LANG_CXX11 -void MessageAccessInfo::set_name(::std::string&& value) { - set_has_name(); - name_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.MessageAccessInfo.name) -} -#endif -void MessageAccessInfo::set_name(const char* value) { - GOOGLE_DCHECK(value != NULL); - set_has_name(); - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); - // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.MessageAccessInfo.name) -} -void MessageAccessInfo::set_name(const char* value, size_t size) { - set_has_name(); - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.MessageAccessInfo.name) -} -::std::string* MessageAccessInfo::mutable_name() { - set_has_name(); - // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.MessageAccessInfo.name) - return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -::std::string* MessageAccessInfo::release_name() { - // @@protoc_insertion_point(field_release:google.protobuf.compiler.MessageAccessInfo.name) - clear_has_name(); - return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -void MessageAccessInfo::set_allocated_name(::std::string* name) { - if (name != NULL) { - set_has_name(); - } else { - clear_has_name(); - } - name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.MessageAccessInfo.name) -} - -// optional uint64 count = 2; -bool MessageAccessInfo::has_count() const { - return (_has_bits_[0] & 0x00000002u) != 0; -} -void MessageAccessInfo::set_has_count() { - _has_bits_[0] |= 0x00000002u; -} -void MessageAccessInfo::clear_has_count() { - _has_bits_[0] &= ~0x00000002u; -} -void MessageAccessInfo::clear_count() { - count_ = GOOGLE_ULONGLONG(0); - clear_has_count(); -} -::google::protobuf::uint64 MessageAccessInfo::count() const { - // @@protoc_insertion_point(field_get:google.protobuf.compiler.MessageAccessInfo.count) - return count_; -} -void MessageAccessInfo::set_count(::google::protobuf::uint64 value) { - set_has_count(); - count_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.compiler.MessageAccessInfo.count) -} - -// repeated .google.protobuf.compiler.FieldAccessInfo field = 3; -int MessageAccessInfo::field_size() const { - return field_.size(); -} -void MessageAccessInfo::clear_field() { - field_.Clear(); -} -const ::google::protobuf::compiler::FieldAccessInfo& MessageAccessInfo::field(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.compiler.MessageAccessInfo.field) - return field_.Get(index); -} -::google::protobuf::compiler::FieldAccessInfo* MessageAccessInfo::mutable_field(int index) { - // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.MessageAccessInfo.field) - return field_.Mutable(index); -} -::google::protobuf::compiler::FieldAccessInfo* MessageAccessInfo::add_field() { - // @@protoc_insertion_point(field_add:google.protobuf.compiler.MessageAccessInfo.field) - return field_.Add(); -} -::google::protobuf::RepeatedPtrField< ::google::protobuf::compiler::FieldAccessInfo >* -MessageAccessInfo::mutable_field() { - // @@protoc_insertion_point(field_mutable_list:google.protobuf.compiler.MessageAccessInfo.field) - return &field_; -} -const ::google::protobuf::RepeatedPtrField< ::google::protobuf::compiler::FieldAccessInfo >& -MessageAccessInfo::field() const { - // @@protoc_insertion_point(field_list:google.protobuf.compiler.MessageAccessInfo.field) - return field_; -} - -#endif // PROTOBUF_INLINE_NOT_IN_HEADERS - -// =================================================================== - -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const int AccessInfo::kMessageFieldNumber; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 - -AccessInfo::AccessInfo() - : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { - protobuf_google_2fprotobuf_2fcompiler_2fprofile_2eproto::InitDefaults(); - } - SharedCtor(); - // @@protoc_insertion_point(constructor:google.protobuf.compiler.AccessInfo) -} -AccessInfo::AccessInfo(const AccessInfo& from) - : ::google::protobuf::Message(), - _internal_metadata_(NULL), - _has_bits_(from._has_bits_), - _cached_size_(0), - message_(from.message_) { - _internal_metadata_.MergeFrom(from._internal_metadata_); - // @@protoc_insertion_point(copy_constructor:google.protobuf.compiler.AccessInfo) -} - -void AccessInfo::SharedCtor() { - _cached_size_ = 0; -} - -AccessInfo::~AccessInfo() { - // @@protoc_insertion_point(destructor:google.protobuf.compiler.AccessInfo) - SharedDtor(); -} - -void AccessInfo::SharedDtor() { -} - -void AccessInfo::SetCachedSize(int size) const { - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); -} -const ::google::protobuf::Descriptor* AccessInfo::descriptor() { - protobuf_google_2fprotobuf_2fcompiler_2fprofile_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fcompiler_2fprofile_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; -} - -const AccessInfo& AccessInfo::default_instance() { - protobuf_google_2fprotobuf_2fcompiler_2fprofile_2eproto::InitDefaults(); - return *internal_default_instance(); -} - -AccessInfo* AccessInfo::New(::google::protobuf::Arena* arena) const { - AccessInfo* n = new AccessInfo; - if (arena != NULL) { - arena->Own(n); - } - return n; -} - -void AccessInfo::Clear() { -// @@protoc_insertion_point(message_clear_start:google.protobuf.compiler.AccessInfo) - message_.Clear(); - _has_bits_.Clear(); - _internal_metadata_.Clear(); -} - -bool AccessInfo::MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure - ::google::protobuf::uint32 tag; - // @@protoc_insertion_point(parse_start:google.protobuf.compiler.AccessInfo) - for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); - tag = p.first; - if (!p.second) goto handle_unusual; - switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // repeated .google.protobuf.compiler.MessageAccessInfo message = 1; - case 1: { - if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(10u)) { - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( - input, add_message())); - } else { - goto handle_unusual; - } - break; - } - - default: { - handle_unusual: - if (tag == 0 || - ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - goto success; - } - DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); - break; - } - } - } -success: - // @@protoc_insertion_point(parse_success:google.protobuf.compiler.AccessInfo) - return true; -failure: - // @@protoc_insertion_point(parse_failure:google.protobuf.compiler.AccessInfo) - return false; -#undef DO_ -} - -void AccessInfo::SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const { - // @@protoc_insertion_point(serialize_start:google.protobuf.compiler.AccessInfo) - ::google::protobuf::uint32 cached_has_bits = 0; - (void) cached_has_bits; - - // repeated .google.protobuf.compiler.MessageAccessInfo message = 1; - for (unsigned int i = 0, n = this->message_size(); i < n; i++) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 1, this->message(i), output); - } - - if (_internal_metadata_.have_unknown_fields()) { - ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); - } - // @@protoc_insertion_point(serialize_end:google.protobuf.compiler.AccessInfo) -} - -::google::protobuf::uint8* AccessInfo::InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* target) const { - // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.compiler.AccessInfo) - ::google::protobuf::uint32 cached_has_bits = 0; - (void) cached_has_bits; - - // repeated .google.protobuf.compiler.MessageAccessInfo message = 1; - for (unsigned int i = 0, n = this->message_size(); i < n; i++) { - target = ::google::protobuf::internal::WireFormatLite:: - InternalWriteMessageNoVirtualToArray( - 1, this->message(i), deterministic, target); - } - - if (_internal_metadata_.have_unknown_fields()) { - target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); - } - // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.compiler.AccessInfo) - return target; -} - -size_t AccessInfo::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:google.protobuf.compiler.AccessInfo) - size_t total_size = 0; - - if (_internal_metadata_.have_unknown_fields()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } - // repeated .google.protobuf.compiler.MessageAccessInfo message = 1; - { - unsigned int count = this->message_size(); - total_size += 1UL * count; - for (unsigned int i = 0; i < count; i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->message(i)); - } - } - - int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = cached_size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); - return total_size; -} - -void AccessInfo::MergeFrom(const ::google::protobuf::Message& from) { -// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.compiler.AccessInfo) - GOOGLE_DCHECK_NE(&from, this); - const AccessInfo* source = - ::google::protobuf::internal::DynamicCastToGenerated<const AccessInfo>( - &from); - if (source == NULL) { - // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.compiler.AccessInfo) - ::google::protobuf::internal::ReflectionOps::Merge(from, this); - } else { - // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.compiler.AccessInfo) - MergeFrom(*source); - } -} - -void AccessInfo::MergeFrom(const AccessInfo& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.AccessInfo) - GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom(from._internal_metadata_); - ::google::protobuf::uint32 cached_has_bits = 0; - (void) cached_has_bits; - - message_.MergeFrom(from.message_); -} - -void AccessInfo::CopyFrom(const ::google::protobuf::Message& from) { -// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.compiler.AccessInfo) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -void AccessInfo::CopyFrom(const AccessInfo& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.compiler.AccessInfo) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool AccessInfo::IsInitialized() const { - return true; -} - -void AccessInfo::Swap(AccessInfo* other) { - if (other == this) return; - InternalSwap(other); -} -void AccessInfo::InternalSwap(AccessInfo* other) { - message_.InternalSwap(&other->message_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _internal_metadata_.Swap(&other->_internal_metadata_); - std::swap(_cached_size_, other->_cached_size_); -} - -::google::protobuf::Metadata AccessInfo::GetMetadata() const { - protobuf_google_2fprotobuf_2fcompiler_2fprofile_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fcompiler_2fprofile_2eproto::file_level_metadata[kIndexInFileMessages]; -} - -#if PROTOBUF_INLINE_NOT_IN_HEADERS -// AccessInfo - -// repeated .google.protobuf.compiler.MessageAccessInfo message = 1; -int AccessInfo::message_size() const { - return message_.size(); -} -void AccessInfo::clear_message() { - message_.Clear(); -} -const ::google::protobuf::compiler::MessageAccessInfo& AccessInfo::message(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.compiler.AccessInfo.message) - return message_.Get(index); -} -::google::protobuf::compiler::MessageAccessInfo* AccessInfo::mutable_message(int index) { - // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.AccessInfo.message) - return message_.Mutable(index); -} -::google::protobuf::compiler::MessageAccessInfo* AccessInfo::add_message() { - // @@protoc_insertion_point(field_add:google.protobuf.compiler.AccessInfo.message) - return message_.Add(); -} -::google::protobuf::RepeatedPtrField< ::google::protobuf::compiler::MessageAccessInfo >* -AccessInfo::mutable_message() { - // @@protoc_insertion_point(field_mutable_list:google.protobuf.compiler.AccessInfo.message) - return &message_; -} -const ::google::protobuf::RepeatedPtrField< ::google::protobuf::compiler::MessageAccessInfo >& -AccessInfo::message() const { - // @@protoc_insertion_point(field_list:google.protobuf.compiler.AccessInfo.message) - return message_; -} - -#endif // PROTOBUF_INLINE_NOT_IN_HEADERS - -// @@protoc_insertion_point(namespace_scope) - -} // namespace compiler -} // namespace protobuf -} // namespace google - -// @@protoc_insertion_point(global_scope) diff --git a/src/google/protobuf/compiler/profile.pb.h b/src/google/protobuf/compiler/profile.pb.h deleted file mode 100644 index d20b87ed..00000000 --- a/src/google/protobuf/compiler/profile.pb.h +++ /dev/null @@ -1,728 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/protobuf/compiler/profile.proto - -#ifndef PROTOBUF_google_2fprotobuf_2fcompiler_2fprofile_2eproto__INCLUDED -#define PROTOBUF_google_2fprotobuf_2fcompiler_2fprofile_2eproto__INCLUDED - -#include <string> - -#include <google/protobuf/stubs/common.h> - -#if GOOGLE_PROTOBUF_VERSION < 3003000 -#error This file was generated by a newer version of protoc which is -#error incompatible with your Protocol Buffer headers. Please update -#error your headers. -#endif -#if 3003000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION -#error This file was generated by an older version of protoc which is -#error incompatible with your Protocol Buffer headers. Please -#error regenerate this file with a newer version of protoc. -#endif - -#include <google/protobuf/io/coded_stream.h> -#include <google/protobuf/arena.h> -#include <google/protobuf/arenastring.h> -#include <google/protobuf/generated_message_table_driven.h> -#include <google/protobuf/generated_message_util.h> -#include <google/protobuf/metadata.h> -#include <google/protobuf/message.h> -#include <google/protobuf/repeated_field.h> // IWYU pragma: export -#include <google/protobuf/extension_set.h> // IWYU pragma: export -#include <google/protobuf/unknown_field_set.h> -// @@protoc_insertion_point(includes) -namespace google { -namespace protobuf { -namespace compiler { -class AccessInfo; -class AccessInfoDefaultTypeInternal; -LIBPROTOC_EXPORT extern AccessInfoDefaultTypeInternal _AccessInfo_default_instance_; -class FieldAccessInfo; -class FieldAccessInfoDefaultTypeInternal; -LIBPROTOC_EXPORT extern FieldAccessInfoDefaultTypeInternal _FieldAccessInfo_default_instance_; -class MessageAccessInfo; -class MessageAccessInfoDefaultTypeInternal; -LIBPROTOC_EXPORT extern MessageAccessInfoDefaultTypeInternal _MessageAccessInfo_default_instance_; -} // namespace compiler -} // namespace protobuf -} // namespace google - -namespace google { -namespace protobuf { -namespace compiler { - -namespace protobuf_google_2fprotobuf_2fcompiler_2fprofile_2eproto { -// Internal implementation detail -- do not call these. -struct LIBPROTOC_EXPORT TableStruct { - static const ::google::protobuf::internal::ParseTableField entries[]; - static const ::google::protobuf::internal::AuxillaryParseTableField aux[]; - static const ::google::protobuf::internal::ParseTable schema[]; - static const ::google::protobuf::uint32 offsets[]; - static void InitDefaultsImpl(); - static void Shutdown(); -}; -void LIBPROTOC_EXPORT AddDescriptors(); -void LIBPROTOC_EXPORT InitDefaults(); -} // namespace protobuf_google_2fprotobuf_2fcompiler_2fprofile_2eproto - -// =================================================================== - -class LIBPROTOC_EXPORT FieldAccessInfo : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.FieldAccessInfo) */ { - public: - FieldAccessInfo(); - virtual ~FieldAccessInfo(); - - FieldAccessInfo(const FieldAccessInfo& from); - - inline FieldAccessInfo& operator=(const FieldAccessInfo& from) { - CopyFrom(from); - return *this; - } - - inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields(); - } - - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields(); - } - - static const ::google::protobuf::Descriptor* descriptor(); - static const FieldAccessInfo& default_instance(); - - static inline const FieldAccessInfo* internal_default_instance() { - return reinterpret_cast<const FieldAccessInfo*>( - &_FieldAccessInfo_default_instance_); - } - static PROTOBUF_CONSTEXPR int const kIndexInFileMessages = - 0; - - void Swap(FieldAccessInfo* other); - - // implements Message ---------------------------------------------- - - inline FieldAccessInfo* New() const PROTOBUF_FINAL { return New(NULL); } - - FieldAccessInfo* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; - void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; - void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; - void CopyFrom(const FieldAccessInfo& from); - void MergeFrom(const FieldAccessInfo& from); - void Clear() PROTOBUF_FINAL; - bool IsInitialized() const PROTOBUF_FINAL; - - size_t ByteSizeLong() const PROTOBUF_FINAL; - bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; - void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; - ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; - int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } - private: - void SharedCtor(); - void SharedDtor(); - void SetCachedSize(int size) const PROTOBUF_FINAL; - void InternalSwap(FieldAccessInfo* other); - private: - inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return NULL; - } - inline void* MaybeArenaPtr() const { - return NULL; - } - public: - - ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - // optional string name = 1; - bool has_name() const; - void clear_name(); - static const int kNameFieldNumber = 1; - const ::std::string& name() const; - void set_name(const ::std::string& value); - #if LANG_CXX11 - void set_name(::std::string&& value); - #endif - void set_name(const char* value); - void set_name(const char* value, size_t size); - ::std::string* mutable_name(); - ::std::string* release_name(); - void set_allocated_name(::std::string* name); - - // optional uint64 getters_count = 2; - bool has_getters_count() const; - void clear_getters_count(); - static const int kGettersCountFieldNumber = 2; - ::google::protobuf::uint64 getters_count() const; - void set_getters_count(::google::protobuf::uint64 value); - - // optional uint64 setters_count = 3; - bool has_setters_count() const; - void clear_setters_count(); - static const int kSettersCountFieldNumber = 3; - ::google::protobuf::uint64 setters_count() const; - void set_setters_count(::google::protobuf::uint64 value); - - // optional uint64 configs_count = 4; - bool has_configs_count() const; - void clear_configs_count(); - static const int kConfigsCountFieldNumber = 4; - ::google::protobuf::uint64 configs_count() const; - void set_configs_count(::google::protobuf::uint64 value); - - // @@protoc_insertion_point(class_scope:google.protobuf.compiler.FieldAccessInfo) - private: - void set_has_name(); - void clear_has_name(); - void set_has_getters_count(); - void clear_has_getters_count(); - void set_has_setters_count(); - void clear_has_setters_count(); - void set_has_configs_count(); - void clear_has_configs_count(); - - ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - ::google::protobuf::internal::HasBits<1> _has_bits_; - mutable int _cached_size_; - ::google::protobuf::internal::ArenaStringPtr name_; - ::google::protobuf::uint64 getters_count_; - ::google::protobuf::uint64 setters_count_; - ::google::protobuf::uint64 configs_count_; - friend struct protobuf_google_2fprotobuf_2fcompiler_2fprofile_2eproto::TableStruct; -}; -// ------------------------------------------------------------------- - -class LIBPROTOC_EXPORT MessageAccessInfo : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.MessageAccessInfo) */ { - public: - MessageAccessInfo(); - virtual ~MessageAccessInfo(); - - MessageAccessInfo(const MessageAccessInfo& from); - - inline MessageAccessInfo& operator=(const MessageAccessInfo& from) { - CopyFrom(from); - return *this; - } - - inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields(); - } - - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields(); - } - - static const ::google::protobuf::Descriptor* descriptor(); - static const MessageAccessInfo& default_instance(); - - static inline const MessageAccessInfo* internal_default_instance() { - return reinterpret_cast<const MessageAccessInfo*>( - &_MessageAccessInfo_default_instance_); - } - static PROTOBUF_CONSTEXPR int const kIndexInFileMessages = - 1; - - void Swap(MessageAccessInfo* other); - - // implements Message ---------------------------------------------- - - inline MessageAccessInfo* New() const PROTOBUF_FINAL { return New(NULL); } - - MessageAccessInfo* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; - void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; - void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; - void CopyFrom(const MessageAccessInfo& from); - void MergeFrom(const MessageAccessInfo& from); - void Clear() PROTOBUF_FINAL; - bool IsInitialized() const PROTOBUF_FINAL; - - size_t ByteSizeLong() const PROTOBUF_FINAL; - bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; - void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; - ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; - int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } - private: - void SharedCtor(); - void SharedDtor(); - void SetCachedSize(int size) const PROTOBUF_FINAL; - void InternalSwap(MessageAccessInfo* other); - private: - inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return NULL; - } - inline void* MaybeArenaPtr() const { - return NULL; - } - public: - - ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - // repeated .google.protobuf.compiler.FieldAccessInfo field = 3; - int field_size() const; - void clear_field(); - static const int kFieldFieldNumber = 3; - const ::google::protobuf::compiler::FieldAccessInfo& field(int index) const; - ::google::protobuf::compiler::FieldAccessInfo* mutable_field(int index); - ::google::protobuf::compiler::FieldAccessInfo* add_field(); - ::google::protobuf::RepeatedPtrField< ::google::protobuf::compiler::FieldAccessInfo >* - mutable_field(); - const ::google::protobuf::RepeatedPtrField< ::google::protobuf::compiler::FieldAccessInfo >& - field() const; - - // optional string name = 1; - bool has_name() const; - void clear_name(); - static const int kNameFieldNumber = 1; - const ::std::string& name() const; - void set_name(const ::std::string& value); - #if LANG_CXX11 - void set_name(::std::string&& value); - #endif - void set_name(const char* value); - void set_name(const char* value, size_t size); - ::std::string* mutable_name(); - ::std::string* release_name(); - void set_allocated_name(::std::string* name); - - // optional uint64 count = 2; - bool has_count() const; - void clear_count(); - static const int kCountFieldNumber = 2; - ::google::protobuf::uint64 count() const; - void set_count(::google::protobuf::uint64 value); - - // @@protoc_insertion_point(class_scope:google.protobuf.compiler.MessageAccessInfo) - private: - void set_has_name(); - void clear_has_name(); - void set_has_count(); - void clear_has_count(); - - ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - ::google::protobuf::internal::HasBits<1> _has_bits_; - mutable int _cached_size_; - ::google::protobuf::RepeatedPtrField< ::google::protobuf::compiler::FieldAccessInfo > field_; - ::google::protobuf::internal::ArenaStringPtr name_; - ::google::protobuf::uint64 count_; - friend struct protobuf_google_2fprotobuf_2fcompiler_2fprofile_2eproto::TableStruct; -}; -// ------------------------------------------------------------------- - -class LIBPROTOC_EXPORT AccessInfo : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.AccessInfo) */ { - public: - AccessInfo(); - virtual ~AccessInfo(); - - AccessInfo(const AccessInfo& from); - - inline AccessInfo& operator=(const AccessInfo& from) { - CopyFrom(from); - return *this; - } - - inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields(); - } - - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields(); - } - - static const ::google::protobuf::Descriptor* descriptor(); - static const AccessInfo& default_instance(); - - static inline const AccessInfo* internal_default_instance() { - return reinterpret_cast<const AccessInfo*>( - &_AccessInfo_default_instance_); - } - static PROTOBUF_CONSTEXPR int const kIndexInFileMessages = - 2; - - void Swap(AccessInfo* other); - - // implements Message ---------------------------------------------- - - inline AccessInfo* New() const PROTOBUF_FINAL { return New(NULL); } - - AccessInfo* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; - void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; - void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; - void CopyFrom(const AccessInfo& from); - void MergeFrom(const AccessInfo& from); - void Clear() PROTOBUF_FINAL; - bool IsInitialized() const PROTOBUF_FINAL; - - size_t ByteSizeLong() const PROTOBUF_FINAL; - bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; - void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; - ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; - int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } - private: - void SharedCtor(); - void SharedDtor(); - void SetCachedSize(int size) const PROTOBUF_FINAL; - void InternalSwap(AccessInfo* other); - private: - inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return NULL; - } - inline void* MaybeArenaPtr() const { - return NULL; - } - public: - - ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - // repeated .google.protobuf.compiler.MessageAccessInfo message = 1; - int message_size() const; - void clear_message(); - static const int kMessageFieldNumber = 1; - const ::google::protobuf::compiler::MessageAccessInfo& message(int index) const; - ::google::protobuf::compiler::MessageAccessInfo* mutable_message(int index); - ::google::protobuf::compiler::MessageAccessInfo* add_message(); - ::google::protobuf::RepeatedPtrField< ::google::protobuf::compiler::MessageAccessInfo >* - mutable_message(); - const ::google::protobuf::RepeatedPtrField< ::google::protobuf::compiler::MessageAccessInfo >& - message() const; - - // @@protoc_insertion_point(class_scope:google.protobuf.compiler.AccessInfo) - private: - - ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - ::google::protobuf::internal::HasBits<1> _has_bits_; - mutable int _cached_size_; - ::google::protobuf::RepeatedPtrField< ::google::protobuf::compiler::MessageAccessInfo > message_; - friend struct protobuf_google_2fprotobuf_2fcompiler_2fprofile_2eproto::TableStruct; -}; -// =================================================================== - - -// =================================================================== - -#if !PROTOBUF_INLINE_NOT_IN_HEADERS -// FieldAccessInfo - -// optional string name = 1; -inline bool FieldAccessInfo::has_name() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -inline void FieldAccessInfo::set_has_name() { - _has_bits_[0] |= 0x00000001u; -} -inline void FieldAccessInfo::clear_has_name() { - _has_bits_[0] &= ~0x00000001u; -} -inline void FieldAccessInfo::clear_name() { - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - clear_has_name(); -} -inline const ::std::string& FieldAccessInfo::name() const { - // @@protoc_insertion_point(field_get:google.protobuf.compiler.FieldAccessInfo.name) - return name_.GetNoArena(); -} -inline void FieldAccessInfo::set_name(const ::std::string& value) { - set_has_name(); - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.compiler.FieldAccessInfo.name) -} -#if LANG_CXX11 -inline void FieldAccessInfo::set_name(::std::string&& value) { - set_has_name(); - name_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.FieldAccessInfo.name) -} -#endif -inline void FieldAccessInfo::set_name(const char* value) { - GOOGLE_DCHECK(value != NULL); - set_has_name(); - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); - // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.FieldAccessInfo.name) -} -inline void FieldAccessInfo::set_name(const char* value, size_t size) { - set_has_name(); - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.FieldAccessInfo.name) -} -inline ::std::string* FieldAccessInfo::mutable_name() { - set_has_name(); - // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.FieldAccessInfo.name) - return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -inline ::std::string* FieldAccessInfo::release_name() { - // @@protoc_insertion_point(field_release:google.protobuf.compiler.FieldAccessInfo.name) - clear_has_name(); - return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -inline void FieldAccessInfo::set_allocated_name(::std::string* name) { - if (name != NULL) { - set_has_name(); - } else { - clear_has_name(); - } - name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.FieldAccessInfo.name) -} - -// optional uint64 getters_count = 2; -inline bool FieldAccessInfo::has_getters_count() const { - return (_has_bits_[0] & 0x00000002u) != 0; -} -inline void FieldAccessInfo::set_has_getters_count() { - _has_bits_[0] |= 0x00000002u; -} -inline void FieldAccessInfo::clear_has_getters_count() { - _has_bits_[0] &= ~0x00000002u; -} -inline void FieldAccessInfo::clear_getters_count() { - getters_count_ = GOOGLE_ULONGLONG(0); - clear_has_getters_count(); -} -inline ::google::protobuf::uint64 FieldAccessInfo::getters_count() const { - // @@protoc_insertion_point(field_get:google.protobuf.compiler.FieldAccessInfo.getters_count) - return getters_count_; -} -inline void FieldAccessInfo::set_getters_count(::google::protobuf::uint64 value) { - set_has_getters_count(); - getters_count_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.compiler.FieldAccessInfo.getters_count) -} - -// optional uint64 setters_count = 3; -inline bool FieldAccessInfo::has_setters_count() const { - return (_has_bits_[0] & 0x00000004u) != 0; -} -inline void FieldAccessInfo::set_has_setters_count() { - _has_bits_[0] |= 0x00000004u; -} -inline void FieldAccessInfo::clear_has_setters_count() { - _has_bits_[0] &= ~0x00000004u; -} -inline void FieldAccessInfo::clear_setters_count() { - setters_count_ = GOOGLE_ULONGLONG(0); - clear_has_setters_count(); -} -inline ::google::protobuf::uint64 FieldAccessInfo::setters_count() const { - // @@protoc_insertion_point(field_get:google.protobuf.compiler.FieldAccessInfo.setters_count) - return setters_count_; -} -inline void FieldAccessInfo::set_setters_count(::google::protobuf::uint64 value) { - set_has_setters_count(); - setters_count_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.compiler.FieldAccessInfo.setters_count) -} - -// optional uint64 configs_count = 4; -inline bool FieldAccessInfo::has_configs_count() const { - return (_has_bits_[0] & 0x00000008u) != 0; -} -inline void FieldAccessInfo::set_has_configs_count() { - _has_bits_[0] |= 0x00000008u; -} -inline void FieldAccessInfo::clear_has_configs_count() { - _has_bits_[0] &= ~0x00000008u; -} -inline void FieldAccessInfo::clear_configs_count() { - configs_count_ = GOOGLE_ULONGLONG(0); - clear_has_configs_count(); -} -inline ::google::protobuf::uint64 FieldAccessInfo::configs_count() const { - // @@protoc_insertion_point(field_get:google.protobuf.compiler.FieldAccessInfo.configs_count) - return configs_count_; -} -inline void FieldAccessInfo::set_configs_count(::google::protobuf::uint64 value) { - set_has_configs_count(); - configs_count_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.compiler.FieldAccessInfo.configs_count) -} - -// ------------------------------------------------------------------- - -// MessageAccessInfo - -// optional string name = 1; -inline bool MessageAccessInfo::has_name() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -inline void MessageAccessInfo::set_has_name() { - _has_bits_[0] |= 0x00000001u; -} -inline void MessageAccessInfo::clear_has_name() { - _has_bits_[0] &= ~0x00000001u; -} -inline void MessageAccessInfo::clear_name() { - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - clear_has_name(); -} -inline const ::std::string& MessageAccessInfo::name() const { - // @@protoc_insertion_point(field_get:google.protobuf.compiler.MessageAccessInfo.name) - return name_.GetNoArena(); -} -inline void MessageAccessInfo::set_name(const ::std::string& value) { - set_has_name(); - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.compiler.MessageAccessInfo.name) -} -#if LANG_CXX11 -inline void MessageAccessInfo::set_name(::std::string&& value) { - set_has_name(); - name_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.MessageAccessInfo.name) -} -#endif -inline void MessageAccessInfo::set_name(const char* value) { - GOOGLE_DCHECK(value != NULL); - set_has_name(); - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); - // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.MessageAccessInfo.name) -} -inline void MessageAccessInfo::set_name(const char* value, size_t size) { - set_has_name(); - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.MessageAccessInfo.name) -} -inline ::std::string* MessageAccessInfo::mutable_name() { - set_has_name(); - // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.MessageAccessInfo.name) - return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -inline ::std::string* MessageAccessInfo::release_name() { - // @@protoc_insertion_point(field_release:google.protobuf.compiler.MessageAccessInfo.name) - clear_has_name(); - return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -inline void MessageAccessInfo::set_allocated_name(::std::string* name) { - if (name != NULL) { - set_has_name(); - } else { - clear_has_name(); - } - name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.MessageAccessInfo.name) -} - -// optional uint64 count = 2; -inline bool MessageAccessInfo::has_count() const { - return (_has_bits_[0] & 0x00000002u) != 0; -} -inline void MessageAccessInfo::set_has_count() { - _has_bits_[0] |= 0x00000002u; -} -inline void MessageAccessInfo::clear_has_count() { - _has_bits_[0] &= ~0x00000002u; -} -inline void MessageAccessInfo::clear_count() { - count_ = GOOGLE_ULONGLONG(0); - clear_has_count(); -} -inline ::google::protobuf::uint64 MessageAccessInfo::count() const { - // @@protoc_insertion_point(field_get:google.protobuf.compiler.MessageAccessInfo.count) - return count_; -} -inline void MessageAccessInfo::set_count(::google::protobuf::uint64 value) { - set_has_count(); - count_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.compiler.MessageAccessInfo.count) -} - -// repeated .google.protobuf.compiler.FieldAccessInfo field = 3; -inline int MessageAccessInfo::field_size() const { - return field_.size(); -} -inline void MessageAccessInfo::clear_field() { - field_.Clear(); -} -inline const ::google::protobuf::compiler::FieldAccessInfo& MessageAccessInfo::field(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.compiler.MessageAccessInfo.field) - return field_.Get(index); -} -inline ::google::protobuf::compiler::FieldAccessInfo* MessageAccessInfo::mutable_field(int index) { - // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.MessageAccessInfo.field) - return field_.Mutable(index); -} -inline ::google::protobuf::compiler::FieldAccessInfo* MessageAccessInfo::add_field() { - // @@protoc_insertion_point(field_add:google.protobuf.compiler.MessageAccessInfo.field) - return field_.Add(); -} -inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::compiler::FieldAccessInfo >* -MessageAccessInfo::mutable_field() { - // @@protoc_insertion_point(field_mutable_list:google.protobuf.compiler.MessageAccessInfo.field) - return &field_; -} -inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::compiler::FieldAccessInfo >& -MessageAccessInfo::field() const { - // @@protoc_insertion_point(field_list:google.protobuf.compiler.MessageAccessInfo.field) - return field_; -} - -// ------------------------------------------------------------------- - -// AccessInfo - -// repeated .google.protobuf.compiler.MessageAccessInfo message = 1; -inline int AccessInfo::message_size() const { - return message_.size(); -} -inline void AccessInfo::clear_message() { - message_.Clear(); -} -inline const ::google::protobuf::compiler::MessageAccessInfo& AccessInfo::message(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.compiler.AccessInfo.message) - return message_.Get(index); -} -inline ::google::protobuf::compiler::MessageAccessInfo* AccessInfo::mutable_message(int index) { - // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.AccessInfo.message) - return message_.Mutable(index); -} -inline ::google::protobuf::compiler::MessageAccessInfo* AccessInfo::add_message() { - // @@protoc_insertion_point(field_add:google.protobuf.compiler.AccessInfo.message) - return message_.Add(); -} -inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::compiler::MessageAccessInfo >* -AccessInfo::mutable_message() { - // @@protoc_insertion_point(field_mutable_list:google.protobuf.compiler.AccessInfo.message) - return &message_; -} -inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::compiler::MessageAccessInfo >& -AccessInfo::message() const { - // @@protoc_insertion_point(field_list:google.protobuf.compiler.AccessInfo.message) - return message_; -} - -#endif // !PROTOBUF_INLINE_NOT_IN_HEADERS -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - - -// @@protoc_insertion_point(namespace_scope) - - -} // namespace compiler -} // namespace protobuf -} // namespace google - -// @@protoc_insertion_point(global_scope) - -#endif // PROTOBUF_google_2fprotobuf_2fcompiler_2fprofile_2eproto__INCLUDED diff --git a/src/google/protobuf/compiler/python/python_generator.cc b/src/google/protobuf/compiler/python/python_generator.cc index 21a7e158..5ca6b4ee 100644 --- a/src/google/protobuf/compiler/python/python_generator.cc +++ b/src/google/protobuf/compiler/python/python_generator.cc @@ -63,11 +63,12 @@ #include <google/protobuf/stubs/common.h> #include <google/protobuf/stubs/stringprintf.h> #include <google/protobuf/io/printer.h> -#include <google/protobuf/descriptor.h> #include <google/protobuf/io/zero_copy_stream.h> +#include <google/protobuf/descriptor.h> #include <google/protobuf/stubs/strutil.h> #include <google/protobuf/stubs/substitute.h> + namespace google { namespace protobuf { namespace compiler { @@ -75,12 +76,21 @@ namespace python { namespace { +// Reimplemented here because we can't bring in +// absl/strings/string_view_utils.h because it needs C++11. +bool StrStartsWith(StringPiece sp, StringPiece x) { + return sp.size() >= x.size() && sp.substr(0, x.size()) == x; +} +bool StrEndsWith(StringPiece sp, StringPiece x) { + return sp.size() >= x.size() && sp.substr(sp.size() - x.size()) == x; +} + // Returns a copy of |filename| with any trailing ".protodevel" or ".proto // suffix stripped. // TODO(robinson): Unify with copy in compiler/cpp/internal/helpers.cc. string StripProto(const string& filename) { - const char* suffix = HasSuffixString(filename, ".protodevel") - ? ".protodevel" : ".proto"; + const char* suffix = + StrEndsWith(filename, ".protodevel") ? ".protodevel" : ".proto"; return StripSuffixString(filename, suffix); } @@ -350,7 +360,9 @@ bool Generator::Generate(const FileDescriptor* file, // can only be successfully parsed after we register corresponding // extensions. Therefore we parse all options again here to recognize // custom options that may be unknown when we define the descriptors. + // This does not apply to services because they are not used by extensions. FixAllDescriptorOptions(); + PrintServiceDescriptors(); if (HasGenericServices(file)) { PrintServices(); } @@ -562,9 +574,16 @@ void Generator::PrintMessageDescriptors() const { } } -void Generator::PrintServices() const { +void Generator::PrintServiceDescriptors() const { for (int i = 0; i < file_->service_count(); ++i) { PrintServiceDescriptor(*file_->service(i)); + AddServiceToFileDescriptor(*file_->service(i)); + printer_->Print("\n"); + } +} + +void Generator::PrintServices() const { + for (int i = 0; i < file_->service_count(); ++i) { PrintServiceClass(*file_->service(i)); PrintServiceStub(*file_->service(i)); printer_->Print("\n"); @@ -628,7 +647,10 @@ void Generator::PrintServiceDescriptor( } printer_->Outdent(); - printer_->Print("])\n\n"); + printer_->Print("])\n"); + printer_->Print("_sym_db.RegisterServiceDescriptor($name$)\n", "name", + service_name); + printer_->Print("\n"); } @@ -887,6 +909,18 @@ void Generator::AddMessageToFileDescriptor(const Descriptor& descriptor) const { printer_->Print(m, file_descriptor_template); } +void Generator::AddServiceToFileDescriptor( + const ServiceDescriptor& descriptor) const { + std::map<string, string> m; + m["descriptor_name"] = kDescriptorKey; + m["service_name"] = descriptor.name(); + m["service_descriptor_name"] = ModuleLevelServiceDescriptorName(descriptor); + const char file_descriptor_template[] = + "$descriptor_name$.services_by_name['$service_name$'] = " + "$service_descriptor_name$\n"; + printer_->Print(m, file_descriptor_template); +} + void Generator::AddEnumToFileDescriptor( const EnumDescriptor& descriptor) const { std::map<string, string> m; @@ -1117,7 +1151,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$$json_name$)"; + " options=$options$$json_name$, file=DESCRIPTOR)"; printer_->Print(m, field_descriptor_decl); } diff --git a/src/google/protobuf/compiler/python/python_generator.h b/src/google/protobuf/compiler/python/python_generator.h index 594260af..2b5a028b 100644 --- a/src/google/protobuf/compiler/python/python_generator.h +++ b/src/google/protobuf/compiler/python/python_generator.h @@ -112,6 +112,7 @@ class LIBPROTOC_EXPORT Generator : public CodeGenerator { void AddMessageToFileDescriptor(const Descriptor& descriptor) const; void AddEnumToFileDescriptor(const EnumDescriptor& descriptor) const; void AddExtensionToFileDescriptor(const FieldDescriptor& descriptor) const; + void AddServiceToFileDescriptor(const ServiceDescriptor& descriptor) const; string FieldReferencingExpression(const Descriptor* containing_type, const FieldDescriptor& field, const string& python_dict_name) const; @@ -126,11 +127,12 @@ class LIBPROTOC_EXPORT Generator : public CodeGenerator { void FixForeignFieldsInNestedExtensions(const Descriptor& descriptor) const; void PrintServices() const; + void PrintServiceDescriptors() const; void PrintServiceDescriptor(const ServiceDescriptor& descriptor) const; void PrintServiceClass(const ServiceDescriptor& descriptor) const; void PrintServiceStub(const ServiceDescriptor& descriptor) const; void PrintDescriptorKeyAndModuleName( - const ServiceDescriptor& descriptor) const ; + const ServiceDescriptor& descriptor) const; void PrintEnumValueDescriptor(const EnumValueDescriptor& descriptor) const; string OptionsValue(const string& class_name, diff --git a/src/google/protobuf/compiler/subprocess.cc b/src/google/protobuf/compiler/subprocess.cc index 933450fa..2e5a89ac 100644 --- a/src/google/protobuf/compiler/subprocess.cc +++ b/src/google/protobuf/compiler/subprocess.cc @@ -33,6 +33,7 @@ #include <google/protobuf/compiler/subprocess.h> #include <algorithm> +#include <cstring> #include <iostream> #ifndef _WIN32 @@ -47,11 +48,20 @@ #include <google/protobuf/message.h> #include <google/protobuf/stubs/substitute.h> - namespace google { namespace protobuf { namespace compiler { +namespace { +char* portable_strdup(const char* s) { + char* ns = (char*) malloc(strlen(s) + 1); + if (ns != NULL) { + strcpy(ns, s); + } + return ns; +} +} // namespace + #ifdef _WIN32 static void CloseHandleOrDie(HANDLE handle) { @@ -115,7 +125,7 @@ void Subprocess::Start(const string& program, SearchMode search_mode) { } // CreateProcess() mutates its second parameter. WTF? - char* name_copy = strdup(program.c_str()); + char* name_copy = portable_strdup(program.c_str()); // Create the process. PROCESS_INFORMATION process_info; @@ -299,7 +309,7 @@ void Subprocess::Start(const string& program, SearchMode search_mode) { GOOGLE_CHECK(pipe(stdin_pipe) != -1); GOOGLE_CHECK(pipe(stdout_pipe) != -1); - char* argv[2] = { strdup(program.c_str()), NULL }; + char* argv[2] = { portable_strdup(program.c_str()), NULL }; child_pid_ = fork(); if (child_pid_ == -1) { @@ -347,7 +357,6 @@ void Subprocess::Start(const string& program, SearchMode search_mode) { bool Subprocess::Communicate(const Message& input, Message* output, string* error) { - GOOGLE_CHECK_NE(child_stdin_, -1) << "Must call Start() first."; // The "sighandler_t" typedef is GNU-specific, so define our own. diff --git a/src/google/protobuf/compiler/subprocess.h b/src/google/protobuf/compiler/subprocess.h index 25138631..9d980b06 100644 --- a/src/google/protobuf/compiler/subprocess.h +++ b/src/google/protobuf/compiler/subprocess.h @@ -44,7 +44,6 @@ #include <string> - namespace google { namespace protobuf { diff --git a/src/google/protobuf/compiler/zip_output_unittest.sh b/src/google/protobuf/compiler/zip_output_unittest.sh index 6fc7136d..f8597912 100755 --- a/src/google/protobuf/compiler/zip_output_unittest.sh +++ b/src/google/protobuf/compiler/zip_output_unittest.sh @@ -41,6 +41,8 @@ fail() { TEST_TMPDIR=. PROTOC=./protoc +JAR=jar +UNZIP=unzip echo ' syntax = "proto2"; @@ -57,8 +59,9 @@ $PROTOC \ || fail 'protoc failed.' echo "Testing output to zip..." -if unzip -h > /dev/null; then - unzip -t $TEST_TMPDIR/testzip.zip > $TEST_TMPDIR/testzip.list || fail 'unzip failed.' +if $UNZIP -h > /dev/null; then + $UNZIP -t $TEST_TMPDIR/testzip.zip > $TEST_TMPDIR/testzip.list \ + || fail 'unzip failed.' grep 'testing: testzip\.pb\.cc *OK$' $TEST_TMPDIR/testzip.list > /dev/null \ || fail 'testzip.pb.cc not found in output zip.' @@ -73,8 +76,14 @@ else fi echo "Testing output to jar..." -if jar c $TEST_TMPDIR/testzip.proto > /dev/null; then - jar tf $TEST_TMPDIR/testzip.jar > $TEST_TMPDIR/testzip.list || fail 'jar failed.' +if $JAR c $TEST_TMPDIR/testzip.proto > /dev/null; then + $JAR tf $TEST_TMPDIR/testzip.jar > $TEST_TMPDIR/testzip.list \ + || fail 'jar failed.' + + # Check that -interface.jar timestamps are normalized: + if [[ "$(TZ=UTC $JAR tvf $TEST_TMPDIR/testzip.jar)" != *'Tue Jan 01 00:00:00 UTC 1980'* ]]; then + fail 'Zip did not contain normalized timestamps' + fi grep '^test/jar/Foo\.java$' $TEST_TMPDIR/testzip.list > /dev/null \ || fail 'Foo.java not found in output jar.' diff --git a/src/google/protobuf/compiler/zip_writer.cc b/src/google/protobuf/compiler/zip_writer.cc index 458cced2..1799af6a 100644 --- a/src/google/protobuf/compiler/zip_writer.cc +++ b/src/google/protobuf/compiler/zip_writer.cc @@ -70,6 +70,10 @@ namespace google { namespace protobuf { namespace compiler { +// January 1, 1980 as a DOS date. +// see https://msdn.microsoft.com/en-us/library/9kkf9tah.aspx +static const uint16 kDosEpoch = 1 << 5 | 1; + static const uint32 kCRC32Table[256] = { 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, @@ -154,7 +158,7 @@ bool ZipWriter::Write(const string& filename, const string& contents) { WriteShort(&output, 0); // flags WriteShort(&output, 0); // compression method: stored WriteShort(&output, 0); // last modified time - WriteShort(&output, 0); // last modified date + WriteShort(&output, kDosEpoch); // last modified date output.WriteLittleEndian32(info.crc32); // crc-32 output.WriteLittleEndian32(info.size); // compressed size output.WriteLittleEndian32(info.size); // uncompressed size @@ -185,7 +189,7 @@ bool ZipWriter::WriteDirectory() { WriteShort(&output, 0); // flags WriteShort(&output, 0); // compression method: stored WriteShort(&output, 0); // last modified time - WriteShort(&output, 0); // last modified date + WriteShort(&output, kDosEpoch); // last modified date output.WriteLittleEndian32(crc32); // crc-32 output.WriteLittleEndian32(size); // compressed size output.WriteLittleEndian32(size); // uncompressed size diff --git a/src/google/protobuf/descriptor.cc b/src/google/protobuf/descriptor.cc index 6a807926..9d48bfba 100644 --- a/src/google/protobuf/descriptor.cc +++ b/src/google/protobuf/descriptor.cc @@ -32,7 +32,10 @@ // Based on original Protocol Buffers design by // Sanjay Ghemawat, Jeff Dean, and others. +#include <algorithm> +#include <functional> #include <google/protobuf/stubs/hash.h> +#include <limits> #include <map> #include <memory> #ifndef _SHARED_PTR_H @@ -41,28 +44,27 @@ #include <set> #include <string> #include <vector> -#include <algorithm> -#include <limits> +#include <google/protobuf/stubs/common.h> +#include <google/protobuf/stubs/logging.h> +#include <google/protobuf/stubs/mutex.h> +#include <google/protobuf/stubs/once.h> +#include <google/protobuf/stubs/stringprintf.h> +#include <google/protobuf/stubs/strutil.h> +#include <google/protobuf/io/strtod.h> +#include <google/protobuf/io/coded_stream.h> +#include <google/protobuf/io/tokenizer.h> +#include <google/protobuf/io/zero_copy_stream_impl.h> +#include <google/protobuf/descriptor.pb.h> #include <google/protobuf/descriptor.h> #include <google/protobuf/descriptor_database.h> -#include <google/protobuf/descriptor.pb.h> #include <google/protobuf/dynamic_message.h> #include <google/protobuf/generated_message_util.h> #include <google/protobuf/text_format.h> #include <google/protobuf/unknown_field_set.h> #include <google/protobuf/wire_format.h> -#include <google/protobuf/io/strtod.h> -#include <google/protobuf/io/coded_stream.h> -#include <google/protobuf/io/tokenizer.h> -#include <google/protobuf/io/zero_copy_stream_impl.h> -#include <google/protobuf/stubs/common.h> -#include <google/protobuf/stubs/logging.h> -#include <google/protobuf/stubs/mutex.h> -#include <google/protobuf/stubs/once.h> -#include <google/protobuf/stubs/stringprintf.h> -#include <google/protobuf/stubs/strutil.h> #include <google/protobuf/stubs/substitute.h> + #include <google/protobuf/stubs/map_util.h> #include <google/protobuf/stubs/stl_util.h> @@ -374,15 +376,13 @@ class PrefixRemover { string prefix_; }; -// A DescriptorPool contains a bunch of hash_maps to implement the +// 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 +// most efficient to construct a fixed set of large hash-maps used by // all objects in the pool rather than construct one or more small -// hash_maps for each object. +// hash-maps for each object. // -// The keys to these hash_maps are (parent, name) or (parent, number) -// pairs. Unfortunately STL doesn't provide hash functions for pair<>, -// so we must invent our own. +// The keys to these hash-maps are (parent, name) or (parent, number) pairs. // // TODO(kenton): Use StringPiece rather than const char* in keys? It would // be a lot cleaner but we'd just have to convert it back to const char* @@ -397,6 +397,13 @@ struct PointerStringPairEqual { } }; +typedef std::pair<const Descriptor*, int> DescriptorIntPair; +typedef std::pair<const EnumDescriptor*, int> EnumIntPair; + +#define HASH_MAP hash_map +#define HASH_SET hash_set +#define HASH_FXN hash + template<typename PairType> struct PointerIntegerPairHash { size_t operator()(const PairType& p) const { @@ -416,9 +423,6 @@ struct PointerIntegerPairHash { } }; -typedef std::pair<const Descriptor*, int> DescriptorIntPair; -typedef std::pair<const EnumDescriptor*, int> EnumIntPair; - struct PointerStringPairHash { size_t operator()(const PointerStringPair& p) const { // FIXME(kenton): What is the best way to compute this hash? I have @@ -444,31 +448,37 @@ struct PointerStringPairHash { const Symbol kNullSymbol; -typedef hash_map<const char*, Symbol, - hash<const char*>, streq> - SymbolsByNameMap; -typedef hash_map<PointerStringPair, Symbol, - PointerStringPairHash, PointerStringPairEqual> - SymbolsByParentMap; -typedef hash_map<const char*, const FileDescriptor*, - hash<const char*>, streq> - FilesByNameMap; -typedef hash_map<PointerStringPair, const FieldDescriptor*, +typedef HASH_MAP<const char*, Symbol, HASH_FXN<const char*>, streq> + SymbolsByNameMap; + +typedef HASH_MAP<PointerStringPair, Symbol, PointerStringPairHash, + PointerStringPairEqual> + SymbolsByParentMap; + +typedef HASH_MAP<const char*, const FileDescriptor*, HASH_FXN<const char*>, + streq> + FilesByNameMap; + +typedef HASH_MAP<PointerStringPair, const FieldDescriptor*, PointerStringPairHash, PointerStringPairEqual> - FieldsByNameMap; -typedef hash_map<DescriptorIntPair, const FieldDescriptor*, - PointerIntegerPairHash<DescriptorIntPair> > - FieldsByNumberMap; -typedef hash_map<EnumIntPair, const EnumValueDescriptor*, - PointerIntegerPairHash<EnumIntPair> > - EnumValuesByNumberMap; -// This is a map rather than a hash_map, since we use it to iterate + FieldsByNameMap; + +typedef HASH_MAP<DescriptorIntPair, const FieldDescriptor*, + PointerIntegerPairHash<DescriptorIntPair>, + std::equal_to<DescriptorIntPair> > + FieldsByNumberMap; + +typedef HASH_MAP<EnumIntPair, const EnumValueDescriptor*, + PointerIntegerPairHash<EnumIntPair>, + std::equal_to<EnumIntPair> > + EnumValuesByNumberMap; +// This is a map rather than a hash-map, since we use it to iterate // through all the extensions that extend a given Descriptor, and an // ordered data structure that implements lower_bound is convenient // for that. typedef std::map<DescriptorIntPair, const FieldDescriptor*> ExtensionsGroupedByDescriptorMap; -typedef hash_map<string, const SourceCodeInfo_Location*> LocationsByPathMap; +typedef HASH_MAP<string, const SourceCodeInfo_Location*> LocationsByPathMap; std::set<string>* allowed_proto3_extendees_ = NULL; GOOGLE_PROTOBUF_DECLARE_ONCE(allowed_proto3_extendees_init_); @@ -563,17 +573,17 @@ class DescriptorPool::Tables { // execution of the current public API call, but for compatibility with // legacy clients, this is cleared at the beginning of each public API call. // Not used when fallback_database_ == NULL. - hash_set<string> known_bad_files_; + HASH_SET<string> known_bad_files_; // A set of symbols which we have tried to load from the fallback database // and encountered errors. We will not attempt to load them again during // execution of the current public API call, but for compatibility with // legacy clients, this is cleared at the beginning of each public API call. - hash_set<string> known_bad_symbols_; + HASH_SET<string> known_bad_symbols_; // The set of descriptors for which we've already loaded the full // set of extensions numbers from fallback_database_. - hash_set<const Descriptor*> extensions_loaded_from_db_; + HASH_SET<const Descriptor*> extensions_loaded_from_db_; // ----------------------------------------------------------------- // Finding items. @@ -592,7 +602,7 @@ class DescriptorPool::Tables { // These return NULL if not found. inline const FileDescriptor* FindFile(const string& key) const; inline const FieldDescriptor* FindExtension(const Descriptor* extendee, - int number); + int number) const; inline void FindAllExtensions(const Descriptor* extendee, std::vector<const FieldDescriptor*>* out) const; @@ -751,11 +761,27 @@ class FileDescriptorTables { const SourceCodeInfo_Location* GetSourceLocation( const std::vector<int>& path, const SourceCodeInfo* info) const; + // Must be called after BuildFileImpl(), even if the build failed and + // we are going to roll back to the last checkpoint. + void FinalizeTables(); + private: - SymbolsByParentMap symbols_by_parent_; - FieldsByNameMap fields_by_lowercase_name_; - FieldsByNameMap fields_by_camelcase_name_; - FieldsByNumberMap fields_by_number_; // Not including extensions. + const void* FindParentForFieldsByMap(const FieldDescriptor* field) const; + static void FieldsByLowercaseNamesLazyInitStatic( + const FileDescriptorTables* tables); + void FieldsByLowercaseNamesLazyInitInternal() const; + static void FieldsByCamelcaseNamesLazyInitStatic( + const FileDescriptorTables* tables); + void FieldsByCamelcaseNamesLazyInitInternal() const; + + SymbolsByParentMap symbols_by_parent_; + mutable FieldsByNameMap fields_by_lowercase_name_; + mutable FieldsByNameMap* fields_by_lowercase_name_tmp_; + mutable GoogleOnceDynamic fields_by_lowercase_name_once_; + mutable FieldsByNameMap fields_by_camelcase_name_; + mutable FieldsByNameMap* fields_by_camelcase_name_tmp_; + mutable GoogleOnceDynamic fields_by_camelcase_name_once_; + FieldsByNumberMap fields_by_number_; // Not including extensions. EnumValuesByNumberMap enum_values_by_number_; mutable EnumValuesByNumberMap unknown_enum_values_by_number_ GOOGLE_GUARDED_BY(unknown_enum_values_mu_); @@ -770,14 +796,13 @@ class FileDescriptorTables { }; DescriptorPool::Tables::Tables() - // Start some hash_map and hash_set objects with a small # of buckets + // Start some hash-map and hash-set objects with a small # of buckets : known_bad_files_(3), known_bad_symbols_(3), extensions_loaded_from_db_(3), symbols_by_name_(3), files_by_name_(3) {} - DescriptorPool::Tables::~Tables() { GOOGLE_DCHECK(checkpoints_.empty()); // Note that the deletion order is important, since the destructors of some @@ -792,14 +817,16 @@ DescriptorPool::Tables::~Tables() { } FileDescriptorTables::FileDescriptorTables() - // Initialize all the hash tables to start out with a small # of buckets + // Initialize all the hash tables to start out with a small # of buckets. : symbols_by_parent_(3), fields_by_lowercase_name_(3), + fields_by_lowercase_name_tmp_(new FieldsByNameMap()), fields_by_camelcase_name_(3), + fields_by_camelcase_name_tmp_(new FieldsByNameMap()), fields_by_number_(3), enum_values_by_number_(3), - unknown_enum_values_by_number_(3) { -} + unknown_enum_values_by_number_(3), + locations_by_path_(3) {} FileDescriptorTables::~FileDescriptorTables() {} @@ -929,8 +956,10 @@ inline Symbol FileDescriptorTables::FindNestedSymbolOfType( Symbol DescriptorPool::Tables::FindByNameHelper( const DescriptorPool* pool, const string& name) { MutexLockMaybe lock(pool->mutex_); - known_bad_symbols_.clear(); - known_bad_files_.clear(); + if (pool->fallback_database_ != NULL) { + known_bad_symbols_.clear(); + known_bad_files_.clear(); + } Symbol result = FindSymbol(name); if (result.IsNull() && pool->underlay_ != NULL) { @@ -959,14 +988,59 @@ inline const FieldDescriptor* FileDescriptorTables::FindFieldByNumber( return FindPtrOrNull(fields_by_number_, std::make_pair(parent, number)); } +const void* FileDescriptorTables::FindParentForFieldsByMap( + const FieldDescriptor* field) const { + if (field->is_extension()) { + if (field->extension_scope() == NULL) { + return field->file(); + } else { + return field->extension_scope(); + } + } else { + return field->containing_type(); + } +} + +void FileDescriptorTables::FieldsByLowercaseNamesLazyInitStatic( + const FileDescriptorTables* tables) { + tables->FieldsByLowercaseNamesLazyInitInternal(); +} + +void FileDescriptorTables::FieldsByLowercaseNamesLazyInitInternal() const { + for (FieldsByNumberMap::const_iterator it = fields_by_number_.begin(); + it != fields_by_number_.end(); it++) { + PointerStringPair lowercase_key(FindParentForFieldsByMap(it->second), + it->second->lowercase_name().c_str()); + InsertIfNotPresent(&fields_by_lowercase_name_, lowercase_key, it->second); + } +} + inline const FieldDescriptor* FileDescriptorTables::FindFieldByLowercaseName( const void* parent, const string& lowercase_name) const { + fields_by_lowercase_name_once_.Init( + &FileDescriptorTables::FieldsByLowercaseNamesLazyInitStatic, this); return FindPtrOrNull(fields_by_lowercase_name_, PointerStringPair(parent, lowercase_name.c_str())); } +void FileDescriptorTables::FieldsByCamelcaseNamesLazyInitStatic( + const FileDescriptorTables* tables) { + tables->FieldsByCamelcaseNamesLazyInitInternal(); +} + +void FileDescriptorTables::FieldsByCamelcaseNamesLazyInitInternal() const { + for (FieldsByNumberMap::const_iterator it = fields_by_number_.begin(); + it != fields_by_number_.end(); it++) { + PointerStringPair camelcase_key(FindParentForFieldsByMap(it->second), + it->second->camelcase_name().c_str()); + InsertIfNotPresent(&fields_by_camelcase_name_, camelcase_key, it->second); + } +} + inline const FieldDescriptor* FileDescriptorTables::FindFieldByCamelcaseName( const void* parent, const string& camelcase_name) const { + fields_by_camelcase_name_once_.Init( + &FileDescriptorTables::FieldsByCamelcaseNamesLazyInitStatic, this); return FindPtrOrNull(fields_by_camelcase_name_, PointerStringPair(parent, camelcase_name.c_str())); } @@ -1030,7 +1104,7 @@ FileDescriptorTables::FindEnumValueByNumberCreatingIfUnknown( inline const FieldDescriptor* DescriptorPool::Tables::FindExtension( - const Descriptor* extendee, int number) { + const Descriptor* extendee, int number) const { return FindPtrOrNull(extensions_, std::make_pair(extendee, number)); } @@ -1071,24 +1145,40 @@ bool DescriptorPool::Tables::AddFile(const FileDescriptor* file) { } } +void FileDescriptorTables::FinalizeTables() { + // Clean up the temporary maps used by AddFieldByStylizedNames(). + delete fields_by_lowercase_name_tmp_; + fields_by_lowercase_name_tmp_ = NULL; + delete fields_by_camelcase_name_tmp_; + fields_by_camelcase_name_tmp_ = NULL; +} + void FileDescriptorTables::AddFieldByStylizedNames( const FieldDescriptor* field) { - const void* parent; - if (field->is_extension()) { - if (field->extension_scope() == NULL) { - parent = field->file(); - } else { - parent = field->extension_scope(); - } - } else { - parent = field->containing_type(); - } + const void* parent = FindParentForFieldsByMap(field); + + // We want fields_by_{lower,camel}case_name_ to be lazily built, but + // cross-link order determines which entry will be present in the case of a + // conflict. So we use the temporary maps that get destroyed after + // BuildFileImpl() to detect the conflicts, and only store the conflicts in + // the map that will persist. We will then lazily populate the rest of the + // entries from fields_by_number_. PointerStringPair lowercase_key(parent, field->lowercase_name().c_str()); - InsertIfNotPresent(&fields_by_lowercase_name_, lowercase_key, field); + if (!InsertIfNotPresent(fields_by_lowercase_name_tmp_, lowercase_key, + field)) { + InsertIfNotPresent( + &fields_by_lowercase_name_, lowercase_key, + FindPtrOrNull(*fields_by_lowercase_name_tmp_, lowercase_key)); + } PointerStringPair camelcase_key(parent, field->camelcase_name().c_str()); - InsertIfNotPresent(&fields_by_camelcase_name_, camelcase_key, field); + if (!InsertIfNotPresent(fields_by_camelcase_name_tmp_, camelcase_key, + field)) { + InsertIfNotPresent( + &fields_by_camelcase_name_, camelcase_key, + FindPtrOrNull(*fields_by_camelcase_name_tmp_, camelcase_key)); + } } bool FileDescriptorTables::AddFieldByNumber(const FieldDescriptor* field) { @@ -1323,8 +1413,10 @@ void DescriptorPool::InternalAddGeneratedFile( const FileDescriptor* DescriptorPool::FindFileByName(const string& name) const { MutexLockMaybe lock(mutex_); - tables_->known_bad_symbols_.clear(); - tables_->known_bad_files_.clear(); + if (fallback_database_ != NULL) { + tables_->known_bad_symbols_.clear(); + tables_->known_bad_files_.clear(); + } const FileDescriptor* result = tables_->FindFile(name); if (result != NULL) return result; if (underlay_ != NULL) { @@ -1341,8 +1433,10 @@ const FileDescriptor* DescriptorPool::FindFileByName(const string& name) const { const FileDescriptor* DescriptorPool::FindFileContainingSymbol( const string& symbol_name) const { MutexLockMaybe lock(mutex_); - tables_->known_bad_symbols_.clear(); - tables_->known_bad_files_.clear(); + if (fallback_database_ != NULL) { + tables_->known_bad_symbols_.clear(); + tables_->known_bad_files_.clear(); + } Symbol result = tables_->FindSymbol(symbol_name); if (!result.IsNull()) return result.GetFile(); if (underlay_ != NULL) { @@ -1418,9 +1512,20 @@ const MethodDescriptor* DescriptorPool::FindMethodByName( const FieldDescriptor* DescriptorPool::FindExtensionByNumber( const Descriptor* extendee, int number) const { + // A faster path to reduce lock contention in finding extensions, assuming + // most extensions will be cache hit. + if (mutex_ != NULL) { + ReaderMutexLock lock(mutex_); + const FieldDescriptor* result = tables_->FindExtension(extendee, number); + if (result != NULL) { + return result; + } + } MutexLockMaybe lock(mutex_); - tables_->known_bad_symbols_.clear(); - tables_->known_bad_files_.clear(); + if (fallback_database_ != NULL) { + tables_->known_bad_symbols_.clear(); + tables_->known_bad_files_.clear(); + } const FieldDescriptor* result = tables_->FindExtension(extendee, number); if (result != NULL) { return result; @@ -1442,8 +1547,10 @@ void DescriptorPool::FindAllExtensions( const Descriptor* extendee, std::vector<const FieldDescriptor*>* out) const { MutexLockMaybe lock(mutex_); - tables_->known_bad_symbols_.clear(); - tables_->known_bad_files_.clear(); + if (fallback_database_ != NULL) { + tables_->known_bad_symbols_.clear(); + tables_->known_bad_files_.clear(); + } // Initialize tables_->extensions_ from the fallback database first // (but do this only once per descriptor). @@ -1720,6 +1827,18 @@ Descriptor::FindReservedRangeContainingNumber(int number) const { return NULL; } +const EnumDescriptor::ReservedRange* +EnumDescriptor::FindReservedRangeContainingNumber(int number) const { + // TODO(chrisn): Consider a non-linear search. + for (int i = 0; i < reserved_range_count(); i++) { + if (number >= reserved_range(i)->start && + number <= reserved_range(i)->end) { + return reserved_range(i); + } + } + return NULL; +} + // ------------------------------------------------------------------- bool DescriptorPool::TryFindFileInFallbackDatabase(const string& name) const { @@ -1825,8 +1944,8 @@ bool DescriptorPool::TryFindExtensionInFallbackDatabase( // =================================================================== -bool FieldDescriptor::is_map() const { - return type() == TYPE_MESSAGE && message_type()->options().map_entry(); +bool FieldDescriptor::is_map_message_type() const { + return message_type_->options().map_entry(); } string FieldDescriptor::DefaultValueAsString(bool quote_string_type) const { @@ -1953,6 +2072,10 @@ void Descriptor::CopyTo(DescriptorProto* proto) const { DescriptorProto::ExtensionRange* range = proto->add_extension_range(); range->set_start(extension_range(i)->start); range->set_end(extension_range(i)->end); + const ExtensionRangeOptions* options = extension_range(i)->options_; + if (options != &ExtensionRangeOptions::default_instance()) { + range->mutable_options()->CopyFrom(*options); + } } for (int i = 0; i < extension_count(); i++) { extension(i)->CopyTo(proto->add_extension()); @@ -2058,6 +2181,14 @@ void EnumDescriptor::CopyTo(EnumDescriptorProto* proto) const { for (int i = 0; i < value_count(); i++) { value(i)->CopyTo(proto->add_value()); } + for (int i = 0; i < reserved_range_count(); i++) { + EnumDescriptorProto::EnumReservedRange* range = proto->add_reserved_range(); + range->set_start(reserved_range(i)->start); + range->set_end(reserved_range(i)->end); + } + for (int i = 0; i < reserved_name_count(); i++) { + proto->add_reserved_name(reserved_name(i)); + } if (&options() != &EnumOptions::default_instance()) { proto->mutable_options()->CopyFrom(options()); @@ -2690,6 +2821,30 @@ void EnumDescriptor::DebugString(int depth, string *contents, for (int i = 0; i < value_count(); i++) { value(i)->DebugString(depth, contents, debug_string_options); } + + if (reserved_range_count() > 0) { + strings::SubstituteAndAppend(contents, "$0 reserved ", prefix); + for (int i = 0; i < reserved_range_count(); i++) { + const EnumDescriptor::ReservedRange* range = reserved_range(i); + if (range->end == range->start) { + strings::SubstituteAndAppend(contents, "$0, ", range->start); + } else { + strings::SubstituteAndAppend(contents, "$0 to $1, ", + range->start, range->end); + } + } + contents->replace(contents->size() - 2, 2, ";\n"); + } + + if (reserved_name_count() > 0) { + strings::SubstituteAndAppend(contents, "$0 reserved ", prefix); + for (int i = 0; i < reserved_name_count(); i++) { + strings::SubstituteAndAppend(contents, "\"$0\", ", + CEscape(reserved_name(i))); + } + contents->replace(contents->size() - 2, 2, ";\n"); + } + strings::SubstituteAndAppend(contents, "$0}\n", prefix); comment_printer.AddPostComment(contents); @@ -2989,7 +3144,7 @@ class DescriptorBuilder { friend class OptionInterpreter; // Non-recursive part of BuildFile functionality. - const FileDescriptor* BuildFileImpl(const FileDescriptorProto& proto); + FileDescriptor* BuildFileImpl(const FileDescriptorProto& proto); const DescriptorPool* pool_; DescriptorPool::Tables* tables_; // for convenience @@ -3173,6 +3328,9 @@ class DescriptorBuilder { void BuildReservedRange(const DescriptorProto::ReservedRange& proto, const Descriptor* parent, Descriptor::ReservedRange* result); + void BuildReservedRange(const EnumDescriptorProto::EnumReservedRange& proto, + const EnumDescriptor* parent, + EnumDescriptor::ReservedRange* result); void BuildOneof(const OneofDescriptorProto& proto, Descriptor* parent, OneofDescriptor* result); @@ -3203,6 +3361,8 @@ class DescriptorBuilder { void CrossLinkMessage(Descriptor* message, const DescriptorProto& proto); void CrossLinkField(FieldDescriptor* field, const FieldDescriptorProto& proto); + void CrossLinkExtensionRange(Descriptor::ExtensionRange* range, + const DescriptorProto::ExtensionRange& proto); void CrossLinkEnum(EnumDescriptor* enum_type, const EnumDescriptorProto& proto); void CrossLinkEnumValue(EnumValueDescriptor* enum_value, @@ -3382,6 +3542,8 @@ class DescriptorBuilder { void DetectMapConflicts(const Descriptor* message, const DescriptorProto& proto); + void ValidateJSType(FieldDescriptor* field, + const FieldDescriptorProto& proto); }; const FileDescriptor* DescriptorPool::BuildFile( @@ -3509,8 +3671,8 @@ void DescriptorBuilder::AddWarning( bool DescriptorBuilder::IsInPackage(const FileDescriptor* file, const string& package_name) { return HasPrefixString(file->package(), package_name) && - (file->package().size() == package_name.size() || - file->package()[package_name.size()] == '.'); + (file->package().size() == package_name.size() || + file->package()[package_name.size()] == '.'); } void DescriptorBuilder::RecordPublicDependencies(const FileDescriptor* file) { @@ -4080,14 +4242,25 @@ const FileDescriptor* DescriptorBuilder::BuildFile( tables_->pending_files_.pop_back(); } } - return BuildFileImpl(proto); -} -const FileDescriptor* DescriptorBuilder::BuildFileImpl( - const FileDescriptorProto& proto) { // Checkpoint the tables so that we can roll back if something goes wrong. tables_->AddCheckpoint(); + FileDescriptor* result = BuildFileImpl(proto); + + file_tables_->FinalizeTables(); + if (result) { + tables_->ClearLastCheckpoint(); + result->finished_building_ = true; + } else { + tables_->RollbackToLastCheckpoint(); + } + + return result; +} + +FileDescriptor* DescriptorBuilder::BuildFileImpl( + const FileDescriptorProto& proto) { FileDescriptor* result = tables_->Allocate<FileDescriptor>(); file_ = result; @@ -4139,7 +4312,6 @@ const FileDescriptor* DescriptorBuilder::BuildFileImpl( "A file with this name is already in the pool."); // Bail out early so that if this is actually the exact same file, we // don't end up reporting that every single symbol is already defined. - tables_->RollbackToLastCheckpoint(); return NULL; } if (!result->package().empty()) { @@ -4155,8 +4327,10 @@ const FileDescriptor* DescriptorBuilder::BuildFileImpl( result->dependencies_once_ = tables_->AllocateOnceDynamic(); result->dependencies_names_ = tables_->AllocateArray<const string*>(proto.dependency_size()); - memset(result->dependencies_names_, 0, - sizeof(*result->dependencies_names_) * proto.dependency_size()); + if (proto.dependency_size() > 0) { + memset(result->dependencies_names_, 0, + sizeof(*result->dependencies_names_) * proto.dependency_size()); + } } else { result->dependencies_once_ = NULL; result->dependencies_names_ = NULL; @@ -4180,17 +4354,16 @@ const FileDescriptor* DescriptorBuilder::BuildFileImpl( // Recursive import. dependency/result is not fully initialized, and it's // dangerous to try to do anything with it. The recursive import error // will be detected and reported in DescriptorBuilder::BuildFile(). - tables_->RollbackToLastCheckpoint(); return NULL; } if (dependency == NULL) { - if (pool_->allow_unknown_ || - (!pool_->enforce_weak_ && weak_deps.find(i) != weak_deps.end())) { - dependency = - pool_->NewPlaceholderFileWithMutexHeld(proto.dependency(i)); - } else { - if (!pool_->lazily_build_dependencies_) { + if (!pool_->lazily_build_dependencies_) { + if (pool_->allow_unknown_ || + (!pool_->enforce_weak_ && weak_deps.find(i) != weak_deps.end())) { + dependency = + pool_->NewPlaceholderFileWithMutexHeld(proto.dependency(i)); + } else { AddImportError(proto, i); } } @@ -4316,11 +4489,8 @@ const FileDescriptor* DescriptorBuilder::BuildFileImpl( } if (had_errors_) { - tables_->RollbackToLastCheckpoint(); return NULL; } else { - tables_->ClearLastCheckpoint(); - result->finished_building_ = true; return result; } } @@ -4387,7 +4557,7 @@ void DescriptorBuilder::BuildMessage(const DescriptorProto& proto, } } - hash_set<string> reserved_name_set; + HASH_SET<string> reserved_name_set; for (int i = 0; i < proto.reserved_name_size(); i++) { const string& name = proto.reserved_name(i); if (reserved_name_set.find(name) == reserved_name_set.end()) { @@ -4776,6 +4946,13 @@ void DescriptorBuilder::BuildExtensionRange( DescriptorPool::ErrorCollector::NUMBER, "Extension range end number must be greater than start number."); } + + if (!proto.has_options()) { + result->options_ = NULL; // Will set to default_instance later. + } else { + AllocateOptionsImpl(parent->full_name(), parent->full_name(), + proto.options(), result); + } } void DescriptorBuilder::BuildReservedRange( @@ -4791,6 +4968,19 @@ void DescriptorBuilder::BuildReservedRange( } } +void DescriptorBuilder::BuildReservedRange( + const EnumDescriptorProto::EnumReservedRange& proto, + const EnumDescriptor* parent, EnumDescriptor::ReservedRange* result) { + result->start = proto.start(); + result->end = proto.end(); + + if (result->start > result->end) { + AddError(parent->full_name(), proto, + DescriptorPool::ErrorCollector::NUMBER, + "Reserved range end number must be greater than start number."); + } +} + void DescriptorBuilder::BuildOneof(const OneofDescriptorProto& proto, Descriptor* parent, OneofDescriptor* result) { @@ -4912,6 +5102,17 @@ void DescriptorBuilder::BuildEnum(const EnumDescriptorProto& proto, } BUILD_ARRAY(proto, result, value, BuildEnumValue, result); + BUILD_ARRAY(proto, result, reserved_range, BuildReservedRange, result); + + // Copy reserved names. + int reserved_name_count = proto.reserved_name_size(); + result->reserved_name_count_ = reserved_name_count; + result->reserved_names_ = + tables_->AllocateArray<const string*>(reserved_name_count); + for (int i = 0; i < reserved_name_count; ++i) { + result->reserved_names_[i] = + tables_->AllocateString(proto.reserved_name(i)); + } CheckEnumValueUniqueness(proto, result); @@ -4924,6 +5125,56 @@ void DescriptorBuilder::BuildEnum(const EnumDescriptorProto& proto, AddSymbol(result->full_name(), parent, result->name(), proto, Symbol(result)); + + for (int i = 0; i < proto.reserved_range_size(); i++) { + const EnumDescriptorProto_EnumReservedRange& range1 = + proto.reserved_range(i); + for (int j = i + 1; j < proto.reserved_range_size(); j++) { + const EnumDescriptorProto_EnumReservedRange& range2 = + proto.reserved_range(j); + if (range1.end() > range2.start() && range2.end() > range1.start()) { + AddError(result->full_name(), proto.reserved_range(i), + DescriptorPool::ErrorCollector::NUMBER, + strings::Substitute("Reserved range $0 to $1 overlaps with " + "already-defined range $2 to $3.", + range2.start(), range2.end() - 1, + range1.start(), range1.end() - 1)); + } + } + } + + HASH_SET<string> reserved_name_set; + for (int i = 0; i < proto.reserved_name_size(); i++) { + const string& name = proto.reserved_name(i); + if (reserved_name_set.find(name) == reserved_name_set.end()) { + reserved_name_set.insert(name); + } else { + AddError(name, proto, DescriptorPool::ErrorCollector::NAME, + strings::Substitute( + "Enum value \"$0\" is reserved multiple times.", + name)); + } + } + + for (int i = 0; i < result->value_count(); i++) { + const EnumValueDescriptor* value = result->value(i); + for (int j = 0; j < result->reserved_range_count(); j++) { + const EnumDescriptor::ReservedRange* range = result->reserved_range(j); + if (range->start <= value->number() && value->number() <= range->end) { + AddError(value->full_name(), proto.reserved_range(j), + DescriptorPool::ErrorCollector::NUMBER, + strings::Substitute( + "Enum value \"$0\" uses reserved number $1.", + value->name(), value->number())); + } + } + if (reserved_name_set.find(value->name()) != reserved_name_set.end()) { + AddError(value->full_name(), proto.value(i), + DescriptorPool::ErrorCollector::NAME, + strings::Substitute( + "Enum value \"$0\" is reserved.", value->name())); + } + } } void DescriptorBuilder::BuildEnumValue(const EnumValueDescriptorProto& proto, @@ -5100,6 +5351,11 @@ void DescriptorBuilder::CrossLinkMessage( CrossLinkField(&message->extensions_[i], proto.extension(i)); } + for (int i = 0; i < message->extension_range_count(); i++) { + CrossLinkExtensionRange(&message->extension_ranges_[i], + proto.extension_range(i)); + } + // Set up field array for each oneof. // First count the number of fields per oneof. @@ -5162,6 +5418,14 @@ void DescriptorBuilder::CrossLinkMessage( } } +void DescriptorBuilder::CrossLinkExtensionRange( + Descriptor::ExtensionRange* range, + const DescriptorProto::ExtensionRange& proto) { + if (range->options_ == NULL) { + range->options_ = &ExtensionRangeOptions::default_instance(); + } +} + void DescriptorBuilder::CrossLinkField( FieldDescriptor* field, const FieldDescriptorProto& proto) { if (field->options_ == NULL) { @@ -5219,25 +5483,27 @@ void DescriptorBuilder::CrossLinkField( bool expecting_enum = (proto.type() == FieldDescriptorProto::TYPE_ENUM) || proto.has_default_value(); + // In case of weak fields we force building the dependency. We need to know + // if the type exist or not. If it doesnt exist we substitute Empty which + // should only be done if the type can't be found in the generated pool. + // TODO(gerbens) Ideally we should query the database directly to check + // if weak fields exist or not so that we don't need to force building + // weak dependencies. However the name lookup rules for symbols are + // somewhat complicated, so I defer it too another CL. + bool is_weak = !pool_->enforce_weak_ && proto.options().weak(); + bool is_lazy = pool_->lazily_build_dependencies_ && !is_weak; + Symbol type = LookupSymbol(proto.type_name(), field->full_name(), expecting_enum ? DescriptorPool::PLACEHOLDER_ENUM : DescriptorPool::PLACEHOLDER_MESSAGE, - LOOKUP_TYPES, !pool_->lazily_build_dependencies_); - - // If the type is a weak type, we change the type to a google.protobuf.Empty field. - if (type.IsNull() && !pool_->enforce_weak_ && proto.options().weak()) { - type = FindSymbol(kNonLinkedWeakMessageReplacementName); - } + LOOKUP_TYPES, !is_lazy); if (type.IsNull()) { - if (pool_->lazily_build_dependencies_) { + if (is_lazy) { // Save the symbol names for later for lookup, and allocate the once // object needed for the accessors. string name = proto.type_name(); - if (!pool_->enforce_weak_ && proto.options().weak()) { - name = kNonLinkedWeakMessageReplacementName; - } field->type_once_ = tables_->AllocateOnceDynamic(); field->type_name_ = tables_->AllocateString(name); if (proto.has_default_value()) { @@ -5255,10 +5521,17 @@ void DescriptorBuilder::CrossLinkField( } return; } else { - AddNotDefinedError(field->full_name(), proto, - DescriptorPool::ErrorCollector::TYPE, - proto.type_name()); - return; + // If the type is a weak type, we change the type to a google.protobuf.Empty + // field. + if (is_weak) { + type = FindSymbol(kNonLinkedWeakMessageReplacementName); + } + if (type.IsNull()) { + AddNotDefinedError(field->full_name(), proto, + DescriptorPool::ErrorCollector::TYPE, + proto.type_name()); + return; + } } } @@ -5734,6 +6007,8 @@ void DescriptorBuilder::ValidateFieldOptions(FieldDescriptor* field, } } + ValidateJSType(field, proto); + } void DescriptorBuilder::ValidateEnumOptions(EnumDescriptor* enm, @@ -5922,6 +6197,40 @@ void DescriptorBuilder::DetectMapConflicts(const Descriptor* message, } } +void DescriptorBuilder::ValidateJSType(FieldDescriptor* field, + const FieldDescriptorProto& proto) { + FieldOptions::JSType jstype = field->options().jstype(); + // The default is always acceptable. + if (jstype == FieldOptions::JS_NORMAL) { + return; + } + + switch (field->type()) { + // Integral 64-bit types may be represented as JavaScript numbers or + // strings. + case FieldDescriptor::TYPE_UINT64: + case FieldDescriptor::TYPE_INT64: + case FieldDescriptor::TYPE_SINT64: + case FieldDescriptor::TYPE_FIXED64: + case FieldDescriptor::TYPE_SFIXED64: + if (jstype == FieldOptions::JS_STRING || + jstype == FieldOptions::JS_NUMBER) { + return; + } + AddError(field->full_name(), proto, DescriptorPool::ErrorCollector::TYPE, + "Illegal jstype for int64, uint64, sint64, fixed64 " + "or sfixed64 field: " + + FieldOptions_JSType_descriptor()->value(jstype)->name()); + break; + + // No other types permit a jstype option. + default: + AddError(field->full_name(), proto, DescriptorPool::ErrorCollector::TYPE, + "jstype is only allowed on int64, uint64, sint64, fixed64 " + "or sfixed64 fields."); + break; + } +} #undef VALIDATE_OPTIONS_FROM_ARRAY @@ -6663,6 +6972,7 @@ void DescriptorBuilder::LogUnusedDependency(const FileDescriptorProto& proto, annotation_extensions.insert("google.protobuf.FieldOptions"); annotation_extensions.insert("google.protobuf.EnumOptions"); annotation_extensions.insert("google.protobuf.EnumValueOptions"); + annotation_extensions.insert("google.protobuf.EnumValueOptions"); annotation_extensions.insert("google.protobuf.ServiceOptions"); annotation_extensions.insert("google.protobuf.MethodOptions"); annotation_extensions.insert("google.protobuf.StreamOptions"); @@ -6769,13 +7079,6 @@ const EnumValueDescriptor* FieldDescriptor::default_value_enum() const { return default_value_enum_; } -FieldDescriptor::Type FieldDescriptor::type() const { - if (type_once_) { - type_once_->Init(&FieldDescriptor::TypeOnceInit, this); - } - return type_; -} - void FileDescriptor::InternalDependenciesOnceInit() const { GOOGLE_CHECK(finished_building_ == true); for (int i = 0; i < dependency_count(); i++) { diff --git a/src/google/protobuf/descriptor.h b/src/google/protobuf/descriptor.h index 7aea7344..5f5159a8 100644 --- a/src/google/protobuf/descriptor.h +++ b/src/google/protobuf/descriptor.h @@ -99,6 +99,7 @@ class FieldOptions; class OneofOptions; class EnumOptions; class EnumValueOptions; +class ExtensionRangeOptions; class ServiceOptions; class MethodOptions; class FileOptions; @@ -337,8 +338,12 @@ class LIBPROTOBUF_EXPORT Descriptor { // A range of field numbers which are designated for third-party // extensions. struct ExtensionRange { + typedef ExtensionRangeOptions OptionsType; + int start; // inclusive int end; // exclusive + + const ExtensionRangeOptions* options_; }; // The number of extension ranges in this message type. @@ -440,27 +445,30 @@ class LIBPROTOBUF_EXPORT Descriptor { const Descriptor* containing_type_; const MessageOptions* options_; - // True if this is a placeholder for an unknown type. - bool is_placeholder_; - // True if this is a placeholder and the type name wasn't fully-qualified. - bool is_unqualified_placeholder_; + // These arrays are separated from their sizes to minimize padding on 64-bit. + FieldDescriptor* fields_; + OneofDescriptor* oneof_decls_; + Descriptor* nested_types_; + EnumDescriptor* enum_types_; + ExtensionRange* extension_ranges_; + FieldDescriptor* extensions_; + ReservedRange* reserved_ranges_; + const string** reserved_names_; int field_count_; - FieldDescriptor* fields_; int oneof_decl_count_; - OneofDescriptor* oneof_decls_; int nested_type_count_; - Descriptor* nested_types_; int enum_type_count_; - EnumDescriptor* enum_types_; int extension_range_count_; - ExtensionRange* extension_ranges_; int extension_count_; - FieldDescriptor* extensions_; int reserved_range_count_; - ReservedRange* reserved_ranges_; int reserved_name_count_; - const string** reserved_names_; + + // True if this is a placeholder for an unknown type. + bool is_placeholder_; + // True if this is a placeholder and the type name wasn't fully-qualified. + bool is_unqualified_placeholder_; + // IMPORTANT: If you add a new field, make sure to search for all instances // of Allocate<Descriptor>() and AllocateArray<Descriptor>() in descriptor.cc // and update them to initialize the field. @@ -477,6 +485,7 @@ class LIBPROTOBUF_EXPORT Descriptor { GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Descriptor); }; + // Describes a single field of a message. To get the descriptor for a given // field, first get the Descriptor for the message in which it is defined, // then call Descriptor::FindFieldByName(). To get a FieldDescriptor for @@ -732,24 +741,28 @@ class LIBPROTOBUF_EXPORT FieldDescriptor { // to this descriptor from the file root. void GetLocationPath(std::vector<int>* output) const; + // Returns true if this is a map message type. + bool is_map_message_type() const; + const string* name_; const string* full_name_; const string* lowercase_name_; const string* camelcase_name_; - // Whether the user has specified the json_name field option in the .proto - // 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 camelcase_name_. const string* json_name_; const FileDescriptor* file_; - int number_; GoogleOnceDynamic* type_once_; static void TypeOnceInit(const FieldDescriptor* to_init); void InternalTypeOnceInit() const; mutable Type type_; Label label_; + bool has_default_value_; + // Whether the user has specified the json_name field option in the .proto + // file. + bool has_json_name_; bool is_extension_; + int number_; int index_in_oneof_; const Descriptor* containing_type_; const OneofDescriptor* containing_oneof_; @@ -763,7 +776,6 @@ class LIBPROTOBUF_EXPORT FieldDescriptor { // of Allocate<FieldDescriptor>() and AllocateArray<FieldDescriptor>() in // descriptor.cc and update them to initialize the field. - bool has_default_value_; union { int32 default_value_int32_; int64 default_value_int64_; @@ -794,6 +806,7 @@ class LIBPROTOBUF_EXPORT FieldDescriptor { GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FieldDescriptor); }; + // Describes a oneof defined in a message type. class LIBPROTOBUF_EXPORT OneofDescriptor { public: @@ -803,6 +816,8 @@ class LIBPROTOBUF_EXPORT OneofDescriptor { // Index of this oneof within the message's oneof array. int index() const; + // The .proto file in which this oneof was defined. Never NULL. + const FileDescriptor* file() const; // The Descriptor for the message containing this oneof. const Descriptor* containing_type() const; @@ -912,12 +927,42 @@ class LIBPROTOBUF_EXPORT EnumDescriptor { // See Descriptor::DebugStringWithOptions(). string DebugStringWithOptions(const DebugStringOptions& options) const; - // Returns true if this is a placeholder for an unknown enum. This will // only be the case if this descriptor comes from a DescriptorPool // with AllowUnknownDependencies() set. bool is_placeholder() const; + // Reserved fields ------------------------------------------------- + + // A range of reserved field numbers. + struct ReservedRange { + int start; // inclusive + int end; // inclusive + }; + + // The number of reserved ranges in this message type. + int reserved_range_count() const; + // Gets an reserved range by index, where 0 <= index < + // reserved_range_count(). These are returned in the order they were defined + // in the .proto file. + const EnumDescriptor::ReservedRange* reserved_range(int index) const; + + // Returns true if the number is in one of the reserved ranges. + bool IsReservedNumber(int number) const; + + // Returns NULL if no reserved range contains the given number. + const EnumDescriptor::ReservedRange* + FindReservedRangeContainingNumber(int number) const; + + // The number of reserved field names in this message type. + int reserved_name_count() const; + + // Gets a reserved name by index, where 0 <= index < reserved_name_count(). + const string& reserved_name(int index) const; + + // Returns true if the field name is reserved. + bool IsReservedName(const string& name) const; + // Source Location --------------------------------------------------- // Updates |*out_location| to the source location of the complete @@ -964,6 +1009,12 @@ class LIBPROTOBUF_EXPORT EnumDescriptor { int value_count_; EnumValueDescriptor* values_; + + int reserved_range_count_; + int reserved_name_count_; + EnumDescriptor::ReservedRange* reserved_ranges_; + const string** reserved_names_; + // IMPORTANT: If you add a new field, make sure to search for all instances // of Allocate<EnumDescriptor>() and AllocateArray<EnumDescriptor>() in // descriptor.cc and update them to initialize the field. @@ -998,6 +1049,8 @@ class LIBPROTOBUF_EXPORT EnumValueDescriptor { // with C++ scoping rules for enums. const string& full_name() const; + // The .proto file in which this value was defined. Never NULL. + const FileDescriptor* file() const; // The type of this value. Never NULL. const EnumDescriptor* type() const; @@ -1122,8 +1175,8 @@ class LIBPROTOBUF_EXPORT ServiceDescriptor { const string* full_name_; const FileDescriptor* file_; const ServiceOptions* options_; - int method_count_; MethodDescriptor* methods_; + int method_count_; // IMPORTANT: If you add a new field, make sure to search for all instances // of Allocate<ServiceDescriptor>() and AllocateArray<ServiceDescriptor>() in // descriptor.cc and update them to initialize the field. @@ -1136,6 +1189,7 @@ class LIBPROTOBUF_EXPORT ServiceDescriptor { GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ServiceDescriptor); }; + // Describes an individual service method. To obtain a MethodDescriptor given // a service, first get its ServiceDescriptor, then call // ServiceDescriptor::FindMethodByName(). Use DescriptorPool to construct your @@ -1149,6 +1203,8 @@ class LIBPROTOBUF_EXPORT MethodDescriptor { // Index within the service's Descriptor. int index() const; + // The .proto file in which this method was defined. Never NULL. + const FileDescriptor* file() const; // Gets the service to which this method belongs. Never NULL. const ServiceDescriptor* service() const; @@ -1360,36 +1416,39 @@ class LIBPROTOBUF_EXPORT FileDescriptor { const string* name_; const string* package_; const DescriptorPool* pool_; - int dependency_count_; - mutable const FileDescriptor** dependencies_; - const string** dependencies_names_; GoogleOnceDynamic* dependencies_once_; static void DependenciesOnceInit(const FileDescriptor* to_init); void InternalDependenciesOnceInit() const; + + // These are arranged to minimze padding on 64-bit. + int dependency_count_; int public_dependency_count_; - int* public_dependencies_; int weak_dependency_count_; - int* weak_dependencies_; int message_type_count_; - Descriptor* message_types_; int enum_type_count_; - EnumDescriptor* enum_types_; int service_count_; - ServiceDescriptor* services_; int extension_count_; Syntax syntax_; bool is_placeholder_; - FieldDescriptor* extensions_; - const FileOptions* options_; - - const FileDescriptorTables* tables_; - const SourceCodeInfo* source_code_info_; // Indicates the FileDescriptor is completed building. Used to verify // that type accessor functions that can possibly build a dependent file // aren't called during the process of building the file. bool finished_building_; + mutable const FileDescriptor** dependencies_; + const string** dependencies_names_; + int* public_dependencies_; + int* weak_dependencies_; + Descriptor* message_types_; + EnumDescriptor* enum_types_; + ServiceDescriptor* services_; + FieldDescriptor* extensions_; + const FileOptions* options_; + + const FileDescriptorTables* tables_; + const SourceCodeInfo* source_code_info_; + // IMPORTANT: If you add a new field, make sure to search for all instances // of Allocate<FileDescriptor>() and AllocateArray<FileDescriptor>() in // descriptor.cc and update them to initialize the field. @@ -1408,6 +1467,7 @@ class LIBPROTOBUF_EXPORT FileDescriptor { GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FileDescriptor); }; + // =================================================================== // Used to construct descriptors. @@ -1748,12 +1808,13 @@ class LIBPROTOBUF_EXPORT DescriptorPool { bool lazily_build_dependencies_; bool allow_unknown_; bool enforce_weak_; - std::set<string> unused_import_track_files_; bool disallow_enforce_utf8_; + std::set<string> unused_import_track_files_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(DescriptorPool); }; + // inline methods ==================================================== // These macros makes this repetitive code more readable. @@ -1842,6 +1903,10 @@ PROTOBUF_DEFINE_ARRAY_ACCESSOR(EnumDescriptor, value, const EnumValueDescriptor*) PROTOBUF_DEFINE_OPTIONS_ACCESSOR(EnumDescriptor, EnumOptions) PROTOBUF_DEFINE_ACCESSOR(EnumDescriptor, is_placeholder, bool) +PROTOBUF_DEFINE_ACCESSOR(EnumDescriptor, reserved_range_count, int) +PROTOBUF_DEFINE_ARRAY_ACCESSOR(EnumDescriptor, reserved_range, + const EnumDescriptor::ReservedRange*) +PROTOBUF_DEFINE_ACCESSOR(EnumDescriptor, reserved_name_count, int) PROTOBUF_DEFINE_STRING_ACCESSOR(EnumValueDescriptor, name) PROTOBUF_DEFINE_STRING_ACCESSOR(EnumValueDescriptor, full_name) @@ -1913,6 +1978,32 @@ inline const string& Descriptor::reserved_name(int index) const { return *reserved_names_[index]; } +inline bool EnumDescriptor::IsReservedNumber(int number) const { + return FindReservedRangeContainingNumber(number) != NULL; +} + +inline bool EnumDescriptor::IsReservedName(const string& name) const { + for (int i = 0; i < reserved_name_count(); i++) { + if (name == reserved_name(i)) { + return true; + } + } + return false; +} + +// Can't use PROTOBUF_DEFINE_ARRAY_ACCESSOR because reserved_names_ is actually +// an array of pointers rather than the usual array of objects. +inline const string& EnumDescriptor::reserved_name(int index) const { + return *reserved_names_[index]; +} + +inline FieldDescriptor::Type FieldDescriptor::type() const { + if (type_once_) { + type_once_->Init(&FieldDescriptor::TypeOnceInit, this); + } + return type_; +} + inline bool FieldDescriptor::is_required() const { return label() == LABEL_REQUIRED; } @@ -1929,6 +2020,10 @@ inline bool FieldDescriptor::is_packable() const { return is_repeated() && IsTypePackable(type()); } +inline bool FieldDescriptor::is_map() const { + return type() == TYPE_MESSAGE && is_map_message_type(); +} + // To save space, index() is computed by looking at the descriptor's position // in the parent's array of children. inline int FieldDescriptor::index() const { @@ -1949,6 +2044,10 @@ inline int Descriptor::index() const { } } +inline const FileDescriptor* OneofDescriptor::file() const { + return containing_type()->file(); +} + inline int OneofDescriptor::index() const { return static_cast<int>(this - containing_type_->oneof_decls_); } @@ -1961,6 +2060,10 @@ inline int EnumDescriptor::index() const { } } +inline const FileDescriptor* EnumValueDescriptor::file() const { + return type()->file(); +} + inline int EnumValueDescriptor::index() const { return static_cast<int>(this - type_->values_); } @@ -1969,6 +2072,10 @@ inline int ServiceDescriptor::index() const { return static_cast<int>(this - file_->services_); } +inline const FileDescriptor* MethodDescriptor::file() const { + return service()->file(); +} + inline int MethodDescriptor::index() const { return static_cast<int>(this - service_->methods_); } diff --git a/src/google/protobuf/descriptor.pb.cc b/src/google/protobuf/descriptor.pb.cc index ff0819ec..c8362376 100644 --- a/src/google/protobuf/descriptor.pb.cc +++ b/src/google/protobuf/descriptor.pb.cc @@ -1,7 +1,6 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/protobuf/descriptor.proto -#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION #include <google/protobuf/descriptor.pb.h> #include <algorithm> @@ -15,134 +14,781 @@ #include <google/protobuf/generated_message_reflection.h> #include <google/protobuf/reflection_ops.h> #include <google/protobuf/wire_format.h> +// This is a temporary google only hack +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS +#include "third_party/protobuf/version.h" +#endif // @@protoc_insertion_point(includes) - namespace google { namespace protobuf { -class FileDescriptorSetDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<FileDescriptorSet> { +class FileDescriptorSetDefaultTypeInternal { + public: + ::google::protobuf::internal::ExplicitlyConstructed<FileDescriptorSet> + _instance; } _FileDescriptorSet_default_instance_; -class FileDescriptorProtoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<FileDescriptorProto> { +class FileDescriptorProtoDefaultTypeInternal { + public: + ::google::protobuf::internal::ExplicitlyConstructed<FileDescriptorProto> + _instance; } _FileDescriptorProto_default_instance_; -class DescriptorProto_ExtensionRangeDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<DescriptorProto_ExtensionRange> { +class DescriptorProto_ExtensionRangeDefaultTypeInternal { + public: + ::google::protobuf::internal::ExplicitlyConstructed<DescriptorProto_ExtensionRange> + _instance; } _DescriptorProto_ExtensionRange_default_instance_; -class DescriptorProto_ReservedRangeDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<DescriptorProto_ReservedRange> { +class DescriptorProto_ReservedRangeDefaultTypeInternal { + public: + ::google::protobuf::internal::ExplicitlyConstructed<DescriptorProto_ReservedRange> + _instance; } _DescriptorProto_ReservedRange_default_instance_; -class DescriptorProtoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<DescriptorProto> { +class DescriptorProtoDefaultTypeInternal { + public: + ::google::protobuf::internal::ExplicitlyConstructed<DescriptorProto> + _instance; } _DescriptorProto_default_instance_; -class FieldDescriptorProtoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<FieldDescriptorProto> { +class ExtensionRangeOptionsDefaultTypeInternal { + public: + ::google::protobuf::internal::ExplicitlyConstructed<ExtensionRangeOptions> + _instance; +} _ExtensionRangeOptions_default_instance_; +class FieldDescriptorProtoDefaultTypeInternal { + public: + ::google::protobuf::internal::ExplicitlyConstructed<FieldDescriptorProto> + _instance; } _FieldDescriptorProto_default_instance_; -class OneofDescriptorProtoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<OneofDescriptorProto> { +class OneofDescriptorProtoDefaultTypeInternal { + public: + ::google::protobuf::internal::ExplicitlyConstructed<OneofDescriptorProto> + _instance; } _OneofDescriptorProto_default_instance_; -class EnumDescriptorProtoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<EnumDescriptorProto> { +class EnumDescriptorProto_EnumReservedRangeDefaultTypeInternal { + public: + ::google::protobuf::internal::ExplicitlyConstructed<EnumDescriptorProto_EnumReservedRange> + _instance; +} _EnumDescriptorProto_EnumReservedRange_default_instance_; +class EnumDescriptorProtoDefaultTypeInternal { + public: + ::google::protobuf::internal::ExplicitlyConstructed<EnumDescriptorProto> + _instance; } _EnumDescriptorProto_default_instance_; -class EnumValueDescriptorProtoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<EnumValueDescriptorProto> { +class EnumValueDescriptorProtoDefaultTypeInternal { + public: + ::google::protobuf::internal::ExplicitlyConstructed<EnumValueDescriptorProto> + _instance; } _EnumValueDescriptorProto_default_instance_; -class ServiceDescriptorProtoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<ServiceDescriptorProto> { +class ServiceDescriptorProtoDefaultTypeInternal { + public: + ::google::protobuf::internal::ExplicitlyConstructed<ServiceDescriptorProto> + _instance; } _ServiceDescriptorProto_default_instance_; -class MethodDescriptorProtoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<MethodDescriptorProto> { +class MethodDescriptorProtoDefaultTypeInternal { + public: + ::google::protobuf::internal::ExplicitlyConstructed<MethodDescriptorProto> + _instance; } _MethodDescriptorProto_default_instance_; -class FileOptionsDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<FileOptions> { +class FileOptionsDefaultTypeInternal { + public: + ::google::protobuf::internal::ExplicitlyConstructed<FileOptions> + _instance; } _FileOptions_default_instance_; -class MessageOptionsDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<MessageOptions> { +class MessageOptionsDefaultTypeInternal { + public: + ::google::protobuf::internal::ExplicitlyConstructed<MessageOptions> + _instance; } _MessageOptions_default_instance_; -class FieldOptionsDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<FieldOptions> { +class FieldOptionsDefaultTypeInternal { + public: + ::google::protobuf::internal::ExplicitlyConstructed<FieldOptions> + _instance; } _FieldOptions_default_instance_; -class OneofOptionsDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<OneofOptions> { +class OneofOptionsDefaultTypeInternal { + public: + ::google::protobuf::internal::ExplicitlyConstructed<OneofOptions> + _instance; } _OneofOptions_default_instance_; -class EnumOptionsDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<EnumOptions> { +class EnumOptionsDefaultTypeInternal { + public: + ::google::protobuf::internal::ExplicitlyConstructed<EnumOptions> + _instance; } _EnumOptions_default_instance_; -class EnumValueOptionsDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<EnumValueOptions> { +class EnumValueOptionsDefaultTypeInternal { + public: + ::google::protobuf::internal::ExplicitlyConstructed<EnumValueOptions> + _instance; } _EnumValueOptions_default_instance_; -class ServiceOptionsDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<ServiceOptions> { +class ServiceOptionsDefaultTypeInternal { + public: + ::google::protobuf::internal::ExplicitlyConstructed<ServiceOptions> + _instance; } _ServiceOptions_default_instance_; -class MethodOptionsDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<MethodOptions> { +class MethodOptionsDefaultTypeInternal { + public: + ::google::protobuf::internal::ExplicitlyConstructed<MethodOptions> + _instance; } _MethodOptions_default_instance_; -class UninterpretedOption_NamePartDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<UninterpretedOption_NamePart> { +class UninterpretedOption_NamePartDefaultTypeInternal { + public: + ::google::protobuf::internal::ExplicitlyConstructed<UninterpretedOption_NamePart> + _instance; } _UninterpretedOption_NamePart_default_instance_; -class UninterpretedOptionDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<UninterpretedOption> { +class UninterpretedOptionDefaultTypeInternal { + public: + ::google::protobuf::internal::ExplicitlyConstructed<UninterpretedOption> + _instance; } _UninterpretedOption_default_instance_; -class SourceCodeInfo_LocationDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<SourceCodeInfo_Location> { +class SourceCodeInfo_LocationDefaultTypeInternal { + public: + ::google::protobuf::internal::ExplicitlyConstructed<SourceCodeInfo_Location> + _instance; } _SourceCodeInfo_Location_default_instance_; -class SourceCodeInfoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<SourceCodeInfo> { +class SourceCodeInfoDefaultTypeInternal { + public: + ::google::protobuf::internal::ExplicitlyConstructed<SourceCodeInfo> + _instance; } _SourceCodeInfo_default_instance_; -class GeneratedCodeInfo_AnnotationDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<GeneratedCodeInfo_Annotation> { +class GeneratedCodeInfo_AnnotationDefaultTypeInternal { + public: + ::google::protobuf::internal::ExplicitlyConstructed<GeneratedCodeInfo_Annotation> + _instance; } _GeneratedCodeInfo_Annotation_default_instance_; -class GeneratedCodeInfoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<GeneratedCodeInfo> { +class GeneratedCodeInfoDefaultTypeInternal { + public: + ::google::protobuf::internal::ExplicitlyConstructed<GeneratedCodeInfo> + _instance; } _GeneratedCodeInfo_default_instance_; - +} // namespace protobuf +} // namespace google namespace protobuf_google_2fprotobuf_2fdescriptor_2eproto { +void InitDefaultsFileDescriptorSetImpl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); +#else + ::google::protobuf::internal::InitProtobufDefaults(); +#endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsFileDescriptorProto(); + { + void* ptr = &::google::protobuf::_FileDescriptorSet_default_instance_; + new (ptr) ::google::protobuf::FileDescriptorSet(); + ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); + } + ::google::protobuf::FileDescriptorSet::InitAsDefaultInstance(); +} -namespace { +void InitDefaultsFileDescriptorSet() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsFileDescriptorSetImpl); +} -::google::protobuf::Metadata file_level_metadata[25]; -const ::google::protobuf::EnumDescriptor* file_level_enum_descriptors[6]; +void InitDefaultsFileDescriptorProtoImpl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; -} // namespace +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); +#else + ::google::protobuf::internal::InitProtobufDefaults(); +#endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsDescriptorProto(); + protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsEnumDescriptorProto(); + protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsServiceDescriptorProto(); + protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsFieldDescriptorProto(); + protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsFileOptions(); + protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsSourceCodeInfo(); + { + void* ptr = &::google::protobuf::_FileDescriptorProto_default_instance_; + new (ptr) ::google::protobuf::FileDescriptorProto(); + ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); + } + ::google::protobuf::FileDescriptorProto::InitAsDefaultInstance(); +} -PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::ParseTableField - const TableStruct::entries[] = { - {0, 0, 0, ::google::protobuf::internal::kInvalidMask, 0, 0}, -}; +void InitDefaultsFileDescriptorProto() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsFileDescriptorProtoImpl); +} -PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::AuxillaryParseTableField - const TableStruct::aux[] = { - ::google::protobuf::internal::AuxillaryParseTableField(), -}; -PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::ParseTable const - TableStruct::schema[] = { - { NULL, NULL, 0, -1, -1, false }, - { NULL, NULL, 0, -1, -1, false }, - { NULL, NULL, 0, -1, -1, false }, - { NULL, NULL, 0, -1, -1, false }, - { NULL, NULL, 0, -1, -1, false }, - { NULL, NULL, 0, -1, -1, false }, - { NULL, NULL, 0, -1, -1, false }, - { NULL, NULL, 0, -1, -1, false }, - { NULL, NULL, 0, -1, -1, false }, - { NULL, NULL, 0, -1, -1, false }, - { NULL, NULL, 0, -1, -1, false }, - { NULL, NULL, 0, -1, -1, false }, - { NULL, NULL, 0, -1, -1, false }, - { NULL, NULL, 0, -1, -1, false }, - { NULL, NULL, 0, -1, -1, false }, - { NULL, NULL, 0, -1, -1, false }, - { NULL, NULL, 0, -1, -1, false }, - { NULL, NULL, 0, -1, -1, false }, - { NULL, NULL, 0, -1, -1, false }, - { NULL, NULL, 0, -1, -1, false }, - { NULL, NULL, 0, -1, -1, false }, - { NULL, NULL, 0, -1, -1, false }, - { NULL, NULL, 0, -1, -1, false }, - { NULL, NULL, 0, -1, -1, false }, - { NULL, NULL, 0, -1, -1, false }, -}; +void InitDefaultsDescriptorProto_ExtensionRangeImpl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); +#else + ::google::protobuf::internal::InitProtobufDefaults(); +#endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsExtensionRangeOptions(); + { + void* ptr = &::google::protobuf::_DescriptorProto_ExtensionRange_default_instance_; + new (ptr) ::google::protobuf::DescriptorProto_ExtensionRange(); + ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); + } + ::google::protobuf::DescriptorProto_ExtensionRange::InitAsDefaultInstance(); +} + +void InitDefaultsDescriptorProto_ExtensionRange() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsDescriptorProto_ExtensionRangeImpl); +} + +void InitDefaultsDescriptorProto_ReservedRangeImpl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); +#else + ::google::protobuf::internal::InitProtobufDefaults(); +#endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + { + void* ptr = &::google::protobuf::_DescriptorProto_ReservedRange_default_instance_; + new (ptr) ::google::protobuf::DescriptorProto_ReservedRange(); + ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); + } + ::google::protobuf::DescriptorProto_ReservedRange::InitAsDefaultInstance(); +} + +void InitDefaultsDescriptorProto_ReservedRange() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsDescriptorProto_ReservedRangeImpl); +} + +void InitDefaultsDescriptorProtoImpl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); +#else + ::google::protobuf::internal::InitProtobufDefaults(); +#endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsFieldDescriptorProto(); + protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsEnumDescriptorProto(); + protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsDescriptorProto_ExtensionRange(); + protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsOneofDescriptorProto(); + protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsMessageOptions(); + protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsDescriptorProto_ReservedRange(); + { + void* ptr = &::google::protobuf::_DescriptorProto_default_instance_; + new (ptr) ::google::protobuf::DescriptorProto(); + ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); + } + ::google::protobuf::DescriptorProto::InitAsDefaultInstance(); +} + +void InitDefaultsDescriptorProto() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsDescriptorProtoImpl); +} + +void InitDefaultsExtensionRangeOptionsImpl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); +#else + ::google::protobuf::internal::InitProtobufDefaults(); +#endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsUninterpretedOption(); + { + void* ptr = &::google::protobuf::_ExtensionRangeOptions_default_instance_; + new (ptr) ::google::protobuf::ExtensionRangeOptions(); + ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); + } + ::google::protobuf::ExtensionRangeOptions::InitAsDefaultInstance(); +} + +void InitDefaultsExtensionRangeOptions() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsExtensionRangeOptionsImpl); +} + +void InitDefaultsFieldDescriptorProtoImpl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); +#else + ::google::protobuf::internal::InitProtobufDefaults(); +#endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsFieldOptions(); + { + void* ptr = &::google::protobuf::_FieldDescriptorProto_default_instance_; + new (ptr) ::google::protobuf::FieldDescriptorProto(); + ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); + } + ::google::protobuf::FieldDescriptorProto::InitAsDefaultInstance(); +} + +void InitDefaultsFieldDescriptorProto() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsFieldDescriptorProtoImpl); +} + +void InitDefaultsOneofDescriptorProtoImpl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); +#else + ::google::protobuf::internal::InitProtobufDefaults(); +#endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsOneofOptions(); + { + void* ptr = &::google::protobuf::_OneofDescriptorProto_default_instance_; + new (ptr) ::google::protobuf::OneofDescriptorProto(); + ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); + } + ::google::protobuf::OneofDescriptorProto::InitAsDefaultInstance(); +} + +void InitDefaultsOneofDescriptorProto() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsOneofDescriptorProtoImpl); +} + +void InitDefaultsEnumDescriptorProto_EnumReservedRangeImpl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); +#else + ::google::protobuf::internal::InitProtobufDefaults(); +#endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + { + void* ptr = &::google::protobuf::_EnumDescriptorProto_EnumReservedRange_default_instance_; + new (ptr) ::google::protobuf::EnumDescriptorProto_EnumReservedRange(); + ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); + } + ::google::protobuf::EnumDescriptorProto_EnumReservedRange::InitAsDefaultInstance(); +} + +void InitDefaultsEnumDescriptorProto_EnumReservedRange() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsEnumDescriptorProto_EnumReservedRangeImpl); +} + +void InitDefaultsEnumDescriptorProtoImpl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); +#else + ::google::protobuf::internal::InitProtobufDefaults(); +#endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsEnumValueDescriptorProto(); + protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsEnumOptions(); + protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsEnumDescriptorProto_EnumReservedRange(); + { + void* ptr = &::google::protobuf::_EnumDescriptorProto_default_instance_; + new (ptr) ::google::protobuf::EnumDescriptorProto(); + ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); + } + ::google::protobuf::EnumDescriptorProto::InitAsDefaultInstance(); +} + +void InitDefaultsEnumDescriptorProto() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsEnumDescriptorProtoImpl); +} + +void InitDefaultsEnumValueDescriptorProtoImpl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); +#else + ::google::protobuf::internal::InitProtobufDefaults(); +#endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsEnumValueOptions(); + { + void* ptr = &::google::protobuf::_EnumValueDescriptorProto_default_instance_; + new (ptr) ::google::protobuf::EnumValueDescriptorProto(); + ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); + } + ::google::protobuf::EnumValueDescriptorProto::InitAsDefaultInstance(); +} + +void InitDefaultsEnumValueDescriptorProto() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsEnumValueDescriptorProtoImpl); +} + +void InitDefaultsServiceDescriptorProtoImpl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); +#else + ::google::protobuf::internal::InitProtobufDefaults(); +#endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsMethodDescriptorProto(); + protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsServiceOptions(); + { + void* ptr = &::google::protobuf::_ServiceDescriptorProto_default_instance_; + new (ptr) ::google::protobuf::ServiceDescriptorProto(); + ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); + } + ::google::protobuf::ServiceDescriptorProto::InitAsDefaultInstance(); +} + +void InitDefaultsServiceDescriptorProto() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsServiceDescriptorProtoImpl); +} + +void InitDefaultsMethodDescriptorProtoImpl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); +#else + ::google::protobuf::internal::InitProtobufDefaults(); +#endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsMethodOptions(); + { + void* ptr = &::google::protobuf::_MethodDescriptorProto_default_instance_; + new (ptr) ::google::protobuf::MethodDescriptorProto(); + ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); + } + ::google::protobuf::MethodDescriptorProto::InitAsDefaultInstance(); +} + +void InitDefaultsMethodDescriptorProto() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsMethodDescriptorProtoImpl); +} + +void InitDefaultsFileOptionsImpl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); +#else + ::google::protobuf::internal::InitProtobufDefaults(); +#endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsUninterpretedOption(); + { + void* ptr = &::google::protobuf::_FileOptions_default_instance_; + new (ptr) ::google::protobuf::FileOptions(); + ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); + } + ::google::protobuf::FileOptions::InitAsDefaultInstance(); +} + +void InitDefaultsFileOptions() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsFileOptionsImpl); +} + +void InitDefaultsMessageOptionsImpl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); +#else + ::google::protobuf::internal::InitProtobufDefaults(); +#endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsUninterpretedOption(); + { + void* ptr = &::google::protobuf::_MessageOptions_default_instance_; + new (ptr) ::google::protobuf::MessageOptions(); + ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); + } + ::google::protobuf::MessageOptions::InitAsDefaultInstance(); +} + +void InitDefaultsMessageOptions() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsMessageOptionsImpl); +} + +void InitDefaultsFieldOptionsImpl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); +#else + ::google::protobuf::internal::InitProtobufDefaults(); +#endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsUninterpretedOption(); + { + void* ptr = &::google::protobuf::_FieldOptions_default_instance_; + new (ptr) ::google::protobuf::FieldOptions(); + ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); + } + ::google::protobuf::FieldOptions::InitAsDefaultInstance(); +} + +void InitDefaultsFieldOptions() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsFieldOptionsImpl); +} + +void InitDefaultsOneofOptionsImpl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; -const ::google::protobuf::uint32 TableStruct::offsets[] = { - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorSet, _has_bits_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorSet, _internal_metadata_), +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); +#else + ::google::protobuf::internal::InitProtobufDefaults(); +#endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsUninterpretedOption(); + { + void* ptr = &::google::protobuf::_OneofOptions_default_instance_; + new (ptr) ::google::protobuf::OneofOptions(); + ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); + } + ::google::protobuf::OneofOptions::InitAsDefaultInstance(); +} + +void InitDefaultsOneofOptions() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsOneofOptionsImpl); +} + +void InitDefaultsEnumOptionsImpl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); +#else + ::google::protobuf::internal::InitProtobufDefaults(); +#endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsUninterpretedOption(); + { + void* ptr = &::google::protobuf::_EnumOptions_default_instance_; + new (ptr) ::google::protobuf::EnumOptions(); + ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); + } + ::google::protobuf::EnumOptions::InitAsDefaultInstance(); +} + +void InitDefaultsEnumOptions() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsEnumOptionsImpl); +} + +void InitDefaultsEnumValueOptionsImpl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); +#else + ::google::protobuf::internal::InitProtobufDefaults(); +#endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsUninterpretedOption(); + { + void* ptr = &::google::protobuf::_EnumValueOptions_default_instance_; + new (ptr) ::google::protobuf::EnumValueOptions(); + ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); + } + ::google::protobuf::EnumValueOptions::InitAsDefaultInstance(); +} + +void InitDefaultsEnumValueOptions() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsEnumValueOptionsImpl); +} + +void InitDefaultsServiceOptionsImpl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); +#else + ::google::protobuf::internal::InitProtobufDefaults(); +#endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsUninterpretedOption(); + { + void* ptr = &::google::protobuf::_ServiceOptions_default_instance_; + new (ptr) ::google::protobuf::ServiceOptions(); + ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); + } + ::google::protobuf::ServiceOptions::InitAsDefaultInstance(); +} + +void InitDefaultsServiceOptions() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsServiceOptionsImpl); +} + +void InitDefaultsMethodOptionsImpl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); +#else + ::google::protobuf::internal::InitProtobufDefaults(); +#endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsUninterpretedOption(); + { + void* ptr = &::google::protobuf::_MethodOptions_default_instance_; + new (ptr) ::google::protobuf::MethodOptions(); + ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); + } + ::google::protobuf::MethodOptions::InitAsDefaultInstance(); +} + +void InitDefaultsMethodOptions() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsMethodOptionsImpl); +} + +void InitDefaultsUninterpretedOption_NamePartImpl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); +#else + ::google::protobuf::internal::InitProtobufDefaults(); +#endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + { + void* ptr = &::google::protobuf::_UninterpretedOption_NamePart_default_instance_; + new (ptr) ::google::protobuf::UninterpretedOption_NamePart(); + ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); + } + ::google::protobuf::UninterpretedOption_NamePart::InitAsDefaultInstance(); +} + +void InitDefaultsUninterpretedOption_NamePart() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsUninterpretedOption_NamePartImpl); +} + +void InitDefaultsUninterpretedOptionImpl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); +#else + ::google::protobuf::internal::InitProtobufDefaults(); +#endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsUninterpretedOption_NamePart(); + { + void* ptr = &::google::protobuf::_UninterpretedOption_default_instance_; + new (ptr) ::google::protobuf::UninterpretedOption(); + ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); + } + ::google::protobuf::UninterpretedOption::InitAsDefaultInstance(); +} + +void InitDefaultsUninterpretedOption() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsUninterpretedOptionImpl); +} + +void InitDefaultsSourceCodeInfo_LocationImpl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); +#else + ::google::protobuf::internal::InitProtobufDefaults(); +#endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + { + void* ptr = &::google::protobuf::_SourceCodeInfo_Location_default_instance_; + new (ptr) ::google::protobuf::SourceCodeInfo_Location(); + ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); + } + ::google::protobuf::SourceCodeInfo_Location::InitAsDefaultInstance(); +} + +void InitDefaultsSourceCodeInfo_Location() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsSourceCodeInfo_LocationImpl); +} + +void InitDefaultsSourceCodeInfoImpl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); +#else + ::google::protobuf::internal::InitProtobufDefaults(); +#endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsSourceCodeInfo_Location(); + { + void* ptr = &::google::protobuf::_SourceCodeInfo_default_instance_; + new (ptr) ::google::protobuf::SourceCodeInfo(); + ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); + } + ::google::protobuf::SourceCodeInfo::InitAsDefaultInstance(); +} + +void InitDefaultsSourceCodeInfo() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsSourceCodeInfoImpl); +} + +void InitDefaultsGeneratedCodeInfo_AnnotationImpl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); +#else + ::google::protobuf::internal::InitProtobufDefaults(); +#endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + { + void* ptr = &::google::protobuf::_GeneratedCodeInfo_Annotation_default_instance_; + new (ptr) ::google::protobuf::GeneratedCodeInfo_Annotation(); + ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); + } + ::google::protobuf::GeneratedCodeInfo_Annotation::InitAsDefaultInstance(); +} + +void InitDefaultsGeneratedCodeInfo_Annotation() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsGeneratedCodeInfo_AnnotationImpl); +} + +void InitDefaultsGeneratedCodeInfoImpl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); +#else + ::google::protobuf::internal::InitProtobufDefaults(); +#endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsGeneratedCodeInfo_Annotation(); + { + void* ptr = &::google::protobuf::_GeneratedCodeInfo_default_instance_; + new (ptr) ::google::protobuf::GeneratedCodeInfo(); + ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); + } + ::google::protobuf::GeneratedCodeInfo::InitAsDefaultInstance(); +} + +void InitDefaultsGeneratedCodeInfo() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsGeneratedCodeInfoImpl); +} + +::google::protobuf::Metadata file_level_metadata[27]; +const ::google::protobuf::EnumDescriptor* file_level_enum_descriptors[6]; + +const ::google::protobuf::uint32 TableStruct::offsets[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileDescriptorSet, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileDescriptorSet, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorSet, file_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileDescriptorSet, file_), ~0u, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, _has_bits_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileDescriptorProto, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileDescriptorProto, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, name_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, package_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, dependency_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, public_dependency_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, weak_dependency_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, message_type_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, enum_type_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, service_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, extension_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, options_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, source_code_info_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, syntax_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileDescriptorProto, name_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileDescriptorProto, package_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileDescriptorProto, dependency_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileDescriptorProto, public_dependency_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileDescriptorProto, weak_dependency_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileDescriptorProto, message_type_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileDescriptorProto, enum_type_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileDescriptorProto, service_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileDescriptorProto, extension_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileDescriptorProto, options_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileDescriptorProto, source_code_info_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileDescriptorProto, syntax_), 0, 1, ~0u, @@ -155,39 +801,41 @@ const ::google::protobuf::uint32 TableStruct::offsets[] = { 3, 4, 2, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ExtensionRange, _has_bits_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ExtensionRange, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::DescriptorProto_ExtensionRange, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::DescriptorProto_ExtensionRange, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ExtensionRange, start_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ExtensionRange, end_), - 0, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::DescriptorProto_ExtensionRange, start_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::DescriptorProto_ExtensionRange, end_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::DescriptorProto_ExtensionRange, options_), 1, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ReservedRange, _has_bits_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ReservedRange, _internal_metadata_), + 2, + 0, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::DescriptorProto_ReservedRange, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::DescriptorProto_ReservedRange, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ReservedRange, start_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ReservedRange, end_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::DescriptorProto_ReservedRange, start_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::DescriptorProto_ReservedRange, end_), 0, 1, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, _has_bits_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::DescriptorProto, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::DescriptorProto, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, name_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, field_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, extension_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, nested_type_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, enum_type_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, extension_range_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, oneof_decl_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, options_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, reserved_range_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, reserved_name_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::DescriptorProto, name_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::DescriptorProto, field_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::DescriptorProto, extension_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::DescriptorProto, nested_type_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::DescriptorProto, enum_type_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::DescriptorProto, extension_range_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::DescriptorProto, oneof_decl_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::DescriptorProto, options_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::DescriptorProto, reserved_range_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::DescriptorProto, reserved_name_), 0, ~0u, ~0u, @@ -198,21 +846,28 @@ const ::google::protobuf::uint32 TableStruct::offsets[] = { 1, ~0u, ~0u, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, _has_bits_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::ExtensionRangeOptions, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::ExtensionRangeOptions, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::ExtensionRangeOptions, _extensions_), + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::ExtensionRangeOptions, uninterpreted_option_), + ~0u, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FieldDescriptorProto, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FieldDescriptorProto, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, name_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, number_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, label_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, type_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, type_name_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, extendee_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, default_value_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, oneof_index_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, json_name_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, options_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FieldDescriptorProto, name_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FieldDescriptorProto, number_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FieldDescriptorProto, label_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FieldDescriptorProto, type_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FieldDescriptorProto, type_name_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FieldDescriptorProto, extendee_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FieldDescriptorProto, default_value_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FieldDescriptorProto, oneof_index_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FieldDescriptorProto, json_name_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FieldDescriptorProto, options_), 0, 6, 8, @@ -223,133 +878,148 @@ const ::google::protobuf::uint32 TableStruct::offsets[] = { 7, 4, 5, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofDescriptorProto, _has_bits_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofDescriptorProto, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::OneofDescriptorProto, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::OneofDescriptorProto, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::OneofDescriptorProto, name_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::OneofDescriptorProto, options_), + 0, + 1, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::EnumDescriptorProto_EnumReservedRange, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::EnumDescriptorProto_EnumReservedRange, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofDescriptorProto, name_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofDescriptorProto, options_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::EnumDescriptorProto_EnumReservedRange, start_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::EnumDescriptorProto_EnumReservedRange, end_), 0, 1, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumDescriptorProto, _has_bits_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumDescriptorProto, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::EnumDescriptorProto, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::EnumDescriptorProto, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumDescriptorProto, name_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumDescriptorProto, value_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumDescriptorProto, options_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::EnumDescriptorProto, name_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::EnumDescriptorProto, value_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::EnumDescriptorProto, options_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::EnumDescriptorProto, reserved_range_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::EnumDescriptorProto, reserved_name_), 0, ~0u, 1, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueDescriptorProto, _has_bits_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueDescriptorProto, _internal_metadata_), + ~0u, + ~0u, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::EnumValueDescriptorProto, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::EnumValueDescriptorProto, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueDescriptorProto, name_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueDescriptorProto, number_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueDescriptorProto, options_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::EnumValueDescriptorProto, name_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::EnumValueDescriptorProto, number_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::EnumValueDescriptorProto, options_), 0, 2, 1, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceDescriptorProto, _has_bits_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceDescriptorProto, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::ServiceDescriptorProto, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::ServiceDescriptorProto, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceDescriptorProto, name_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceDescriptorProto, method_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceDescriptorProto, options_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::ServiceDescriptorProto, name_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::ServiceDescriptorProto, method_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::ServiceDescriptorProto, options_), 0, ~0u, 1, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, _has_bits_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::MethodDescriptorProto, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::MethodDescriptorProto, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, name_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, input_type_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, output_type_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, options_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, client_streaming_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, server_streaming_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::MethodDescriptorProto, name_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::MethodDescriptorProto, input_type_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::MethodDescriptorProto, output_type_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::MethodDescriptorProto, options_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::MethodDescriptorProto, client_streaming_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::MethodDescriptorProto, server_streaming_), 0, 1, 2, 3, 4, 5, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, _has_bits_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, _internal_metadata_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, _extensions_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileOptions, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileOptions, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileOptions, _extensions_), ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_package_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_outer_classname_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_multiple_files_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_generate_equals_and_hash_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_string_check_utf8_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, optimize_for_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, go_package_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, cc_generic_services_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_generic_services_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, py_generic_services_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, deprecated_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, cc_enable_arenas_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, objc_class_prefix_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, csharp_namespace_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, swift_prefix_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, php_class_prefix_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, php_namespace_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, uninterpreted_option_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileOptions, java_package_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileOptions, java_outer_classname_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileOptions, java_multiple_files_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileOptions, java_generate_equals_and_hash_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileOptions, java_string_check_utf8_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileOptions, optimize_for_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileOptions, go_package_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileOptions, cc_generic_services_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileOptions, java_generic_services_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileOptions, py_generic_services_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileOptions, php_generic_services_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileOptions, deprecated_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileOptions, cc_enable_arenas_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileOptions, objc_class_prefix_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileOptions, csharp_namespace_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileOptions, swift_prefix_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileOptions, php_class_prefix_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileOptions, php_namespace_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileOptions, uninterpreted_option_), 0, 1, - 8, 9, 10, - 16, - 2, 11, + 17, + 2, 12, 13, 14, 15, + 16, + 8, 3, 4, 5, 6, 7, ~0u, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, _has_bits_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, _internal_metadata_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, _extensions_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::MessageOptions, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::MessageOptions, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::MessageOptions, _extensions_), ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, message_set_wire_format_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, no_standard_descriptor_accessor_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, deprecated_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, map_entry_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, uninterpreted_option_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::MessageOptions, message_set_wire_format_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::MessageOptions, no_standard_descriptor_accessor_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::MessageOptions, deprecated_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::MessageOptions, map_entry_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::MessageOptions, uninterpreted_option_), 0, 1, 2, 3, ~0u, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, _has_bits_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, _internal_metadata_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, _extensions_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FieldOptions, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FieldOptions, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FieldOptions, _extensions_), ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, ctype_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, packed_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, jstype_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, lazy_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, deprecated_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, weak_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, uninterpreted_option_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FieldOptions, ctype_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FieldOptions, packed_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FieldOptions, jstype_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FieldOptions, lazy_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FieldOptions, deprecated_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FieldOptions, weak_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FieldOptions, uninterpreted_option_), 0, 1, 5, @@ -357,74 +1027,74 @@ const ::google::protobuf::uint32 TableStruct::offsets[] = { 3, 4, ~0u, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofOptions, _has_bits_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofOptions, _internal_metadata_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofOptions, _extensions_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::OneofOptions, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::OneofOptions, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::OneofOptions, _extensions_), ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofOptions, uninterpreted_option_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::OneofOptions, uninterpreted_option_), ~0u, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumOptions, _has_bits_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumOptions, _internal_metadata_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumOptions, _extensions_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::EnumOptions, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::EnumOptions, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::EnumOptions, _extensions_), ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumOptions, allow_alias_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumOptions, deprecated_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumOptions, uninterpreted_option_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::EnumOptions, allow_alias_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::EnumOptions, deprecated_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::EnumOptions, uninterpreted_option_), 0, 1, ~0u, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueOptions, _has_bits_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueOptions, _internal_metadata_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueOptions, _extensions_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::EnumValueOptions, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::EnumValueOptions, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::EnumValueOptions, _extensions_), ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueOptions, deprecated_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueOptions, uninterpreted_option_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::EnumValueOptions, deprecated_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::EnumValueOptions, uninterpreted_option_), 0, ~0u, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceOptions, _has_bits_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceOptions, _internal_metadata_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceOptions, _extensions_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::ServiceOptions, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::ServiceOptions, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::ServiceOptions, _extensions_), ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceOptions, deprecated_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceOptions, uninterpreted_option_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::ServiceOptions, deprecated_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::ServiceOptions, uninterpreted_option_), 0, ~0u, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodOptions, _has_bits_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodOptions, _internal_metadata_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodOptions, _extensions_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::MethodOptions, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::MethodOptions, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::MethodOptions, _extensions_), ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodOptions, deprecated_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodOptions, idempotency_level_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodOptions, uninterpreted_option_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::MethodOptions, deprecated_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::MethodOptions, idempotency_level_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::MethodOptions, uninterpreted_option_), 0, 1, ~0u, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption_NamePart, _has_bits_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption_NamePart, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::UninterpretedOption_NamePart, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::UninterpretedOption_NamePart, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption_NamePart, name_part_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption_NamePart, is_extension_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::UninterpretedOption_NamePart, name_part_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::UninterpretedOption_NamePart, is_extension_), 0, 1, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, _has_bits_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::UninterpretedOption, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::UninterpretedOption, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, name_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, identifier_value_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, positive_int_value_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, negative_int_value_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, double_value_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, string_value_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, aggregate_value_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::UninterpretedOption, name_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::UninterpretedOption, identifier_value_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::UninterpretedOption, positive_int_value_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::UninterpretedOption, negative_int_value_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::UninterpretedOption, double_value_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::UninterpretedOption, string_value_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::UninterpretedOption, aggregate_value_), ~0u, 0, 3, @@ -432,108 +1102,109 @@ const ::google::protobuf::uint32 TableStruct::offsets[] = { 5, 1, 2, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, _has_bits_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::SourceCodeInfo_Location, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::SourceCodeInfo_Location, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, path_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, span_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, leading_comments_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, trailing_comments_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, leading_detached_comments_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::SourceCodeInfo_Location, path_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::SourceCodeInfo_Location, span_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::SourceCodeInfo_Location, leading_comments_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::SourceCodeInfo_Location, trailing_comments_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::SourceCodeInfo_Location, leading_detached_comments_), ~0u, ~0u, 0, 1, ~0u, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo, _has_bits_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::SourceCodeInfo, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::SourceCodeInfo, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo, location_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::SourceCodeInfo, location_), ~0u, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo_Annotation, _has_bits_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo_Annotation, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::GeneratedCodeInfo_Annotation, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::GeneratedCodeInfo_Annotation, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo_Annotation, path_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo_Annotation, source_file_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo_Annotation, begin_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo_Annotation, end_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::GeneratedCodeInfo_Annotation, path_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::GeneratedCodeInfo_Annotation, source_file_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::GeneratedCodeInfo_Annotation, begin_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::GeneratedCodeInfo_Annotation, end_), ~0u, 0, 1, 2, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo, _has_bits_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::GeneratedCodeInfo, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::GeneratedCodeInfo, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo, annotation_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::GeneratedCodeInfo, annotation_), ~0u, }; - -static const ::google::protobuf::internal::MigrationSchema schemas[] = { - { 0, 6, sizeof(FileDescriptorSet)}, - { 7, 24, sizeof(FileDescriptorProto)}, - { 36, 43, sizeof(DescriptorProto_ExtensionRange)}, - { 45, 52, sizeof(DescriptorProto_ReservedRange)}, - { 54, 69, sizeof(DescriptorProto)}, - { 79, 94, sizeof(FieldDescriptorProto)}, - { 104, 111, sizeof(OneofDescriptorProto)}, - { 113, 121, sizeof(EnumDescriptorProto)}, - { 124, 132, sizeof(EnumValueDescriptorProto)}, - { 135, 143, sizeof(ServiceDescriptorProto)}, - { 146, 157, sizeof(MethodDescriptorProto)}, - { 163, 186, sizeof(FileOptions)}, - { 204, 214, sizeof(MessageOptions)}, - { 219, 231, sizeof(FieldOptions)}, - { 238, 244, sizeof(OneofOptions)}, - { 245, 253, sizeof(EnumOptions)}, - { 256, 263, sizeof(EnumValueOptions)}, - { 265, 272, sizeof(ServiceOptions)}, - { 274, 282, sizeof(MethodOptions)}, - { 285, 292, sizeof(UninterpretedOption_NamePart)}, - { 294, 306, sizeof(UninterpretedOption)}, - { 313, 323, sizeof(SourceCodeInfo_Location)}, - { 328, 334, sizeof(SourceCodeInfo)}, - { 335, 344, sizeof(GeneratedCodeInfo_Annotation)}, - { 348, 354, sizeof(GeneratedCodeInfo)}, +static const ::google::protobuf::internal::MigrationSchema schemas[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { + { 0, 6, sizeof(::google::protobuf::FileDescriptorSet)}, + { 7, 24, sizeof(::google::protobuf::FileDescriptorProto)}, + { 36, 44, sizeof(::google::protobuf::DescriptorProto_ExtensionRange)}, + { 47, 54, sizeof(::google::protobuf::DescriptorProto_ReservedRange)}, + { 56, 71, sizeof(::google::protobuf::DescriptorProto)}, + { 81, 87, sizeof(::google::protobuf::ExtensionRangeOptions)}, + { 88, 103, sizeof(::google::protobuf::FieldDescriptorProto)}, + { 113, 120, sizeof(::google::protobuf::OneofDescriptorProto)}, + { 122, 129, sizeof(::google::protobuf::EnumDescriptorProto_EnumReservedRange)}, + { 131, 141, sizeof(::google::protobuf::EnumDescriptorProto)}, + { 146, 154, sizeof(::google::protobuf::EnumValueDescriptorProto)}, + { 157, 165, sizeof(::google::protobuf::ServiceDescriptorProto)}, + { 168, 179, sizeof(::google::protobuf::MethodDescriptorProto)}, + { 185, 209, sizeof(::google::protobuf::FileOptions)}, + { 228, 238, sizeof(::google::protobuf::MessageOptions)}, + { 243, 255, sizeof(::google::protobuf::FieldOptions)}, + { 262, 268, sizeof(::google::protobuf::OneofOptions)}, + { 269, 277, sizeof(::google::protobuf::EnumOptions)}, + { 280, 287, sizeof(::google::protobuf::EnumValueOptions)}, + { 289, 296, sizeof(::google::protobuf::ServiceOptions)}, + { 298, 306, sizeof(::google::protobuf::MethodOptions)}, + { 309, 316, sizeof(::google::protobuf::UninterpretedOption_NamePart)}, + { 318, 330, sizeof(::google::protobuf::UninterpretedOption)}, + { 337, 347, sizeof(::google::protobuf::SourceCodeInfo_Location)}, + { 352, 358, sizeof(::google::protobuf::SourceCodeInfo)}, + { 359, 368, sizeof(::google::protobuf::GeneratedCodeInfo_Annotation)}, + { 372, 378, sizeof(::google::protobuf::GeneratedCodeInfo)}, }; static ::google::protobuf::Message const * const file_default_instances[] = { - reinterpret_cast<const ::google::protobuf::Message*>(&_FileDescriptorSet_default_instance_), - reinterpret_cast<const ::google::protobuf::Message*>(&_FileDescriptorProto_default_instance_), - reinterpret_cast<const ::google::protobuf::Message*>(&_DescriptorProto_ExtensionRange_default_instance_), - reinterpret_cast<const ::google::protobuf::Message*>(&_DescriptorProto_ReservedRange_default_instance_), - reinterpret_cast<const ::google::protobuf::Message*>(&_DescriptorProto_default_instance_), - reinterpret_cast<const ::google::protobuf::Message*>(&_FieldDescriptorProto_default_instance_), - reinterpret_cast<const ::google::protobuf::Message*>(&_OneofDescriptorProto_default_instance_), - reinterpret_cast<const ::google::protobuf::Message*>(&_EnumDescriptorProto_default_instance_), - reinterpret_cast<const ::google::protobuf::Message*>(&_EnumValueDescriptorProto_default_instance_), - reinterpret_cast<const ::google::protobuf::Message*>(&_ServiceDescriptorProto_default_instance_), - reinterpret_cast<const ::google::protobuf::Message*>(&_MethodDescriptorProto_default_instance_), - reinterpret_cast<const ::google::protobuf::Message*>(&_FileOptions_default_instance_), - reinterpret_cast<const ::google::protobuf::Message*>(&_MessageOptions_default_instance_), - reinterpret_cast<const ::google::protobuf::Message*>(&_FieldOptions_default_instance_), - reinterpret_cast<const ::google::protobuf::Message*>(&_OneofOptions_default_instance_), - reinterpret_cast<const ::google::protobuf::Message*>(&_EnumOptions_default_instance_), - reinterpret_cast<const ::google::protobuf::Message*>(&_EnumValueOptions_default_instance_), - reinterpret_cast<const ::google::protobuf::Message*>(&_ServiceOptions_default_instance_), - reinterpret_cast<const ::google::protobuf::Message*>(&_MethodOptions_default_instance_), - reinterpret_cast<const ::google::protobuf::Message*>(&_UninterpretedOption_NamePart_default_instance_), - reinterpret_cast<const ::google::protobuf::Message*>(&_UninterpretedOption_default_instance_), - reinterpret_cast<const ::google::protobuf::Message*>(&_SourceCodeInfo_Location_default_instance_), - reinterpret_cast<const ::google::protobuf::Message*>(&_SourceCodeInfo_default_instance_), - reinterpret_cast<const ::google::protobuf::Message*>(&_GeneratedCodeInfo_Annotation_default_instance_), - reinterpret_cast<const ::google::protobuf::Message*>(&_GeneratedCodeInfo_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_FileDescriptorSet_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_FileDescriptorProto_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_DescriptorProto_ExtensionRange_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_DescriptorProto_ReservedRange_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_DescriptorProto_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_ExtensionRangeOptions_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_FieldDescriptorProto_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_OneofDescriptorProto_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_EnumDescriptorProto_EnumReservedRange_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_EnumDescriptorProto_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_EnumValueDescriptorProto_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_ServiceDescriptorProto_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_MethodDescriptorProto_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_FileOptions_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_MessageOptions_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_FieldOptions_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_OneofOptions_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_EnumOptions_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_EnumValueOptions_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_ServiceOptions_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_MethodOptions_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_UninterpretedOption_NamePart_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_UninterpretedOption_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_SourceCodeInfo_Location_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_SourceCodeInfo_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_GeneratedCodeInfo_Annotation_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_GeneratedCodeInfo_default_instance_), }; -namespace { - void protobuf_AssignDescriptors() { AddDescriptors(); ::google::protobuf::MessageFactory* factory = NULL; @@ -547,123 +1218,15 @@ void protobuf_AssignDescriptorsOnce() { ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors); } -void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; +void protobuf_RegisterTypes(const ::std::string&) GOOGLE_PROTOBUF_ATTRIBUTE_COLD; void protobuf_RegisterTypes(const ::std::string&) { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 25); -} - -} // namespace - -void TableStruct::Shutdown() { - _FileDescriptorSet_default_instance_.Shutdown(); - delete file_level_metadata[0].reflection; - _FileDescriptorProto_default_instance_.Shutdown(); - delete file_level_metadata[1].reflection; - _DescriptorProto_ExtensionRange_default_instance_.Shutdown(); - delete file_level_metadata[2].reflection; - _DescriptorProto_ReservedRange_default_instance_.Shutdown(); - delete file_level_metadata[3].reflection; - _DescriptorProto_default_instance_.Shutdown(); - delete file_level_metadata[4].reflection; - _FieldDescriptorProto_default_instance_.Shutdown(); - delete file_level_metadata[5].reflection; - _OneofDescriptorProto_default_instance_.Shutdown(); - delete file_level_metadata[6].reflection; - _EnumDescriptorProto_default_instance_.Shutdown(); - delete file_level_metadata[7].reflection; - _EnumValueDescriptorProto_default_instance_.Shutdown(); - delete file_level_metadata[8].reflection; - _ServiceDescriptorProto_default_instance_.Shutdown(); - delete file_level_metadata[9].reflection; - _MethodDescriptorProto_default_instance_.Shutdown(); - delete file_level_metadata[10].reflection; - _FileOptions_default_instance_.Shutdown(); - delete file_level_metadata[11].reflection; - _MessageOptions_default_instance_.Shutdown(); - delete file_level_metadata[12].reflection; - _FieldOptions_default_instance_.Shutdown(); - delete file_level_metadata[13].reflection; - _OneofOptions_default_instance_.Shutdown(); - delete file_level_metadata[14].reflection; - _EnumOptions_default_instance_.Shutdown(); - delete file_level_metadata[15].reflection; - _EnumValueOptions_default_instance_.Shutdown(); - delete file_level_metadata[16].reflection; - _ServiceOptions_default_instance_.Shutdown(); - delete file_level_metadata[17].reflection; - _MethodOptions_default_instance_.Shutdown(); - delete file_level_metadata[18].reflection; - _UninterpretedOption_NamePart_default_instance_.Shutdown(); - delete file_level_metadata[19].reflection; - _UninterpretedOption_default_instance_.Shutdown(); - delete file_level_metadata[20].reflection; - _SourceCodeInfo_Location_default_instance_.Shutdown(); - delete file_level_metadata[21].reflection; - _SourceCodeInfo_default_instance_.Shutdown(); - delete file_level_metadata[22].reflection; - _GeneratedCodeInfo_Annotation_default_instance_.Shutdown(); - delete file_level_metadata[23].reflection; - _GeneratedCodeInfo_default_instance_.Shutdown(); - delete file_level_metadata[24].reflection; -} - -void TableStruct::InitDefaultsImpl() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - ::google::protobuf::internal::InitProtobufDefaults(); - _FileDescriptorSet_default_instance_.DefaultConstruct(); - _FileDescriptorProto_default_instance_.DefaultConstruct(); - _DescriptorProto_ExtensionRange_default_instance_.DefaultConstruct(); - _DescriptorProto_ReservedRange_default_instance_.DefaultConstruct(); - _DescriptorProto_default_instance_.DefaultConstruct(); - _FieldDescriptorProto_default_instance_.DefaultConstruct(); - _OneofDescriptorProto_default_instance_.DefaultConstruct(); - _EnumDescriptorProto_default_instance_.DefaultConstruct(); - _EnumValueDescriptorProto_default_instance_.DefaultConstruct(); - _ServiceDescriptorProto_default_instance_.DefaultConstruct(); - _MethodDescriptorProto_default_instance_.DefaultConstruct(); - _FileOptions_default_instance_.DefaultConstruct(); - _MessageOptions_default_instance_.DefaultConstruct(); - _FieldOptions_default_instance_.DefaultConstruct(); - _OneofOptions_default_instance_.DefaultConstruct(); - _EnumOptions_default_instance_.DefaultConstruct(); - _EnumValueOptions_default_instance_.DefaultConstruct(); - _ServiceOptions_default_instance_.DefaultConstruct(); - _MethodOptions_default_instance_.DefaultConstruct(); - _UninterpretedOption_NamePart_default_instance_.DefaultConstruct(); - _UninterpretedOption_default_instance_.DefaultConstruct(); - _SourceCodeInfo_Location_default_instance_.DefaultConstruct(); - _SourceCodeInfo_default_instance_.DefaultConstruct(); - _GeneratedCodeInfo_Annotation_default_instance_.DefaultConstruct(); - _GeneratedCodeInfo_default_instance_.DefaultConstruct(); - _FileDescriptorProto_default_instance_.get_mutable()->options_ = const_cast< ::google::protobuf::FileOptions*>( - ::google::protobuf::FileOptions::internal_default_instance()); - _FileDescriptorProto_default_instance_.get_mutable()->source_code_info_ = const_cast< ::google::protobuf::SourceCodeInfo*>( - ::google::protobuf::SourceCodeInfo::internal_default_instance()); - _DescriptorProto_default_instance_.get_mutable()->options_ = const_cast< ::google::protobuf::MessageOptions*>( - ::google::protobuf::MessageOptions::internal_default_instance()); - _FieldDescriptorProto_default_instance_.get_mutable()->options_ = const_cast< ::google::protobuf::FieldOptions*>( - ::google::protobuf::FieldOptions::internal_default_instance()); - _OneofDescriptorProto_default_instance_.get_mutable()->options_ = const_cast< ::google::protobuf::OneofOptions*>( - ::google::protobuf::OneofOptions::internal_default_instance()); - _EnumDescriptorProto_default_instance_.get_mutable()->options_ = const_cast< ::google::protobuf::EnumOptions*>( - ::google::protobuf::EnumOptions::internal_default_instance()); - _EnumValueDescriptorProto_default_instance_.get_mutable()->options_ = const_cast< ::google::protobuf::EnumValueOptions*>( - ::google::protobuf::EnumValueOptions::internal_default_instance()); - _ServiceDescriptorProto_default_instance_.get_mutable()->options_ = const_cast< ::google::protobuf::ServiceOptions*>( - ::google::protobuf::ServiceOptions::internal_default_instance()); - _MethodDescriptorProto_default_instance_.get_mutable()->options_ = const_cast< ::google::protobuf::MethodOptions*>( - ::google::protobuf::MethodOptions::internal_default_instance()); + ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 27); } -void InitDefaults() { - static GOOGLE_PROTOBUF_DECLARE_ONCE(once); - ::google::protobuf::GoogleOnceInit(&once, &TableStruct::InitDefaultsImpl); -} void AddDescriptorsImpl() { InitDefaults(); - static const char descriptor[] = { + static const char descriptor[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { "\n google/protobuf/descriptor.proto\022\017goog" "le.protobuf\"G\n\021FileDescriptorSet\0222\n\004file" "\030\001 \003(\0132$.google.protobuf.FileDescriptorP" @@ -679,7 +1242,7 @@ void AddDescriptorsImpl() { "\022-\n\007options\030\010 \001(\0132\034.google.protobuf.File" "Options\0229\n\020source_code_info\030\t \001(\0132\037.goog" "le.protobuf.SourceCodeInfo\022\016\n\006syntax\030\014 \001" - "(\t\"\360\004\n\017DescriptorProto\022\014\n\004name\030\001 \001(\t\0224\n\005" + "(\t\"\251\005\n\017DescriptorProto\022\014\n\004name\030\001 \001(\t\0224\n\005" "field\030\002 \003(\0132%.google.protobuf.FieldDescr" "iptorProto\0228\n\textension\030\006 \003(\0132%.google.p" "rotobuf.FieldDescriptorProto\0225\n\013nested_t" @@ -692,140 +1255,148 @@ void AddDescriptorsImpl() { "ions\030\007 \001(\0132\037.google.protobuf.MessageOpti" "ons\022F\n\016reserved_range\030\t \003(\0132..google.pro" "tobuf.DescriptorProto.ReservedRange\022\025\n\rr" - "eserved_name\030\n \003(\t\032,\n\016ExtensionRange\022\r\n\005" - "start\030\001 \001(\005\022\013\n\003end\030\002 \001(\005\032+\n\rReservedRang" - "e\022\r\n\005start\030\001 \001(\005\022\013\n\003end\030\002 \001(\005\"\274\005\n\024FieldD" - "escriptorProto\022\014\n\004name\030\001 \001(\t\022\016\n\006number\030\003" - " \001(\005\022:\n\005label\030\004 \001(\0162+.google.protobuf.Fi" - "eldDescriptorProto.Label\0228\n\004type\030\005 \001(\0162*" - ".google.protobuf.FieldDescriptorProto.Ty" - "pe\022\021\n\ttype_name\030\006 \001(\t\022\020\n\010extendee\030\002 \001(\t\022" - "\025\n\rdefault_value\030\007 \001(\t\022\023\n\013oneof_index\030\t " - "\001(\005\022\021\n\tjson_name\030\n \001(\t\022.\n\007options\030\010 \001(\0132" - "\035.google.protobuf.FieldOptions\"\266\002\n\004Type\022" - "\017\n\013TYPE_DOUBLE\020\001\022\016\n\nTYPE_FLOAT\020\002\022\016\n\nTYPE" - "_INT64\020\003\022\017\n\013TYPE_UINT64\020\004\022\016\n\nTYPE_INT32\020" - "\005\022\020\n\014TYPE_FIXED64\020\006\022\020\n\014TYPE_FIXED32\020\007\022\r\n" - "\tTYPE_BOOL\020\010\022\017\n\013TYPE_STRING\020\t\022\016\n\nTYPE_GR" - "OUP\020\n\022\020\n\014TYPE_MESSAGE\020\013\022\016\n\nTYPE_BYTES\020\014\022" - "\017\n\013TYPE_UINT32\020\r\022\r\n\tTYPE_ENUM\020\016\022\021\n\rTYPE_" - "SFIXED32\020\017\022\021\n\rTYPE_SFIXED64\020\020\022\017\n\013TYPE_SI" - "NT32\020\021\022\017\n\013TYPE_SINT64\020\022\"C\n\005Label\022\022\n\016LABE" - "L_OPTIONAL\020\001\022\022\n\016LABEL_REQUIRED\020\002\022\022\n\016LABE" - "L_REPEATED\020\003\"T\n\024OneofDescriptorProto\022\014\n\004" - "name\030\001 \001(\t\022.\n\007options\030\002 \001(\0132\035.google.pro" - "tobuf.OneofOptions\"\214\001\n\023EnumDescriptorPro" - "to\022\014\n\004name\030\001 \001(\t\0228\n\005value\030\002 \003(\0132).google" - ".protobuf.EnumValueDescriptorProto\022-\n\007op" - "tions\030\003 \001(\0132\034.google.protobuf.EnumOption" - "s\"l\n\030EnumValueDescriptorProto\022\014\n\004name\030\001 " - "\001(\t\022\016\n\006number\030\002 \001(\005\0222\n\007options\030\003 \001(\0132!.g" - "oogle.protobuf.EnumValueOptions\"\220\001\n\026Serv" - "iceDescriptorProto\022\014\n\004name\030\001 \001(\t\0226\n\006meth" - "od\030\002 \003(\0132&.google.protobuf.MethodDescrip" - "torProto\0220\n\007options\030\003 \001(\0132\037.google.proto" - "buf.ServiceOptions\"\301\001\n\025MethodDescriptorP" - "roto\022\014\n\004name\030\001 \001(\t\022\022\n\ninput_type\030\002 \001(\t\022\023" - "\n\013output_type\030\003 \001(\t\022/\n\007options\030\004 \001(\0132\036.g" - "oogle.protobuf.MethodOptions\022\037\n\020client_s" - "treaming\030\005 \001(\010:\005false\022\037\n\020server_streamin" - "g\030\006 \001(\010:\005false\"\313\005\n\013FileOptions\022\024\n\014java_p" - "ackage\030\001 \001(\t\022\034\n\024java_outer_classname\030\010 \001" - "(\t\022\"\n\023java_multiple_files\030\n \001(\010:\005false\022)" - "\n\035java_generate_equals_and_hash\030\024 \001(\010B\002\030" - "\001\022%\n\026java_string_check_utf8\030\033 \001(\010:\005false" - "\022F\n\014optimize_for\030\t \001(\0162).google.protobuf" - ".FileOptions.OptimizeMode:\005SPEED\022\022\n\ngo_p" - "ackage\030\013 \001(\t\022\"\n\023cc_generic_services\030\020 \001(" - "\010:\005false\022$\n\025java_generic_services\030\021 \001(\010:" - "\005false\022\"\n\023py_generic_services\030\022 \001(\010:\005fal" - "se\022\031\n\ndeprecated\030\027 \001(\010:\005false\022\037\n\020cc_enab" - "le_arenas\030\037 \001(\010:\005false\022\031\n\021objc_class_pre" - "fix\030$ \001(\t\022\030\n\020csharp_namespace\030% \001(\t\022\024\n\014s" - "wift_prefix\030\' \001(\t\022\030\n\020php_class_prefix\030( " - "\001(\t\022\025\n\rphp_namespace\030) \001(\t\022C\n\024uninterpre" - "ted_option\030\347\007 \003(\0132$.google.protobuf.Unin" - "terpretedOption\":\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\'\"\362\001\n\016MessageOptions\022&\n\027messa" - "ge_set_wire_format\030\001 \001(\010:\005false\022.\n\037no_st" - "andard_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_option\030\347\007 \003(\0132$.g" - "oogle.protobuf.UninterpretedOption*\t\010\350\007\020" - "\200\200\200\200\002J\004\010\010\020\tJ\004\010\t\020\n\"\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" - "Type:\tJS_NORMAL\022\023\n\004lazy\030\005 \001(\010:\005false\022\031\n\n" - "deprecated\030\003 \001(\010:\005false\022\023\n\004weak\030\n \001(\010:\005f" - "alse\022C\n\024uninterpreted_option\030\347\007 \003(\0132$.go" - "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\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\"\223\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\002J\004\010\005\020\006" - "\"}\n\020EnumValueOptions\022\031\n\ndeprecated\030\001 \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\"{\n\016ServiceOptions\022\031\n\ndeprecated\030" - "! \001(\010:\005false\022C\n\024uninterpreted_option\030\347\007 " - "\003(\0132$.google.protobuf.UninterpretedOptio" - "n*\t\010\350\007\020\200\200\200\200\002\"\255\002\n\rMethodOptions\022\031\n\ndeprec" - "ated\030! \001(\010:\005false\022_\n\021idempotency_level\030\"" - " \001(\0162/.google.protobuf.MethodOptions.Ide" - "mpotencyLevel:\023IDEMPOTENCY_UNKNOWN\022C\n\024un" - "interpreted_option\030\347\007 \003(\0132$.google.proto" - "buf.UninterpretedOption\"P\n\020IdempotencyLe" - "vel\022\027\n\023IDEMPOTENCY_UNKNOWN\020\000\022\023\n\017NO_SIDE_" - "EFFECTS\020\001\022\016\n\nIDEMPOTENT\020\002*\t\010\350\007\020\200\200\200\200\002\"\236\002\n" - "\023UninterpretedOption\022;\n\004name\030\002 \003(\0132-.goo" - "gle.protobuf.UninterpretedOption.NamePar" - "t\022\030\n\020identifier_value\030\003 \001(\t\022\032\n\022positive_" - "int_value\030\004 \001(\004\022\032\n\022negative_int_value\030\005 " - "\001(\003\022\024\n\014double_value\030\006 \001(\001\022\024\n\014string_valu" - "e\030\007 \001(\014\022\027\n\017aggregate_value\030\010 \001(\t\0323\n\010Name" - "Part\022\021\n\tname_part\030\001 \002(\t\022\024\n\014is_extension\030" - "\002 \002(\010\"\325\001\n\016SourceCodeInfo\022:\n\010location\030\001 \003" - "(\0132(.google.protobuf.SourceCodeInfo.Loca" - "tion\032\206\001\n\010Location\022\020\n\004path\030\001 \003(\005B\002\020\001\022\020\n\004s" - "pan\030\002 \003(\005B\002\020\001\022\030\n\020leading_comments\030\003 \001(\t\022" - "\031\n\021trailing_comments\030\004 \001(\t\022!\n\031leading_de" - "tached_comments\030\006 \003(\t\"\247\001\n\021GeneratedCodeI" - "nfo\022A\n\nannotation\030\001 \003(\0132-.google.protobu" - "f.GeneratedCodeInfo.Annotation\032O\n\nAnnota" - "tion\022\020\n\004path\030\001 \003(\005B\002\020\001\022\023\n\013source_file\030\002 " - "\001(\t\022\r\n\005begin\030\003 \001(\005\022\013\n\003end\030\004 \001(\005B\214\001\n\023com." - "google.protobufB\020DescriptorProtosH\001Z>git" - "hub.com/golang/protobuf/protoc-gen-go/de" - "scriptor;descriptor\242\002\003GPB\252\002\032Google.Proto" - "buf.Reflection" + "eserved_name\030\n \003(\t\032e\n\016ExtensionRange\022\r\n\005" + "start\030\001 \001(\005\022\013\n\003end\030\002 \001(\005\0227\n\007options\030\003 \001(" + "\0132&.google.protobuf.ExtensionRangeOption" + "s\032+\n\rReservedRange\022\r\n\005start\030\001 \001(\005\022\013\n\003end" + "\030\002 \001(\005\"g\n\025ExtensionRangeOptions\022C\n\024unint" + "erpreted_option\030\347\007 \003(\0132$.google.protobuf" + ".UninterpretedOption*\t\010\350\007\020\200\200\200\200\002\"\274\005\n\024Fiel" + "dDescriptorProto\022\014\n\004name\030\001 \001(\t\022\016\n\006number" + "\030\003 \001(\005\022:\n\005label\030\004 \001(\0162+.google.protobuf." + "FieldDescriptorProto.Label\0228\n\004type\030\005 \001(\016" + "2*.google.protobuf.FieldDescriptorProto." + "Type\022\021\n\ttype_name\030\006 \001(\t\022\020\n\010extendee\030\002 \001(" + "\t\022\025\n\rdefault_value\030\007 \001(\t\022\023\n\013oneof_index\030" + "\t \001(\005\022\021\n\tjson_name\030\n \001(\t\022.\n\007options\030\010 \001(" + "\0132\035.google.protobuf.FieldOptions\"\266\002\n\004Typ" + "e\022\017\n\013TYPE_DOUBLE\020\001\022\016\n\nTYPE_FLOAT\020\002\022\016\n\nTY" + "PE_INT64\020\003\022\017\n\013TYPE_UINT64\020\004\022\016\n\nTYPE_INT3" + "2\020\005\022\020\n\014TYPE_FIXED64\020\006\022\020\n\014TYPE_FIXED32\020\007\022" + "\r\n\tTYPE_BOOL\020\010\022\017\n\013TYPE_STRING\020\t\022\016\n\nTYPE_" + "GROUP\020\n\022\020\n\014TYPE_MESSAGE\020\013\022\016\n\nTYPE_BYTES\020" + "\014\022\017\n\013TYPE_UINT32\020\r\022\r\n\tTYPE_ENUM\020\016\022\021\n\rTYP" + "E_SFIXED32\020\017\022\021\n\rTYPE_SFIXED64\020\020\022\017\n\013TYPE_" + "SINT32\020\021\022\017\n\013TYPE_SINT64\020\022\"C\n\005Label\022\022\n\016LA" + "BEL_OPTIONAL\020\001\022\022\n\016LABEL_REQUIRED\020\002\022\022\n\016LA" + "BEL_REPEATED\020\003\"T\n\024OneofDescriptorProto\022\014" + "\n\004name\030\001 \001(\t\022.\n\007options\030\002 \001(\0132\035.google.p" + "rotobuf.OneofOptions\"\244\002\n\023EnumDescriptorP" + "roto\022\014\n\004name\030\001 \001(\t\0228\n\005value\030\002 \003(\0132).goog" + "le.protobuf.EnumValueDescriptorProto\022-\n\007" + "options\030\003 \001(\0132\034.google.protobuf.EnumOpti" + "ons\022N\n\016reserved_range\030\004 \003(\01326.google.pro" + "tobuf.EnumDescriptorProto.EnumReservedRa" + "nge\022\025\n\rreserved_name\030\005 \003(\t\032/\n\021EnumReserv" + "edRange\022\r\n\005start\030\001 \001(\005\022\013\n\003end\030\002 \001(\005\"l\n\030E" + "numValueDescriptorProto\022\014\n\004name\030\001 \001(\t\022\016\n" + "\006number\030\002 \001(\005\0222\n\007options\030\003 \001(\0132!.google." + "protobuf.EnumValueOptions\"\220\001\n\026ServiceDes" + "criptorProto\022\014\n\004name\030\001 \001(\t\0226\n\006method\030\002 \003" + "(\0132&.google.protobuf.MethodDescriptorPro" + "to\0220\n\007options\030\003 \001(\0132\037.google.protobuf.Se" + "rviceOptions\"\301\001\n\025MethodDescriptorProto\022\014" + "\n\004name\030\001 \001(\t\022\022\n\ninput_type\030\002 \001(\t\022\023\n\013outp" + "ut_type\030\003 \001(\t\022/\n\007options\030\004 \001(\0132\036.google." + "protobuf.MethodOptions\022\037\n\020client_streami" + "ng\030\005 \001(\010:\005false\022\037\n\020server_streaming\030\006 \001(" + "\010:\005false\"\360\005\n\013FileOptions\022\024\n\014java_package" + "\030\001 \001(\t\022\034\n\024java_outer_classname\030\010 \001(\t\022\"\n\023" + "java_multiple_files\030\n \001(\010:\005false\022)\n\035java" + "_generate_equals_and_hash\030\024 \001(\010B\002\030\001\022%\n\026j" + "ava_string_check_utf8\030\033 \001(\010:\005false\022F\n\014op" + "timize_for\030\t \001(\0162).google.protobuf.FileO" + "ptions.OptimizeMode:\005SPEED\022\022\n\ngo_package" + "\030\013 \001(\t\022\"\n\023cc_generic_services\030\020 \001(\010:\005fal" + "se\022$\n\025java_generic_services\030\021 \001(\010:\005false" + "\022\"\n\023py_generic_services\030\022 \001(\010:\005false\022#\n\024" + "php_generic_services\030* \001(\010:\005false\022\031\n\ndep" + "recated\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\022\024\n\014swift_pref" + "ix\030\' \001(\t\022\030\n\020php_class_prefix\030( \001(\t\022\025\n\rph" + "p_namespace\030) \001(\t\022C\n\024uninterpreted_optio" + "n\030\347\007 \003(\0132$.google.protobuf.Uninterpreted" + "Option\":\n\014OptimizeMode\022\t\n\005SPEED\020\001\022\r\n\tCOD" + "E_SIZE\020\002\022\020\n\014LITE_RUNTIME\020\003*\t\010\350\007\020\200\200\200\200\002J\004\010" + "&\020\'\"\362\001\n\016MessageOptions\022&\n\027message_set_wi" + "re_format\030\001 \001(\010:\005false\022.\n\037no_standard_de" + "scriptor_accessor\030\002 \001(\010:\005false\022\031\n\ndeprec" + "ated\030\003 \001(\010:\005false\022\021\n\tmap_entry\030\007 \001(\010\022C\n\024" + "uninterpreted_option\030\347\007 \003(\0132$.google.pro" + "tobuf.UninterpretedOption*\t\010\350\007\020\200\200\200\200\002J\004\010\010" + "\020\tJ\004\010\t\020\n\"\236\003\n\014FieldOptions\022:\n\005ctype\030\001 \001(\016" + "2#.google.protobuf.FieldOptions.CType:\006S" + "TRING\022\016\n\006packed\030\002 \001(\010\022\?\n\006jstype\030\006 \001(\0162$." + "google.protobuf.FieldOptions.JSType:\tJS_" + "NORMAL\022\023\n\004lazy\030\005 \001(\010:\005false\022\031\n\ndeprecate" + "d\030\003 \001(\010:\005false\022\023\n\004weak\030\n \001(\010:\005false\022C\n\024u" + "ninterpreted_option\030\347\007 \003(\0132$.google.prot" + "obuf.UninterpretedOption\"/\n\005CType\022\n\n\006STR" + "ING\020\000\022\010\n\004CORD\020\001\022\020\n\014STRING_PIECE\020\002\"5\n\006JST" + "ype\022\r\n\tJS_NORMAL\020\000\022\r\n\tJS_STRING\020\001\022\r\n\tJS_" + "NUMBER\020\002*\t\010\350\007\020\200\200\200\200\002J\004\010\004\020\005\"^\n\014OneofOption" + "s\022C\n\024uninterpreted_option\030\347\007 \003(\0132$.googl" + "e.protobuf.UninterpretedOption*\t\010\350\007\020\200\200\200\200" + "\002\"\223\001\n\013EnumOptions\022\023\n\013allow_alias\030\002 \001(\010\022\031" + "\n\ndeprecated\030\003 \001(\010:\005false\022C\n\024uninterpret" + "ed_option\030\347\007 \003(\0132$.google.protobuf.Unint" + "erpretedOption*\t\010\350\007\020\200\200\200\200\002J\004\010\005\020\006\"}\n\020EnumV" + "alueOptions\022\031\n\ndeprecated\030\001 \001(\010:\005false\022C" + "\n\024uninterpreted_option\030\347\007 \003(\0132$.google.p" + "rotobuf.UninterpretedOption*\t\010\350\007\020\200\200\200\200\002\"{" + "\n\016ServiceOptions\022\031\n\ndeprecated\030! \001(\010:\005fa" + "lse\022C\n\024uninterpreted_option\030\347\007 \003(\0132$.goo" + "gle.protobuf.UninterpretedOption*\t\010\350\007\020\200\200" + "\200\200\002\"\255\002\n\rMethodOptions\022\031\n\ndeprecated\030! \001(" + "\010:\005false\022_\n\021idempotency_level\030\" \001(\0162/.go" + "ogle.protobuf.MethodOptions.IdempotencyL" + "evel:\023IDEMPOTENCY_UNKNOWN\022C\n\024uninterpret" + "ed_option\030\347\007 \003(\0132$.google.protobuf.Unint" + "erpretedOption\"P\n\020IdempotencyLevel\022\027\n\023ID" + "EMPOTENCY_UNKNOWN\020\000\022\023\n\017NO_SIDE_EFFECTS\020\001" + "\022\016\n\nIDEMPOTENT\020\002*\t\010\350\007\020\200\200\200\200\002\"\236\002\n\023Uninterp" + "retedOption\022;\n\004name\030\002 \003(\0132-.google.proto" + "buf.UninterpretedOption.NamePart\022\030\n\020iden" + "tifier_value\030\003 \001(\t\022\032\n\022positive_int_value" + "\030\004 \001(\004\022\032\n\022negative_int_value\030\005 \001(\003\022\024\n\014do" + "uble_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\tn" + "ame_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(.goog" + "le.protobuf.SourceCodeInfo.Location\032\206\001\n\010" + "Location\022\020\n\004path\030\001 \003(\005B\002\020\001\022\020\n\004span\030\002 \003(\005" + "B\002\020\001\022\030\n\020leading_comments\030\003 \001(\t\022\031\n\021traili" + "ng_comments\030\004 \001(\t\022!\n\031leading_detached_co" + "mments\030\006 \003(\t\"\247\001\n\021GeneratedCodeInfo\022A\n\nan" + "notation\030\001 \003(\0132-.google.protobuf.Generat" + "edCodeInfo.Annotation\032O\n\nAnnotation\022\020\n\004p" + "ath\030\001 \003(\005B\002\020\001\022\023\n\013source_file\030\002 \001(\t\022\r\n\005be" + "gin\030\003 \001(\005\022\013\n\003end\030\004 \001(\005B\217\001\n\023com.google.pr" + "otobufB\020DescriptorProtosH\001Z>github.com/g" + "olang/protobuf/protoc-gen-go/descriptor;" + "descriptor\370\001\001\242\002\003GPB\252\002\032Google.Protobuf.Re" + "flection" }; ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( - descriptor, 5614); + descriptor, 5968); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/descriptor.proto", &protobuf_RegisterTypes); - ::google::protobuf::internal::OnShutdown(&TableStruct::Shutdown); } void AddDescriptors() { static GOOGLE_PROTOBUF_DECLARE_ONCE(once); ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl); } -// Force AddDescriptors() to be called at static initialization time. +// Force AddDescriptors() to be called at dynamic initialization time. struct StaticDescriptorInitializer { StaticDescriptorInitializer() { AddDescriptors(); } } static_descriptor_initializer; - } // namespace protobuf_google_2fprotobuf_2fdescriptor_2eproto - +namespace google { +namespace protobuf { const ::google::protobuf::EnumDescriptor* FieldDescriptorProto_Type_descriptor() { protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_enum_descriptors[0]; @@ -997,6 +1568,8 @@ const int MethodOptions::IdempotencyLevel_ARRAYSIZE; // =================================================================== +void FileDescriptorSet::InitAsDefaultInstance() { +} #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int FileDescriptorSet::kFileFieldNumber; #endif // !defined(_MSC_VER) || _MSC_VER >= 1900 @@ -1004,11 +1577,20 @@ const int FileDescriptorSet::kFileFieldNumber; FileDescriptorSet::FileDescriptorSet() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsFileDescriptorSet(); } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.FileDescriptorSet) } +FileDescriptorSet::FileDescriptorSet(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(), + _internal_metadata_(arena), + file_(arena) { + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsFileDescriptorSet(); + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:google.protobuf.FileDescriptorSet) +} FileDescriptorSet::FileDescriptorSet(const FileDescriptorSet& from) : ::google::protobuf::Message(), _internal_metadata_(NULL), @@ -1029,33 +1611,37 @@ FileDescriptorSet::~FileDescriptorSet() { } void FileDescriptorSet::SharedDtor() { + GOOGLE_DCHECK(GetArenaNoVirtual() == NULL); } +void FileDescriptorSet::ArenaDtor(void* object) { + FileDescriptorSet* _this = reinterpret_cast< FileDescriptorSet* >(object); + (void)_this; +} +void FileDescriptorSet::RegisterArenaDtor(::google::protobuf::Arena* arena) { +} void FileDescriptorSet::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* FileDescriptorSet::descriptor() { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const FileDescriptorSet& FileDescriptorSet::default_instance() { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsFileDescriptorSet(); return *internal_default_instance(); } -FileDescriptorSet* FileDescriptorSet::New(::google::protobuf::Arena* arena) const { - FileDescriptorSet* n = new FileDescriptorSet; - if (arena != NULL) { - arena->Own(n); - } - return n; -} void FileDescriptorSet::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.FileDescriptorSet) + ::google::protobuf::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + file_.Clear(); _has_bits_.Clear(); _internal_metadata_.Clear(); @@ -1074,8 +1660,8 @@ bool FileDescriptorSet::MergePartialFromCodedStream( // repeated .google.protobuf.FileDescriptorProto file = 1; case 1: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(10u)) { - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + static_cast< ::google::protobuf::uint8>(10u /* 10 & 0xFF */)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, add_file())); } else { goto handle_unusual; @@ -1085,13 +1671,11 @@ bool FileDescriptorSet::MergePartialFromCodedStream( default: { handle_unusual: - if (tag == 0 || - ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + if (tag == 0) { goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); + input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } @@ -1112,34 +1696,39 @@ void FileDescriptorSet::SerializeWithCachedSizes( (void) cached_has_bits; // repeated .google.protobuf.FileDescriptorProto file = 1; - for (unsigned int i = 0, n = this->file_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->file_size()); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 1, this->file(i), output); + 1, + this->file(static_cast<int>(i)), + output); } if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); + _internal_metadata_.unknown_fields(), output); } // @@protoc_insertion_point(serialize_end:google.protobuf.FileDescriptorSet) } ::google::protobuf::uint8* FileDescriptorSet::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.FileDescriptorSet) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; // repeated .google.protobuf.FileDescriptorProto file = 1; - for (unsigned int i = 0, n = this->file_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->file_size()); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: - InternalWriteMessageNoVirtualToArray( - 1, this->file(i), deterministic, target); + InternalWriteMessageToArray( + 1, this->file(static_cast<int>(i)), deterministic, target); } if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); + _internal_metadata_.unknown_fields(), target); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.FileDescriptorSet) return target; @@ -1152,16 +1741,16 @@ size_t FileDescriptorSet::ByteSizeLong() const { if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); + _internal_metadata_.unknown_fields()); } // repeated .google.protobuf.FileDescriptorProto file = 1; { - unsigned int count = this->file_size(); + unsigned int count = static_cast<unsigned int>(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)); + ::google::protobuf::internal::WireFormatLite::MessageSize( + this->file(static_cast<int>(i))); } } @@ -1218,57 +1807,71 @@ bool FileDescriptorSet::IsInitialized() const { void FileDescriptorSet::Swap(FileDescriptorSet* other) { if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + FileDescriptorSet* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } + } +} +void FileDescriptorSet::UnsafeArenaSwap(FileDescriptorSet* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); InternalSwap(other); } void FileDescriptorSet::InternalSwap(FileDescriptorSet* other) { - file_.InternalSwap(&other->file_); - std::swap(_has_bits_[0], other->_has_bits_[0]); + using std::swap; + CastToBase(&file_)->InternalSwap(CastToBase(&other->file_)); + swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); - std::swap(_cached_size_, other->_cached_size_); + swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata FileDescriptorSet::GetMetadata() const { protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages]; + return ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages]; } -#if PROTOBUF_INLINE_NOT_IN_HEADERS -// FileDescriptorSet -// repeated .google.protobuf.FileDescriptorProto file = 1; -int FileDescriptorSet::file_size() const { - return file_.size(); -} -void FileDescriptorSet::clear_file() { - file_.Clear(); -} -const ::google::protobuf::FileDescriptorProto& FileDescriptorSet::file(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorSet.file) - return file_.Get(index); -} -::google::protobuf::FileDescriptorProto* FileDescriptorSet::mutable_file(int index) { - // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorSet.file) - return file_.Mutable(index); -} -::google::protobuf::FileDescriptorProto* FileDescriptorSet::add_file() { - // @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorSet.file) - return file_.Add(); +// =================================================================== + +void FileDescriptorProto::InitAsDefaultInstance() { + ::google::protobuf::_FileDescriptorProto_default_instance_._instance.get_mutable()->options_ = const_cast< ::google::protobuf::FileOptions*>( + ::google::protobuf::FileOptions::internal_default_instance()); + ::google::protobuf::_FileDescriptorProto_default_instance_._instance.get_mutable()->source_code_info_ = const_cast< ::google::protobuf::SourceCodeInfo*>( + ::google::protobuf::SourceCodeInfo::internal_default_instance()); } -::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto >* -FileDescriptorSet::mutable_file() { - // @@protoc_insertion_point(field_mutable_list:google.protobuf.FileDescriptorSet.file) - return &file_; +void FileDescriptorProto::unsafe_arena_set_allocated_options( + ::google::protobuf::FileOptions* options) { + if (GetArenaNoVirtual() == NULL) { + delete options_; + } + options_ = options; + if (options) { + set_has_options(); + } else { + clear_has_options(); + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.FileDescriptorProto.options) } -const ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto >& -FileDescriptorSet::file() const { - // @@protoc_insertion_point(field_list:google.protobuf.FileDescriptorSet.file) - return file_; +void FileDescriptorProto::unsafe_arena_set_allocated_source_code_info( + ::google::protobuf::SourceCodeInfo* source_code_info) { + if (GetArenaNoVirtual() == NULL) { + delete source_code_info_; + } + source_code_info_ = source_code_info; + if (source_code_info) { + set_has_source_code_info(); + } else { + clear_has_source_code_info(); + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.FileDescriptorProto.source_code_info) } - -#endif // PROTOBUF_INLINE_NOT_IN_HEADERS - -// =================================================================== - #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int FileDescriptorProto::kNameFieldNumber; const int FileDescriptorProto::kPackageFieldNumber; @@ -1287,11 +1890,26 @@ const int FileDescriptorProto::kSyntaxFieldNumber; FileDescriptorProto::FileDescriptorProto() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsFileDescriptorProto(); } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.FileDescriptorProto) } +FileDescriptorProto::FileDescriptorProto(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(), + _internal_metadata_(arena), + dependency_(arena), + message_type_(arena), + enum_type_(arena), + service_(arena), + extension_(arena), + public_dependency_(arena), + weak_dependency_(arena) { + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsFileDescriptorProto(); + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:google.protobuf.FileDescriptorProto) +} FileDescriptorProto::FileDescriptorProto(const FileDescriptorProto& from) : ::google::protobuf::Message(), _internal_metadata_(NULL), @@ -1307,15 +1925,18 @@ FileDescriptorProto::FileDescriptorProto(const FileDescriptorProto& from) _internal_metadata_.MergeFrom(from._internal_metadata_); name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); if (from.has_name()) { - name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name(), + GetArenaNoVirtual()); } package_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); if (from.has_package()) { - package_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.package_); + package_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.package(), + GetArenaNoVirtual()); } syntax_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); if (from.has_syntax()) { - syntax_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.syntax_); + syntax_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.syntax(), + GetArenaNoVirtual()); } if (from.has_options()) { options_ = new ::google::protobuf::FileOptions(*from.options_); @@ -1335,8 +1956,9 @@ void FileDescriptorProto::SharedCtor() { name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); package_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); syntax_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - ::memset(&options_, 0, reinterpret_cast<char*>(&source_code_info_) - - reinterpret_cast<char*>(&options_) + sizeof(source_code_info_)); + ::memset(&options_, 0, static_cast<size_t>( + reinterpret_cast<char*>(&source_code_info_) - + reinterpret_cast<char*>(&options_)) + sizeof(source_code_info_)); } FileDescriptorProto::~FileDescriptorProto() { @@ -1345,42 +1967,42 @@ FileDescriptorProto::~FileDescriptorProto() { } void FileDescriptorProto::SharedDtor() { + GOOGLE_DCHECK(GetArenaNoVirtual() == NULL); name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); package_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); syntax_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != internal_default_instance()) { - delete options_; - } - if (this != internal_default_instance()) { - delete source_code_info_; - } + if (this != internal_default_instance()) delete options_; + if (this != internal_default_instance()) delete source_code_info_; } +void FileDescriptorProto::ArenaDtor(void* object) { + FileDescriptorProto* _this = reinterpret_cast< FileDescriptorProto* >(object); + (void)_this; +} +void FileDescriptorProto::RegisterArenaDtor(::google::protobuf::Arena* arena) { +} void FileDescriptorProto::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* FileDescriptorProto::descriptor() { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const FileDescriptorProto& FileDescriptorProto::default_instance() { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsFileDescriptorProto(); return *internal_default_instance(); } -FileDescriptorProto* FileDescriptorProto::New(::google::protobuf::Arena* arena) const { - FileDescriptorProto* n = new FileDescriptorProto; - if (arena != NULL) { - arena->Own(n); - } - return n; -} void FileDescriptorProto::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.FileDescriptorProto) + ::google::protobuf::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + dependency_.Clear(); message_type_.Clear(); enum_type_.Clear(); @@ -1388,26 +2010,27 @@ void FileDescriptorProto::Clear() { extension_.Clear(); public_dependency_.Clear(); weak_dependency_.Clear(); - if (_has_bits_[0 / 32] & 31u) { - if (has_name()) { + cached_has_bits = _has_bits_[0]; + if (cached_has_bits & 31u) { + if (cached_has_bits & 0x00000001u) { GOOGLE_DCHECK(!name_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); - (*name_.UnsafeRawStringPointer())->clear(); + name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - if (has_package()) { + if (cached_has_bits & 0x00000002u) { GOOGLE_DCHECK(!package_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); - (*package_.UnsafeRawStringPointer())->clear(); + package_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - if (has_syntax()) { + if (cached_has_bits & 0x00000004u) { GOOGLE_DCHECK(!syntax_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); - (*syntax_.UnsafeRawStringPointer())->clear(); + syntax_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - if (has_options()) { + if (cached_has_bits & 0x00000008u) { GOOGLE_DCHECK(options_ != NULL); - options_->::google::protobuf::FileOptions::Clear(); + options_->Clear(); } - if (has_source_code_info()) { + if (cached_has_bits & 0x00000010u) { GOOGLE_DCHECK(source_code_info_ != NULL); - source_code_info_->::google::protobuf::SourceCodeInfo::Clear(); + source_code_info_->Clear(); } } _has_bits_.Clear(); @@ -1427,11 +2050,11 @@ bool FileDescriptorProto::MergePartialFromCodedStream( // optional string name = 1; case 1: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(10u)) { + static_cast< ::google::protobuf::uint8>(10u /* 10 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->name().data(), this->name().length(), + this->name().data(), static_cast<int>(this->name().length()), ::google::protobuf::internal::WireFormat::PARSE, "google.protobuf.FileDescriptorProto.name"); } else { @@ -1443,11 +2066,11 @@ bool FileDescriptorProto::MergePartialFromCodedStream( // optional string package = 2; case 2: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(18u)) { + static_cast< ::google::protobuf::uint8>(18u /* 18 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_package())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->package().data(), this->package().length(), + this->package().data(), static_cast<int>(this->package().length()), ::google::protobuf::internal::WireFormat::PARSE, "google.protobuf.FileDescriptorProto.package"); } else { @@ -1459,12 +2082,12 @@ bool FileDescriptorProto::MergePartialFromCodedStream( // repeated string dependency = 3; case 3: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(26u)) { + static_cast< ::google::protobuf::uint8>(26u /* 26 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->add_dependency())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->dependency(this->dependency_size() - 1).data(), - this->dependency(this->dependency_size() - 1).length(), + static_cast<int>(this->dependency(this->dependency_size() - 1).length()), ::google::protobuf::internal::WireFormat::PARSE, "google.protobuf.FileDescriptorProto.dependency"); } else { @@ -1476,8 +2099,8 @@ bool FileDescriptorProto::MergePartialFromCodedStream( // repeated .google.protobuf.DescriptorProto message_type = 4; case 4: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(34u)) { - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + static_cast< ::google::protobuf::uint8>(34u /* 34 & 0xFF */)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, add_message_type())); } else { goto handle_unusual; @@ -1488,8 +2111,8 @@ bool FileDescriptorProto::MergePartialFromCodedStream( // repeated .google.protobuf.EnumDescriptorProto enum_type = 5; case 5: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(42u)) { - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + static_cast< ::google::protobuf::uint8>(42u /* 42 & 0xFF */)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, add_enum_type())); } else { goto handle_unusual; @@ -1500,8 +2123,8 @@ bool FileDescriptorProto::MergePartialFromCodedStream( // repeated .google.protobuf.ServiceDescriptorProto service = 6; case 6: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(50u)) { - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + static_cast< ::google::protobuf::uint8>(50u /* 50 & 0xFF */)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, add_service())); } else { goto handle_unusual; @@ -1512,8 +2135,8 @@ bool FileDescriptorProto::MergePartialFromCodedStream( // repeated .google.protobuf.FieldDescriptorProto extension = 7; case 7: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(58u)) { - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + static_cast< ::google::protobuf::uint8>(58u /* 58 & 0xFF */)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, add_extension())); } else { goto handle_unusual; @@ -1524,8 +2147,8 @@ bool FileDescriptorProto::MergePartialFromCodedStream( // optional .google.protobuf.FileOptions options = 8; case 8: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(66u)) { - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + static_cast< ::google::protobuf::uint8>(66u /* 66 & 0xFF */)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, mutable_options())); } else { goto handle_unusual; @@ -1536,8 +2159,8 @@ bool FileDescriptorProto::MergePartialFromCodedStream( // optional .google.protobuf.SourceCodeInfo source_code_info = 9; case 9: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(74u)) { - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + static_cast< ::google::protobuf::uint8>(74u /* 74 & 0xFF */)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, mutable_source_code_info())); } else { goto handle_unusual; @@ -1548,12 +2171,13 @@ bool FileDescriptorProto::MergePartialFromCodedStream( // repeated int32 public_dependency = 10; case 10: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(80u)) { + static_cast< ::google::protobuf::uint8>(80u /* 80 & 0xFF */)) { DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( 1, 80u, input, this->mutable_public_dependency()))); - } else if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(82u)) { + } else if ( + static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(82u /* 82 & 0xFF */)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, this->mutable_public_dependency()))); @@ -1566,12 +2190,13 @@ bool FileDescriptorProto::MergePartialFromCodedStream( // repeated int32 weak_dependency = 11; case 11: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(88u)) { + static_cast< ::google::protobuf::uint8>(88u /* 88 & 0xFF */)) { DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( 1, 88u, input, this->mutable_weak_dependency()))); - } else if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(90u)) { + } else if ( + static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(90u /* 90 & 0xFF */)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, this->mutable_weak_dependency()))); @@ -1584,11 +2209,11 @@ bool FileDescriptorProto::MergePartialFromCodedStream( // optional string syntax = 12; case 12: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(98u)) { + static_cast< ::google::protobuf::uint8>(98u /* 98 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_syntax())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->syntax().data(), this->syntax().length(), + this->syntax().data(), static_cast<int>(this->syntax().length()), ::google::protobuf::internal::WireFormat::PARSE, "google.protobuf.FileDescriptorProto.syntax"); } else { @@ -1599,13 +2224,11 @@ bool FileDescriptorProto::MergePartialFromCodedStream( default: { handle_unusual: - if (tag == 0 || - ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + if (tag == 0) { goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); + input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } @@ -1629,7 +2252,7 @@ void FileDescriptorProto::SerializeWithCachedSizes( // optional string name = 1; if (cached_has_bits & 0x00000001u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->name().data(), this->name().length(), + this->name().data(), static_cast<int>(this->name().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.FileDescriptorProto.name"); ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( @@ -1639,7 +2262,7 @@ void FileDescriptorProto::SerializeWithCachedSizes( // optional string package = 2; if (cached_has_bits & 0x00000002u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->package().data(), this->package().length(), + this->package().data(), static_cast<int>(this->package().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.FileDescriptorProto.package"); ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( @@ -1649,7 +2272,7 @@ void FileDescriptorProto::SerializeWithCachedSizes( // repeated string dependency = 3; for (int i = 0, n = this->dependency_size(); i < n; i++) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->dependency(i).data(), this->dependency(i).length(), + this->dependency(i).data(), static_cast<int>(this->dependency(i).length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.FileDescriptorProto.dependency"); ::google::protobuf::internal::WireFormatLite::WriteString( @@ -1657,39 +2280,51 @@ void FileDescriptorProto::SerializeWithCachedSizes( } // repeated .google.protobuf.DescriptorProto message_type = 4; - for (unsigned int i = 0, n = this->message_type_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->message_type_size()); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 4, this->message_type(i), output); + 4, + this->message_type(static_cast<int>(i)), + output); } // repeated .google.protobuf.EnumDescriptorProto enum_type = 5; - for (unsigned int i = 0, n = this->enum_type_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->enum_type_size()); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 5, this->enum_type(i), output); + 5, + this->enum_type(static_cast<int>(i)), + output); } // repeated .google.protobuf.ServiceDescriptorProto service = 6; - for (unsigned int i = 0, n = this->service_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->service_size()); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 6, this->service(i), output); + 6, + this->service(static_cast<int>(i)), + output); } // repeated .google.protobuf.FieldDescriptorProto extension = 7; - for (unsigned int i = 0, n = this->extension_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->extension_size()); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 7, this->extension(i), output); + 7, + this->extension(static_cast<int>(i)), + output); } // optional .google.protobuf.FileOptions options = 8; if (cached_has_bits & 0x00000008u) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 8, *this->options_, output); + 8, *options_, output); } // optional .google.protobuf.SourceCodeInfo source_code_info = 9; if (cached_has_bits & 0x00000010u) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 9, *this->source_code_info_, output); + 9, *source_code_info_, output); } // repeated int32 public_dependency = 10; @@ -1707,7 +2342,7 @@ void FileDescriptorProto::SerializeWithCachedSizes( // optional string syntax = 12; if (cached_has_bits & 0x00000004u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->syntax().data(), this->syntax().length(), + this->syntax().data(), static_cast<int>(this->syntax().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.FileDescriptorProto.syntax"); ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( @@ -1716,13 +2351,14 @@ void FileDescriptorProto::SerializeWithCachedSizes( if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); + _internal_metadata_.unknown_fields(), output); } // @@protoc_insertion_point(serialize_end:google.protobuf.FileDescriptorProto) } ::google::protobuf::uint8* FileDescriptorProto::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.FileDescriptorProto) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -1731,7 +2367,7 @@ void FileDescriptorProto::SerializeWithCachedSizes( // optional string name = 1; if (cached_has_bits & 0x00000001u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->name().data(), this->name().length(), + this->name().data(), static_cast<int>(this->name().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.FileDescriptorProto.name"); target = @@ -1742,7 +2378,7 @@ void FileDescriptorProto::SerializeWithCachedSizes( // optional string package = 2; if (cached_has_bits & 0x00000002u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->package().data(), this->package().length(), + this->package().data(), static_cast<int>(this->package().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.FileDescriptorProto.package"); target = @@ -1753,7 +2389,7 @@ void FileDescriptorProto::SerializeWithCachedSizes( // repeated string dependency = 3; for (int i = 0, n = this->dependency_size(); i < n; i++) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->dependency(i).data(), this->dependency(i).length(), + this->dependency(i).data(), static_cast<int>(this->dependency(i).length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.FileDescriptorProto.dependency"); target = ::google::protobuf::internal::WireFormatLite:: @@ -1761,45 +2397,49 @@ void FileDescriptorProto::SerializeWithCachedSizes( } // repeated .google.protobuf.DescriptorProto message_type = 4; - for (unsigned int i = 0, n = this->message_type_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->message_type_size()); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: - InternalWriteMessageNoVirtualToArray( - 4, this->message_type(i), deterministic, target); + InternalWriteMessageToArray( + 4, this->message_type(static_cast<int>(i)), deterministic, target); } // repeated .google.protobuf.EnumDescriptorProto enum_type = 5; - for (unsigned int i = 0, n = this->enum_type_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->enum_type_size()); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: - InternalWriteMessageNoVirtualToArray( - 5, this->enum_type(i), deterministic, target); + InternalWriteMessageToArray( + 5, this->enum_type(static_cast<int>(i)), deterministic, target); } // repeated .google.protobuf.ServiceDescriptorProto service = 6; - for (unsigned int i = 0, n = this->service_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->service_size()); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: - InternalWriteMessageNoVirtualToArray( - 6, this->service(i), deterministic, target); + InternalWriteMessageToArray( + 6, this->service(static_cast<int>(i)), deterministic, target); } // repeated .google.protobuf.FieldDescriptorProto extension = 7; - for (unsigned int i = 0, n = this->extension_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->extension_size()); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: - InternalWriteMessageNoVirtualToArray( - 7, this->extension(i), deterministic, target); + InternalWriteMessageToArray( + 7, this->extension(static_cast<int>(i)), deterministic, target); } // optional .google.protobuf.FileOptions options = 8; if (cached_has_bits & 0x00000008u) { target = ::google::protobuf::internal::WireFormatLite:: - InternalWriteMessageNoVirtualToArray( - 8, *this->options_, deterministic, target); + InternalWriteMessageToArray( + 8, *options_, deterministic, target); } // optional .google.protobuf.SourceCodeInfo source_code_info = 9; if (cached_has_bits & 0x00000010u) { target = ::google::protobuf::internal::WireFormatLite:: - InternalWriteMessageNoVirtualToArray( - 9, *this->source_code_info_, deterministic, target); + InternalWriteMessageToArray( + 9, *source_code_info_, deterministic, target); } // repeated int32 public_dependency = 10; @@ -1813,7 +2453,7 @@ void FileDescriptorProto::SerializeWithCachedSizes( // optional string syntax = 12; if (cached_has_bits & 0x00000004u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->syntax().data(), this->syntax().length(), + this->syntax().data(), static_cast<int>(this->syntax().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.FileDescriptorProto.syntax"); target = @@ -1823,7 +2463,7 @@ void FileDescriptorProto::SerializeWithCachedSizes( if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); + _internal_metadata_.unknown_fields(), target); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.FileDescriptorProto) return target; @@ -1836,7 +2476,7 @@ size_t FileDescriptorProto::ByteSizeLong() const { if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); + _internal_metadata_.unknown_fields()); } // repeated string dependency = 3; total_size += 1 * @@ -1848,45 +2488,45 @@ size_t FileDescriptorProto::ByteSizeLong() const { // repeated .google.protobuf.DescriptorProto message_type = 4; { - unsigned int count = this->message_type_size(); + unsigned int count = static_cast<unsigned int>(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)); + ::google::protobuf::internal::WireFormatLite::MessageSize( + this->message_type(static_cast<int>(i))); } } // repeated .google.protobuf.EnumDescriptorProto enum_type = 5; { - unsigned int count = this->enum_type_size(); + unsigned int count = static_cast<unsigned int>(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)); + ::google::protobuf::internal::WireFormatLite::MessageSize( + this->enum_type(static_cast<int>(i))); } } // repeated .google.protobuf.ServiceDescriptorProto service = 6; { - unsigned int count = this->service_size(); + unsigned int count = static_cast<unsigned int>(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)); + ::google::protobuf::internal::WireFormatLite::MessageSize( + this->service(static_cast<int>(i))); } } // repeated .google.protobuf.FieldDescriptorProto extension = 7; { - unsigned int count = this->extension_size(); + unsigned int count = static_cast<unsigned int>(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)); + ::google::protobuf::internal::WireFormatLite::MessageSize( + this->extension(static_cast<int>(i))); } } @@ -1933,15 +2573,15 @@ size_t FileDescriptorProto::ByteSizeLong() const { // optional .google.protobuf.FileOptions options = 8; if (has_options()) { total_size += 1 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - *this->options_); + ::google::protobuf::internal::WireFormatLite::MessageSize( + *options_); } // optional .google.protobuf.SourceCodeInfo source_code_info = 9; if (has_source_code_info()) { total_size += 1 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - *this->source_code_info_); + ::google::protobuf::internal::WireFormatLite::MessageSize( + *source_code_info_); } } @@ -1984,16 +2624,13 @@ void FileDescriptorProto::MergeFrom(const FileDescriptorProto& from) { cached_has_bits = from._has_bits_[0]; if (cached_has_bits & 31u) { if (cached_has_bits & 0x00000001u) { - set_has_name(); - name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); + set_name(from.name()); } if (cached_has_bits & 0x00000002u) { - set_has_package(); - package_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.package_); + set_package(from.package()); } if (cached_has_bits & 0x00000004u) { - set_has_syntax(); - syntax_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.syntax_); + set_syntax(from.syntax()); } if (cached_has_bits & 0x00000008u) { mutable_options()->::google::protobuf::FileOptions::MergeFrom(from.options()); @@ -2031,595 +2668,111 @@ bool FileDescriptorProto::IsInitialized() const { void FileDescriptorProto::Swap(FileDescriptorProto* other) { if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + FileDescriptorProto* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } + } +} +void FileDescriptorProto::UnsafeArenaSwap(FileDescriptorProto* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); InternalSwap(other); } void FileDescriptorProto::InternalSwap(FileDescriptorProto* other) { - dependency_.InternalSwap(&other->dependency_); - message_type_.InternalSwap(&other->message_type_); - enum_type_.InternalSwap(&other->enum_type_); - service_.InternalSwap(&other->service_); - extension_.InternalSwap(&other->extension_); + using std::swap; + dependency_.InternalSwap(CastToBase(&other->dependency_)); + CastToBase(&message_type_)->InternalSwap(CastToBase(&other->message_type_)); + CastToBase(&enum_type_)->InternalSwap(CastToBase(&other->enum_type_)); + CastToBase(&service_)->InternalSwap(CastToBase(&other->service_)); + CastToBase(&extension_)->InternalSwap(CastToBase(&other->extension_)); public_dependency_.InternalSwap(&other->public_dependency_); weak_dependency_.InternalSwap(&other->weak_dependency_); name_.Swap(&other->name_); package_.Swap(&other->package_); syntax_.Swap(&other->syntax_); - std::swap(options_, other->options_); - std::swap(source_code_info_, other->source_code_info_); - std::swap(_has_bits_[0], other->_has_bits_[0]); + swap(options_, other->options_); + swap(source_code_info_, other->source_code_info_); + swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); - std::swap(_cached_size_, other->_cached_size_); + swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata FileDescriptorProto::GetMetadata() const { protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages]; + return ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages]; } -#if PROTOBUF_INLINE_NOT_IN_HEADERS -// FileDescriptorProto - -// optional string name = 1; -bool FileDescriptorProto::has_name() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -void FileDescriptorProto::set_has_name() { - _has_bits_[0] |= 0x00000001u; -} -void FileDescriptorProto::clear_has_name() { - _has_bits_[0] &= ~0x00000001u; -} -void FileDescriptorProto::clear_name() { - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - clear_has_name(); -} -const ::std::string& FileDescriptorProto::name() const { - // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.name) - return name_.GetNoArena(); -} -void FileDescriptorProto::set_name(const ::std::string& value) { - set_has_name(); - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.name) -} -#if LANG_CXX11 -void FileDescriptorProto::set_name(::std::string&& value) { - set_has_name(); - name_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileDescriptorProto.name) -} -#endif -void FileDescriptorProto::set_name(const char* value) { - GOOGLE_DCHECK(value != NULL); - 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) { - set_has_name(); - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileDescriptorProto.name) -} -::std::string* FileDescriptorProto::mutable_name() { - set_has_name(); - // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.name) - return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -::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) { - if (name != NULL) { - set_has_name(); - } else { - clear_has_name(); - } - name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileDescriptorProto.name) -} -// optional string package = 2; -bool FileDescriptorProto::has_package() const { - return (_has_bits_[0] & 0x00000002u) != 0; -} -void FileDescriptorProto::set_has_package() { - _has_bits_[0] |= 0x00000002u; -} -void FileDescriptorProto::clear_has_package() { - _has_bits_[0] &= ~0x00000002u; -} -void FileDescriptorProto::clear_package() { - package_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - clear_has_package(); -} -const ::std::string& FileDescriptorProto::package() const { - // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.package) - return package_.GetNoArena(); -} -void FileDescriptorProto::set_package(const ::std::string& value) { - set_has_package(); - package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.package) -} -#if LANG_CXX11 -void FileDescriptorProto::set_package(::std::string&& value) { - set_has_package(); - package_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileDescriptorProto.package) -} -#endif -void FileDescriptorProto::set_package(const char* value) { - GOOGLE_DCHECK(value != NULL); - 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) { - set_has_package(); - package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileDescriptorProto.package) -} -::std::string* FileDescriptorProto::mutable_package() { - set_has_package(); - // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.package) - return package_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -::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) { - if (package != NULL) { - set_has_package(); - } else { - clear_has_package(); - } - package_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), package); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileDescriptorProto.package) -} - -// repeated string dependency = 3; -int FileDescriptorProto::dependency_size() const { - return dependency_.size(); -} -void FileDescriptorProto::clear_dependency() { - dependency_.Clear(); -} -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) { - // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.dependency) - return dependency_.Mutable(index); -} -void FileDescriptorProto::set_dependency(int index, const ::std::string& value) { - // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.dependency) - dependency_.Mutable(index)->assign(value); -} -#if LANG_CXX11 -void FileDescriptorProto::set_dependency(int index, ::std::string&& value) { - // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.dependency) - dependency_.Mutable(index)->assign(std::move(value)); -} -#endif -void FileDescriptorProto::set_dependency(int index, const char* value) { - GOOGLE_DCHECK(value != NULL); - 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) { - dependency_.Mutable(index)->assign( - reinterpret_cast<const char*>(value), size); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileDescriptorProto.dependency) -} -::std::string* FileDescriptorProto::add_dependency() { - // @@protoc_insertion_point(field_add_mutable:google.protobuf.FileDescriptorProto.dependency) - return dependency_.Add(); -} -void FileDescriptorProto::add_dependency(const ::std::string& value) { - dependency_.Add()->assign(value); - // @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.dependency) -} -#if LANG_CXX11 -void FileDescriptorProto::add_dependency(::std::string&& value) { - dependency_.Add(std::move(value)); - // @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.dependency) -} -#endif -void FileDescriptorProto::add_dependency(const char* value) { - GOOGLE_DCHECK(value != NULL); - dependency_.Add()->assign(value); - // @@protoc_insertion_point(field_add_char:google.protobuf.FileDescriptorProto.dependency) -} -void FileDescriptorProto::add_dependency(const char* value, size_t size) { - dependency_.Add()->assign(reinterpret_cast<const char*>(value), size); - // @@protoc_insertion_point(field_add_pointer:google.protobuf.FileDescriptorProto.dependency) -} -const ::google::protobuf::RepeatedPtrField< ::std::string>& -FileDescriptorProto::dependency() const { - // @@protoc_insertion_point(field_list:google.protobuf.FileDescriptorProto.dependency) - return dependency_; -} -::google::protobuf::RepeatedPtrField< ::std::string>* -FileDescriptorProto::mutable_dependency() { - // @@protoc_insertion_point(field_mutable_list:google.protobuf.FileDescriptorProto.dependency) - return &dependency_; -} - -// repeated int32 public_dependency = 10; -int FileDescriptorProto::public_dependency_size() const { - return public_dependency_.size(); -} -void FileDescriptorProto::clear_public_dependency() { - public_dependency_.Clear(); -} -::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) { - public_dependency_.Set(index, value); - // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.public_dependency) -} -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 >& -FileDescriptorProto::public_dependency() const { - // @@protoc_insertion_point(field_list:google.protobuf.FileDescriptorProto.public_dependency) - return public_dependency_; -} -::google::protobuf::RepeatedField< ::google::protobuf::int32 >* -FileDescriptorProto::mutable_public_dependency() { - // @@protoc_insertion_point(field_mutable_list:google.protobuf.FileDescriptorProto.public_dependency) - return &public_dependency_; -} - -// repeated int32 weak_dependency = 11; -int FileDescriptorProto::weak_dependency_size() const { - return weak_dependency_.size(); -} -void FileDescriptorProto::clear_weak_dependency() { - weak_dependency_.Clear(); -} -::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) { - weak_dependency_.Set(index, value); - // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.weak_dependency) -} -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 >& -FileDescriptorProto::weak_dependency() const { - // @@protoc_insertion_point(field_list:google.protobuf.FileDescriptorProto.weak_dependency) - return weak_dependency_; -} -::google::protobuf::RepeatedField< ::google::protobuf::int32 >* -FileDescriptorProto::mutable_weak_dependency() { - // @@protoc_insertion_point(field_mutable_list:google.protobuf.FileDescriptorProto.weak_dependency) - return &weak_dependency_; -} - -// repeated .google.protobuf.DescriptorProto message_type = 4; -int FileDescriptorProto::message_type_size() const { - return message_type_.size(); -} -void FileDescriptorProto::clear_message_type() { - message_type_.Clear(); -} -const ::google::protobuf::DescriptorProto& FileDescriptorProto::message_type(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.message_type) - return message_type_.Get(index); -} -::google::protobuf::DescriptorProto* FileDescriptorProto::mutable_message_type(int index) { - // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.message_type) - return message_type_.Mutable(index); -} -::google::protobuf::DescriptorProto* FileDescriptorProto::add_message_type() { - // @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.message_type) - return message_type_.Add(); -} -::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto >* -FileDescriptorProto::mutable_message_type() { - // @@protoc_insertion_point(field_mutable_list:google.protobuf.FileDescriptorProto.message_type) - return &message_type_; -} -const ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto >& -FileDescriptorProto::message_type() const { - // @@protoc_insertion_point(field_list:google.protobuf.FileDescriptorProto.message_type) - return message_type_; -} - -// repeated .google.protobuf.EnumDescriptorProto enum_type = 5; -int FileDescriptorProto::enum_type_size() const { - return enum_type_.size(); -} -void FileDescriptorProto::clear_enum_type() { - enum_type_.Clear(); -} -const ::google::protobuf::EnumDescriptorProto& FileDescriptorProto::enum_type(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.enum_type) - return enum_type_.Get(index); -} -::google::protobuf::EnumDescriptorProto* FileDescriptorProto::mutable_enum_type(int index) { - // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.enum_type) - return enum_type_.Mutable(index); -} -::google::protobuf::EnumDescriptorProto* FileDescriptorProto::add_enum_type() { - // @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.enum_type) - return enum_type_.Add(); -} -::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumDescriptorProto >* -FileDescriptorProto::mutable_enum_type() { - // @@protoc_insertion_point(field_mutable_list:google.protobuf.FileDescriptorProto.enum_type) - return &enum_type_; -} -const ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumDescriptorProto >& -FileDescriptorProto::enum_type() const { - // @@protoc_insertion_point(field_list:google.protobuf.FileDescriptorProto.enum_type) - return enum_type_; -} - -// repeated .google.protobuf.ServiceDescriptorProto service = 6; -int FileDescriptorProto::service_size() const { - return service_.size(); -} -void FileDescriptorProto::clear_service() { - service_.Clear(); -} -const ::google::protobuf::ServiceDescriptorProto& FileDescriptorProto::service(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.service) - return service_.Get(index); -} -::google::protobuf::ServiceDescriptorProto* FileDescriptorProto::mutable_service(int index) { - // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.service) - return service_.Mutable(index); -} -::google::protobuf::ServiceDescriptorProto* FileDescriptorProto::add_service() { - // @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.service) - return service_.Add(); -} -::google::protobuf::RepeatedPtrField< ::google::protobuf::ServiceDescriptorProto >* -FileDescriptorProto::mutable_service() { - // @@protoc_insertion_point(field_mutable_list:google.protobuf.FileDescriptorProto.service) - return &service_; -} -const ::google::protobuf::RepeatedPtrField< ::google::protobuf::ServiceDescriptorProto >& -FileDescriptorProto::service() const { - // @@protoc_insertion_point(field_list:google.protobuf.FileDescriptorProto.service) - return service_; -} - -// repeated .google.protobuf.FieldDescriptorProto extension = 7; -int FileDescriptorProto::extension_size() const { - return extension_.size(); -} -void FileDescriptorProto::clear_extension() { - extension_.Clear(); -} -const ::google::protobuf::FieldDescriptorProto& FileDescriptorProto::extension(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.extension) - return extension_.Get(index); -} -::google::protobuf::FieldDescriptorProto* FileDescriptorProto::mutable_extension(int index) { - // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.extension) - return extension_.Mutable(index); -} -::google::protobuf::FieldDescriptorProto* FileDescriptorProto::add_extension() { - // @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.extension) - return extension_.Add(); -} -::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >* -FileDescriptorProto::mutable_extension() { - // @@protoc_insertion_point(field_mutable_list:google.protobuf.FileDescriptorProto.extension) - return &extension_; -} -const ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >& -FileDescriptorProto::extension() const { - // @@protoc_insertion_point(field_list:google.protobuf.FileDescriptorProto.extension) - return extension_; -} +// =================================================================== -// optional .google.protobuf.FileOptions options = 8; -bool FileDescriptorProto::has_options() const { - return (_has_bits_[0] & 0x00000008u) != 0; +void DescriptorProto_ExtensionRange::InitAsDefaultInstance() { + ::google::protobuf::_DescriptorProto_ExtensionRange_default_instance_._instance.get_mutable()->options_ = const_cast< ::google::protobuf::ExtensionRangeOptions*>( + ::google::protobuf::ExtensionRangeOptions::internal_default_instance()); } -void FileDescriptorProto::set_has_options() { - _has_bits_[0] |= 0x00000008u; -} -void FileDescriptorProto::clear_has_options() { - _has_bits_[0] &= ~0x00000008u; -} -void FileDescriptorProto::clear_options() { - if (options_ != NULL) options_->::google::protobuf::FileOptions::Clear(); - clear_has_options(); -} -const ::google::protobuf::FileOptions& FileDescriptorProto::options() const { - // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.options) - return options_ != NULL ? *options_ - : *::google::protobuf::FileOptions::internal_default_instance(); -} -::google::protobuf::FileOptions* FileDescriptorProto::mutable_options() { - set_has_options(); - if (options_ == NULL) { - options_ = new ::google::protobuf::FileOptions; +void DescriptorProto_ExtensionRange::unsafe_arena_set_allocated_options( + ::google::protobuf::ExtensionRangeOptions* options) { + if (GetArenaNoVirtual() == NULL) { + delete options_; } - // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.options) - return options_; -} -::google::protobuf::FileOptions* FileDescriptorProto::release_options() { - // @@protoc_insertion_point(field_release:google.protobuf.FileDescriptorProto.options) - clear_has_options(); - ::google::protobuf::FileOptions* temp = options_; - options_ = NULL; - return temp; -} -void FileDescriptorProto::set_allocated_options(::google::protobuf::FileOptions* options) { - delete options_; options_ = options; if (options) { set_has_options(); } else { clear_has_options(); } - // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileDescriptorProto.options) -} - -// optional .google.protobuf.SourceCodeInfo source_code_info = 9; -bool FileDescriptorProto::has_source_code_info() const { - return (_has_bits_[0] & 0x00000010u) != 0; -} -void FileDescriptorProto::set_has_source_code_info() { - _has_bits_[0] |= 0x00000010u; + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.DescriptorProto.ExtensionRange.options) } -void FileDescriptorProto::clear_has_source_code_info() { - _has_bits_[0] &= ~0x00000010u; -} -void FileDescriptorProto::clear_source_code_info() { - if (source_code_info_ != NULL) source_code_info_->::google::protobuf::SourceCodeInfo::Clear(); - clear_has_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_ - : *::google::protobuf::SourceCodeInfo::internal_default_instance(); -} -::google::protobuf::SourceCodeInfo* FileDescriptorProto::mutable_source_code_info() { - set_has_source_code_info(); - if (source_code_info_ == NULL) { - source_code_info_ = new ::google::protobuf::SourceCodeInfo; - } - // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.source_code_info) - return source_code_info_; -} -::google::protobuf::SourceCodeInfo* FileDescriptorProto::release_source_code_info() { - // @@protoc_insertion_point(field_release:google.protobuf.FileDescriptorProto.source_code_info) - clear_has_source_code_info(); - ::google::protobuf::SourceCodeInfo* temp = source_code_info_; - source_code_info_ = NULL; - return temp; -} -void FileDescriptorProto::set_allocated_source_code_info(::google::protobuf::SourceCodeInfo* source_code_info) { - delete source_code_info_; - source_code_info_ = source_code_info; - if (source_code_info) { - set_has_source_code_info(); - } else { - clear_has_source_code_info(); - } - // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileDescriptorProto.source_code_info) -} - -// optional string syntax = 12; -bool FileDescriptorProto::has_syntax() const { - return (_has_bits_[0] & 0x00000004u) != 0; -} -void FileDescriptorProto::set_has_syntax() { - _has_bits_[0] |= 0x00000004u; -} -void FileDescriptorProto::clear_has_syntax() { - _has_bits_[0] &= ~0x00000004u; -} -void FileDescriptorProto::clear_syntax() { - syntax_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - clear_has_syntax(); -} -const ::std::string& FileDescriptorProto::syntax() const { - // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.syntax) - return syntax_.GetNoArena(); -} -void FileDescriptorProto::set_syntax(const ::std::string& value) { - set_has_syntax(); - syntax_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.syntax) -} -#if LANG_CXX11 -void FileDescriptorProto::set_syntax(::std::string&& value) { - set_has_syntax(); - syntax_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileDescriptorProto.syntax) -} -#endif -void FileDescriptorProto::set_syntax(const char* value) { - GOOGLE_DCHECK(value != NULL); - 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) { - set_has_syntax(); - syntax_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileDescriptorProto.syntax) -} -::std::string* FileDescriptorProto::mutable_syntax() { - set_has_syntax(); - // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.syntax) - return syntax_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -::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) { - if (syntax != NULL) { - set_has_syntax(); - } else { - clear_has_syntax(); - } - syntax_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), syntax); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileDescriptorProto.syntax) -} - -#endif // PROTOBUF_INLINE_NOT_IN_HEADERS - -// =================================================================== - #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int DescriptorProto_ExtensionRange::kStartFieldNumber; const int DescriptorProto_ExtensionRange::kEndFieldNumber; +const int DescriptorProto_ExtensionRange::kOptionsFieldNumber; #endif // !defined(_MSC_VER) || _MSC_VER >= 1900 DescriptorProto_ExtensionRange::DescriptorProto_ExtensionRange() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsDescriptorProto_ExtensionRange(); } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.DescriptorProto.ExtensionRange) } +DescriptorProto_ExtensionRange::DescriptorProto_ExtensionRange(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(), + _internal_metadata_(arena) { + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsDescriptorProto_ExtensionRange(); + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:google.protobuf.DescriptorProto.ExtensionRange) +} DescriptorProto_ExtensionRange::DescriptorProto_ExtensionRange(const DescriptorProto_ExtensionRange& from) : ::google::protobuf::Message(), _internal_metadata_(NULL), _has_bits_(from._has_bits_), _cached_size_(0) { _internal_metadata_.MergeFrom(from._internal_metadata_); + if (from.has_options()) { + options_ = new ::google::protobuf::ExtensionRangeOptions(*from.options_); + } else { + options_ = NULL; + } ::memcpy(&start_, &from.start_, - reinterpret_cast<char*>(&end_) - - reinterpret_cast<char*>(&start_) + sizeof(end_)); + static_cast<size_t>(reinterpret_cast<char*>(&end_) - + reinterpret_cast<char*>(&start_)) + sizeof(end_)); // @@protoc_insertion_point(copy_constructor:google.protobuf.DescriptorProto.ExtensionRange) } void DescriptorProto_ExtensionRange::SharedCtor() { _cached_size_ = 0; - ::memset(&start_, 0, reinterpret_cast<char*>(&end_) - - reinterpret_cast<char*>(&start_) + sizeof(end_)); + ::memset(&options_, 0, static_cast<size_t>( + reinterpret_cast<char*>(&end_) - + reinterpret_cast<char*>(&options_)) + sizeof(end_)); } DescriptorProto_ExtensionRange::~DescriptorProto_ExtensionRange() { @@ -2628,36 +2781,47 @@ DescriptorProto_ExtensionRange::~DescriptorProto_ExtensionRange() { } void DescriptorProto_ExtensionRange::SharedDtor() { + GOOGLE_DCHECK(GetArenaNoVirtual() == NULL); + if (this != internal_default_instance()) delete options_; } +void DescriptorProto_ExtensionRange::ArenaDtor(void* object) { + DescriptorProto_ExtensionRange* _this = reinterpret_cast< DescriptorProto_ExtensionRange* >(object); + (void)_this; +} +void DescriptorProto_ExtensionRange::RegisterArenaDtor(::google::protobuf::Arena* arena) { +} void DescriptorProto_ExtensionRange::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* DescriptorProto_ExtensionRange::descriptor() { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const DescriptorProto_ExtensionRange& DescriptorProto_ExtensionRange::default_instance() { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsDescriptorProto_ExtensionRange(); return *internal_default_instance(); } -DescriptorProto_ExtensionRange* DescriptorProto_ExtensionRange::New(::google::protobuf::Arena* arena) const { - DescriptorProto_ExtensionRange* n = new DescriptorProto_ExtensionRange; - if (arena != NULL) { - arena->Own(n); - } - return n; -} void DescriptorProto_ExtensionRange::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.DescriptorProto.ExtensionRange) - if (_has_bits_[0 / 32] & 3u) { - ::memset(&start_, 0, reinterpret_cast<char*>(&end_) - - reinterpret_cast<char*>(&start_) + sizeof(end_)); + ::google::protobuf::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + cached_has_bits = _has_bits_[0]; + if (cached_has_bits & 0x00000001u) { + GOOGLE_DCHECK(options_ != NULL); + options_->Clear(); + } + if (cached_has_bits & 6u) { + ::memset(&start_, 0, static_cast<size_t>( + reinterpret_cast<char*>(&end_) - + reinterpret_cast<char*>(&start_)) + sizeof(end_)); } _has_bits_.Clear(); _internal_metadata_.Clear(); @@ -2676,7 +2840,7 @@ bool DescriptorProto_ExtensionRange::MergePartialFromCodedStream( // optional int32 start = 1; case 1: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(8u)) { + static_cast< ::google::protobuf::uint8>(8u /* 8 & 0xFF */)) { set_has_start(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -2690,7 +2854,7 @@ bool DescriptorProto_ExtensionRange::MergePartialFromCodedStream( // optional int32 end = 2; case 2: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(16u)) { + static_cast< ::google::protobuf::uint8>(16u /* 16 & 0xFF */)) { set_has_end(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -2701,15 +2865,25 @@ bool DescriptorProto_ExtensionRange::MergePartialFromCodedStream( break; } + // optional .google.protobuf.ExtensionRangeOptions options = 3; + case 3: { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(26u /* 26 & 0xFF */)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( + input, mutable_options())); + } else { + goto handle_unusual; + } + break; + } + default: { handle_unusual: - if (tag == 0 || - ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + if (tag == 0) { goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); + input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } @@ -2731,42 +2905,56 @@ void DescriptorProto_ExtensionRange::SerializeWithCachedSizes( cached_has_bits = _has_bits_[0]; // optional int32 start = 1; - if (cached_has_bits & 0x00000001u) { + if (cached_has_bits & 0x00000002u) { ::google::protobuf::internal::WireFormatLite::WriteInt32(1, this->start(), output); } // optional int32 end = 2; - if (cached_has_bits & 0x00000002u) { + if (cached_has_bits & 0x00000004u) { ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->end(), output); } + // optional .google.protobuf.ExtensionRangeOptions options = 3; + if (cached_has_bits & 0x00000001u) { + ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( + 3, *options_, output); + } + if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); + _internal_metadata_.unknown_fields(), output); } // @@protoc_insertion_point(serialize_end:google.protobuf.DescriptorProto.ExtensionRange) } ::google::protobuf::uint8* DescriptorProto_ExtensionRange::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.DescriptorProto.ExtensionRange) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; cached_has_bits = _has_bits_[0]; // optional int32 start = 1; - if (cached_has_bits & 0x00000001u) { + if (cached_has_bits & 0x00000002u) { target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(1, this->start(), target); } // optional int32 end = 2; - if (cached_has_bits & 0x00000002u) { + if (cached_has_bits & 0x00000004u) { target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->end(), target); } + // optional .google.protobuf.ExtensionRangeOptions options = 3; + if (cached_has_bits & 0x00000001u) { + target = ::google::protobuf::internal::WireFormatLite:: + InternalWriteMessageToArray( + 3, *options_, deterministic, target); + } + if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); + _internal_metadata_.unknown_fields(), target); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.DescriptorProto.ExtensionRange) return target; @@ -2779,9 +2967,16 @@ size_t DescriptorProto_ExtensionRange::ByteSizeLong() const { if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); + _internal_metadata_.unknown_fields()); } - if (_has_bits_[0 / 32] & 3u) { + if (_has_bits_[0 / 32] & 7u) { + // optional .google.protobuf.ExtensionRangeOptions options = 3; + if (has_options()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::MessageSize( + *options_); + } + // optional int32 start = 1; if (has_start()) { total_size += 1 + @@ -2827,11 +3022,14 @@ void DescriptorProto_ExtensionRange::MergeFrom(const DescriptorProto_ExtensionRa (void) cached_has_bits; cached_has_bits = from._has_bits_[0]; - if (cached_has_bits & 3u) { + if (cached_has_bits & 7u) { if (cached_has_bits & 0x00000001u) { - start_ = from.start_; + mutable_options()->::google::protobuf::ExtensionRangeOptions::MergeFrom(from.options()); } if (cached_has_bits & 0x00000002u) { + start_ = from.start_; + } + if (cached_has_bits & 0x00000004u) { end_ = from.end_; } _has_bits_[0] |= cached_has_bits; @@ -2853,81 +3051,51 @@ void DescriptorProto_ExtensionRange::CopyFrom(const DescriptorProto_ExtensionRan } bool DescriptorProto_ExtensionRange::IsInitialized() const { + if (has_options()) { + if (!this->options_->IsInitialized()) return false; + } return true; } void DescriptorProto_ExtensionRange::Swap(DescriptorProto_ExtensionRange* other) { if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + DescriptorProto_ExtensionRange* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } + } +} +void DescriptorProto_ExtensionRange::UnsafeArenaSwap(DescriptorProto_ExtensionRange* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); InternalSwap(other); } void DescriptorProto_ExtensionRange::InternalSwap(DescriptorProto_ExtensionRange* other) { - std::swap(start_, other->start_); - std::swap(end_, other->end_); - std::swap(_has_bits_[0], other->_has_bits_[0]); + using std::swap; + swap(options_, other->options_); + swap(start_, other->start_); + swap(end_, other->end_); + swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); - std::swap(_cached_size_, other->_cached_size_); + swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata DescriptorProto_ExtensionRange::GetMetadata() const { protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages]; -} - -#if PROTOBUF_INLINE_NOT_IN_HEADERS -// DescriptorProto_ExtensionRange - -// optional int32 start = 1; -bool DescriptorProto_ExtensionRange::has_start() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -void DescriptorProto_ExtensionRange::set_has_start() { - _has_bits_[0] |= 0x00000001u; -} -void DescriptorProto_ExtensionRange::clear_has_start() { - _has_bits_[0] &= ~0x00000001u; -} -void DescriptorProto_ExtensionRange::clear_start() { - start_ = 0; - clear_has_start(); -} -::google::protobuf::int32 DescriptorProto_ExtensionRange::start() const { - // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.ExtensionRange.start) - return start_; -} -void DescriptorProto_ExtensionRange::set_start(::google::protobuf::int32 value) { - set_has_start(); - start_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.ExtensionRange.start) -} - -// optional int32 end = 2; -bool DescriptorProto_ExtensionRange::has_end() const { - return (_has_bits_[0] & 0x00000002u) != 0; -} -void DescriptorProto_ExtensionRange::set_has_end() { - _has_bits_[0] |= 0x00000002u; -} -void DescriptorProto_ExtensionRange::clear_has_end() { - _has_bits_[0] &= ~0x00000002u; -} -void DescriptorProto_ExtensionRange::clear_end() { - end_ = 0; - clear_has_end(); -} -::google::protobuf::int32 DescriptorProto_ExtensionRange::end() const { - // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.ExtensionRange.end) - return end_; -} -void DescriptorProto_ExtensionRange::set_end(::google::protobuf::int32 value) { - set_has_end(); - end_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.ExtensionRange.end) + return ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages]; } -#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== +void DescriptorProto_ReservedRange::InitAsDefaultInstance() { +} #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int DescriptorProto_ReservedRange::kStartFieldNumber; const int DescriptorProto_ReservedRange::kEndFieldNumber; @@ -2936,11 +3104,19 @@ const int DescriptorProto_ReservedRange::kEndFieldNumber; DescriptorProto_ReservedRange::DescriptorProto_ReservedRange() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsDescriptorProto_ReservedRange(); } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.DescriptorProto.ReservedRange) } +DescriptorProto_ReservedRange::DescriptorProto_ReservedRange(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(), + _internal_metadata_(arena) { + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsDescriptorProto_ReservedRange(); + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:google.protobuf.DescriptorProto.ReservedRange) +} DescriptorProto_ReservedRange::DescriptorProto_ReservedRange(const DescriptorProto_ReservedRange& from) : ::google::protobuf::Message(), _internal_metadata_(NULL), @@ -2948,15 +3124,16 @@ DescriptorProto_ReservedRange::DescriptorProto_ReservedRange(const DescriptorPro _cached_size_(0) { _internal_metadata_.MergeFrom(from._internal_metadata_); ::memcpy(&start_, &from.start_, - reinterpret_cast<char*>(&end_) - - reinterpret_cast<char*>(&start_) + sizeof(end_)); + static_cast<size_t>(reinterpret_cast<char*>(&end_) - + reinterpret_cast<char*>(&start_)) + sizeof(end_)); // @@protoc_insertion_point(copy_constructor:google.protobuf.DescriptorProto.ReservedRange) } void DescriptorProto_ReservedRange::SharedCtor() { _cached_size_ = 0; - ::memset(&start_, 0, reinterpret_cast<char*>(&end_) - - reinterpret_cast<char*>(&start_) + sizeof(end_)); + ::memset(&start_, 0, static_cast<size_t>( + reinterpret_cast<char*>(&end_) - + reinterpret_cast<char*>(&start_)) + sizeof(end_)); } DescriptorProto_ReservedRange::~DescriptorProto_ReservedRange() { @@ -2965,36 +3142,42 @@ DescriptorProto_ReservedRange::~DescriptorProto_ReservedRange() { } void DescriptorProto_ReservedRange::SharedDtor() { + GOOGLE_DCHECK(GetArenaNoVirtual() == NULL); } +void DescriptorProto_ReservedRange::ArenaDtor(void* object) { + DescriptorProto_ReservedRange* _this = reinterpret_cast< DescriptorProto_ReservedRange* >(object); + (void)_this; +} +void DescriptorProto_ReservedRange::RegisterArenaDtor(::google::protobuf::Arena* arena) { +} void DescriptorProto_ReservedRange::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* DescriptorProto_ReservedRange::descriptor() { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const DescriptorProto_ReservedRange& DescriptorProto_ReservedRange::default_instance() { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsDescriptorProto_ReservedRange(); return *internal_default_instance(); } -DescriptorProto_ReservedRange* DescriptorProto_ReservedRange::New(::google::protobuf::Arena* arena) const { - DescriptorProto_ReservedRange* n = new DescriptorProto_ReservedRange; - if (arena != NULL) { - arena->Own(n); - } - return n; -} void DescriptorProto_ReservedRange::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.DescriptorProto.ReservedRange) - if (_has_bits_[0 / 32] & 3u) { - ::memset(&start_, 0, reinterpret_cast<char*>(&end_) - - reinterpret_cast<char*>(&start_) + sizeof(end_)); + ::google::protobuf::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + cached_has_bits = _has_bits_[0]; + if (cached_has_bits & 3u) { + ::memset(&start_, 0, static_cast<size_t>( + reinterpret_cast<char*>(&end_) - + reinterpret_cast<char*>(&start_)) + sizeof(end_)); } _has_bits_.Clear(); _internal_metadata_.Clear(); @@ -3013,7 +3196,7 @@ bool DescriptorProto_ReservedRange::MergePartialFromCodedStream( // optional int32 start = 1; case 1: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(8u)) { + static_cast< ::google::protobuf::uint8>(8u /* 8 & 0xFF */)) { set_has_start(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -3027,7 +3210,7 @@ bool DescriptorProto_ReservedRange::MergePartialFromCodedStream( // optional int32 end = 2; case 2: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(16u)) { + static_cast< ::google::protobuf::uint8>(16u /* 16 & 0xFF */)) { set_has_end(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -3040,13 +3223,11 @@ bool DescriptorProto_ReservedRange::MergePartialFromCodedStream( default: { handle_unusual: - if (tag == 0 || - ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + if (tag == 0) { goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); + input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } @@ -3079,13 +3260,14 @@ void DescriptorProto_ReservedRange::SerializeWithCachedSizes( if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); + _internal_metadata_.unknown_fields(), output); } // @@protoc_insertion_point(serialize_end:google.protobuf.DescriptorProto.ReservedRange) } ::google::protobuf::uint8* DescriptorProto_ReservedRange::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.DescriptorProto.ReservedRange) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -3103,7 +3285,7 @@ void DescriptorProto_ReservedRange::SerializeWithCachedSizes( if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); + _internal_metadata_.unknown_fields(), target); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.DescriptorProto.ReservedRange) return target; @@ -3116,7 +3298,7 @@ size_t DescriptorProto_ReservedRange::ByteSizeLong() const { if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); + _internal_metadata_.unknown_fields()); } if (_has_bits_[0 / 32] & 3u) { // optional int32 start = 1; @@ -3195,76 +3377,57 @@ bool DescriptorProto_ReservedRange::IsInitialized() const { void DescriptorProto_ReservedRange::Swap(DescriptorProto_ReservedRange* other) { if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + DescriptorProto_ReservedRange* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } + } +} +void DescriptorProto_ReservedRange::UnsafeArenaSwap(DescriptorProto_ReservedRange* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); InternalSwap(other); } void DescriptorProto_ReservedRange::InternalSwap(DescriptorProto_ReservedRange* other) { - std::swap(start_, other->start_); - std::swap(end_, other->end_); - std::swap(_has_bits_[0], other->_has_bits_[0]); + using std::swap; + swap(start_, other->start_); + swap(end_, other->end_); + swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); - std::swap(_cached_size_, other->_cached_size_); + swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata DescriptorProto_ReservedRange::GetMetadata() const { protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages]; + return ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages]; } -#if PROTOBUF_INLINE_NOT_IN_HEADERS -// DescriptorProto_ReservedRange -// optional int32 start = 1; -bool DescriptorProto_ReservedRange::has_start() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -void DescriptorProto_ReservedRange::set_has_start() { - _has_bits_[0] |= 0x00000001u; -} -void DescriptorProto_ReservedRange::clear_has_start() { - _has_bits_[0] &= ~0x00000001u; -} -void DescriptorProto_ReservedRange::clear_start() { - start_ = 0; - clear_has_start(); -} -::google::protobuf::int32 DescriptorProto_ReservedRange::start() const { - // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.ReservedRange.start) - return start_; -} -void DescriptorProto_ReservedRange::set_start(::google::protobuf::int32 value) { - set_has_start(); - start_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.ReservedRange.start) -} +// =================================================================== -// optional int32 end = 2; -bool DescriptorProto_ReservedRange::has_end() const { - return (_has_bits_[0] & 0x00000002u) != 0; -} -void DescriptorProto_ReservedRange::set_has_end() { - _has_bits_[0] |= 0x00000002u; -} -void DescriptorProto_ReservedRange::clear_has_end() { - _has_bits_[0] &= ~0x00000002u; -} -void DescriptorProto_ReservedRange::clear_end() { - end_ = 0; - clear_has_end(); -} -::google::protobuf::int32 DescriptorProto_ReservedRange::end() const { - // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.ReservedRange.end) - return end_; +void DescriptorProto::InitAsDefaultInstance() { + ::google::protobuf::_DescriptorProto_default_instance_._instance.get_mutable()->options_ = const_cast< ::google::protobuf::MessageOptions*>( + ::google::protobuf::MessageOptions::internal_default_instance()); } -void DescriptorProto_ReservedRange::set_end(::google::protobuf::int32 value) { - set_has_end(); - end_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.ReservedRange.end) +void DescriptorProto::unsafe_arena_set_allocated_options( + ::google::protobuf::MessageOptions* options) { + if (GetArenaNoVirtual() == NULL) { + delete options_; + } + options_ = options; + if (options) { + set_has_options(); + } else { + clear_has_options(); + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.DescriptorProto.options) } - -#endif // PROTOBUF_INLINE_NOT_IN_HEADERS - -// =================================================================== - #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int DescriptorProto::kNameFieldNumber; const int DescriptorProto::kFieldFieldNumber; @@ -3281,11 +3444,27 @@ const int DescriptorProto::kReservedNameFieldNumber; DescriptorProto::DescriptorProto() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsDescriptorProto(); } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.DescriptorProto) } +DescriptorProto::DescriptorProto(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(), + _internal_metadata_(arena), + field_(arena), + nested_type_(arena), + enum_type_(arena), + extension_range_(arena), + extension_(arena), + oneof_decl_(arena), + reserved_range_(arena), + reserved_name_(arena) { + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsDescriptorProto(); + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:google.protobuf.DescriptorProto) +} DescriptorProto::DescriptorProto(const DescriptorProto& from) : ::google::protobuf::Message(), _internal_metadata_(NULL), @@ -3302,7 +3481,8 @@ DescriptorProto::DescriptorProto(const DescriptorProto& from) _internal_metadata_.MergeFrom(from._internal_metadata_); name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); if (from.has_name()) { - name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name(), + GetArenaNoVirtual()); } if (from.has_options()) { options_ = new ::google::protobuf::MessageOptions(*from.options_); @@ -3324,37 +3504,39 @@ DescriptorProto::~DescriptorProto() { } void DescriptorProto::SharedDtor() { + GOOGLE_DCHECK(GetArenaNoVirtual() == NULL); name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != internal_default_instance()) { - delete options_; - } + if (this != internal_default_instance()) delete options_; } +void DescriptorProto::ArenaDtor(void* object) { + DescriptorProto* _this = reinterpret_cast< DescriptorProto* >(object); + (void)_this; +} +void DescriptorProto::RegisterArenaDtor(::google::protobuf::Arena* arena) { +} void DescriptorProto::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* DescriptorProto::descriptor() { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const DescriptorProto& DescriptorProto::default_instance() { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsDescriptorProto(); return *internal_default_instance(); } -DescriptorProto* DescriptorProto::New(::google::protobuf::Arena* arena) const { - DescriptorProto* n = new DescriptorProto; - if (arena != NULL) { - arena->Own(n); - } - return n; -} void DescriptorProto::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.DescriptorProto) + ::google::protobuf::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + field_.Clear(); nested_type_.Clear(); enum_type_.Clear(); @@ -3363,14 +3545,15 @@ void DescriptorProto::Clear() { oneof_decl_.Clear(); reserved_range_.Clear(); reserved_name_.Clear(); - if (_has_bits_[0 / 32] & 3u) { - if (has_name()) { + cached_has_bits = _has_bits_[0]; + if (cached_has_bits & 3u) { + if (cached_has_bits & 0x00000001u) { GOOGLE_DCHECK(!name_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); - (*name_.UnsafeRawStringPointer())->clear(); + name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - if (has_options()) { + if (cached_has_bits & 0x00000002u) { GOOGLE_DCHECK(options_ != NULL); - options_->::google::protobuf::MessageOptions::Clear(); + options_->Clear(); } } _has_bits_.Clear(); @@ -3390,11 +3573,11 @@ bool DescriptorProto::MergePartialFromCodedStream( // optional string name = 1; case 1: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(10u)) { + static_cast< ::google::protobuf::uint8>(10u /* 10 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->name().data(), this->name().length(), + this->name().data(), static_cast<int>(this->name().length()), ::google::protobuf::internal::WireFormat::PARSE, "google.protobuf.DescriptorProto.name"); } else { @@ -3406,8 +3589,8 @@ bool DescriptorProto::MergePartialFromCodedStream( // repeated .google.protobuf.FieldDescriptorProto field = 2; case 2: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(18u)) { - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + static_cast< ::google::protobuf::uint8>(18u /* 18 & 0xFF */)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, add_field())); } else { goto handle_unusual; @@ -3418,8 +3601,8 @@ bool DescriptorProto::MergePartialFromCodedStream( // repeated .google.protobuf.DescriptorProto nested_type = 3; case 3: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(26u)) { - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + static_cast< ::google::protobuf::uint8>(26u /* 26 & 0xFF */)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, add_nested_type())); } else { goto handle_unusual; @@ -3430,8 +3613,8 @@ bool DescriptorProto::MergePartialFromCodedStream( // repeated .google.protobuf.EnumDescriptorProto enum_type = 4; case 4: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(34u)) { - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + static_cast< ::google::protobuf::uint8>(34u /* 34 & 0xFF */)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, add_enum_type())); } else { goto handle_unusual; @@ -3442,8 +3625,8 @@ bool DescriptorProto::MergePartialFromCodedStream( // repeated .google.protobuf.DescriptorProto.ExtensionRange extension_range = 5; case 5: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(42u)) { - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + static_cast< ::google::protobuf::uint8>(42u /* 42 & 0xFF */)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, add_extension_range())); } else { goto handle_unusual; @@ -3454,8 +3637,8 @@ bool DescriptorProto::MergePartialFromCodedStream( // repeated .google.protobuf.FieldDescriptorProto extension = 6; case 6: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(50u)) { - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + static_cast< ::google::protobuf::uint8>(50u /* 50 & 0xFF */)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, add_extension())); } else { goto handle_unusual; @@ -3466,8 +3649,8 @@ bool DescriptorProto::MergePartialFromCodedStream( // optional .google.protobuf.MessageOptions options = 7; case 7: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(58u)) { - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + static_cast< ::google::protobuf::uint8>(58u /* 58 & 0xFF */)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, mutable_options())); } else { goto handle_unusual; @@ -3478,8 +3661,8 @@ bool DescriptorProto::MergePartialFromCodedStream( // repeated .google.protobuf.OneofDescriptorProto oneof_decl = 8; case 8: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(66u)) { - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + static_cast< ::google::protobuf::uint8>(66u /* 66 & 0xFF */)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, add_oneof_decl())); } else { goto handle_unusual; @@ -3490,8 +3673,8 @@ bool DescriptorProto::MergePartialFromCodedStream( // repeated .google.protobuf.DescriptorProto.ReservedRange reserved_range = 9; case 9: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(74u)) { - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + static_cast< ::google::protobuf::uint8>(74u /* 74 & 0xFF */)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, add_reserved_range())); } else { goto handle_unusual; @@ -3502,12 +3685,12 @@ bool DescriptorProto::MergePartialFromCodedStream( // repeated string reserved_name = 10; case 10: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(82u)) { + static_cast< ::google::protobuf::uint8>(82u /* 82 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->add_reserved_name())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->reserved_name(this->reserved_name_size() - 1).data(), - this->reserved_name(this->reserved_name_size() - 1).length(), + static_cast<int>(this->reserved_name(this->reserved_name_size() - 1).length()), ::google::protobuf::internal::WireFormat::PARSE, "google.protobuf.DescriptorProto.reserved_name"); } else { @@ -3518,13 +3701,11 @@ bool DescriptorProto::MergePartialFromCodedStream( default: { handle_unusual: - if (tag == 0 || - ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + if (tag == 0) { goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); + input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } @@ -3548,7 +3729,7 @@ void DescriptorProto::SerializeWithCachedSizes( // optional string name = 1; if (cached_has_bits & 0x00000001u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->name().data(), this->name().length(), + this->name().data(), static_cast<int>(this->name().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.DescriptorProto.name"); ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( @@ -3556,57 +3737,78 @@ void DescriptorProto::SerializeWithCachedSizes( } // repeated .google.protobuf.FieldDescriptorProto field = 2; - for (unsigned int i = 0, n = this->field_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->field_size()); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 2, this->field(i), output); + 2, + this->field(static_cast<int>(i)), + output); } // repeated .google.protobuf.DescriptorProto nested_type = 3; - for (unsigned int i = 0, n = this->nested_type_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->nested_type_size()); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 3, this->nested_type(i), output); + 3, + this->nested_type(static_cast<int>(i)), + output); } // repeated .google.protobuf.EnumDescriptorProto enum_type = 4; - for (unsigned int i = 0, n = this->enum_type_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->enum_type_size()); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 4, this->enum_type(i), output); + 4, + this->enum_type(static_cast<int>(i)), + output); } // repeated .google.protobuf.DescriptorProto.ExtensionRange extension_range = 5; - for (unsigned int i = 0, n = this->extension_range_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->extension_range_size()); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 5, this->extension_range(i), output); + 5, + this->extension_range(static_cast<int>(i)), + output); } // repeated .google.protobuf.FieldDescriptorProto extension = 6; - for (unsigned int i = 0, n = this->extension_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->extension_size()); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 6, this->extension(i), output); + 6, + this->extension(static_cast<int>(i)), + output); } // optional .google.protobuf.MessageOptions options = 7; if (cached_has_bits & 0x00000002u) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 7, *this->options_, output); + 7, *options_, output); } // repeated .google.protobuf.OneofDescriptorProto oneof_decl = 8; - for (unsigned int i = 0, n = this->oneof_decl_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->oneof_decl_size()); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 8, this->oneof_decl(i), output); + 8, + this->oneof_decl(static_cast<int>(i)), + output); } // repeated .google.protobuf.DescriptorProto.ReservedRange reserved_range = 9; - for (unsigned int i = 0, n = this->reserved_range_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->reserved_range_size()); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 9, this->reserved_range(i), output); + 9, + this->reserved_range(static_cast<int>(i)), + output); } // repeated string reserved_name = 10; for (int i = 0, n = this->reserved_name_size(); i < n; i++) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->reserved_name(i).data(), this->reserved_name(i).length(), + this->reserved_name(i).data(), static_cast<int>(this->reserved_name(i).length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.DescriptorProto.reserved_name"); ::google::protobuf::internal::WireFormatLite::WriteString( @@ -3615,13 +3817,14 @@ void DescriptorProto::SerializeWithCachedSizes( if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); + _internal_metadata_.unknown_fields(), output); } // @@protoc_insertion_point(serialize_end:google.protobuf.DescriptorProto) } ::google::protobuf::uint8* DescriptorProto::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.DescriptorProto) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -3630,7 +3833,7 @@ void DescriptorProto::SerializeWithCachedSizes( // optional string name = 1; if (cached_has_bits & 0x00000001u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->name().data(), this->name().length(), + this->name().data(), static_cast<int>(this->name().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.DescriptorProto.name"); target = @@ -3639,65 +3842,72 @@ void DescriptorProto::SerializeWithCachedSizes( } // repeated .google.protobuf.FieldDescriptorProto field = 2; - for (unsigned int i = 0, n = this->field_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->field_size()); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: - InternalWriteMessageNoVirtualToArray( - 2, this->field(i), deterministic, target); + InternalWriteMessageToArray( + 2, this->field(static_cast<int>(i)), deterministic, target); } // repeated .google.protobuf.DescriptorProto nested_type = 3; - for (unsigned int i = 0, n = this->nested_type_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->nested_type_size()); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: - InternalWriteMessageNoVirtualToArray( - 3, this->nested_type(i), deterministic, target); + InternalWriteMessageToArray( + 3, this->nested_type(static_cast<int>(i)), deterministic, target); } // repeated .google.protobuf.EnumDescriptorProto enum_type = 4; - for (unsigned int i = 0, n = this->enum_type_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->enum_type_size()); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: - InternalWriteMessageNoVirtualToArray( - 4, this->enum_type(i), deterministic, target); + InternalWriteMessageToArray( + 4, this->enum_type(static_cast<int>(i)), deterministic, target); } // repeated .google.protobuf.DescriptorProto.ExtensionRange extension_range = 5; - for (unsigned int i = 0, n = this->extension_range_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->extension_range_size()); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: - InternalWriteMessageNoVirtualToArray( - 5, this->extension_range(i), deterministic, target); + InternalWriteMessageToArray( + 5, this->extension_range(static_cast<int>(i)), deterministic, target); } // repeated .google.protobuf.FieldDescriptorProto extension = 6; - for (unsigned int i = 0, n = this->extension_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->extension_size()); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: - InternalWriteMessageNoVirtualToArray( - 6, this->extension(i), deterministic, target); + InternalWriteMessageToArray( + 6, this->extension(static_cast<int>(i)), deterministic, target); } // optional .google.protobuf.MessageOptions options = 7; if (cached_has_bits & 0x00000002u) { target = ::google::protobuf::internal::WireFormatLite:: - InternalWriteMessageNoVirtualToArray( - 7, *this->options_, deterministic, target); + InternalWriteMessageToArray( + 7, *options_, deterministic, target); } // repeated .google.protobuf.OneofDescriptorProto oneof_decl = 8; - for (unsigned int i = 0, n = this->oneof_decl_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->oneof_decl_size()); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: - InternalWriteMessageNoVirtualToArray( - 8, this->oneof_decl(i), deterministic, target); + InternalWriteMessageToArray( + 8, this->oneof_decl(static_cast<int>(i)), deterministic, target); } // repeated .google.protobuf.DescriptorProto.ReservedRange reserved_range = 9; - for (unsigned int i = 0, n = this->reserved_range_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->reserved_range_size()); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: - InternalWriteMessageNoVirtualToArray( - 9, this->reserved_range(i), deterministic, target); + InternalWriteMessageToArray( + 9, this->reserved_range(static_cast<int>(i)), deterministic, target); } // repeated string reserved_name = 10; for (int i = 0, n = this->reserved_name_size(); i < n; i++) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->reserved_name(i).data(), this->reserved_name(i).length(), + this->reserved_name(i).data(), static_cast<int>(this->reserved_name(i).length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.DescriptorProto.reserved_name"); target = ::google::protobuf::internal::WireFormatLite:: @@ -3706,7 +3916,7 @@ void DescriptorProto::SerializeWithCachedSizes( if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); + _internal_metadata_.unknown_fields(), target); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.DescriptorProto) return target; @@ -3719,82 +3929,82 @@ size_t DescriptorProto::ByteSizeLong() const { if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); + _internal_metadata_.unknown_fields()); } // repeated .google.protobuf.FieldDescriptorProto field = 2; { - unsigned int count = this->field_size(); + unsigned int count = static_cast<unsigned int>(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)); + ::google::protobuf::internal::WireFormatLite::MessageSize( + this->field(static_cast<int>(i))); } } // repeated .google.protobuf.DescriptorProto nested_type = 3; { - unsigned int count = this->nested_type_size(); + unsigned int count = static_cast<unsigned int>(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)); + ::google::protobuf::internal::WireFormatLite::MessageSize( + this->nested_type(static_cast<int>(i))); } } // repeated .google.protobuf.EnumDescriptorProto enum_type = 4; { - unsigned int count = this->enum_type_size(); + unsigned int count = static_cast<unsigned int>(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)); + ::google::protobuf::internal::WireFormatLite::MessageSize( + this->enum_type(static_cast<int>(i))); } } // repeated .google.protobuf.DescriptorProto.ExtensionRange extension_range = 5; { - unsigned int count = this->extension_range_size(); + unsigned int count = static_cast<unsigned int>(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)); + ::google::protobuf::internal::WireFormatLite::MessageSize( + this->extension_range(static_cast<int>(i))); } } // repeated .google.protobuf.FieldDescriptorProto extension = 6; { - unsigned int count = this->extension_size(); + unsigned int count = static_cast<unsigned int>(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)); + ::google::protobuf::internal::WireFormatLite::MessageSize( + this->extension(static_cast<int>(i))); } } // repeated .google.protobuf.OneofDescriptorProto oneof_decl = 8; { - unsigned int count = this->oneof_decl_size(); + unsigned int count = static_cast<unsigned int>(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)); + ::google::protobuf::internal::WireFormatLite::MessageSize( + this->oneof_decl(static_cast<int>(i))); } } // repeated .google.protobuf.DescriptorProto.ReservedRange reserved_range = 9; { - unsigned int count = this->reserved_range_size(); + unsigned int count = static_cast<unsigned int>(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)); + ::google::protobuf::internal::WireFormatLite::MessageSize( + this->reserved_range(static_cast<int>(i))); } } @@ -3817,8 +4027,8 @@ size_t DescriptorProto::ByteSizeLong() const { // optional .google.protobuf.MessageOptions options = 7; if (has_options()) { total_size += 1 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - *this->options_); + ::google::protobuf::internal::WireFormatLite::MessageSize( + *options_); } } @@ -3862,8 +4072,7 @@ void DescriptorProto::MergeFrom(const DescriptorProto& from) { cached_has_bits = from._has_bits_[0]; if (cached_has_bits & 3u) { if (cached_has_bits & 0x00000001u) { - set_has_name(); - name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); + set_name(from.name()); } if (cached_has_bits & 0x00000002u) { mutable_options()->::google::protobuf::MessageOptions::MergeFrom(from.options()); @@ -3889,6 +4098,7 @@ bool DescriptorProto::IsInitialized() const { if (!::google::protobuf::internal::AllAreInitialized(this->field())) return false; if (!::google::protobuf::internal::AllAreInitialized(this->nested_type())) return false; if (!::google::protobuf::internal::AllAreInitialized(this->enum_type())) return false; + if (!::google::protobuf::internal::AllAreInitialized(this->extension_range())) return false; if (!::google::protobuf::internal::AllAreInitialized(this->extension())) return false; if (!::google::protobuf::internal::AllAreInitialized(this->oneof_decl())) return false; if (has_options()) { @@ -3899,423 +4109,362 @@ bool DescriptorProto::IsInitialized() const { void DescriptorProto::Swap(DescriptorProto* other) { if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + DescriptorProto* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } + } +} +void DescriptorProto::UnsafeArenaSwap(DescriptorProto* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); InternalSwap(other); } void DescriptorProto::InternalSwap(DescriptorProto* other) { - field_.InternalSwap(&other->field_); - nested_type_.InternalSwap(&other->nested_type_); - enum_type_.InternalSwap(&other->enum_type_); - extension_range_.InternalSwap(&other->extension_range_); - extension_.InternalSwap(&other->extension_); - oneof_decl_.InternalSwap(&other->oneof_decl_); - reserved_range_.InternalSwap(&other->reserved_range_); - reserved_name_.InternalSwap(&other->reserved_name_); + using std::swap; + CastToBase(&field_)->InternalSwap(CastToBase(&other->field_)); + CastToBase(&nested_type_)->InternalSwap(CastToBase(&other->nested_type_)); + CastToBase(&enum_type_)->InternalSwap(CastToBase(&other->enum_type_)); + CastToBase(&extension_range_)->InternalSwap(CastToBase(&other->extension_range_)); + CastToBase(&extension_)->InternalSwap(CastToBase(&other->extension_)); + CastToBase(&oneof_decl_)->InternalSwap(CastToBase(&other->oneof_decl_)); + CastToBase(&reserved_range_)->InternalSwap(CastToBase(&other->reserved_range_)); + reserved_name_.InternalSwap(CastToBase(&other->reserved_name_)); name_.Swap(&other->name_); - std::swap(options_, other->options_); - std::swap(_has_bits_[0], other->_has_bits_[0]); + swap(options_, other->options_); + swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); - std::swap(_cached_size_, other->_cached_size_); + swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata DescriptorProto::GetMetadata() const { protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages]; + return ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages]; } -#if PROTOBUF_INLINE_NOT_IN_HEADERS -// DescriptorProto -// optional string name = 1; -bool DescriptorProto::has_name() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -void DescriptorProto::set_has_name() { - _has_bits_[0] |= 0x00000001u; -} -void DescriptorProto::clear_has_name() { - _has_bits_[0] &= ~0x00000001u; -} -void DescriptorProto::clear_name() { - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - clear_has_name(); -} -const ::std::string& DescriptorProto::name() const { - // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.name) - return name_.GetNoArena(); -} -void DescriptorProto::set_name(const ::std::string& value) { - set_has_name(); - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.name) -} -#if LANG_CXX11 -void DescriptorProto::set_name(::std::string&& value) { - set_has_name(); - name_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.DescriptorProto.name) -} -#endif -void DescriptorProto::set_name(const char* value) { - GOOGLE_DCHECK(value != NULL); - 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) { - set_has_name(); - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.DescriptorProto.name) -} -::std::string* DescriptorProto::mutable_name() { - set_has_name(); - // @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.name) - return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -::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) { - if (name != NULL) { - set_has_name(); - } else { - clear_has_name(); - } - name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.DescriptorProto.name) -} +// =================================================================== -// repeated .google.protobuf.FieldDescriptorProto field = 2; -int DescriptorProto::field_size() const { - return field_.size(); -} -void DescriptorProto::clear_field() { - field_.Clear(); -} -const ::google::protobuf::FieldDescriptorProto& DescriptorProto::field(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.field) - return field_.Get(index); -} -::google::protobuf::FieldDescriptorProto* DescriptorProto::mutable_field(int index) { - // @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.field) - return field_.Mutable(index); -} -::google::protobuf::FieldDescriptorProto* DescriptorProto::add_field() { - // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.field) - return field_.Add(); -} -::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >* -DescriptorProto::mutable_field() { - // @@protoc_insertion_point(field_mutable_list:google.protobuf.DescriptorProto.field) - return &field_; -} -const ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >& -DescriptorProto::field() const { - // @@protoc_insertion_point(field_list:google.protobuf.DescriptorProto.field) - return field_; +void ExtensionRangeOptions::InitAsDefaultInstance() { } +#if !defined(_MSC_VER) || _MSC_VER >= 1900 +const int ExtensionRangeOptions::kUninterpretedOptionFieldNumber; +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 -// repeated .google.protobuf.FieldDescriptorProto extension = 6; -int DescriptorProto::extension_size() const { - return extension_.size(); -} -void DescriptorProto::clear_extension() { - extension_.Clear(); -} -const ::google::protobuf::FieldDescriptorProto& DescriptorProto::extension(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.extension) - return extension_.Get(index); -} -::google::protobuf::FieldDescriptorProto* DescriptorProto::mutable_extension(int index) { - // @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.extension) - return extension_.Mutable(index); -} -::google::protobuf::FieldDescriptorProto* DescriptorProto::add_extension() { - // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.extension) - return extension_.Add(); +ExtensionRangeOptions::ExtensionRangeOptions() + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsExtensionRangeOptions(); + } + SharedCtor(); + // @@protoc_insertion_point(constructor:google.protobuf.ExtensionRangeOptions) } -::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >* -DescriptorProto::mutable_extension() { - // @@protoc_insertion_point(field_mutable_list:google.protobuf.DescriptorProto.extension) - return &extension_; +ExtensionRangeOptions::ExtensionRangeOptions(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(), + _extensions_(arena), + _internal_metadata_(arena), + uninterpreted_option_(arena) { + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsExtensionRangeOptions(); + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:google.protobuf.ExtensionRangeOptions) } -const ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >& -DescriptorProto::extension() const { - // @@protoc_insertion_point(field_list:google.protobuf.DescriptorProto.extension) - return extension_; +ExtensionRangeOptions::ExtensionRangeOptions(const ExtensionRangeOptions& from) + : ::google::protobuf::Message(), + _internal_metadata_(NULL), + _has_bits_(from._has_bits_), + _cached_size_(0), + uninterpreted_option_(from.uninterpreted_option_) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + _extensions_.MergeFrom(from._extensions_); + // @@protoc_insertion_point(copy_constructor:google.protobuf.ExtensionRangeOptions) } -// repeated .google.protobuf.DescriptorProto nested_type = 3; -int DescriptorProto::nested_type_size() const { - return nested_type_.size(); -} -void DescriptorProto::clear_nested_type() { - nested_type_.Clear(); -} -const ::google::protobuf::DescriptorProto& DescriptorProto::nested_type(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.nested_type) - return nested_type_.Get(index); -} -::google::protobuf::DescriptorProto* DescriptorProto::mutable_nested_type(int index) { - // @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.nested_type) - return nested_type_.Mutable(index); -} -::google::protobuf::DescriptorProto* DescriptorProto::add_nested_type() { - // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.nested_type) - return nested_type_.Add(); -} -::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto >* -DescriptorProto::mutable_nested_type() { - // @@protoc_insertion_point(field_mutable_list:google.protobuf.DescriptorProto.nested_type) - return &nested_type_; -} -const ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto >& -DescriptorProto::nested_type() const { - // @@protoc_insertion_point(field_list:google.protobuf.DescriptorProto.nested_type) - return nested_type_; +void ExtensionRangeOptions::SharedCtor() { + _cached_size_ = 0; } -// repeated .google.protobuf.EnumDescriptorProto enum_type = 4; -int DescriptorProto::enum_type_size() const { - return enum_type_.size(); -} -void DescriptorProto::clear_enum_type() { - enum_type_.Clear(); -} -const ::google::protobuf::EnumDescriptorProto& DescriptorProto::enum_type(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.enum_type) - return enum_type_.Get(index); -} -::google::protobuf::EnumDescriptorProto* DescriptorProto::mutable_enum_type(int index) { - // @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.enum_type) - return enum_type_.Mutable(index); -} -::google::protobuf::EnumDescriptorProto* DescriptorProto::add_enum_type() { - // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.enum_type) - return enum_type_.Add(); -} -::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumDescriptorProto >* -DescriptorProto::mutable_enum_type() { - // @@protoc_insertion_point(field_mutable_list:google.protobuf.DescriptorProto.enum_type) - return &enum_type_; -} -const ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumDescriptorProto >& -DescriptorProto::enum_type() const { - // @@protoc_insertion_point(field_list:google.protobuf.DescriptorProto.enum_type) - return enum_type_; +ExtensionRangeOptions::~ExtensionRangeOptions() { + // @@protoc_insertion_point(destructor:google.protobuf.ExtensionRangeOptions) + SharedDtor(); } -// repeated .google.protobuf.DescriptorProto.ExtensionRange extension_range = 5; -int DescriptorProto::extension_range_size() const { - return extension_range_.size(); -} -void DescriptorProto::clear_extension_range() { - extension_range_.Clear(); -} -const ::google::protobuf::DescriptorProto_ExtensionRange& DescriptorProto::extension_range(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.extension_range) - return extension_range_.Get(index); -} -::google::protobuf::DescriptorProto_ExtensionRange* DescriptorProto::mutable_extension_range(int index) { - // @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.extension_range) - return extension_range_.Mutable(index); -} -::google::protobuf::DescriptorProto_ExtensionRange* DescriptorProto::add_extension_range() { - // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.extension_range) - return extension_range_.Add(); -} -::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto_ExtensionRange >* -DescriptorProto::mutable_extension_range() { - // @@protoc_insertion_point(field_mutable_list:google.protobuf.DescriptorProto.extension_range) - return &extension_range_; -} -const ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto_ExtensionRange >& -DescriptorProto::extension_range() const { - // @@protoc_insertion_point(field_list:google.protobuf.DescriptorProto.extension_range) - return extension_range_; +void ExtensionRangeOptions::SharedDtor() { + GOOGLE_DCHECK(GetArenaNoVirtual() == NULL); } -// repeated .google.protobuf.OneofDescriptorProto oneof_decl = 8; -int DescriptorProto::oneof_decl_size() const { - return oneof_decl_.size(); +void ExtensionRangeOptions::ArenaDtor(void* object) { + ExtensionRangeOptions* _this = reinterpret_cast< ExtensionRangeOptions* >(object); + (void)_this; } -void DescriptorProto::clear_oneof_decl() { - oneof_decl_.Clear(); -} -const ::google::protobuf::OneofDescriptorProto& DescriptorProto::oneof_decl(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.oneof_decl) - return oneof_decl_.Get(index); -} -::google::protobuf::OneofDescriptorProto* DescriptorProto::mutable_oneof_decl(int index) { - // @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.oneof_decl) - return oneof_decl_.Mutable(index); +void ExtensionRangeOptions::RegisterArenaDtor(::google::protobuf::Arena* arena) { } -::google::protobuf::OneofDescriptorProto* DescriptorProto::add_oneof_decl() { - // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.oneof_decl) - return oneof_decl_.Add(); -} -::google::protobuf::RepeatedPtrField< ::google::protobuf::OneofDescriptorProto >* -DescriptorProto::mutable_oneof_decl() { - // @@protoc_insertion_point(field_mutable_list:google.protobuf.DescriptorProto.oneof_decl) - return &oneof_decl_; +void ExtensionRangeOptions::SetCachedSize(int size) const { + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); } -const ::google::protobuf::RepeatedPtrField< ::google::protobuf::OneofDescriptorProto >& -DescriptorProto::oneof_decl() const { - // @@protoc_insertion_point(field_list:google.protobuf.DescriptorProto.oneof_decl) - return oneof_decl_; +const ::google::protobuf::Descriptor* ExtensionRangeOptions::descriptor() { + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } -// optional .google.protobuf.MessageOptions options = 7; -bool DescriptorProto::has_options() const { - return (_has_bits_[0] & 0x00000002u) != 0; -} -void DescriptorProto::set_has_options() { - _has_bits_[0] |= 0x00000002u; +const ExtensionRangeOptions& ExtensionRangeOptions::default_instance() { + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsExtensionRangeOptions(); + return *internal_default_instance(); } -void DescriptorProto::clear_has_options() { - _has_bits_[0] &= ~0x00000002u; + + +void ExtensionRangeOptions::Clear() { +// @@protoc_insertion_point(message_clear_start:google.protobuf.ExtensionRangeOptions) + ::google::protobuf::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + _extensions_.Clear(); + uninterpreted_option_.Clear(); + _has_bits_.Clear(); + _internal_metadata_.Clear(); } -void DescriptorProto::clear_options() { - if (options_ != NULL) options_->::google::protobuf::MessageOptions::Clear(); - clear_has_options(); + +bool ExtensionRangeOptions::MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input) { +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure + ::google::protobuf::uint32 tag; + // @@protoc_insertion_point(parse_start:google.protobuf.ExtensionRangeOptions) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(16383u); + tag = p.first; + if (!p.second) goto handle_unusual; + switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { + // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; + case 999: { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(58u /* 7994 & 0xFF */)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( + input, add_uninterpreted_option())); + } else { + goto handle_unusual; + } + break; + } + + default: { + handle_unusual: + if (tag == 0) { + goto success; + } + if ((8000u <= tag)) { + DO_(_extensions_.ParseField(tag, input, + internal_default_instance(), + _internal_metadata_.mutable_unknown_fields())); + continue; + } + DO_(::google::protobuf::internal::WireFormat::SkipField( + input, tag, _internal_metadata_.mutable_unknown_fields())); + break; + } + } + } +success: + // @@protoc_insertion_point(parse_success:google.protobuf.ExtensionRangeOptions) + return true; +failure: + // @@protoc_insertion_point(parse_failure:google.protobuf.ExtensionRangeOptions) + return false; +#undef DO_ } -const ::google::protobuf::MessageOptions& DescriptorProto::options() const { - // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.options) - return options_ != NULL ? *options_ - : *::google::protobuf::MessageOptions::internal_default_instance(); + +void ExtensionRangeOptions::SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:google.protobuf.ExtensionRangeOptions) + ::google::protobuf::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->uninterpreted_option_size()); i < n; i++) { + ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( + 999, + this->uninterpreted_option(static_cast<int>(i)), + output); + } + + // Extension range [1000, 536870912) + _extensions_.SerializeWithCachedSizes( + 1000, 536870912, output); + + if (_internal_metadata_.have_unknown_fields()) { + ::google::protobuf::internal::WireFormat::SerializeUnknownFields( + _internal_metadata_.unknown_fields(), output); + } + // @@protoc_insertion_point(serialize_end:google.protobuf.ExtensionRangeOptions) } -::google::protobuf::MessageOptions* DescriptorProto::mutable_options() { - set_has_options(); - if (options_ == NULL) { - options_ = new ::google::protobuf::MessageOptions; + +::google::protobuf::uint8* ExtensionRangeOptions::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.ExtensionRangeOptions) + ::google::protobuf::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->uninterpreted_option_size()); i < n; i++) { + target = ::google::protobuf::internal::WireFormatLite:: + InternalWriteMessageToArray( + 999, this->uninterpreted_option(static_cast<int>(i)), deterministic, target); } - // @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.options) - return options_; + + // Extension range [1000, 536870912) + target = _extensions_.InternalSerializeWithCachedSizesToArray( + 1000, 536870912, deterministic, target); + + if (_internal_metadata_.have_unknown_fields()) { + target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields(), target); + } + // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.ExtensionRangeOptions) + return target; } -::google::protobuf::MessageOptions* DescriptorProto::release_options() { - // @@protoc_insertion_point(field_release:google.protobuf.DescriptorProto.options) - clear_has_options(); - ::google::protobuf::MessageOptions* temp = options_; - options_ = NULL; - return temp; + +size_t ExtensionRangeOptions::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:google.protobuf.ExtensionRangeOptions) + size_t total_size = 0; + + total_size += _extensions_.ByteSize(); + + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + _internal_metadata_.unknown_fields()); + } + // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; + { + unsigned int count = static_cast<unsigned int>(this->uninterpreted_option_size()); + total_size += 2UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSize( + this->uninterpreted_option(static_cast<int>(i))); + } + } + + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = cached_size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); + return total_size; } -void DescriptorProto::set_allocated_options(::google::protobuf::MessageOptions* options) { - delete options_; - options_ = options; - if (options) { - set_has_options(); + +void ExtensionRangeOptions::MergeFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.ExtensionRangeOptions) + GOOGLE_DCHECK_NE(&from, this); + const ExtensionRangeOptions* source = + ::google::protobuf::internal::DynamicCastToGenerated<const ExtensionRangeOptions>( + &from); + if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.ExtensionRangeOptions) + ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { - clear_has_options(); + // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.ExtensionRangeOptions) + MergeFrom(*source); } - // @@protoc_insertion_point(field_set_allocated:google.protobuf.DescriptorProto.options) } -// repeated .google.protobuf.DescriptorProto.ReservedRange reserved_range = 9; -int DescriptorProto::reserved_range_size() const { - return reserved_range_.size(); -} -void DescriptorProto::clear_reserved_range() { - reserved_range_.Clear(); -} -const ::google::protobuf::DescriptorProto_ReservedRange& DescriptorProto::reserved_range(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.reserved_range) - return reserved_range_.Get(index); -} -::google::protobuf::DescriptorProto_ReservedRange* DescriptorProto::mutable_reserved_range(int index) { - // @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.reserved_range) - return reserved_range_.Mutable(index); -} -::google::protobuf::DescriptorProto_ReservedRange* DescriptorProto::add_reserved_range() { - // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.reserved_range) - return reserved_range_.Add(); -} -::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto_ReservedRange >* -DescriptorProto::mutable_reserved_range() { - // @@protoc_insertion_point(field_mutable_list:google.protobuf.DescriptorProto.reserved_range) - return &reserved_range_; -} -const ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto_ReservedRange >& -DescriptorProto::reserved_range() const { - // @@protoc_insertion_point(field_list:google.protobuf.DescriptorProto.reserved_range) - return reserved_range_; -} +void ExtensionRangeOptions::MergeFrom(const ExtensionRangeOptions& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.ExtensionRangeOptions) + GOOGLE_DCHECK_NE(&from, this); + _extensions_.MergeFrom(from._extensions_); + _internal_metadata_.MergeFrom(from._internal_metadata_); + ::google::protobuf::uint32 cached_has_bits = 0; + (void) cached_has_bits; -// repeated string reserved_name = 10; -int DescriptorProto::reserved_name_size() const { - return reserved_name_.size(); -} -void DescriptorProto::clear_reserved_name() { - reserved_name_.Clear(); -} -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) { - // @@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) { - // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.reserved_name) - reserved_name_.Mutable(index)->assign(value); -} -#if LANG_CXX11 -void DescriptorProto::set_reserved_name(int index, ::std::string&& value) { - // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.reserved_name) - reserved_name_.Mutable(index)->assign(std::move(value)); -} -#endif -void DescriptorProto::set_reserved_name(int index, const char* value) { - GOOGLE_DCHECK(value != NULL); - 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) { - reserved_name_.Mutable(index)->assign( - reinterpret_cast<const char*>(value), size); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.DescriptorProto.reserved_name) + uninterpreted_option_.MergeFrom(from.uninterpreted_option_); } -::std::string* DescriptorProto::add_reserved_name() { - // @@protoc_insertion_point(field_add_mutable:google.protobuf.DescriptorProto.reserved_name) - return reserved_name_.Add(); + +void ExtensionRangeOptions::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.ExtensionRangeOptions) + if (&from == this) return; + Clear(); + MergeFrom(from); } -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 ExtensionRangeOptions::CopyFrom(const ExtensionRangeOptions& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.ExtensionRangeOptions) + if (&from == this) return; + Clear(); + MergeFrom(from); } -#if LANG_CXX11 -void DescriptorProto::add_reserved_name(::std::string&& value) { - reserved_name_.Add(std::move(value)); - // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.reserved_name) + +bool ExtensionRangeOptions::IsInitialized() const { + if (!_extensions_.IsInitialized()) { + return false; + } + + if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false; + return true; } -#endif -void DescriptorProto::add_reserved_name(const char* value) { - GOOGLE_DCHECK(value != NULL); - reserved_name_.Add()->assign(value); - // @@protoc_insertion_point(field_add_char:google.protobuf.DescriptorProto.reserved_name) + +void ExtensionRangeOptions::Swap(ExtensionRangeOptions* other) { + if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + ExtensionRangeOptions* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } + } } -void DescriptorProto::add_reserved_name(const char* value, size_t size) { - reserved_name_.Add()->assign(reinterpret_cast<const char*>(value), size); - // @@protoc_insertion_point(field_add_pointer:google.protobuf.DescriptorProto.reserved_name) +void ExtensionRangeOptions::UnsafeArenaSwap(ExtensionRangeOptions* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + InternalSwap(other); } -const ::google::protobuf::RepeatedPtrField< ::std::string>& -DescriptorProto::reserved_name() const { - // @@protoc_insertion_point(field_list:google.protobuf.DescriptorProto.reserved_name) - return reserved_name_; +void ExtensionRangeOptions::InternalSwap(ExtensionRangeOptions* other) { + using std::swap; + CastToBase(&uninterpreted_option_)->InternalSwap(CastToBase(&other->uninterpreted_option_)); + swap(_has_bits_[0], other->_has_bits_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + swap(_cached_size_, other->_cached_size_); + _extensions_.Swap(&other->_extensions_); } -::google::protobuf::RepeatedPtrField< ::std::string>* -DescriptorProto::mutable_reserved_name() { - // @@protoc_insertion_point(field_mutable_list:google.protobuf.DescriptorProto.reserved_name) - return &reserved_name_; + +::google::protobuf::Metadata ExtensionRangeOptions::GetMetadata() const { + protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages]; } -#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== +void FieldDescriptorProto::InitAsDefaultInstance() { + ::google::protobuf::_FieldDescriptorProto_default_instance_._instance.get_mutable()->options_ = const_cast< ::google::protobuf::FieldOptions*>( + ::google::protobuf::FieldOptions::internal_default_instance()); +} +void FieldDescriptorProto::unsafe_arena_set_allocated_options( + ::google::protobuf::FieldOptions* options) { + if (GetArenaNoVirtual() == NULL) { + delete options_; + } + options_ = options; + if (options) { + set_has_options(); + } else { + clear_has_options(); + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.FieldDescriptorProto.options) +} #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int FieldDescriptorProto::kNameFieldNumber; const int FieldDescriptorProto::kNumberFieldNumber; @@ -4332,11 +4481,19 @@ const int FieldDescriptorProto::kOptionsFieldNumber; FieldDescriptorProto::FieldDescriptorProto() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsFieldDescriptorProto(); } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.FieldDescriptorProto) } +FieldDescriptorProto::FieldDescriptorProto(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(), + _internal_metadata_(arena) { + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsFieldDescriptorProto(); + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:google.protobuf.FieldDescriptorProto) +} FieldDescriptorProto::FieldDescriptorProto(const FieldDescriptorProto& from) : ::google::protobuf::Message(), _internal_metadata_(NULL), @@ -4345,23 +4502,28 @@ FieldDescriptorProto::FieldDescriptorProto(const FieldDescriptorProto& from) _internal_metadata_.MergeFrom(from._internal_metadata_); name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); if (from.has_name()) { - name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name(), + GetArenaNoVirtual()); } extendee_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); if (from.has_extendee()) { - extendee_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.extendee_); + extendee_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.extendee(), + GetArenaNoVirtual()); } type_name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); if (from.has_type_name()) { - type_name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.type_name_); + type_name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.type_name(), + GetArenaNoVirtual()); } default_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); if (from.has_default_value()) { - default_value_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.default_value_); + default_value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.default_value(), + GetArenaNoVirtual()); } json_name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); if (from.has_json_name()) { - json_name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.json_name_); + json_name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.json_name(), + GetArenaNoVirtual()); } if (from.has_options()) { options_ = new ::google::protobuf::FieldOptions(*from.options_); @@ -4369,8 +4531,8 @@ FieldDescriptorProto::FieldDescriptorProto(const FieldDescriptorProto& from) options_ = NULL; } ::memcpy(&number_, &from.number_, - reinterpret_cast<char*>(&type_) - - reinterpret_cast<char*>(&number_) + sizeof(type_)); + static_cast<size_t>(reinterpret_cast<char*>(&type_) - + reinterpret_cast<char*>(&number_)) + sizeof(type_)); // @@protoc_insertion_point(copy_constructor:google.protobuf.FieldDescriptorProto) } @@ -4381,8 +4543,9 @@ void FieldDescriptorProto::SharedCtor() { type_name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); default_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); json_name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - ::memset(&options_, 0, reinterpret_cast<char*>(&oneof_index_) - - reinterpret_cast<char*>(&options_) + sizeof(oneof_index_)); + ::memset(&options_, 0, static_cast<size_t>( + reinterpret_cast<char*>(&oneof_index_) - + reinterpret_cast<char*>(&options_)) + sizeof(oneof_index_)); label_ = 1; type_ = 1; } @@ -4393,72 +4556,76 @@ FieldDescriptorProto::~FieldDescriptorProto() { } void FieldDescriptorProto::SharedDtor() { + GOOGLE_DCHECK(GetArenaNoVirtual() == NULL); name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); extendee_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); type_name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); default_value_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); json_name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != internal_default_instance()) { - delete options_; - } + if (this != internal_default_instance()) delete options_; } +void FieldDescriptorProto::ArenaDtor(void* object) { + FieldDescriptorProto* _this = reinterpret_cast< FieldDescriptorProto* >(object); + (void)_this; +} +void FieldDescriptorProto::RegisterArenaDtor(::google::protobuf::Arena* arena) { +} void FieldDescriptorProto::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* FieldDescriptorProto::descriptor() { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const FieldDescriptorProto& FieldDescriptorProto::default_instance() { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsFieldDescriptorProto(); return *internal_default_instance(); } -FieldDescriptorProto* FieldDescriptorProto::New(::google::protobuf::Arena* arena) const { - FieldDescriptorProto* n = new FieldDescriptorProto; - if (arena != NULL) { - arena->Own(n); - } - return n; -} void FieldDescriptorProto::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.FieldDescriptorProto) - if (_has_bits_[0 / 32] & 63u) { - if (has_name()) { + ::google::protobuf::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + cached_has_bits = _has_bits_[0]; + if (cached_has_bits & 63u) { + if (cached_has_bits & 0x00000001u) { GOOGLE_DCHECK(!name_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); - (*name_.UnsafeRawStringPointer())->clear(); + name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - if (has_extendee()) { + if (cached_has_bits & 0x00000002u) { GOOGLE_DCHECK(!extendee_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); - (*extendee_.UnsafeRawStringPointer())->clear(); + extendee_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - if (has_type_name()) { + if (cached_has_bits & 0x00000004u) { GOOGLE_DCHECK(!type_name_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); - (*type_name_.UnsafeRawStringPointer())->clear(); + type_name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - if (has_default_value()) { + if (cached_has_bits & 0x00000008u) { GOOGLE_DCHECK(!default_value_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); - (*default_value_.UnsafeRawStringPointer())->clear(); + default_value_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - if (has_json_name()) { + if (cached_has_bits & 0x00000010u) { GOOGLE_DCHECK(!json_name_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); - (*json_name_.UnsafeRawStringPointer())->clear(); + json_name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - if (has_options()) { + if (cached_has_bits & 0x00000020u) { GOOGLE_DCHECK(options_ != NULL); - options_->::google::protobuf::FieldOptions::Clear(); + options_->Clear(); } } - if (_has_bits_[0 / 32] & 192u) { - ::memset(&number_, 0, reinterpret_cast<char*>(&oneof_index_) - - reinterpret_cast<char*>(&number_) + sizeof(oneof_index_)); + if (cached_has_bits & 192u) { + ::memset(&number_, 0, static_cast<size_t>( + reinterpret_cast<char*>(&oneof_index_) - + reinterpret_cast<char*>(&number_)) + sizeof(oneof_index_)); } - if (_has_bits_[8 / 32] & 768u) { + if (cached_has_bits & 768u) { label_ = 1; type_ = 1; } @@ -4479,11 +4646,11 @@ bool FieldDescriptorProto::MergePartialFromCodedStream( // optional string name = 1; case 1: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(10u)) { + static_cast< ::google::protobuf::uint8>(10u /* 10 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->name().data(), this->name().length(), + this->name().data(), static_cast<int>(this->name().length()), ::google::protobuf::internal::WireFormat::PARSE, "google.protobuf.FieldDescriptorProto.name"); } else { @@ -4495,11 +4662,11 @@ bool FieldDescriptorProto::MergePartialFromCodedStream( // optional string extendee = 2; case 2: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(18u)) { + static_cast< ::google::protobuf::uint8>(18u /* 18 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_extendee())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->extendee().data(), this->extendee().length(), + this->extendee().data(), static_cast<int>(this->extendee().length()), ::google::protobuf::internal::WireFormat::PARSE, "google.protobuf.FieldDescriptorProto.extendee"); } else { @@ -4511,7 +4678,7 @@ bool FieldDescriptorProto::MergePartialFromCodedStream( // optional int32 number = 3; case 3: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(24u)) { + static_cast< ::google::protobuf::uint8>(24u /* 24 & 0xFF */)) { set_has_number(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -4525,7 +4692,7 @@ bool FieldDescriptorProto::MergePartialFromCodedStream( // optional .google.protobuf.FieldDescriptorProto.Label label = 4; case 4: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(32u)) { + static_cast< ::google::protobuf::uint8>(32u /* 32 & 0xFF */)) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -4533,7 +4700,8 @@ bool FieldDescriptorProto::MergePartialFromCodedStream( if (::google::protobuf::FieldDescriptorProto_Label_IsValid(value)) { set_label(static_cast< ::google::protobuf::FieldDescriptorProto_Label >(value)); } else { - mutable_unknown_fields()->AddVarint(4, value); + mutable_unknown_fields()->AddVarint( + 4, static_cast< ::google::protobuf::uint64>(value)); } } else { goto handle_unusual; @@ -4544,7 +4712,7 @@ bool FieldDescriptorProto::MergePartialFromCodedStream( // optional .google.protobuf.FieldDescriptorProto.Type type = 5; case 5: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(40u)) { + static_cast< ::google::protobuf::uint8>(40u /* 40 & 0xFF */)) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -4552,7 +4720,8 @@ bool FieldDescriptorProto::MergePartialFromCodedStream( if (::google::protobuf::FieldDescriptorProto_Type_IsValid(value)) { set_type(static_cast< ::google::protobuf::FieldDescriptorProto_Type >(value)); } else { - mutable_unknown_fields()->AddVarint(5, value); + mutable_unknown_fields()->AddVarint( + 5, static_cast< ::google::protobuf::uint64>(value)); } } else { goto handle_unusual; @@ -4563,11 +4732,11 @@ bool FieldDescriptorProto::MergePartialFromCodedStream( // optional string type_name = 6; case 6: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(50u)) { + static_cast< ::google::protobuf::uint8>(50u /* 50 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_type_name())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->type_name().data(), this->type_name().length(), + this->type_name().data(), static_cast<int>(this->type_name().length()), ::google::protobuf::internal::WireFormat::PARSE, "google.protobuf.FieldDescriptorProto.type_name"); } else { @@ -4579,11 +4748,11 @@ bool FieldDescriptorProto::MergePartialFromCodedStream( // optional string default_value = 7; case 7: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(58u)) { + static_cast< ::google::protobuf::uint8>(58u /* 58 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_default_value())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->default_value().data(), this->default_value().length(), + this->default_value().data(), static_cast<int>(this->default_value().length()), ::google::protobuf::internal::WireFormat::PARSE, "google.protobuf.FieldDescriptorProto.default_value"); } else { @@ -4595,8 +4764,8 @@ bool FieldDescriptorProto::MergePartialFromCodedStream( // optional .google.protobuf.FieldOptions options = 8; case 8: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(66u)) { - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + static_cast< ::google::protobuf::uint8>(66u /* 66 & 0xFF */)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, mutable_options())); } else { goto handle_unusual; @@ -4607,7 +4776,7 @@ bool FieldDescriptorProto::MergePartialFromCodedStream( // optional int32 oneof_index = 9; case 9: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(72u)) { + static_cast< ::google::protobuf::uint8>(72u /* 72 & 0xFF */)) { set_has_oneof_index(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -4621,11 +4790,11 @@ bool FieldDescriptorProto::MergePartialFromCodedStream( // optional string json_name = 10; case 10: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(82u)) { + static_cast< ::google::protobuf::uint8>(82u /* 82 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_json_name())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->json_name().data(), this->json_name().length(), + this->json_name().data(), static_cast<int>(this->json_name().length()), ::google::protobuf::internal::WireFormat::PARSE, "google.protobuf.FieldDescriptorProto.json_name"); } else { @@ -4636,13 +4805,11 @@ bool FieldDescriptorProto::MergePartialFromCodedStream( default: { handle_unusual: - if (tag == 0 || - ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + if (tag == 0) { goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); + input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } @@ -4666,7 +4833,7 @@ void FieldDescriptorProto::SerializeWithCachedSizes( // optional string name = 1; if (cached_has_bits & 0x00000001u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->name().data(), this->name().length(), + this->name().data(), static_cast<int>(this->name().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.FieldDescriptorProto.name"); ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( @@ -4676,7 +4843,7 @@ void FieldDescriptorProto::SerializeWithCachedSizes( // optional string extendee = 2; if (cached_has_bits & 0x00000002u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->extendee().data(), this->extendee().length(), + this->extendee().data(), static_cast<int>(this->extendee().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.FieldDescriptorProto.extendee"); ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( @@ -4703,7 +4870,7 @@ void FieldDescriptorProto::SerializeWithCachedSizes( // optional string type_name = 6; if (cached_has_bits & 0x00000004u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->type_name().data(), this->type_name().length(), + this->type_name().data(), static_cast<int>(this->type_name().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.FieldDescriptorProto.type_name"); ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( @@ -4713,7 +4880,7 @@ void FieldDescriptorProto::SerializeWithCachedSizes( // optional string default_value = 7; if (cached_has_bits & 0x00000008u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->default_value().data(), this->default_value().length(), + this->default_value().data(), static_cast<int>(this->default_value().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.FieldDescriptorProto.default_value"); ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( @@ -4723,7 +4890,7 @@ void FieldDescriptorProto::SerializeWithCachedSizes( // optional .google.protobuf.FieldOptions options = 8; if (cached_has_bits & 0x00000020u) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 8, *this->options_, output); + 8, *options_, output); } // optional int32 oneof_index = 9; @@ -4734,7 +4901,7 @@ void FieldDescriptorProto::SerializeWithCachedSizes( // optional string json_name = 10; if (cached_has_bits & 0x00000010u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->json_name().data(), this->json_name().length(), + this->json_name().data(), static_cast<int>(this->json_name().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.FieldDescriptorProto.json_name"); ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( @@ -4743,13 +4910,14 @@ void FieldDescriptorProto::SerializeWithCachedSizes( if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); + _internal_metadata_.unknown_fields(), output); } // @@protoc_insertion_point(serialize_end:google.protobuf.FieldDescriptorProto) } ::google::protobuf::uint8* FieldDescriptorProto::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.FieldDescriptorProto) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -4758,7 +4926,7 @@ void FieldDescriptorProto::SerializeWithCachedSizes( // optional string name = 1; if (cached_has_bits & 0x00000001u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->name().data(), this->name().length(), + this->name().data(), static_cast<int>(this->name().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.FieldDescriptorProto.name"); target = @@ -4769,7 +4937,7 @@ void FieldDescriptorProto::SerializeWithCachedSizes( // optional string extendee = 2; if (cached_has_bits & 0x00000002u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->extendee().data(), this->extendee().length(), + this->extendee().data(), static_cast<int>(this->extendee().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.FieldDescriptorProto.extendee"); target = @@ -4797,7 +4965,7 @@ void FieldDescriptorProto::SerializeWithCachedSizes( // optional string type_name = 6; if (cached_has_bits & 0x00000004u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->type_name().data(), this->type_name().length(), + this->type_name().data(), static_cast<int>(this->type_name().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.FieldDescriptorProto.type_name"); target = @@ -4808,7 +4976,7 @@ void FieldDescriptorProto::SerializeWithCachedSizes( // optional string default_value = 7; if (cached_has_bits & 0x00000008u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->default_value().data(), this->default_value().length(), + this->default_value().data(), static_cast<int>(this->default_value().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.FieldDescriptorProto.default_value"); target = @@ -4819,8 +4987,8 @@ void FieldDescriptorProto::SerializeWithCachedSizes( // optional .google.protobuf.FieldOptions options = 8; if (cached_has_bits & 0x00000020u) { target = ::google::protobuf::internal::WireFormatLite:: - InternalWriteMessageNoVirtualToArray( - 8, *this->options_, deterministic, target); + InternalWriteMessageToArray( + 8, *options_, deterministic, target); } // optional int32 oneof_index = 9; @@ -4831,7 +4999,7 @@ void FieldDescriptorProto::SerializeWithCachedSizes( // optional string json_name = 10; if (cached_has_bits & 0x00000010u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->json_name().data(), this->json_name().length(), + this->json_name().data(), static_cast<int>(this->json_name().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.FieldDescriptorProto.json_name"); target = @@ -4841,7 +5009,7 @@ void FieldDescriptorProto::SerializeWithCachedSizes( if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); + _internal_metadata_.unknown_fields(), target); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.FieldDescriptorProto) return target; @@ -4854,7 +5022,7 @@ size_t FieldDescriptorProto::ByteSizeLong() const { if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); + _internal_metadata_.unknown_fields()); } if (_has_bits_[0 / 32] & 255u) { // optional string name = 1; @@ -4895,8 +5063,8 @@ size_t FieldDescriptorProto::ByteSizeLong() const { // optional .google.protobuf.FieldOptions options = 8; if (has_options()) { total_size += 1 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - *this->options_); + ::google::protobuf::internal::WireFormatLite::MessageSize( + *options_); } // optional int32 number = 3; @@ -4960,24 +5128,19 @@ void FieldDescriptorProto::MergeFrom(const FieldDescriptorProto& from) { cached_has_bits = from._has_bits_[0]; if (cached_has_bits & 255u) { if (cached_has_bits & 0x00000001u) { - set_has_name(); - name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); + set_name(from.name()); } if (cached_has_bits & 0x00000002u) { - set_has_extendee(); - extendee_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.extendee_); + set_extendee(from.extendee()); } if (cached_has_bits & 0x00000004u) { - set_has_type_name(); - type_name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.type_name_); + set_type_name(from.type_name()); } if (cached_has_bits & 0x00000008u) { - set_has_default_value(); - default_value_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.default_value_); + set_default_value(from.default_value()); } if (cached_has_bits & 0x00000010u) { - set_has_json_name(); - json_name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.json_name_); + set_json_name(from.json_name()); } if (cached_has_bits & 0x00000020u) { mutable_options()->::google::protobuf::FieldOptions::MergeFrom(from.options()); @@ -5024,494 +5187,65 @@ bool FieldDescriptorProto::IsInitialized() const { void FieldDescriptorProto::Swap(FieldDescriptorProto* other) { if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + FieldDescriptorProto* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } + } +} +void FieldDescriptorProto::UnsafeArenaSwap(FieldDescriptorProto* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); InternalSwap(other); } void FieldDescriptorProto::InternalSwap(FieldDescriptorProto* other) { + using std::swap; name_.Swap(&other->name_); extendee_.Swap(&other->extendee_); type_name_.Swap(&other->type_name_); default_value_.Swap(&other->default_value_); json_name_.Swap(&other->json_name_); - std::swap(options_, other->options_); - std::swap(number_, other->number_); - std::swap(oneof_index_, other->oneof_index_); - std::swap(label_, other->label_); - std::swap(type_, other->type_); - std::swap(_has_bits_[0], other->_has_bits_[0]); + swap(options_, other->options_); + swap(number_, other->number_); + swap(oneof_index_, other->oneof_index_); + swap(label_, other->label_); + swap(type_, other->type_); + swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); - std::swap(_cached_size_, other->_cached_size_); + swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata FieldDescriptorProto::GetMetadata() const { protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages]; -} - -#if PROTOBUF_INLINE_NOT_IN_HEADERS -// FieldDescriptorProto - -// optional string name = 1; -bool FieldDescriptorProto::has_name() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -void FieldDescriptorProto::set_has_name() { - _has_bits_[0] |= 0x00000001u; -} -void FieldDescriptorProto::clear_has_name() { - _has_bits_[0] &= ~0x00000001u; -} -void FieldDescriptorProto::clear_name() { - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - clear_has_name(); -} -const ::std::string& FieldDescriptorProto::name() const { - // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.name) - return name_.GetNoArena(); -} -void FieldDescriptorProto::set_name(const ::std::string& value) { - set_has_name(); - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.name) -} -#if LANG_CXX11 -void FieldDescriptorProto::set_name(::std::string&& value) { - set_has_name(); - name_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FieldDescriptorProto.name) -} -#endif -void FieldDescriptorProto::set_name(const char* value) { - GOOGLE_DCHECK(value != NULL); - 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) { - set_has_name(); - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.FieldDescriptorProto.name) -} -::std::string* FieldDescriptorProto::mutable_name() { - set_has_name(); - // @@protoc_insertion_point(field_mutable:google.protobuf.FieldDescriptorProto.name) - return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -::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) { - if (name != NULL) { - set_has_name(); - } else { - clear_has_name(); - } - name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.FieldDescriptorProto.name) + return ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages]; } -// optional int32 number = 3; -bool FieldDescriptorProto::has_number() const { - return (_has_bits_[0] & 0x00000040u) != 0; -} -void FieldDescriptorProto::set_has_number() { - _has_bits_[0] |= 0x00000040u; -} -void FieldDescriptorProto::clear_has_number() { - _has_bits_[0] &= ~0x00000040u; -} -void FieldDescriptorProto::clear_number() { - number_ = 0; - clear_has_number(); -} -::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) { - set_has_number(); - number_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.number) -} -// optional .google.protobuf.FieldDescriptorProto.Label label = 4; -bool FieldDescriptorProto::has_label() const { - return (_has_bits_[0] & 0x00000100u) != 0; -} -void FieldDescriptorProto::set_has_label() { - _has_bits_[0] |= 0x00000100u; -} -void FieldDescriptorProto::clear_has_label() { - _has_bits_[0] &= ~0x00000100u; -} -void FieldDescriptorProto::clear_label() { - label_ = 1; - clear_has_label(); -} -::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) { - assert(::google::protobuf::FieldDescriptorProto_Label_IsValid(value)); - set_has_label(); - label_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.label) -} - -// optional .google.protobuf.FieldDescriptorProto.Type type = 5; -bool FieldDescriptorProto::has_type() const { - return (_has_bits_[0] & 0x00000200u) != 0; -} -void FieldDescriptorProto::set_has_type() { - _has_bits_[0] |= 0x00000200u; -} -void FieldDescriptorProto::clear_has_type() { - _has_bits_[0] &= ~0x00000200u; -} -void FieldDescriptorProto::clear_type() { - type_ = 1; - clear_has_type(); -} -::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) { - assert(::google::protobuf::FieldDescriptorProto_Type_IsValid(value)); - set_has_type(); - type_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.type) -} - -// optional string type_name = 6; -bool FieldDescriptorProto::has_type_name() const { - return (_has_bits_[0] & 0x00000004u) != 0; -} -void FieldDescriptorProto::set_has_type_name() { - _has_bits_[0] |= 0x00000004u; -} -void FieldDescriptorProto::clear_has_type_name() { - _has_bits_[0] &= ~0x00000004u; -} -void FieldDescriptorProto::clear_type_name() { - type_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - clear_has_type_name(); -} -const ::std::string& FieldDescriptorProto::type_name() const { - // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.type_name) - return type_name_.GetNoArena(); -} -void FieldDescriptorProto::set_type_name(const ::std::string& value) { - set_has_type_name(); - type_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.type_name) -} -#if LANG_CXX11 -void FieldDescriptorProto::set_type_name(::std::string&& value) { - set_has_type_name(); - type_name_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FieldDescriptorProto.type_name) -} -#endif -void FieldDescriptorProto::set_type_name(const char* value) { - GOOGLE_DCHECK(value != NULL); - 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) { - set_has_type_name(); - type_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.FieldDescriptorProto.type_name) -} -::std::string* FieldDescriptorProto::mutable_type_name() { - 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() { - // @@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) { - if (type_name != NULL) { - set_has_type_name(); - } else { - clear_has_type_name(); - } - type_name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), type_name); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.FieldDescriptorProto.type_name) -} - -// optional string extendee = 2; -bool FieldDescriptorProto::has_extendee() const { - return (_has_bits_[0] & 0x00000002u) != 0; -} -void FieldDescriptorProto::set_has_extendee() { - _has_bits_[0] |= 0x00000002u; -} -void FieldDescriptorProto::clear_has_extendee() { - _has_bits_[0] &= ~0x00000002u; -} -void FieldDescriptorProto::clear_extendee() { - extendee_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - clear_has_extendee(); -} -const ::std::string& FieldDescriptorProto::extendee() const { - // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.extendee) - return extendee_.GetNoArena(); -} -void FieldDescriptorProto::set_extendee(const ::std::string& value) { - set_has_extendee(); - extendee_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.extendee) -} -#if LANG_CXX11 -void FieldDescriptorProto::set_extendee(::std::string&& value) { - set_has_extendee(); - extendee_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FieldDescriptorProto.extendee) -} -#endif -void FieldDescriptorProto::set_extendee(const char* value) { - GOOGLE_DCHECK(value != NULL); - 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) { - set_has_extendee(); - extendee_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.FieldDescriptorProto.extendee) -} -::std::string* FieldDescriptorProto::mutable_extendee() { - set_has_extendee(); - // @@protoc_insertion_point(field_mutable:google.protobuf.FieldDescriptorProto.extendee) - return extendee_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -::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) { - if (extendee != NULL) { - set_has_extendee(); - } else { - clear_has_extendee(); - } - extendee_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), extendee); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.FieldDescriptorProto.extendee) -} - -// optional string default_value = 7; -bool FieldDescriptorProto::has_default_value() const { - return (_has_bits_[0] & 0x00000008u) != 0; -} -void FieldDescriptorProto::set_has_default_value() { - _has_bits_[0] |= 0x00000008u; -} -void FieldDescriptorProto::clear_has_default_value() { - _has_bits_[0] &= ~0x00000008u; -} -void FieldDescriptorProto::clear_default_value() { - default_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - clear_has_default_value(); -} -const ::std::string& FieldDescriptorProto::default_value() const { - // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.default_value) - return default_value_.GetNoArena(); -} -void FieldDescriptorProto::set_default_value(const ::std::string& value) { - set_has_default_value(); - default_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.default_value) -} -#if LANG_CXX11 -void FieldDescriptorProto::set_default_value(::std::string&& value) { - set_has_default_value(); - default_value_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FieldDescriptorProto.default_value) -} -#endif -void FieldDescriptorProto::set_default_value(const char* value) { - GOOGLE_DCHECK(value != NULL); - 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) { - set_has_default_value(); - default_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.FieldDescriptorProto.default_value) -} -::std::string* FieldDescriptorProto::mutable_default_value() { - 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() { - // @@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) { - if (default_value != NULL) { - set_has_default_value(); - } else { - clear_has_default_value(); - } - default_value_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), default_value); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.FieldDescriptorProto.default_value) -} - -// optional int32 oneof_index = 9; -bool FieldDescriptorProto::has_oneof_index() const { - return (_has_bits_[0] & 0x00000080u) != 0; -} -void FieldDescriptorProto::set_has_oneof_index() { - _has_bits_[0] |= 0x00000080u; -} -void FieldDescriptorProto::clear_has_oneof_index() { - _has_bits_[0] &= ~0x00000080u; -} -void FieldDescriptorProto::clear_oneof_index() { - oneof_index_ = 0; - clear_has_oneof_index(); -} -::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) { - set_has_oneof_index(); - oneof_index_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.oneof_index) -} - -// optional string json_name = 10; -bool FieldDescriptorProto::has_json_name() const { - return (_has_bits_[0] & 0x00000010u) != 0; -} -void FieldDescriptorProto::set_has_json_name() { - _has_bits_[0] |= 0x00000010u; -} -void FieldDescriptorProto::clear_has_json_name() { - _has_bits_[0] &= ~0x00000010u; -} -void FieldDescriptorProto::clear_json_name() { - json_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - clear_has_json_name(); -} -const ::std::string& FieldDescriptorProto::json_name() const { - // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.json_name) - return json_name_.GetNoArena(); -} -void FieldDescriptorProto::set_json_name(const ::std::string& value) { - set_has_json_name(); - json_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.json_name) -} -#if LANG_CXX11 -void FieldDescriptorProto::set_json_name(::std::string&& value) { - set_has_json_name(); - json_name_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FieldDescriptorProto.json_name) -} -#endif -void FieldDescriptorProto::set_json_name(const char* value) { - GOOGLE_DCHECK(value != NULL); - 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) { - set_has_json_name(); - json_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.FieldDescriptorProto.json_name) -} -::std::string* FieldDescriptorProto::mutable_json_name() { - 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() { - // @@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) { - if (json_name != NULL) { - set_has_json_name(); - } else { - clear_has_json_name(); - } - json_name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), json_name); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.FieldDescriptorProto.json_name) -} +// =================================================================== -// optional .google.protobuf.FieldOptions options = 8; -bool FieldDescriptorProto::has_options() const { - return (_has_bits_[0] & 0x00000020u) != 0; -} -void FieldDescriptorProto::set_has_options() { - _has_bits_[0] |= 0x00000020u; -} -void FieldDescriptorProto::clear_has_options() { - _has_bits_[0] &= ~0x00000020u; -} -void FieldDescriptorProto::clear_options() { - if (options_ != NULL) options_->::google::protobuf::FieldOptions::Clear(); - clear_has_options(); -} -const ::google::protobuf::FieldOptions& FieldDescriptorProto::options() const { - // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.options) - return options_ != NULL ? *options_ - : *::google::protobuf::FieldOptions::internal_default_instance(); +void OneofDescriptorProto::InitAsDefaultInstance() { + ::google::protobuf::_OneofDescriptorProto_default_instance_._instance.get_mutable()->options_ = const_cast< ::google::protobuf::OneofOptions*>( + ::google::protobuf::OneofOptions::internal_default_instance()); } -::google::protobuf::FieldOptions* FieldDescriptorProto::mutable_options() { - set_has_options(); - if (options_ == NULL) { - options_ = new ::google::protobuf::FieldOptions; +void OneofDescriptorProto::unsafe_arena_set_allocated_options( + ::google::protobuf::OneofOptions* options) { + if (GetArenaNoVirtual() == NULL) { + delete options_; } - // @@protoc_insertion_point(field_mutable:google.protobuf.FieldDescriptorProto.options) - return options_; -} -::google::protobuf::FieldOptions* FieldDescriptorProto::release_options() { - // @@protoc_insertion_point(field_release:google.protobuf.FieldDescriptorProto.options) - clear_has_options(); - ::google::protobuf::FieldOptions* temp = options_; - options_ = NULL; - return temp; -} -void FieldDescriptorProto::set_allocated_options(::google::protobuf::FieldOptions* options) { - delete options_; options_ = options; if (options) { set_has_options(); } else { clear_has_options(); } - // @@protoc_insertion_point(field_set_allocated:google.protobuf.FieldDescriptorProto.options) + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.OneofDescriptorProto.options) } - -#endif // PROTOBUF_INLINE_NOT_IN_HEADERS - -// =================================================================== - #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int OneofDescriptorProto::kNameFieldNumber; const int OneofDescriptorProto::kOptionsFieldNumber; @@ -5520,11 +5254,19 @@ const int OneofDescriptorProto::kOptionsFieldNumber; OneofDescriptorProto::OneofDescriptorProto() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsOneofDescriptorProto(); } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.OneofDescriptorProto) } +OneofDescriptorProto::OneofDescriptorProto(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(), + _internal_metadata_(arena) { + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsOneofDescriptorProto(); + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:google.protobuf.OneofDescriptorProto) +} OneofDescriptorProto::OneofDescriptorProto(const OneofDescriptorProto& from) : ::google::protobuf::Message(), _internal_metadata_(NULL), @@ -5533,7 +5275,8 @@ OneofDescriptorProto::OneofDescriptorProto(const OneofDescriptorProto& from) _internal_metadata_.MergeFrom(from._internal_metadata_); name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); if (from.has_name()) { - name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name(), + GetArenaNoVirtual()); } if (from.has_options()) { options_ = new ::google::protobuf::OneofOptions(*from.options_); @@ -5555,45 +5298,48 @@ OneofDescriptorProto::~OneofDescriptorProto() { } void OneofDescriptorProto::SharedDtor() { + GOOGLE_DCHECK(GetArenaNoVirtual() == NULL); name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != internal_default_instance()) { - delete options_; - } + if (this != internal_default_instance()) delete options_; } +void OneofDescriptorProto::ArenaDtor(void* object) { + OneofDescriptorProto* _this = reinterpret_cast< OneofDescriptorProto* >(object); + (void)_this; +} +void OneofDescriptorProto::RegisterArenaDtor(::google::protobuf::Arena* arena) { +} void OneofDescriptorProto::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* OneofDescriptorProto::descriptor() { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const OneofDescriptorProto& OneofDescriptorProto::default_instance() { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsOneofDescriptorProto(); return *internal_default_instance(); } -OneofDescriptorProto* OneofDescriptorProto::New(::google::protobuf::Arena* arena) const { - OneofDescriptorProto* n = new OneofDescriptorProto; - if (arena != NULL) { - arena->Own(n); - } - return n; -} void OneofDescriptorProto::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.OneofDescriptorProto) - if (_has_bits_[0 / 32] & 3u) { - if (has_name()) { + ::google::protobuf::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + cached_has_bits = _has_bits_[0]; + if (cached_has_bits & 3u) { + if (cached_has_bits & 0x00000001u) { GOOGLE_DCHECK(!name_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); - (*name_.UnsafeRawStringPointer())->clear(); + name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - if (has_options()) { + if (cached_has_bits & 0x00000002u) { GOOGLE_DCHECK(options_ != NULL); - options_->::google::protobuf::OneofOptions::Clear(); + options_->Clear(); } } _has_bits_.Clear(); @@ -5613,11 +5359,11 @@ bool OneofDescriptorProto::MergePartialFromCodedStream( // optional string name = 1; case 1: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(10u)) { + static_cast< ::google::protobuf::uint8>(10u /* 10 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->name().data(), this->name().length(), + this->name().data(), static_cast<int>(this->name().length()), ::google::protobuf::internal::WireFormat::PARSE, "google.protobuf.OneofDescriptorProto.name"); } else { @@ -5629,8 +5375,8 @@ bool OneofDescriptorProto::MergePartialFromCodedStream( // optional .google.protobuf.OneofOptions options = 2; case 2: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(18u)) { - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + static_cast< ::google::protobuf::uint8>(18u /* 18 & 0xFF */)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, mutable_options())); } else { goto handle_unusual; @@ -5640,13 +5386,11 @@ bool OneofDescriptorProto::MergePartialFromCodedStream( default: { handle_unusual: - if (tag == 0 || - ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + if (tag == 0) { goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); + input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } @@ -5670,7 +5414,7 @@ void OneofDescriptorProto::SerializeWithCachedSizes( // optional string name = 1; if (cached_has_bits & 0x00000001u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->name().data(), this->name().length(), + this->name().data(), static_cast<int>(this->name().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.OneofDescriptorProto.name"); ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( @@ -5680,18 +5424,19 @@ void OneofDescriptorProto::SerializeWithCachedSizes( // optional .google.protobuf.OneofOptions options = 2; if (cached_has_bits & 0x00000002u) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 2, *this->options_, output); + 2, *options_, output); } if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); + _internal_metadata_.unknown_fields(), output); } // @@protoc_insertion_point(serialize_end:google.protobuf.OneofDescriptorProto) } ::google::protobuf::uint8* OneofDescriptorProto::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.OneofDescriptorProto) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -5700,7 +5445,7 @@ void OneofDescriptorProto::SerializeWithCachedSizes( // optional string name = 1; if (cached_has_bits & 0x00000001u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->name().data(), this->name().length(), + this->name().data(), static_cast<int>(this->name().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.OneofDescriptorProto.name"); target = @@ -5711,13 +5456,13 @@ void OneofDescriptorProto::SerializeWithCachedSizes( // optional .google.protobuf.OneofOptions options = 2; if (cached_has_bits & 0x00000002u) { target = ::google::protobuf::internal::WireFormatLite:: - InternalWriteMessageNoVirtualToArray( - 2, *this->options_, deterministic, target); + InternalWriteMessageToArray( + 2, *options_, deterministic, target); } if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); + _internal_metadata_.unknown_fields(), target); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.OneofDescriptorProto) return target; @@ -5730,7 +5475,7 @@ size_t OneofDescriptorProto::ByteSizeLong() const { if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); + _internal_metadata_.unknown_fields()); } if (_has_bits_[0 / 32] & 3u) { // optional string name = 1; @@ -5743,8 +5488,8 @@ size_t OneofDescriptorProto::ByteSizeLong() const { // optional .google.protobuf.OneofOptions options = 2; if (has_options()) { total_size += 1 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - *this->options_); + ::google::protobuf::internal::WireFormatLite::MessageSize( + *options_); } } @@ -5780,8 +5525,7 @@ void OneofDescriptorProto::MergeFrom(const OneofDescriptorProto& from) { cached_has_bits = from._has_bits_[0]; if (cached_has_bits & 3u) { if (cached_has_bits & 0x00000001u) { - set_has_name(); - name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); + set_name(from.name()); } if (cached_has_bits & 0x00000002u) { mutable_options()->::google::protobuf::OneofOptions::MergeFrom(from.options()); @@ -5812,160 +5556,414 @@ bool OneofDescriptorProto::IsInitialized() const { void OneofDescriptorProto::Swap(OneofDescriptorProto* other) { if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + OneofDescriptorProto* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } + } +} +void OneofDescriptorProto::UnsafeArenaSwap(OneofDescriptorProto* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); InternalSwap(other); } void OneofDescriptorProto::InternalSwap(OneofDescriptorProto* other) { + using std::swap; name_.Swap(&other->name_); - std::swap(options_, other->options_); - std::swap(_has_bits_[0], other->_has_bits_[0]); + swap(options_, other->options_); + swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); - std::swap(_cached_size_, other->_cached_size_); + swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata OneofDescriptorProto::GetMetadata() const { protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages]; + return ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages]; } -#if PROTOBUF_INLINE_NOT_IN_HEADERS -// OneofDescriptorProto -// optional string name = 1; -bool OneofDescriptorProto::has_name() const { - return (_has_bits_[0] & 0x00000001u) != 0; +// =================================================================== + +void EnumDescriptorProto_EnumReservedRange::InitAsDefaultInstance() { } -void OneofDescriptorProto::set_has_name() { - _has_bits_[0] |= 0x00000001u; +#if !defined(_MSC_VER) || _MSC_VER >= 1900 +const int EnumDescriptorProto_EnumReservedRange::kStartFieldNumber; +const int EnumDescriptorProto_EnumReservedRange::kEndFieldNumber; +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 + +EnumDescriptorProto_EnumReservedRange::EnumDescriptorProto_EnumReservedRange() + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsEnumDescriptorProto_EnumReservedRange(); + } + SharedCtor(); + // @@protoc_insertion_point(constructor:google.protobuf.EnumDescriptorProto.EnumReservedRange) } -void OneofDescriptorProto::clear_has_name() { - _has_bits_[0] &= ~0x00000001u; +EnumDescriptorProto_EnumReservedRange::EnumDescriptorProto_EnumReservedRange(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(), + _internal_metadata_(arena) { + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsEnumDescriptorProto_EnumReservedRange(); + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:google.protobuf.EnumDescriptorProto.EnumReservedRange) } -void OneofDescriptorProto::clear_name() { - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - clear_has_name(); +EnumDescriptorProto_EnumReservedRange::EnumDescriptorProto_EnumReservedRange(const EnumDescriptorProto_EnumReservedRange& from) + : ::google::protobuf::Message(), + _internal_metadata_(NULL), + _has_bits_(from._has_bits_), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + ::memcpy(&start_, &from.start_, + static_cast<size_t>(reinterpret_cast<char*>(&end_) - + reinterpret_cast<char*>(&start_)) + sizeof(end_)); + // @@protoc_insertion_point(copy_constructor:google.protobuf.EnumDescriptorProto.EnumReservedRange) } -const ::std::string& OneofDescriptorProto::name() const { - // @@protoc_insertion_point(field_get:google.protobuf.OneofDescriptorProto.name) - return name_.GetNoArena(); + +void EnumDescriptorProto_EnumReservedRange::SharedCtor() { + _cached_size_ = 0; + ::memset(&start_, 0, static_cast<size_t>( + reinterpret_cast<char*>(&end_) - + reinterpret_cast<char*>(&start_)) + sizeof(end_)); } -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) + +EnumDescriptorProto_EnumReservedRange::~EnumDescriptorProto_EnumReservedRange() { + // @@protoc_insertion_point(destructor:google.protobuf.EnumDescriptorProto.EnumReservedRange) + SharedDtor(); } -#if LANG_CXX11 -void OneofDescriptorProto::set_name(::std::string&& value) { - set_has_name(); - name_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.OneofDescriptorProto.name) + +void EnumDescriptorProto_EnumReservedRange::SharedDtor() { + GOOGLE_DCHECK(GetArenaNoVirtual() == NULL); } -#endif -void OneofDescriptorProto::set_name(const char* value) { - GOOGLE_DCHECK(value != NULL); - 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) { - set_has_name(); - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.OneofDescriptorProto.name) -} -::std::string* OneofDescriptorProto::mutable_name() { - set_has_name(); - // @@protoc_insertion_point(field_mutable:google.protobuf.OneofDescriptorProto.name) - return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -::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) { - if (name != NULL) { - set_has_name(); - } else { - clear_has_name(); + +void EnumDescriptorProto_EnumReservedRange::ArenaDtor(void* object) { + EnumDescriptorProto_EnumReservedRange* _this = reinterpret_cast< EnumDescriptorProto_EnumReservedRange* >(object); + (void)_this; +} +void EnumDescriptorProto_EnumReservedRange::RegisterArenaDtor(::google::protobuf::Arena* arena) { +} +void EnumDescriptorProto_EnumReservedRange::SetCachedSize(int size) const { + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); +} +const ::google::protobuf::Descriptor* EnumDescriptorProto_EnumReservedRange::descriptor() { + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; +} + +const EnumDescriptorProto_EnumReservedRange& EnumDescriptorProto_EnumReservedRange::default_instance() { + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsEnumDescriptorProto_EnumReservedRange(); + return *internal_default_instance(); +} + + +void EnumDescriptorProto_EnumReservedRange::Clear() { +// @@protoc_insertion_point(message_clear_start:google.protobuf.EnumDescriptorProto.EnumReservedRange) + ::google::protobuf::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + cached_has_bits = _has_bits_[0]; + if (cached_has_bits & 3u) { + ::memset(&start_, 0, static_cast<size_t>( + reinterpret_cast<char*>(&end_) - + reinterpret_cast<char*>(&start_)) + sizeof(end_)); + } + _has_bits_.Clear(); + _internal_metadata_.Clear(); +} + +bool EnumDescriptorProto_EnumReservedRange::MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input) { +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure + ::google::protobuf::uint32 tag; + // @@protoc_insertion_point(parse_start:google.protobuf.EnumDescriptorProto.EnumReservedRange) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); + tag = p.first; + if (!p.second) goto handle_unusual; + switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { + // optional int32 start = 1; + case 1: { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(8u /* 8 & 0xFF */)) { + set_has_start(); + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( + input, &start_))); + } else { + goto handle_unusual; + } + break; + } + + // optional int32 end = 2; + case 2: { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(16u /* 16 & 0xFF */)) { + set_has_end(); + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( + input, &end_))); + } else { + goto handle_unusual; + } + break; + } + + default: { + handle_unusual: + if (tag == 0) { + goto success; + } + DO_(::google::protobuf::internal::WireFormat::SkipField( + input, tag, _internal_metadata_.mutable_unknown_fields())); + break; + } + } } - name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.OneofDescriptorProto.name) +success: + // @@protoc_insertion_point(parse_success:google.protobuf.EnumDescriptorProto.EnumReservedRange) + return true; +failure: + // @@protoc_insertion_point(parse_failure:google.protobuf.EnumDescriptorProto.EnumReservedRange) + return false; +#undef DO_ } -// optional .google.protobuf.OneofOptions options = 2; -bool OneofDescriptorProto::has_options() const { - return (_has_bits_[0] & 0x00000002u) != 0; +void EnumDescriptorProto_EnumReservedRange::SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:google.protobuf.EnumDescriptorProto.EnumReservedRange) + ::google::protobuf::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + cached_has_bits = _has_bits_[0]; + // optional int32 start = 1; + if (cached_has_bits & 0x00000001u) { + ::google::protobuf::internal::WireFormatLite::WriteInt32(1, this->start(), output); + } + + // optional int32 end = 2; + if (cached_has_bits & 0x00000002u) { + ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->end(), output); + } + + if (_internal_metadata_.have_unknown_fields()) { + ::google::protobuf::internal::WireFormat::SerializeUnknownFields( + _internal_metadata_.unknown_fields(), output); + } + // @@protoc_insertion_point(serialize_end:google.protobuf.EnumDescriptorProto.EnumReservedRange) } -void OneofDescriptorProto::set_has_options() { - _has_bits_[0] |= 0x00000002u; + +::google::protobuf::uint8* EnumDescriptorProto_EnumReservedRange::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.EnumDescriptorProto.EnumReservedRange) + ::google::protobuf::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + cached_has_bits = _has_bits_[0]; + // optional int32 start = 1; + if (cached_has_bits & 0x00000001u) { + target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(1, this->start(), target); + } + + // optional int32 end = 2; + if (cached_has_bits & 0x00000002u) { + target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->end(), target); + } + + if (_internal_metadata_.have_unknown_fields()) { + target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields(), target); + } + // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.EnumDescriptorProto.EnumReservedRange) + return target; } -void OneofDescriptorProto::clear_has_options() { - _has_bits_[0] &= ~0x00000002u; + +size_t EnumDescriptorProto_EnumReservedRange::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:google.protobuf.EnumDescriptorProto.EnumReservedRange) + size_t total_size = 0; + + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + _internal_metadata_.unknown_fields()); + } + if (_has_bits_[0 / 32] & 3u) { + // optional int32 start = 1; + if (has_start()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::Int32Size( + this->start()); + } + + // optional int32 end = 2; + if (has_end()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::Int32Size( + this->end()); + } + + } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = cached_size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); + return total_size; } -void OneofDescriptorProto::clear_options() { - if (options_ != NULL) options_->::google::protobuf::OneofOptions::Clear(); - clear_has_options(); + +void EnumDescriptorProto_EnumReservedRange::MergeFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.EnumDescriptorProto.EnumReservedRange) + GOOGLE_DCHECK_NE(&from, this); + const EnumDescriptorProto_EnumReservedRange* source = + ::google::protobuf::internal::DynamicCastToGenerated<const EnumDescriptorProto_EnumReservedRange>( + &from); + if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.EnumDescriptorProto.EnumReservedRange) + ::google::protobuf::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.EnumDescriptorProto.EnumReservedRange) + MergeFrom(*source); + } } -const ::google::protobuf::OneofOptions& OneofDescriptorProto::options() const { - // @@protoc_insertion_point(field_get:google.protobuf.OneofDescriptorProto.options) - return options_ != NULL ? *options_ - : *::google::protobuf::OneofOptions::internal_default_instance(); + +void EnumDescriptorProto_EnumReservedRange::MergeFrom(const EnumDescriptorProto_EnumReservedRange& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumDescriptorProto.EnumReservedRange) + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); + ::google::protobuf::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + cached_has_bits = from._has_bits_[0]; + if (cached_has_bits & 3u) { + if (cached_has_bits & 0x00000001u) { + start_ = from.start_; + } + if (cached_has_bits & 0x00000002u) { + end_ = from.end_; + } + _has_bits_[0] |= cached_has_bits; + } +} + +void EnumDescriptorProto_EnumReservedRange::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.EnumDescriptorProto.EnumReservedRange) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void EnumDescriptorProto_EnumReservedRange::CopyFrom(const EnumDescriptorProto_EnumReservedRange& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.EnumDescriptorProto.EnumReservedRange) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool EnumDescriptorProto_EnumReservedRange::IsInitialized() const { + return true; } -::google::protobuf::OneofOptions* OneofDescriptorProto::mutable_options() { - set_has_options(); - if (options_ == NULL) { - options_ = new ::google::protobuf::OneofOptions; + +void EnumDescriptorProto_EnumReservedRange::Swap(EnumDescriptorProto_EnumReservedRange* other) { + if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + EnumDescriptorProto_EnumReservedRange* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } } - // @@protoc_insertion_point(field_mutable:google.protobuf.OneofDescriptorProto.options) - return options_; } -::google::protobuf::OneofOptions* OneofDescriptorProto::release_options() { - // @@protoc_insertion_point(field_release:google.protobuf.OneofDescriptorProto.options) - clear_has_options(); - ::google::protobuf::OneofOptions* temp = options_; - options_ = NULL; - return temp; +void EnumDescriptorProto_EnumReservedRange::UnsafeArenaSwap(EnumDescriptorProto_EnumReservedRange* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + InternalSwap(other); +} +void EnumDescriptorProto_EnumReservedRange::InternalSwap(EnumDescriptorProto_EnumReservedRange* other) { + using std::swap; + swap(start_, other->start_); + swap(end_, other->end_); + swap(_has_bits_[0], other->_has_bits_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + swap(_cached_size_, other->_cached_size_); +} + +::google::protobuf::Metadata EnumDescriptorProto_EnumReservedRange::GetMetadata() const { + protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages]; +} + + +// =================================================================== + +void EnumDescriptorProto::InitAsDefaultInstance() { + ::google::protobuf::_EnumDescriptorProto_default_instance_._instance.get_mutable()->options_ = const_cast< ::google::protobuf::EnumOptions*>( + ::google::protobuf::EnumOptions::internal_default_instance()); } -void OneofDescriptorProto::set_allocated_options(::google::protobuf::OneofOptions* options) { - delete options_; +void EnumDescriptorProto::unsafe_arena_set_allocated_options( + ::google::protobuf::EnumOptions* options) { + if (GetArenaNoVirtual() == NULL) { + delete options_; + } options_ = options; if (options) { set_has_options(); } else { clear_has_options(); } - // @@protoc_insertion_point(field_set_allocated:google.protobuf.OneofDescriptorProto.options) + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.EnumDescriptorProto.options) } - -#endif // PROTOBUF_INLINE_NOT_IN_HEADERS - -// =================================================================== - #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int EnumDescriptorProto::kNameFieldNumber; const int EnumDescriptorProto::kValueFieldNumber; const int EnumDescriptorProto::kOptionsFieldNumber; +const int EnumDescriptorProto::kReservedRangeFieldNumber; +const int EnumDescriptorProto::kReservedNameFieldNumber; #endif // !defined(_MSC_VER) || _MSC_VER >= 1900 EnumDescriptorProto::EnumDescriptorProto() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsEnumDescriptorProto(); } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.EnumDescriptorProto) } +EnumDescriptorProto::EnumDescriptorProto(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(), + _internal_metadata_(arena), + value_(arena), + reserved_range_(arena), + reserved_name_(arena) { + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsEnumDescriptorProto(); + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:google.protobuf.EnumDescriptorProto) +} EnumDescriptorProto::EnumDescriptorProto(const EnumDescriptorProto& from) : ::google::protobuf::Message(), _internal_metadata_(NULL), _has_bits_(from._has_bits_), _cached_size_(0), - value_(from.value_) { + value_(from.value_), + reserved_range_(from.reserved_range_), + reserved_name_(from.reserved_name_) { _internal_metadata_.MergeFrom(from._internal_metadata_); name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); if (from.has_name()) { - name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name(), + GetArenaNoVirtual()); } if (from.has_options()) { options_ = new ::google::protobuf::EnumOptions(*from.options_); @@ -5987,46 +5985,51 @@ EnumDescriptorProto::~EnumDescriptorProto() { } void EnumDescriptorProto::SharedDtor() { + GOOGLE_DCHECK(GetArenaNoVirtual() == NULL); name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != internal_default_instance()) { - delete options_; - } + if (this != internal_default_instance()) delete options_; } +void EnumDescriptorProto::ArenaDtor(void* object) { + EnumDescriptorProto* _this = reinterpret_cast< EnumDescriptorProto* >(object); + (void)_this; +} +void EnumDescriptorProto::RegisterArenaDtor(::google::protobuf::Arena* arena) { +} void EnumDescriptorProto::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* EnumDescriptorProto::descriptor() { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const EnumDescriptorProto& EnumDescriptorProto::default_instance() { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsEnumDescriptorProto(); return *internal_default_instance(); } -EnumDescriptorProto* EnumDescriptorProto::New(::google::protobuf::Arena* arena) const { - EnumDescriptorProto* n = new EnumDescriptorProto; - if (arena != NULL) { - arena->Own(n); - } - return n; -} void EnumDescriptorProto::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.EnumDescriptorProto) + ::google::protobuf::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + value_.Clear(); - if (_has_bits_[0 / 32] & 3u) { - if (has_name()) { + reserved_range_.Clear(); + reserved_name_.Clear(); + cached_has_bits = _has_bits_[0]; + if (cached_has_bits & 3u) { + if (cached_has_bits & 0x00000001u) { GOOGLE_DCHECK(!name_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); - (*name_.UnsafeRawStringPointer())->clear(); + name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - if (has_options()) { + if (cached_has_bits & 0x00000002u) { GOOGLE_DCHECK(options_ != NULL); - options_->::google::protobuf::EnumOptions::Clear(); + options_->Clear(); } } _has_bits_.Clear(); @@ -6046,11 +6049,11 @@ bool EnumDescriptorProto::MergePartialFromCodedStream( // optional string name = 1; case 1: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(10u)) { + static_cast< ::google::protobuf::uint8>(10u /* 10 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->name().data(), this->name().length(), + this->name().data(), static_cast<int>(this->name().length()), ::google::protobuf::internal::WireFormat::PARSE, "google.protobuf.EnumDescriptorProto.name"); } else { @@ -6062,8 +6065,8 @@ bool EnumDescriptorProto::MergePartialFromCodedStream( // repeated .google.protobuf.EnumValueDescriptorProto value = 2; case 2: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(18u)) { - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + static_cast< ::google::protobuf::uint8>(18u /* 18 & 0xFF */)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, add_value())); } else { goto handle_unusual; @@ -6074,8 +6077,8 @@ bool EnumDescriptorProto::MergePartialFromCodedStream( // optional .google.protobuf.EnumOptions options = 3; case 3: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(26u)) { - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + static_cast< ::google::protobuf::uint8>(26u /* 26 & 0xFF */)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, mutable_options())); } else { goto handle_unusual; @@ -6083,15 +6086,42 @@ bool EnumDescriptorProto::MergePartialFromCodedStream( break; } + // repeated .google.protobuf.EnumDescriptorProto.EnumReservedRange reserved_range = 4; + case 4: { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(34u /* 34 & 0xFF */)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( + input, add_reserved_range())); + } else { + goto handle_unusual; + } + break; + } + + // repeated string reserved_name = 5; + case 5: { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(42u /* 42 & 0xFF */)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadString( + input, this->add_reserved_name())); + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->reserved_name(this->reserved_name_size() - 1).data(), + static_cast<int>(this->reserved_name(this->reserved_name_size() - 1).length()), + ::google::protobuf::internal::WireFormat::PARSE, + "google.protobuf.EnumDescriptorProto.reserved_name"); + } else { + goto handle_unusual; + } + break; + } + default: { handle_unusual: - if (tag == 0 || - ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + if (tag == 0) { goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); + input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } @@ -6115,7 +6145,7 @@ void EnumDescriptorProto::SerializeWithCachedSizes( // optional string name = 1; if (cached_has_bits & 0x00000001u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->name().data(), this->name().length(), + this->name().data(), static_cast<int>(this->name().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.EnumDescriptorProto.name"); ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( @@ -6123,26 +6153,49 @@ void EnumDescriptorProto::SerializeWithCachedSizes( } // repeated .google.protobuf.EnumValueDescriptorProto value = 2; - for (unsigned int i = 0, n = this->value_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->value_size()); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 2, this->value(i), output); + 2, + this->value(static_cast<int>(i)), + output); } // optional .google.protobuf.EnumOptions options = 3; if (cached_has_bits & 0x00000002u) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 3, *this->options_, output); + 3, *options_, output); + } + + // repeated .google.protobuf.EnumDescriptorProto.EnumReservedRange reserved_range = 4; + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->reserved_range_size()); i < n; i++) { + ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( + 4, + this->reserved_range(static_cast<int>(i)), + output); + } + + // repeated string reserved_name = 5; + for (int i = 0, n = this->reserved_name_size(); i < n; i++) { + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->reserved_name(i).data(), static_cast<int>(this->reserved_name(i).length()), + ::google::protobuf::internal::WireFormat::SERIALIZE, + "google.protobuf.EnumDescriptorProto.reserved_name"); + ::google::protobuf::internal::WireFormatLite::WriteString( + 5, this->reserved_name(i), output); } if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); + _internal_metadata_.unknown_fields(), output); } // @@protoc_insertion_point(serialize_end:google.protobuf.EnumDescriptorProto) } ::google::protobuf::uint8* EnumDescriptorProto::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.EnumDescriptorProto) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -6151,7 +6204,7 @@ void EnumDescriptorProto::SerializeWithCachedSizes( // optional string name = 1; if (cached_has_bits & 0x00000001u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->name().data(), this->name().length(), + this->name().data(), static_cast<int>(this->name().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.EnumDescriptorProto.name"); target = @@ -6160,22 +6213,41 @@ void EnumDescriptorProto::SerializeWithCachedSizes( } // repeated .google.protobuf.EnumValueDescriptorProto value = 2; - for (unsigned int i = 0, n = this->value_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->value_size()); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: - InternalWriteMessageNoVirtualToArray( - 2, this->value(i), deterministic, target); + InternalWriteMessageToArray( + 2, this->value(static_cast<int>(i)), deterministic, target); } // optional .google.protobuf.EnumOptions options = 3; if (cached_has_bits & 0x00000002u) { target = ::google::protobuf::internal::WireFormatLite:: - InternalWriteMessageNoVirtualToArray( - 3, *this->options_, deterministic, target); + InternalWriteMessageToArray( + 3, *options_, deterministic, target); + } + + // repeated .google.protobuf.EnumDescriptorProto.EnumReservedRange reserved_range = 4; + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->reserved_range_size()); i < n; i++) { + target = ::google::protobuf::internal::WireFormatLite:: + InternalWriteMessageToArray( + 4, this->reserved_range(static_cast<int>(i)), deterministic, target); + } + + // repeated string reserved_name = 5; + for (int i = 0, n = this->reserved_name_size(); i < n; i++) { + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->reserved_name(i).data(), static_cast<int>(this->reserved_name(i).length()), + ::google::protobuf::internal::WireFormat::SERIALIZE, + "google.protobuf.EnumDescriptorProto.reserved_name"); + target = ::google::protobuf::internal::WireFormatLite:: + WriteStringToArray(5, this->reserved_name(i), target); } if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); + _internal_metadata_.unknown_fields(), target); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.EnumDescriptorProto) return target; @@ -6188,19 +6260,38 @@ size_t EnumDescriptorProto::ByteSizeLong() const { if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); + _internal_metadata_.unknown_fields()); } // repeated .google.protobuf.EnumValueDescriptorProto value = 2; { - unsigned int count = this->value_size(); + unsigned int count = static_cast<unsigned int>(this->value_size()); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSize( + this->value(static_cast<int>(i))); + } + } + + // repeated .google.protobuf.EnumDescriptorProto.EnumReservedRange reserved_range = 4; + { + unsigned int count = static_cast<unsigned int>(this->reserved_range_size()); total_size += 1UL * count; for (unsigned int i = 0; i < count; i++) { total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->value(i)); + ::google::protobuf::internal::WireFormatLite::MessageSize( + this->reserved_range(static_cast<int>(i))); } } + // repeated string reserved_name = 5; + total_size += 1 * + ::google::protobuf::internal::FromIntSize(this->reserved_name_size()); + for (int i = 0, n = this->reserved_name_size(); i < n; i++) { + total_size += ::google::protobuf::internal::WireFormatLite::StringSize( + this->reserved_name(i)); + } + if (_has_bits_[0 / 32] & 3u) { // optional string name = 1; if (has_name()) { @@ -6212,8 +6303,8 @@ size_t EnumDescriptorProto::ByteSizeLong() const { // optional .google.protobuf.EnumOptions options = 3; if (has_options()) { total_size += 1 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - *this->options_); + ::google::protobuf::internal::WireFormatLite::MessageSize( + *options_); } } @@ -6247,11 +6338,12 @@ void EnumDescriptorProto::MergeFrom(const EnumDescriptorProto& from) { (void) cached_has_bits; value_.MergeFrom(from.value_); + reserved_range_.MergeFrom(from.reserved_range_); + reserved_name_.MergeFrom(from.reserved_name_); cached_has_bits = from._has_bits_[0]; if (cached_has_bits & 3u) { if (cached_has_bits & 0x00000001u) { - set_has_name(); - name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); + set_name(from.name()); } if (cached_has_bits & 0x00000002u) { mutable_options()->::google::protobuf::EnumOptions::MergeFrom(from.options()); @@ -6283,167 +6375,60 @@ bool EnumDescriptorProto::IsInitialized() const { void EnumDescriptorProto::Swap(EnumDescriptorProto* other) { if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + EnumDescriptorProto* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } + } +} +void EnumDescriptorProto::UnsafeArenaSwap(EnumDescriptorProto* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); InternalSwap(other); } void EnumDescriptorProto::InternalSwap(EnumDescriptorProto* other) { - value_.InternalSwap(&other->value_); + using std::swap; + CastToBase(&value_)->InternalSwap(CastToBase(&other->value_)); + CastToBase(&reserved_range_)->InternalSwap(CastToBase(&other->reserved_range_)); + reserved_name_.InternalSwap(CastToBase(&other->reserved_name_)); name_.Swap(&other->name_); - std::swap(options_, other->options_); - std::swap(_has_bits_[0], other->_has_bits_[0]); + swap(options_, other->options_); + swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); - std::swap(_cached_size_, other->_cached_size_); + swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata EnumDescriptorProto::GetMetadata() const { protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages]; + return ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages]; } -#if PROTOBUF_INLINE_NOT_IN_HEADERS -// EnumDescriptorProto -// optional string name = 1; -bool EnumDescriptorProto::has_name() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -void EnumDescriptorProto::set_has_name() { - _has_bits_[0] |= 0x00000001u; -} -void EnumDescriptorProto::clear_has_name() { - _has_bits_[0] &= ~0x00000001u; -} -void EnumDescriptorProto::clear_name() { - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - clear_has_name(); -} -const ::std::string& EnumDescriptorProto::name() const { - // @@protoc_insertion_point(field_get:google.protobuf.EnumDescriptorProto.name) - return name_.GetNoArena(); -} -void EnumDescriptorProto::set_name(const ::std::string& value) { - set_has_name(); - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.EnumDescriptorProto.name) -} -#if LANG_CXX11 -void EnumDescriptorProto::set_name(::std::string&& value) { - set_has_name(); - name_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.EnumDescriptorProto.name) -} -#endif -void EnumDescriptorProto::set_name(const char* value) { - GOOGLE_DCHECK(value != NULL); - 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) { - set_has_name(); - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.EnumDescriptorProto.name) -} -::std::string* EnumDescriptorProto::mutable_name() { - set_has_name(); - // @@protoc_insertion_point(field_mutable:google.protobuf.EnumDescriptorProto.name) - return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -::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) { - if (name != NULL) { - set_has_name(); - } else { - clear_has_name(); - } - name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.EnumDescriptorProto.name) -} - -// repeated .google.protobuf.EnumValueDescriptorProto value = 2; -int EnumDescriptorProto::value_size() const { - return value_.size(); -} -void EnumDescriptorProto::clear_value() { - value_.Clear(); -} -const ::google::protobuf::EnumValueDescriptorProto& EnumDescriptorProto::value(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.EnumDescriptorProto.value) - return value_.Get(index); -} -::google::protobuf::EnumValueDescriptorProto* EnumDescriptorProto::mutable_value(int index) { - // @@protoc_insertion_point(field_mutable:google.protobuf.EnumDescriptorProto.value) - return value_.Mutable(index); -} -::google::protobuf::EnumValueDescriptorProto* EnumDescriptorProto::add_value() { - // @@protoc_insertion_point(field_add:google.protobuf.EnumDescriptorProto.value) - return value_.Add(); -} -::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumValueDescriptorProto >* -EnumDescriptorProto::mutable_value() { - // @@protoc_insertion_point(field_mutable_list:google.protobuf.EnumDescriptorProto.value) - return &value_; -} -const ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumValueDescriptorProto >& -EnumDescriptorProto::value() const { - // @@protoc_insertion_point(field_list:google.protobuf.EnumDescriptorProto.value) - return value_; -} +// =================================================================== -// optional .google.protobuf.EnumOptions options = 3; -bool EnumDescriptorProto::has_options() const { - return (_has_bits_[0] & 0x00000002u) != 0; -} -void EnumDescriptorProto::set_has_options() { - _has_bits_[0] |= 0x00000002u; -} -void EnumDescriptorProto::clear_has_options() { - _has_bits_[0] &= ~0x00000002u; -} -void EnumDescriptorProto::clear_options() { - if (options_ != NULL) options_->::google::protobuf::EnumOptions::Clear(); - clear_has_options(); -} -const ::google::protobuf::EnumOptions& EnumDescriptorProto::options() const { - // @@protoc_insertion_point(field_get:google.protobuf.EnumDescriptorProto.options) - return options_ != NULL ? *options_ - : *::google::protobuf::EnumOptions::internal_default_instance(); +void EnumValueDescriptorProto::InitAsDefaultInstance() { + ::google::protobuf::_EnumValueDescriptorProto_default_instance_._instance.get_mutable()->options_ = const_cast< ::google::protobuf::EnumValueOptions*>( + ::google::protobuf::EnumValueOptions::internal_default_instance()); } -::google::protobuf::EnumOptions* EnumDescriptorProto::mutable_options() { - set_has_options(); - if (options_ == NULL) { - options_ = new ::google::protobuf::EnumOptions; +void EnumValueDescriptorProto::unsafe_arena_set_allocated_options( + ::google::protobuf::EnumValueOptions* options) { + if (GetArenaNoVirtual() == NULL) { + delete options_; } - // @@protoc_insertion_point(field_mutable:google.protobuf.EnumDescriptorProto.options) - return options_; -} -::google::protobuf::EnumOptions* EnumDescriptorProto::release_options() { - // @@protoc_insertion_point(field_release:google.protobuf.EnumDescriptorProto.options) - clear_has_options(); - ::google::protobuf::EnumOptions* temp = options_; - options_ = NULL; - return temp; -} -void EnumDescriptorProto::set_allocated_options(::google::protobuf::EnumOptions* options) { - delete options_; options_ = options; if (options) { set_has_options(); } else { clear_has_options(); } - // @@protoc_insertion_point(field_set_allocated:google.protobuf.EnumDescriptorProto.options) + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.EnumValueDescriptorProto.options) } - -#endif // PROTOBUF_INLINE_NOT_IN_HEADERS - -// =================================================================== - #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int EnumValueDescriptorProto::kNameFieldNumber; const int EnumValueDescriptorProto::kNumberFieldNumber; @@ -6453,11 +6438,19 @@ const int EnumValueDescriptorProto::kOptionsFieldNumber; EnumValueDescriptorProto::EnumValueDescriptorProto() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsEnumValueDescriptorProto(); } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.EnumValueDescriptorProto) } +EnumValueDescriptorProto::EnumValueDescriptorProto(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(), + _internal_metadata_(arena) { + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsEnumValueDescriptorProto(); + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:google.protobuf.EnumValueDescriptorProto) +} EnumValueDescriptorProto::EnumValueDescriptorProto(const EnumValueDescriptorProto& from) : ::google::protobuf::Message(), _internal_metadata_(NULL), @@ -6466,7 +6459,8 @@ EnumValueDescriptorProto::EnumValueDescriptorProto(const EnumValueDescriptorProt _internal_metadata_.MergeFrom(from._internal_metadata_); name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); if (from.has_name()) { - name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name(), + GetArenaNoVirtual()); } if (from.has_options()) { options_ = new ::google::protobuf::EnumValueOptions(*from.options_); @@ -6480,8 +6474,9 @@ EnumValueDescriptorProto::EnumValueDescriptorProto(const EnumValueDescriptorProt void EnumValueDescriptorProto::SharedCtor() { _cached_size_ = 0; name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - ::memset(&options_, 0, reinterpret_cast<char*>(&number_) - - reinterpret_cast<char*>(&options_) + sizeof(number_)); + ::memset(&options_, 0, static_cast<size_t>( + reinterpret_cast<char*>(&number_) - + reinterpret_cast<char*>(&options_)) + sizeof(number_)); } EnumValueDescriptorProto::~EnumValueDescriptorProto() { @@ -6490,45 +6485,48 @@ EnumValueDescriptorProto::~EnumValueDescriptorProto() { } void EnumValueDescriptorProto::SharedDtor() { + GOOGLE_DCHECK(GetArenaNoVirtual() == NULL); name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != internal_default_instance()) { - delete options_; - } + if (this != internal_default_instance()) delete options_; } +void EnumValueDescriptorProto::ArenaDtor(void* object) { + EnumValueDescriptorProto* _this = reinterpret_cast< EnumValueDescriptorProto* >(object); + (void)_this; +} +void EnumValueDescriptorProto::RegisterArenaDtor(::google::protobuf::Arena* arena) { +} void EnumValueDescriptorProto::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* EnumValueDescriptorProto::descriptor() { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const EnumValueDescriptorProto& EnumValueDescriptorProto::default_instance() { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsEnumValueDescriptorProto(); return *internal_default_instance(); } -EnumValueDescriptorProto* EnumValueDescriptorProto::New(::google::protobuf::Arena* arena) const { - EnumValueDescriptorProto* n = new EnumValueDescriptorProto; - if (arena != NULL) { - arena->Own(n); - } - return n; -} void EnumValueDescriptorProto::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.EnumValueDescriptorProto) - if (_has_bits_[0 / 32] & 3u) { - if (has_name()) { + ::google::protobuf::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + cached_has_bits = _has_bits_[0]; + if (cached_has_bits & 3u) { + if (cached_has_bits & 0x00000001u) { GOOGLE_DCHECK(!name_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); - (*name_.UnsafeRawStringPointer())->clear(); + name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - if (has_options()) { + if (cached_has_bits & 0x00000002u) { GOOGLE_DCHECK(options_ != NULL); - options_->::google::protobuf::EnumValueOptions::Clear(); + options_->Clear(); } } number_ = 0; @@ -6549,11 +6547,11 @@ bool EnumValueDescriptorProto::MergePartialFromCodedStream( // optional string name = 1; case 1: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(10u)) { + static_cast< ::google::protobuf::uint8>(10u /* 10 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->name().data(), this->name().length(), + this->name().data(), static_cast<int>(this->name().length()), ::google::protobuf::internal::WireFormat::PARSE, "google.protobuf.EnumValueDescriptorProto.name"); } else { @@ -6565,7 +6563,7 @@ bool EnumValueDescriptorProto::MergePartialFromCodedStream( // optional int32 number = 2; case 2: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(16u)) { + static_cast< ::google::protobuf::uint8>(16u /* 16 & 0xFF */)) { set_has_number(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -6579,8 +6577,8 @@ bool EnumValueDescriptorProto::MergePartialFromCodedStream( // optional .google.protobuf.EnumValueOptions options = 3; case 3: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(26u)) { - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + static_cast< ::google::protobuf::uint8>(26u /* 26 & 0xFF */)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, mutable_options())); } else { goto handle_unusual; @@ -6590,13 +6588,11 @@ bool EnumValueDescriptorProto::MergePartialFromCodedStream( default: { handle_unusual: - if (tag == 0 || - ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + if (tag == 0) { goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); + input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } @@ -6620,7 +6616,7 @@ void EnumValueDescriptorProto::SerializeWithCachedSizes( // optional string name = 1; if (cached_has_bits & 0x00000001u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->name().data(), this->name().length(), + this->name().data(), static_cast<int>(this->name().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.EnumValueDescriptorProto.name"); ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( @@ -6635,18 +6631,19 @@ void EnumValueDescriptorProto::SerializeWithCachedSizes( // optional .google.protobuf.EnumValueOptions options = 3; if (cached_has_bits & 0x00000002u) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 3, *this->options_, output); + 3, *options_, output); } if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); + _internal_metadata_.unknown_fields(), output); } // @@protoc_insertion_point(serialize_end:google.protobuf.EnumValueDescriptorProto) } ::google::protobuf::uint8* EnumValueDescriptorProto::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.EnumValueDescriptorProto) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -6655,7 +6652,7 @@ void EnumValueDescriptorProto::SerializeWithCachedSizes( // optional string name = 1; if (cached_has_bits & 0x00000001u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->name().data(), this->name().length(), + this->name().data(), static_cast<int>(this->name().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.EnumValueDescriptorProto.name"); target = @@ -6671,13 +6668,13 @@ void EnumValueDescriptorProto::SerializeWithCachedSizes( // optional .google.protobuf.EnumValueOptions options = 3; if (cached_has_bits & 0x00000002u) { target = ::google::protobuf::internal::WireFormatLite:: - InternalWriteMessageNoVirtualToArray( - 3, *this->options_, deterministic, target); + InternalWriteMessageToArray( + 3, *options_, deterministic, target); } if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); + _internal_metadata_.unknown_fields(), target); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.EnumValueDescriptorProto) return target; @@ -6690,7 +6687,7 @@ size_t EnumValueDescriptorProto::ByteSizeLong() const { if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); + _internal_metadata_.unknown_fields()); } if (_has_bits_[0 / 32] & 7u) { // optional string name = 1; @@ -6703,8 +6700,8 @@ size_t EnumValueDescriptorProto::ByteSizeLong() const { // optional .google.protobuf.EnumValueOptions options = 3; if (has_options()) { total_size += 1 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - *this->options_); + ::google::protobuf::internal::WireFormatLite::MessageSize( + *options_); } // optional int32 number = 2; @@ -6747,8 +6744,7 @@ void EnumValueDescriptorProto::MergeFrom(const EnumValueDescriptorProto& from) { cached_has_bits = from._has_bits_[0]; if (cached_has_bits & 7u) { if (cached_has_bits & 0x00000001u) { - set_has_name(); - name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); + set_name(from.name()); } if (cached_has_bits & 0x00000002u) { mutable_options()->::google::protobuf::EnumValueOptions::MergeFrom(from.options()); @@ -6783,161 +6779,58 @@ bool EnumValueDescriptorProto::IsInitialized() const { void EnumValueDescriptorProto::Swap(EnumValueDescriptorProto* other) { if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + EnumValueDescriptorProto* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } + } +} +void EnumValueDescriptorProto::UnsafeArenaSwap(EnumValueDescriptorProto* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); InternalSwap(other); } void EnumValueDescriptorProto::InternalSwap(EnumValueDescriptorProto* other) { + using std::swap; name_.Swap(&other->name_); - std::swap(options_, other->options_); - std::swap(number_, other->number_); - std::swap(_has_bits_[0], other->_has_bits_[0]); + swap(options_, other->options_); + swap(number_, other->number_); + swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); - std::swap(_cached_size_, other->_cached_size_); + swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata EnumValueDescriptorProto::GetMetadata() const { protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages]; + return ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages]; } -#if PROTOBUF_INLINE_NOT_IN_HEADERS -// EnumValueDescriptorProto - -// optional string name = 1; -bool EnumValueDescriptorProto::has_name() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -void EnumValueDescriptorProto::set_has_name() { - _has_bits_[0] |= 0x00000001u; -} -void EnumValueDescriptorProto::clear_has_name() { - _has_bits_[0] &= ~0x00000001u; -} -void EnumValueDescriptorProto::clear_name() { - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - clear_has_name(); -} -const ::std::string& EnumValueDescriptorProto::name() const { - // @@protoc_insertion_point(field_get:google.protobuf.EnumValueDescriptorProto.name) - return name_.GetNoArena(); -} -void EnumValueDescriptorProto::set_name(const ::std::string& value) { - set_has_name(); - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.EnumValueDescriptorProto.name) -} -#if LANG_CXX11 -void EnumValueDescriptorProto::set_name(::std::string&& value) { - set_has_name(); - name_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.EnumValueDescriptorProto.name) -} -#endif -void EnumValueDescriptorProto::set_name(const char* value) { - GOOGLE_DCHECK(value != NULL); - 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) { - set_has_name(); - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.EnumValueDescriptorProto.name) -} -::std::string* EnumValueDescriptorProto::mutable_name() { - set_has_name(); - // @@protoc_insertion_point(field_mutable:google.protobuf.EnumValueDescriptorProto.name) - return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -::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) { - if (name != NULL) { - set_has_name(); - } else { - clear_has_name(); - } - name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.EnumValueDescriptorProto.name) -} -// optional int32 number = 2; -bool EnumValueDescriptorProto::has_number() const { - return (_has_bits_[0] & 0x00000004u) != 0; -} -void EnumValueDescriptorProto::set_has_number() { - _has_bits_[0] |= 0x00000004u; -} -void EnumValueDescriptorProto::clear_has_number() { - _has_bits_[0] &= ~0x00000004u; -} -void EnumValueDescriptorProto::clear_number() { - number_ = 0; - clear_has_number(); -} -::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) { - set_has_number(); - number_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.EnumValueDescriptorProto.number) -} +// =================================================================== -// optional .google.protobuf.EnumValueOptions options = 3; -bool EnumValueDescriptorProto::has_options() const { - return (_has_bits_[0] & 0x00000002u) != 0; -} -void EnumValueDescriptorProto::set_has_options() { - _has_bits_[0] |= 0x00000002u; -} -void EnumValueDescriptorProto::clear_has_options() { - _has_bits_[0] &= ~0x00000002u; -} -void EnumValueDescriptorProto::clear_options() { - if (options_ != NULL) options_->::google::protobuf::EnumValueOptions::Clear(); - clear_has_options(); -} -const ::google::protobuf::EnumValueOptions& EnumValueDescriptorProto::options() const { - // @@protoc_insertion_point(field_get:google.protobuf.EnumValueDescriptorProto.options) - return options_ != NULL ? *options_ - : *::google::protobuf::EnumValueOptions::internal_default_instance(); +void ServiceDescriptorProto::InitAsDefaultInstance() { + ::google::protobuf::_ServiceDescriptorProto_default_instance_._instance.get_mutable()->options_ = const_cast< ::google::protobuf::ServiceOptions*>( + ::google::protobuf::ServiceOptions::internal_default_instance()); } -::google::protobuf::EnumValueOptions* EnumValueDescriptorProto::mutable_options() { - set_has_options(); - if (options_ == NULL) { - options_ = new ::google::protobuf::EnumValueOptions; +void ServiceDescriptorProto::unsafe_arena_set_allocated_options( + ::google::protobuf::ServiceOptions* options) { + if (GetArenaNoVirtual() == NULL) { + delete options_; } - // @@protoc_insertion_point(field_mutable:google.protobuf.EnumValueDescriptorProto.options) - return options_; -} -::google::protobuf::EnumValueOptions* EnumValueDescriptorProto::release_options() { - // @@protoc_insertion_point(field_release:google.protobuf.EnumValueDescriptorProto.options) - clear_has_options(); - ::google::protobuf::EnumValueOptions* temp = options_; - options_ = NULL; - return temp; -} -void EnumValueDescriptorProto::set_allocated_options(::google::protobuf::EnumValueOptions* options) { - delete options_; options_ = options; if (options) { set_has_options(); } else { clear_has_options(); } - // @@protoc_insertion_point(field_set_allocated:google.protobuf.EnumValueDescriptorProto.options) + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.ServiceDescriptorProto.options) } - -#endif // PROTOBUF_INLINE_NOT_IN_HEADERS - -// =================================================================== - #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int ServiceDescriptorProto::kNameFieldNumber; const int ServiceDescriptorProto::kMethodFieldNumber; @@ -6947,11 +6840,20 @@ const int ServiceDescriptorProto::kOptionsFieldNumber; ServiceDescriptorProto::ServiceDescriptorProto() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsServiceDescriptorProto(); } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.ServiceDescriptorProto) } +ServiceDescriptorProto::ServiceDescriptorProto(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(), + _internal_metadata_(arena), + method_(arena) { + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsServiceDescriptorProto(); + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:google.protobuf.ServiceDescriptorProto) +} ServiceDescriptorProto::ServiceDescriptorProto(const ServiceDescriptorProto& from) : ::google::protobuf::Message(), _internal_metadata_(NULL), @@ -6961,7 +6863,8 @@ ServiceDescriptorProto::ServiceDescriptorProto(const ServiceDescriptorProto& fro _internal_metadata_.MergeFrom(from._internal_metadata_); name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); if (from.has_name()) { - name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name(), + GetArenaNoVirtual()); } if (from.has_options()) { options_ = new ::google::protobuf::ServiceOptions(*from.options_); @@ -6983,46 +6886,49 @@ ServiceDescriptorProto::~ServiceDescriptorProto() { } void ServiceDescriptorProto::SharedDtor() { + GOOGLE_DCHECK(GetArenaNoVirtual() == NULL); name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != internal_default_instance()) { - delete options_; - } + if (this != internal_default_instance()) delete options_; } +void ServiceDescriptorProto::ArenaDtor(void* object) { + ServiceDescriptorProto* _this = reinterpret_cast< ServiceDescriptorProto* >(object); + (void)_this; +} +void ServiceDescriptorProto::RegisterArenaDtor(::google::protobuf::Arena* arena) { +} void ServiceDescriptorProto::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* ServiceDescriptorProto::descriptor() { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const ServiceDescriptorProto& ServiceDescriptorProto::default_instance() { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsServiceDescriptorProto(); return *internal_default_instance(); } -ServiceDescriptorProto* ServiceDescriptorProto::New(::google::protobuf::Arena* arena) const { - ServiceDescriptorProto* n = new ServiceDescriptorProto; - if (arena != NULL) { - arena->Own(n); - } - return n; -} void ServiceDescriptorProto::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.ServiceDescriptorProto) + ::google::protobuf::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + method_.Clear(); - if (_has_bits_[0 / 32] & 3u) { - if (has_name()) { + cached_has_bits = _has_bits_[0]; + if (cached_has_bits & 3u) { + if (cached_has_bits & 0x00000001u) { GOOGLE_DCHECK(!name_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); - (*name_.UnsafeRawStringPointer())->clear(); + name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - if (has_options()) { + if (cached_has_bits & 0x00000002u) { GOOGLE_DCHECK(options_ != NULL); - options_->::google::protobuf::ServiceOptions::Clear(); + options_->Clear(); } } _has_bits_.Clear(); @@ -7042,11 +6948,11 @@ bool ServiceDescriptorProto::MergePartialFromCodedStream( // optional string name = 1; case 1: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(10u)) { + static_cast< ::google::protobuf::uint8>(10u /* 10 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->name().data(), this->name().length(), + this->name().data(), static_cast<int>(this->name().length()), ::google::protobuf::internal::WireFormat::PARSE, "google.protobuf.ServiceDescriptorProto.name"); } else { @@ -7058,8 +6964,8 @@ bool ServiceDescriptorProto::MergePartialFromCodedStream( // repeated .google.protobuf.MethodDescriptorProto method = 2; case 2: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(18u)) { - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + static_cast< ::google::protobuf::uint8>(18u /* 18 & 0xFF */)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, add_method())); } else { goto handle_unusual; @@ -7070,8 +6976,8 @@ bool ServiceDescriptorProto::MergePartialFromCodedStream( // optional .google.protobuf.ServiceOptions options = 3; case 3: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(26u)) { - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + static_cast< ::google::protobuf::uint8>(26u /* 26 & 0xFF */)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, mutable_options())); } else { goto handle_unusual; @@ -7081,13 +6987,11 @@ bool ServiceDescriptorProto::MergePartialFromCodedStream( default: { handle_unusual: - if (tag == 0 || - ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + if (tag == 0) { goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); + input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } @@ -7111,7 +7015,7 @@ void ServiceDescriptorProto::SerializeWithCachedSizes( // optional string name = 1; if (cached_has_bits & 0x00000001u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->name().data(), this->name().length(), + this->name().data(), static_cast<int>(this->name().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.ServiceDescriptorProto.name"); ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( @@ -7119,26 +7023,30 @@ void ServiceDescriptorProto::SerializeWithCachedSizes( } // repeated .google.protobuf.MethodDescriptorProto method = 2; - for (unsigned int i = 0, n = this->method_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->method_size()); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 2, this->method(i), output); + 2, + this->method(static_cast<int>(i)), + output); } // optional .google.protobuf.ServiceOptions options = 3; if (cached_has_bits & 0x00000002u) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 3, *this->options_, output); + 3, *options_, output); } if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); + _internal_metadata_.unknown_fields(), output); } // @@protoc_insertion_point(serialize_end:google.protobuf.ServiceDescriptorProto) } ::google::protobuf::uint8* ServiceDescriptorProto::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.ServiceDescriptorProto) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -7147,7 +7055,7 @@ void ServiceDescriptorProto::SerializeWithCachedSizes( // optional string name = 1; if (cached_has_bits & 0x00000001u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->name().data(), this->name().length(), + this->name().data(), static_cast<int>(this->name().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.ServiceDescriptorProto.name"); target = @@ -7156,22 +7064,23 @@ void ServiceDescriptorProto::SerializeWithCachedSizes( } // repeated .google.protobuf.MethodDescriptorProto method = 2; - for (unsigned int i = 0, n = this->method_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->method_size()); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: - InternalWriteMessageNoVirtualToArray( - 2, this->method(i), deterministic, target); + InternalWriteMessageToArray( + 2, this->method(static_cast<int>(i)), deterministic, target); } // optional .google.protobuf.ServiceOptions options = 3; if (cached_has_bits & 0x00000002u) { target = ::google::protobuf::internal::WireFormatLite:: - InternalWriteMessageNoVirtualToArray( - 3, *this->options_, deterministic, target); + InternalWriteMessageToArray( + 3, *options_, deterministic, target); } if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); + _internal_metadata_.unknown_fields(), target); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.ServiceDescriptorProto) return target; @@ -7184,16 +7093,16 @@ size_t ServiceDescriptorProto::ByteSizeLong() const { if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); + _internal_metadata_.unknown_fields()); } // repeated .google.protobuf.MethodDescriptorProto method = 2; { - unsigned int count = this->method_size(); + unsigned int count = static_cast<unsigned int>(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)); + ::google::protobuf::internal::WireFormatLite::MessageSize( + this->method(static_cast<int>(i))); } } @@ -7208,8 +7117,8 @@ size_t ServiceDescriptorProto::ByteSizeLong() const { // optional .google.protobuf.ServiceOptions options = 3; if (has_options()) { total_size += 1 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - *this->options_); + ::google::protobuf::internal::WireFormatLite::MessageSize( + *options_); } } @@ -7246,8 +7155,7 @@ void ServiceDescriptorProto::MergeFrom(const ServiceDescriptorProto& from) { cached_has_bits = from._has_bits_[0]; if (cached_has_bits & 3u) { if (cached_has_bits & 0x00000001u) { - set_has_name(); - name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); + set_name(from.name()); } if (cached_has_bits & 0x00000002u) { mutable_options()->::google::protobuf::ServiceOptions::MergeFrom(from.options()); @@ -7279,167 +7187,58 @@ bool ServiceDescriptorProto::IsInitialized() const { void ServiceDescriptorProto::Swap(ServiceDescriptorProto* other) { if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + ServiceDescriptorProto* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } + } +} +void ServiceDescriptorProto::UnsafeArenaSwap(ServiceDescriptorProto* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); InternalSwap(other); } void ServiceDescriptorProto::InternalSwap(ServiceDescriptorProto* other) { - method_.InternalSwap(&other->method_); + using std::swap; + CastToBase(&method_)->InternalSwap(CastToBase(&other->method_)); name_.Swap(&other->name_); - std::swap(options_, other->options_); - std::swap(_has_bits_[0], other->_has_bits_[0]); + swap(options_, other->options_); + swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); - std::swap(_cached_size_, other->_cached_size_); + swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata ServiceDescriptorProto::GetMetadata() const { protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages]; + return ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages]; } -#if PROTOBUF_INLINE_NOT_IN_HEADERS -// ServiceDescriptorProto - -// optional string name = 1; -bool ServiceDescriptorProto::has_name() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -void ServiceDescriptorProto::set_has_name() { - _has_bits_[0] |= 0x00000001u; -} -void ServiceDescriptorProto::clear_has_name() { - _has_bits_[0] &= ~0x00000001u; -} -void ServiceDescriptorProto::clear_name() { - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - clear_has_name(); -} -const ::std::string& ServiceDescriptorProto::name() const { - // @@protoc_insertion_point(field_get:google.protobuf.ServiceDescriptorProto.name) - return name_.GetNoArena(); -} -void ServiceDescriptorProto::set_name(const ::std::string& value) { - set_has_name(); - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.ServiceDescriptorProto.name) -} -#if LANG_CXX11 -void ServiceDescriptorProto::set_name(::std::string&& value) { - set_has_name(); - name_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.ServiceDescriptorProto.name) -} -#endif -void ServiceDescriptorProto::set_name(const char* value) { - GOOGLE_DCHECK(value != NULL); - 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) { - set_has_name(); - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.ServiceDescriptorProto.name) -} -::std::string* ServiceDescriptorProto::mutable_name() { - set_has_name(); - // @@protoc_insertion_point(field_mutable:google.protobuf.ServiceDescriptorProto.name) - return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -::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) { - if (name != NULL) { - set_has_name(); - } else { - clear_has_name(); - } - name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.ServiceDescriptorProto.name) -} -// repeated .google.protobuf.MethodDescriptorProto method = 2; -int ServiceDescriptorProto::method_size() const { - return method_.size(); -} -void ServiceDescriptorProto::clear_method() { - method_.Clear(); -} -const ::google::protobuf::MethodDescriptorProto& ServiceDescriptorProto::method(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.ServiceDescriptorProto.method) - return method_.Get(index); -} -::google::protobuf::MethodDescriptorProto* ServiceDescriptorProto::mutable_method(int index) { - // @@protoc_insertion_point(field_mutable:google.protobuf.ServiceDescriptorProto.method) - return method_.Mutable(index); -} -::google::protobuf::MethodDescriptorProto* ServiceDescriptorProto::add_method() { - // @@protoc_insertion_point(field_add:google.protobuf.ServiceDescriptorProto.method) - return method_.Add(); -} -::google::protobuf::RepeatedPtrField< ::google::protobuf::MethodDescriptorProto >* -ServiceDescriptorProto::mutable_method() { - // @@protoc_insertion_point(field_mutable_list:google.protobuf.ServiceDescriptorProto.method) - return &method_; -} -const ::google::protobuf::RepeatedPtrField< ::google::protobuf::MethodDescriptorProto >& -ServiceDescriptorProto::method() const { - // @@protoc_insertion_point(field_list:google.protobuf.ServiceDescriptorProto.method) - return method_; -} +// =================================================================== -// optional .google.protobuf.ServiceOptions options = 3; -bool ServiceDescriptorProto::has_options() const { - return (_has_bits_[0] & 0x00000002u) != 0; -} -void ServiceDescriptorProto::set_has_options() { - _has_bits_[0] |= 0x00000002u; -} -void ServiceDescriptorProto::clear_has_options() { - _has_bits_[0] &= ~0x00000002u; -} -void ServiceDescriptorProto::clear_options() { - if (options_ != NULL) options_->::google::protobuf::ServiceOptions::Clear(); - clear_has_options(); -} -const ::google::protobuf::ServiceOptions& ServiceDescriptorProto::options() const { - // @@protoc_insertion_point(field_get:google.protobuf.ServiceDescriptorProto.options) - return options_ != NULL ? *options_ - : *::google::protobuf::ServiceOptions::internal_default_instance(); +void MethodDescriptorProto::InitAsDefaultInstance() { + ::google::protobuf::_MethodDescriptorProto_default_instance_._instance.get_mutable()->options_ = const_cast< ::google::protobuf::MethodOptions*>( + ::google::protobuf::MethodOptions::internal_default_instance()); } -::google::protobuf::ServiceOptions* ServiceDescriptorProto::mutable_options() { - set_has_options(); - if (options_ == NULL) { - options_ = new ::google::protobuf::ServiceOptions; +void MethodDescriptorProto::unsafe_arena_set_allocated_options( + ::google::protobuf::MethodOptions* options) { + if (GetArenaNoVirtual() == NULL) { + delete options_; } - // @@protoc_insertion_point(field_mutable:google.protobuf.ServiceDescriptorProto.options) - return options_; -} -::google::protobuf::ServiceOptions* ServiceDescriptorProto::release_options() { - // @@protoc_insertion_point(field_release:google.protobuf.ServiceDescriptorProto.options) - clear_has_options(); - ::google::protobuf::ServiceOptions* temp = options_; - options_ = NULL; - return temp; -} -void ServiceDescriptorProto::set_allocated_options(::google::protobuf::ServiceOptions* options) { - delete options_; options_ = options; if (options) { set_has_options(); } else { clear_has_options(); } - // @@protoc_insertion_point(field_set_allocated:google.protobuf.ServiceDescriptorProto.options) + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.MethodDescriptorProto.options) } - -#endif // PROTOBUF_INLINE_NOT_IN_HEADERS - -// =================================================================== - #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int MethodDescriptorProto::kNameFieldNumber; const int MethodDescriptorProto::kInputTypeFieldNumber; @@ -7452,11 +7251,19 @@ const int MethodDescriptorProto::kServerStreamingFieldNumber; MethodDescriptorProto::MethodDescriptorProto() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsMethodDescriptorProto(); } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.MethodDescriptorProto) } +MethodDescriptorProto::MethodDescriptorProto(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(), + _internal_metadata_(arena) { + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsMethodDescriptorProto(); + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:google.protobuf.MethodDescriptorProto) +} MethodDescriptorProto::MethodDescriptorProto(const MethodDescriptorProto& from) : ::google::protobuf::Message(), _internal_metadata_(NULL), @@ -7465,15 +7272,18 @@ MethodDescriptorProto::MethodDescriptorProto(const MethodDescriptorProto& from) _internal_metadata_.MergeFrom(from._internal_metadata_); name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); if (from.has_name()) { - name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name(), + GetArenaNoVirtual()); } input_type_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); if (from.has_input_type()) { - input_type_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.input_type_); + input_type_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.input_type(), + GetArenaNoVirtual()); } output_type_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); if (from.has_output_type()) { - output_type_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.output_type_); + output_type_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.output_type(), + GetArenaNoVirtual()); } if (from.has_options()) { options_ = new ::google::protobuf::MethodOptions(*from.options_); @@ -7481,8 +7291,8 @@ MethodDescriptorProto::MethodDescriptorProto(const MethodDescriptorProto& from) options_ = NULL; } ::memcpy(&client_streaming_, &from.client_streaming_, - reinterpret_cast<char*>(&server_streaming_) - - reinterpret_cast<char*>(&client_streaming_) + sizeof(server_streaming_)); + static_cast<size_t>(reinterpret_cast<char*>(&server_streaming_) - + reinterpret_cast<char*>(&client_streaming_)) + sizeof(server_streaming_)); // @@protoc_insertion_point(copy_constructor:google.protobuf.MethodDescriptorProto) } @@ -7491,8 +7301,9 @@ void MethodDescriptorProto::SharedCtor() { name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); input_type_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); output_type_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - ::memset(&options_, 0, reinterpret_cast<char*>(&server_streaming_) - - reinterpret_cast<char*>(&options_) + sizeof(server_streaming_)); + ::memset(&options_, 0, static_cast<size_t>( + reinterpret_cast<char*>(&server_streaming_) - + reinterpret_cast<char*>(&options_)) + sizeof(server_streaming_)); } MethodDescriptorProto::~MethodDescriptorProto() { @@ -7501,61 +7312,63 @@ MethodDescriptorProto::~MethodDescriptorProto() { } void MethodDescriptorProto::SharedDtor() { + GOOGLE_DCHECK(GetArenaNoVirtual() == NULL); name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); input_type_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); output_type_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != internal_default_instance()) { - delete options_; - } + if (this != internal_default_instance()) delete options_; } +void MethodDescriptorProto::ArenaDtor(void* object) { + MethodDescriptorProto* _this = reinterpret_cast< MethodDescriptorProto* >(object); + (void)_this; +} +void MethodDescriptorProto::RegisterArenaDtor(::google::protobuf::Arena* arena) { +} void MethodDescriptorProto::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* MethodDescriptorProto::descriptor() { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const MethodDescriptorProto& MethodDescriptorProto::default_instance() { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsMethodDescriptorProto(); return *internal_default_instance(); } -MethodDescriptorProto* MethodDescriptorProto::New(::google::protobuf::Arena* arena) const { - MethodDescriptorProto* n = new MethodDescriptorProto; - if (arena != NULL) { - arena->Own(n); - } - return n; -} void MethodDescriptorProto::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.MethodDescriptorProto) - if (_has_bits_[0 / 32] & 15u) { - if (has_name()) { + ::google::protobuf::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + cached_has_bits = _has_bits_[0]; + if (cached_has_bits & 15u) { + if (cached_has_bits & 0x00000001u) { GOOGLE_DCHECK(!name_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); - (*name_.UnsafeRawStringPointer())->clear(); + name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - if (has_input_type()) { + if (cached_has_bits & 0x00000002u) { GOOGLE_DCHECK(!input_type_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); - (*input_type_.UnsafeRawStringPointer())->clear(); + input_type_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - if (has_output_type()) { + if (cached_has_bits & 0x00000004u) { GOOGLE_DCHECK(!output_type_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); - (*output_type_.UnsafeRawStringPointer())->clear(); + output_type_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - if (has_options()) { + if (cached_has_bits & 0x00000008u) { GOOGLE_DCHECK(options_ != NULL); - options_->::google::protobuf::MethodOptions::Clear(); + options_->Clear(); } } - if (_has_bits_[0 / 32] & 48u) { - ::memset(&client_streaming_, 0, reinterpret_cast<char*>(&server_streaming_) - - reinterpret_cast<char*>(&client_streaming_) + sizeof(server_streaming_)); - } + ::memset(&client_streaming_, 0, static_cast<size_t>( + reinterpret_cast<char*>(&server_streaming_) - + reinterpret_cast<char*>(&client_streaming_)) + sizeof(server_streaming_)); _has_bits_.Clear(); _internal_metadata_.Clear(); } @@ -7573,11 +7386,11 @@ bool MethodDescriptorProto::MergePartialFromCodedStream( // optional string name = 1; case 1: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(10u)) { + static_cast< ::google::protobuf::uint8>(10u /* 10 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->name().data(), this->name().length(), + this->name().data(), static_cast<int>(this->name().length()), ::google::protobuf::internal::WireFormat::PARSE, "google.protobuf.MethodDescriptorProto.name"); } else { @@ -7589,11 +7402,11 @@ bool MethodDescriptorProto::MergePartialFromCodedStream( // optional string input_type = 2; case 2: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(18u)) { + static_cast< ::google::protobuf::uint8>(18u /* 18 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_input_type())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->input_type().data(), this->input_type().length(), + this->input_type().data(), static_cast<int>(this->input_type().length()), ::google::protobuf::internal::WireFormat::PARSE, "google.protobuf.MethodDescriptorProto.input_type"); } else { @@ -7605,11 +7418,11 @@ bool MethodDescriptorProto::MergePartialFromCodedStream( // optional string output_type = 3; case 3: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(26u)) { + static_cast< ::google::protobuf::uint8>(26u /* 26 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_output_type())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->output_type().data(), this->output_type().length(), + this->output_type().data(), static_cast<int>(this->output_type().length()), ::google::protobuf::internal::WireFormat::PARSE, "google.protobuf.MethodDescriptorProto.output_type"); } else { @@ -7621,8 +7434,8 @@ bool MethodDescriptorProto::MergePartialFromCodedStream( // optional .google.protobuf.MethodOptions options = 4; case 4: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(34u)) { - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + static_cast< ::google::protobuf::uint8>(34u /* 34 & 0xFF */)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, mutable_options())); } else { goto handle_unusual; @@ -7633,7 +7446,7 @@ bool MethodDescriptorProto::MergePartialFromCodedStream( // optional bool client_streaming = 5 [default = false]; case 5: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(40u)) { + static_cast< ::google::protobuf::uint8>(40u /* 40 & 0xFF */)) { set_has_client_streaming(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -7647,7 +7460,7 @@ bool MethodDescriptorProto::MergePartialFromCodedStream( // optional bool server_streaming = 6 [default = false]; case 6: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(48u)) { + static_cast< ::google::protobuf::uint8>(48u /* 48 & 0xFF */)) { set_has_server_streaming(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -7660,13 +7473,11 @@ bool MethodDescriptorProto::MergePartialFromCodedStream( default: { handle_unusual: - if (tag == 0 || - ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + if (tag == 0) { goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); + input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } @@ -7690,7 +7501,7 @@ void MethodDescriptorProto::SerializeWithCachedSizes( // optional string name = 1; if (cached_has_bits & 0x00000001u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->name().data(), this->name().length(), + this->name().data(), static_cast<int>(this->name().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.MethodDescriptorProto.name"); ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( @@ -7700,7 +7511,7 @@ void MethodDescriptorProto::SerializeWithCachedSizes( // optional string input_type = 2; if (cached_has_bits & 0x00000002u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->input_type().data(), this->input_type().length(), + this->input_type().data(), static_cast<int>(this->input_type().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.MethodDescriptorProto.input_type"); ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( @@ -7710,7 +7521,7 @@ void MethodDescriptorProto::SerializeWithCachedSizes( // optional string output_type = 3; if (cached_has_bits & 0x00000004u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->output_type().data(), this->output_type().length(), + this->output_type().data(), static_cast<int>(this->output_type().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.MethodDescriptorProto.output_type"); ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( @@ -7720,7 +7531,7 @@ void MethodDescriptorProto::SerializeWithCachedSizes( // optional .google.protobuf.MethodOptions options = 4; if (cached_has_bits & 0x00000008u) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 4, *this->options_, output); + 4, *options_, output); } // optional bool client_streaming = 5 [default = false]; @@ -7735,13 +7546,14 @@ void MethodDescriptorProto::SerializeWithCachedSizes( if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); + _internal_metadata_.unknown_fields(), output); } // @@protoc_insertion_point(serialize_end:google.protobuf.MethodDescriptorProto) } ::google::protobuf::uint8* MethodDescriptorProto::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.MethodDescriptorProto) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -7750,7 +7562,7 @@ void MethodDescriptorProto::SerializeWithCachedSizes( // optional string name = 1; if (cached_has_bits & 0x00000001u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->name().data(), this->name().length(), + this->name().data(), static_cast<int>(this->name().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.MethodDescriptorProto.name"); target = @@ -7761,7 +7573,7 @@ void MethodDescriptorProto::SerializeWithCachedSizes( // optional string input_type = 2; if (cached_has_bits & 0x00000002u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->input_type().data(), this->input_type().length(), + this->input_type().data(), static_cast<int>(this->input_type().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.MethodDescriptorProto.input_type"); target = @@ -7772,7 +7584,7 @@ void MethodDescriptorProto::SerializeWithCachedSizes( // optional string output_type = 3; if (cached_has_bits & 0x00000004u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->output_type().data(), this->output_type().length(), + this->output_type().data(), static_cast<int>(this->output_type().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.MethodDescriptorProto.output_type"); target = @@ -7783,8 +7595,8 @@ void MethodDescriptorProto::SerializeWithCachedSizes( // optional .google.protobuf.MethodOptions options = 4; if (cached_has_bits & 0x00000008u) { target = ::google::protobuf::internal::WireFormatLite:: - InternalWriteMessageNoVirtualToArray( - 4, *this->options_, deterministic, target); + InternalWriteMessageToArray( + 4, *options_, deterministic, target); } // optional bool client_streaming = 5 [default = false]; @@ -7799,7 +7611,7 @@ void MethodDescriptorProto::SerializeWithCachedSizes( if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); + _internal_metadata_.unknown_fields(), target); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.MethodDescriptorProto) return target; @@ -7812,7 +7624,7 @@ size_t MethodDescriptorProto::ByteSizeLong() const { if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); + _internal_metadata_.unknown_fields()); } if (_has_bits_[0 / 32] & 63u) { // optional string name = 1; @@ -7839,8 +7651,8 @@ size_t MethodDescriptorProto::ByteSizeLong() const { // optional .google.protobuf.MethodOptions options = 4; if (has_options()) { total_size += 1 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - *this->options_); + ::google::protobuf::internal::WireFormatLite::MessageSize( + *options_); } // optional bool client_streaming = 5 [default = false]; @@ -7886,16 +7698,13 @@ void MethodDescriptorProto::MergeFrom(const MethodDescriptorProto& from) { cached_has_bits = from._has_bits_[0]; if (cached_has_bits & 63u) { if (cached_has_bits & 0x00000001u) { - set_has_name(); - name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); + set_name(from.name()); } if (cached_has_bits & 0x00000002u) { - set_has_input_type(); - input_type_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.input_type_); + set_input_type(from.input_type()); } if (cached_has_bits & 0x00000004u) { - set_has_output_type(); - output_type_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.output_type_); + set_output_type(from.output_type()); } if (cached_has_bits & 0x00000008u) { mutable_options()->::google::protobuf::MethodOptions::MergeFrom(from.options()); @@ -7933,314 +7742,46 @@ bool MethodDescriptorProto::IsInitialized() const { void MethodDescriptorProto::Swap(MethodDescriptorProto* other) { if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + MethodDescriptorProto* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } + } +} +void MethodDescriptorProto::UnsafeArenaSwap(MethodDescriptorProto* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); InternalSwap(other); } void MethodDescriptorProto::InternalSwap(MethodDescriptorProto* other) { + using std::swap; name_.Swap(&other->name_); input_type_.Swap(&other->input_type_); output_type_.Swap(&other->output_type_); - std::swap(options_, other->options_); - std::swap(client_streaming_, other->client_streaming_); - std::swap(server_streaming_, other->server_streaming_); - std::swap(_has_bits_[0], other->_has_bits_[0]); + swap(options_, other->options_); + swap(client_streaming_, other->client_streaming_); + swap(server_streaming_, other->server_streaming_); + swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); - std::swap(_cached_size_, other->_cached_size_); + swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata MethodDescriptorProto::GetMetadata() const { protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages]; + return ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages]; } -#if PROTOBUF_INLINE_NOT_IN_HEADERS -// MethodDescriptorProto - -// optional string name = 1; -bool MethodDescriptorProto::has_name() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -void MethodDescriptorProto::set_has_name() { - _has_bits_[0] |= 0x00000001u; -} -void MethodDescriptorProto::clear_has_name() { - _has_bits_[0] &= ~0x00000001u; -} -void MethodDescriptorProto::clear_name() { - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - clear_has_name(); -} -const ::std::string& MethodDescriptorProto::name() const { - // @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.name) - return name_.GetNoArena(); -} -void MethodDescriptorProto::set_name(const ::std::string& value) { - set_has_name(); - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.name) -} -#if LANG_CXX11 -void MethodDescriptorProto::set_name(::std::string&& value) { - set_has_name(); - name_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.MethodDescriptorProto.name) -} -#endif -void MethodDescriptorProto::set_name(const char* value) { - GOOGLE_DCHECK(value != NULL); - 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) { - set_has_name(); - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.MethodDescriptorProto.name) -} -::std::string* MethodDescriptorProto::mutable_name() { - set_has_name(); - // @@protoc_insertion_point(field_mutable:google.protobuf.MethodDescriptorProto.name) - return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -::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) { - if (name != NULL) { - set_has_name(); - } else { - clear_has_name(); - } - name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.MethodDescriptorProto.name) -} - -// optional string input_type = 2; -bool MethodDescriptorProto::has_input_type() const { - return (_has_bits_[0] & 0x00000002u) != 0; -} -void MethodDescriptorProto::set_has_input_type() { - _has_bits_[0] |= 0x00000002u; -} -void MethodDescriptorProto::clear_has_input_type() { - _has_bits_[0] &= ~0x00000002u; -} -void MethodDescriptorProto::clear_input_type() { - input_type_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - clear_has_input_type(); -} -const ::std::string& MethodDescriptorProto::input_type() const { - // @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.input_type) - return input_type_.GetNoArena(); -} -void MethodDescriptorProto::set_input_type(const ::std::string& value) { - set_has_input_type(); - input_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.input_type) -} -#if LANG_CXX11 -void MethodDescriptorProto::set_input_type(::std::string&& value) { - set_has_input_type(); - input_type_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.MethodDescriptorProto.input_type) -} -#endif -void MethodDescriptorProto::set_input_type(const char* value) { - GOOGLE_DCHECK(value != NULL); - 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) { - set_has_input_type(); - input_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.MethodDescriptorProto.input_type) -} -::std::string* MethodDescriptorProto::mutable_input_type() { - 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() { - // @@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) { - if (input_type != NULL) { - set_has_input_type(); - } else { - clear_has_input_type(); - } - input_type_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), input_type); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.MethodDescriptorProto.input_type) -} - -// optional string output_type = 3; -bool MethodDescriptorProto::has_output_type() const { - return (_has_bits_[0] & 0x00000004u) != 0; -} -void MethodDescriptorProto::set_has_output_type() { - _has_bits_[0] |= 0x00000004u; -} -void MethodDescriptorProto::clear_has_output_type() { - _has_bits_[0] &= ~0x00000004u; -} -void MethodDescriptorProto::clear_output_type() { - output_type_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - clear_has_output_type(); -} -const ::std::string& MethodDescriptorProto::output_type() const { - // @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.output_type) - return output_type_.GetNoArena(); -} -void MethodDescriptorProto::set_output_type(const ::std::string& value) { - set_has_output_type(); - output_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.output_type) -} -#if LANG_CXX11 -void MethodDescriptorProto::set_output_type(::std::string&& value) { - set_has_output_type(); - output_type_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.MethodDescriptorProto.output_type) -} -#endif -void MethodDescriptorProto::set_output_type(const char* value) { - GOOGLE_DCHECK(value != NULL); - 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) { - set_has_output_type(); - output_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.MethodDescriptorProto.output_type) -} -::std::string* MethodDescriptorProto::mutable_output_type() { - 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() { - // @@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) { - if (output_type != NULL) { - set_has_output_type(); - } else { - clear_has_output_type(); - } - output_type_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), output_type); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.MethodDescriptorProto.output_type) -} - -// optional .google.protobuf.MethodOptions options = 4; -bool MethodDescriptorProto::has_options() const { - return (_has_bits_[0] & 0x00000008u) != 0; -} -void MethodDescriptorProto::set_has_options() { - _has_bits_[0] |= 0x00000008u; -} -void MethodDescriptorProto::clear_has_options() { - _has_bits_[0] &= ~0x00000008u; -} -void MethodDescriptorProto::clear_options() { - if (options_ != NULL) options_->::google::protobuf::MethodOptions::Clear(); - clear_has_options(); -} -const ::google::protobuf::MethodOptions& MethodDescriptorProto::options() const { - // @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.options) - return options_ != NULL ? *options_ - : *::google::protobuf::MethodOptions::internal_default_instance(); -} -::google::protobuf::MethodOptions* MethodDescriptorProto::mutable_options() { - set_has_options(); - if (options_ == NULL) { - options_ = new ::google::protobuf::MethodOptions; - } - // @@protoc_insertion_point(field_mutable:google.protobuf.MethodDescriptorProto.options) - return options_; -} -::google::protobuf::MethodOptions* MethodDescriptorProto::release_options() { - // @@protoc_insertion_point(field_release:google.protobuf.MethodDescriptorProto.options) - clear_has_options(); - ::google::protobuf::MethodOptions* temp = options_; - options_ = NULL; - return temp; -} -void MethodDescriptorProto::set_allocated_options(::google::protobuf::MethodOptions* options) { - delete options_; - options_ = options; - if (options) { - set_has_options(); - } else { - clear_has_options(); - } - // @@protoc_insertion_point(field_set_allocated:google.protobuf.MethodDescriptorProto.options) -} - -// optional bool client_streaming = 5 [default = false]; -bool MethodDescriptorProto::has_client_streaming() const { - return (_has_bits_[0] & 0x00000010u) != 0; -} -void MethodDescriptorProto::set_has_client_streaming() { - _has_bits_[0] |= 0x00000010u; -} -void MethodDescriptorProto::clear_has_client_streaming() { - _has_bits_[0] &= ~0x00000010u; -} -void MethodDescriptorProto::clear_client_streaming() { - client_streaming_ = false; - clear_has_client_streaming(); -} -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) { - set_has_client_streaming(); - client_streaming_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.client_streaming) -} - -// optional bool server_streaming = 6 [default = false]; -bool MethodDescriptorProto::has_server_streaming() const { - return (_has_bits_[0] & 0x00000020u) != 0; -} -void MethodDescriptorProto::set_has_server_streaming() { - _has_bits_[0] |= 0x00000020u; -} -void MethodDescriptorProto::clear_has_server_streaming() { - _has_bits_[0] &= ~0x00000020u; -} -void MethodDescriptorProto::clear_server_streaming() { - server_streaming_ = false; - clear_has_server_streaming(); -} -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) { - set_has_server_streaming(); - server_streaming_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.server_streaming) -} - -#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== +void FileOptions::InitAsDefaultInstance() { +} #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int FileOptions::kJavaPackageFieldNumber; const int FileOptions::kJavaOuterClassnameFieldNumber; @@ -8252,6 +7793,7 @@ const int FileOptions::kGoPackageFieldNumber; const int FileOptions::kCcGenericServicesFieldNumber; const int FileOptions::kJavaGenericServicesFieldNumber; const int FileOptions::kPyGenericServicesFieldNumber; +const int FileOptions::kPhpGenericServicesFieldNumber; const int FileOptions::kDeprecatedFieldNumber; const int FileOptions::kCcEnableArenasFieldNumber; const int FileOptions::kObjcClassPrefixFieldNumber; @@ -8265,11 +7807,21 @@ const int FileOptions::kUninterpretedOptionFieldNumber; FileOptions::FileOptions() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsFileOptions(); } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.FileOptions) } +FileOptions::FileOptions(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(), + _extensions_(arena), + _internal_metadata_(arena), + uninterpreted_option_(arena) { + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsFileOptions(); + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:google.protobuf.FileOptions) +} FileOptions::FileOptions(const FileOptions& from) : ::google::protobuf::Message(), _internal_metadata_(NULL), @@ -8280,39 +7832,47 @@ FileOptions::FileOptions(const FileOptions& from) _extensions_.MergeFrom(from._extensions_); java_package_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); if (from.has_java_package()) { - java_package_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.java_package_); + java_package_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.java_package(), + GetArenaNoVirtual()); } java_outer_classname_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); if (from.has_java_outer_classname()) { - java_outer_classname_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.java_outer_classname_); + java_outer_classname_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.java_outer_classname(), + GetArenaNoVirtual()); } go_package_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); if (from.has_go_package()) { - go_package_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.go_package_); + go_package_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.go_package(), + GetArenaNoVirtual()); } objc_class_prefix_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); if (from.has_objc_class_prefix()) { - objc_class_prefix_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.objc_class_prefix_); + objc_class_prefix_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.objc_class_prefix(), + GetArenaNoVirtual()); } csharp_namespace_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); if (from.has_csharp_namespace()) { - csharp_namespace_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.csharp_namespace_); + csharp_namespace_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.csharp_namespace(), + GetArenaNoVirtual()); } swift_prefix_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); if (from.has_swift_prefix()) { - swift_prefix_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.swift_prefix_); + swift_prefix_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.swift_prefix(), + GetArenaNoVirtual()); } php_class_prefix_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); if (from.has_php_class_prefix()) { - php_class_prefix_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.php_class_prefix_); + php_class_prefix_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.php_class_prefix(), + GetArenaNoVirtual()); } php_namespace_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); if (from.has_php_namespace()) { - php_namespace_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.php_namespace_); + php_namespace_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.php_namespace(), + GetArenaNoVirtual()); } - ::memcpy(&java_multiple_files_, &from.java_multiple_files_, - reinterpret_cast<char*>(&optimize_for_) - - reinterpret_cast<char*>(&java_multiple_files_) + sizeof(optimize_for_)); + ::memcpy(&cc_enable_arenas_, &from.cc_enable_arenas_, + static_cast<size_t>(reinterpret_cast<char*>(&optimize_for_) - + reinterpret_cast<char*>(&cc_enable_arenas_)) + sizeof(optimize_for_)); // @@protoc_insertion_point(copy_constructor:google.protobuf.FileOptions) } @@ -8326,8 +7886,9 @@ void FileOptions::SharedCtor() { swift_prefix_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); php_class_prefix_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); php_namespace_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - ::memset(&java_multiple_files_, 0, reinterpret_cast<char*>(&cc_enable_arenas_) - - reinterpret_cast<char*>(&java_multiple_files_) + sizeof(cc_enable_arenas_)); + ::memset(&cc_enable_arenas_, 0, static_cast<size_t>( + reinterpret_cast<char*>(&deprecated_) - + reinterpret_cast<char*>(&cc_enable_arenas_)) + sizeof(deprecated_)); optimize_for_ = 1; } @@ -8337,6 +7898,7 @@ FileOptions::~FileOptions() { } void FileOptions::SharedDtor() { + GOOGLE_DCHECK(GetArenaNoVirtual() == NULL); java_package_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); java_outer_classname_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); go_package_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -8347,72 +7909,80 @@ void FileOptions::SharedDtor() { php_namespace_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } +void FileOptions::ArenaDtor(void* object) { + FileOptions* _this = reinterpret_cast< FileOptions* >(object); + (void)_this; +} +void FileOptions::RegisterArenaDtor(::google::protobuf::Arena* arena) { +} void FileOptions::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* FileOptions::descriptor() { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const FileOptions& FileOptions::default_instance() { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsFileOptions(); return *internal_default_instance(); } -FileOptions* FileOptions::New(::google::protobuf::Arena* arena) const { - FileOptions* n = new FileOptions; - if (arena != NULL) { - arena->Own(n); - } - return n; -} void FileOptions::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.FileOptions) + ::google::protobuf::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + _extensions_.Clear(); uninterpreted_option_.Clear(); - if (_has_bits_[0 / 32] & 255u) { - if (has_java_package()) { + cached_has_bits = _has_bits_[0]; + if (cached_has_bits & 255u) { + if (cached_has_bits & 0x00000001u) { GOOGLE_DCHECK(!java_package_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); - (*java_package_.UnsafeRawStringPointer())->clear(); + java_package_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - if (has_java_outer_classname()) { + if (cached_has_bits & 0x00000002u) { GOOGLE_DCHECK(!java_outer_classname_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); - (*java_outer_classname_.UnsafeRawStringPointer())->clear(); + java_outer_classname_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - if (has_go_package()) { + if (cached_has_bits & 0x00000004u) { GOOGLE_DCHECK(!go_package_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); - (*go_package_.UnsafeRawStringPointer())->clear(); + go_package_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - if (has_objc_class_prefix()) { + if (cached_has_bits & 0x00000008u) { GOOGLE_DCHECK(!objc_class_prefix_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); - (*objc_class_prefix_.UnsafeRawStringPointer())->clear(); + objc_class_prefix_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - if (has_csharp_namespace()) { + if (cached_has_bits & 0x00000010u) { GOOGLE_DCHECK(!csharp_namespace_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); - (*csharp_namespace_.UnsafeRawStringPointer())->clear(); + csharp_namespace_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - if (has_swift_prefix()) { + if (cached_has_bits & 0x00000020u) { GOOGLE_DCHECK(!swift_prefix_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); - (*swift_prefix_.UnsafeRawStringPointer())->clear(); + swift_prefix_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - if (has_php_class_prefix()) { + if (cached_has_bits & 0x00000040u) { GOOGLE_DCHECK(!php_class_prefix_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); - (*php_class_prefix_.UnsafeRawStringPointer())->clear(); + php_class_prefix_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - if (has_php_namespace()) { + if (cached_has_bits & 0x00000080u) { GOOGLE_DCHECK(!php_namespace_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); - (*php_namespace_.UnsafeRawStringPointer())->clear(); + php_namespace_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } } - if (_has_bits_[8 / 32] & 65280u) { - ::memset(&java_multiple_files_, 0, reinterpret_cast<char*>(&cc_enable_arenas_) - - reinterpret_cast<char*>(&java_multiple_files_) + sizeof(cc_enable_arenas_)); + if (cached_has_bits & 65280u) { + ::memset(&cc_enable_arenas_, 0, static_cast<size_t>( + reinterpret_cast<char*>(&php_generic_services_) - + reinterpret_cast<char*>(&cc_enable_arenas_)) + sizeof(php_generic_services_)); + } + if (cached_has_bits & 196608u) { + deprecated_ = false; + optimize_for_ = 1; } - optimize_for_ = 1; _has_bits_.Clear(); _internal_metadata_.Clear(); } @@ -8430,11 +8000,11 @@ bool FileOptions::MergePartialFromCodedStream( // optional string java_package = 1; case 1: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(10u)) { + static_cast< ::google::protobuf::uint8>(10u /* 10 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_java_package())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->java_package().data(), this->java_package().length(), + this->java_package().data(), static_cast<int>(this->java_package().length()), ::google::protobuf::internal::WireFormat::PARSE, "google.protobuf.FileOptions.java_package"); } else { @@ -8446,11 +8016,11 @@ bool FileOptions::MergePartialFromCodedStream( // optional string java_outer_classname = 8; case 8: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(66u)) { + static_cast< ::google::protobuf::uint8>(66u /* 66 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_java_outer_classname())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->java_outer_classname().data(), this->java_outer_classname().length(), + this->java_outer_classname().data(), static_cast<int>(this->java_outer_classname().length()), ::google::protobuf::internal::WireFormat::PARSE, "google.protobuf.FileOptions.java_outer_classname"); } else { @@ -8462,7 +8032,7 @@ bool FileOptions::MergePartialFromCodedStream( // optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED]; case 9: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(72u)) { + static_cast< ::google::protobuf::uint8>(72u /* 72 & 0xFF */)) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -8470,7 +8040,8 @@ bool FileOptions::MergePartialFromCodedStream( if (::google::protobuf::FileOptions_OptimizeMode_IsValid(value)) { set_optimize_for(static_cast< ::google::protobuf::FileOptions_OptimizeMode >(value)); } else { - mutable_unknown_fields()->AddVarint(9, value); + mutable_unknown_fields()->AddVarint( + 9, static_cast< ::google::protobuf::uint64>(value)); } } else { goto handle_unusual; @@ -8481,7 +8052,7 @@ bool FileOptions::MergePartialFromCodedStream( // optional bool java_multiple_files = 10 [default = false]; case 10: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(80u)) { + static_cast< ::google::protobuf::uint8>(80u /* 80 & 0xFF */)) { set_has_java_multiple_files(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -8495,11 +8066,11 @@ bool FileOptions::MergePartialFromCodedStream( // optional string go_package = 11; case 11: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(90u)) { + static_cast< ::google::protobuf::uint8>(90u /* 90 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_go_package())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->go_package().data(), this->go_package().length(), + this->go_package().data(), static_cast<int>(this->go_package().length()), ::google::protobuf::internal::WireFormat::PARSE, "google.protobuf.FileOptions.go_package"); } else { @@ -8511,7 +8082,7 @@ bool FileOptions::MergePartialFromCodedStream( // optional bool cc_generic_services = 16 [default = false]; case 16: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(128u)) { + static_cast< ::google::protobuf::uint8>(128u /* 128 & 0xFF */)) { set_has_cc_generic_services(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -8525,7 +8096,7 @@ bool FileOptions::MergePartialFromCodedStream( // optional bool java_generic_services = 17 [default = false]; case 17: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(136u)) { + static_cast< ::google::protobuf::uint8>(136u /* 136 & 0xFF */)) { set_has_java_generic_services(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -8539,7 +8110,7 @@ bool FileOptions::MergePartialFromCodedStream( // optional bool py_generic_services = 18 [default = false]; case 18: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(144u)) { + static_cast< ::google::protobuf::uint8>(144u /* 144 & 0xFF */)) { set_has_py_generic_services(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -8553,7 +8124,7 @@ bool FileOptions::MergePartialFromCodedStream( // optional bool java_generate_equals_and_hash = 20 [deprecated = true]; case 20: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(160u)) { + static_cast< ::google::protobuf::uint8>(160u /* 160 & 0xFF */)) { set_has_java_generate_equals_and_hash(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -8567,7 +8138,7 @@ bool FileOptions::MergePartialFromCodedStream( // optional bool deprecated = 23 [default = false]; case 23: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(184u)) { + static_cast< ::google::protobuf::uint8>(184u /* 184 & 0xFF */)) { set_has_deprecated(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -8581,7 +8152,7 @@ bool FileOptions::MergePartialFromCodedStream( // optional bool java_string_check_utf8 = 27 [default = false]; case 27: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(216u)) { + static_cast< ::google::protobuf::uint8>(216u /* 216 & 0xFF */)) { set_has_java_string_check_utf8(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -8595,7 +8166,7 @@ bool FileOptions::MergePartialFromCodedStream( // optional bool cc_enable_arenas = 31 [default = false]; case 31: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(248u)) { + static_cast< ::google::protobuf::uint8>(248u /* 248 & 0xFF */)) { set_has_cc_enable_arenas(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -8609,11 +8180,11 @@ bool FileOptions::MergePartialFromCodedStream( // optional string objc_class_prefix = 36; case 36: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(290u)) { + static_cast< ::google::protobuf::uint8>(34u /* 290 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_objc_class_prefix())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->objc_class_prefix().data(), this->objc_class_prefix().length(), + this->objc_class_prefix().data(), static_cast<int>(this->objc_class_prefix().length()), ::google::protobuf::internal::WireFormat::PARSE, "google.protobuf.FileOptions.objc_class_prefix"); } else { @@ -8625,11 +8196,11 @@ bool FileOptions::MergePartialFromCodedStream( // optional string csharp_namespace = 37; case 37: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(298u)) { + static_cast< ::google::protobuf::uint8>(42u /* 298 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_csharp_namespace())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->csharp_namespace().data(), this->csharp_namespace().length(), + this->csharp_namespace().data(), static_cast<int>(this->csharp_namespace().length()), ::google::protobuf::internal::WireFormat::PARSE, "google.protobuf.FileOptions.csharp_namespace"); } else { @@ -8641,11 +8212,11 @@ bool FileOptions::MergePartialFromCodedStream( // optional string swift_prefix = 39; case 39: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(314u)) { + static_cast< ::google::protobuf::uint8>(58u /* 314 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_swift_prefix())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->swift_prefix().data(), this->swift_prefix().length(), + this->swift_prefix().data(), static_cast<int>(this->swift_prefix().length()), ::google::protobuf::internal::WireFormat::PARSE, "google.protobuf.FileOptions.swift_prefix"); } else { @@ -8657,11 +8228,11 @@ bool FileOptions::MergePartialFromCodedStream( // optional string php_class_prefix = 40; case 40: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(322u)) { + static_cast< ::google::protobuf::uint8>(66u /* 322 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_php_class_prefix())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->php_class_prefix().data(), this->php_class_prefix().length(), + this->php_class_prefix().data(), static_cast<int>(this->php_class_prefix().length()), ::google::protobuf::internal::WireFormat::PARSE, "google.protobuf.FileOptions.php_class_prefix"); } else { @@ -8673,11 +8244,11 @@ bool FileOptions::MergePartialFromCodedStream( // optional string php_namespace = 41; case 41: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(330u)) { + static_cast< ::google::protobuf::uint8>(74u /* 330 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_php_namespace())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->php_namespace().data(), this->php_namespace().length(), + this->php_namespace().data(), static_cast<int>(this->php_namespace().length()), ::google::protobuf::internal::WireFormat::PARSE, "google.protobuf.FileOptions.php_namespace"); } else { @@ -8686,11 +8257,25 @@ bool FileOptions::MergePartialFromCodedStream( break; } + // optional bool php_generic_services = 42 [default = false]; + case 42: { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(80u /* 336 & 0xFF */)) { + set_has_php_generic_services(); + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( + input, &php_generic_services_))); + } else { + goto handle_unusual; + } + break; + } + // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; case 999: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(7994u)) { - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + static_cast< ::google::protobuf::uint8>(58u /* 7994 & 0xFF */)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, add_uninterpreted_option())); } else { goto handle_unusual; @@ -8700,18 +8285,17 @@ bool FileOptions::MergePartialFromCodedStream( default: { handle_unusual: - if (tag == 0 || - ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + if (tag == 0) { goto success; } if ((8000u <= tag)) { - DO_(_extensions_.ParseField(tag, input, internal_default_instance(), - mutable_unknown_fields())); + DO_(_extensions_.ParseField(tag, input, + internal_default_instance(), + _internal_metadata_.mutable_unknown_fields())); continue; } DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); + input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } @@ -8735,7 +8319,7 @@ void FileOptions::SerializeWithCachedSizes( // optional string java_package = 1; if (cached_has_bits & 0x00000001u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->java_package().data(), this->java_package().length(), + this->java_package().data(), static_cast<int>(this->java_package().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.FileOptions.java_package"); ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( @@ -8745,7 +8329,7 @@ void FileOptions::SerializeWithCachedSizes( // optional string java_outer_classname = 8; if (cached_has_bits & 0x00000002u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->java_outer_classname().data(), this->java_outer_classname().length(), + this->java_outer_classname().data(), static_cast<int>(this->java_outer_classname().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.FileOptions.java_outer_classname"); ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( @@ -8753,20 +8337,20 @@ void FileOptions::SerializeWithCachedSizes( } // optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED]; - if (cached_has_bits & 0x00010000u) { + if (cached_has_bits & 0x00020000u) { ::google::protobuf::internal::WireFormatLite::WriteEnum( 9, this->optimize_for(), output); } // optional bool java_multiple_files = 10 [default = false]; - if (cached_has_bits & 0x00000100u) { + if (cached_has_bits & 0x00000200u) { ::google::protobuf::internal::WireFormatLite::WriteBool(10, this->java_multiple_files(), output); } // optional string go_package = 11; if (cached_has_bits & 0x00000004u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->go_package().data(), this->go_package().length(), + this->go_package().data(), static_cast<int>(this->go_package().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.FileOptions.go_package"); ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( @@ -8774,44 +8358,44 @@ void FileOptions::SerializeWithCachedSizes( } // optional bool cc_generic_services = 16 [default = false]; - if (cached_has_bits & 0x00000800u) { + if (cached_has_bits & 0x00001000u) { ::google::protobuf::internal::WireFormatLite::WriteBool(16, this->cc_generic_services(), output); } // optional bool java_generic_services = 17 [default = false]; - if (cached_has_bits & 0x00001000u) { + if (cached_has_bits & 0x00002000u) { ::google::protobuf::internal::WireFormatLite::WriteBool(17, this->java_generic_services(), output); } // optional bool py_generic_services = 18 [default = false]; - if (cached_has_bits & 0x00002000u) { + if (cached_has_bits & 0x00004000u) { ::google::protobuf::internal::WireFormatLite::WriteBool(18, this->py_generic_services(), output); } // optional bool java_generate_equals_and_hash = 20 [deprecated = true]; - if (cached_has_bits & 0x00000200u) { + if (cached_has_bits & 0x00000400u) { ::google::protobuf::internal::WireFormatLite::WriteBool(20, this->java_generate_equals_and_hash(), output); } // optional bool deprecated = 23 [default = false]; - if (cached_has_bits & 0x00004000u) { + if (cached_has_bits & 0x00010000u) { ::google::protobuf::internal::WireFormatLite::WriteBool(23, this->deprecated(), output); } // optional bool java_string_check_utf8 = 27 [default = false]; - if (cached_has_bits & 0x00000400u) { + if (cached_has_bits & 0x00000800u) { ::google::protobuf::internal::WireFormatLite::WriteBool(27, this->java_string_check_utf8(), output); } // optional bool cc_enable_arenas = 31 [default = false]; - if (cached_has_bits & 0x00008000u) { + if (cached_has_bits & 0x00000100u) { ::google::protobuf::internal::WireFormatLite::WriteBool(31, this->cc_enable_arenas(), output); } // optional string objc_class_prefix = 36; if (cached_has_bits & 0x00000008u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->objc_class_prefix().data(), this->objc_class_prefix().length(), + this->objc_class_prefix().data(), static_cast<int>(this->objc_class_prefix().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.FileOptions.objc_class_prefix"); ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( @@ -8821,7 +8405,7 @@ void FileOptions::SerializeWithCachedSizes( // optional string csharp_namespace = 37; if (cached_has_bits & 0x00000010u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->csharp_namespace().data(), this->csharp_namespace().length(), + this->csharp_namespace().data(), static_cast<int>(this->csharp_namespace().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.FileOptions.csharp_namespace"); ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( @@ -8831,7 +8415,7 @@ void FileOptions::SerializeWithCachedSizes( // optional string swift_prefix = 39; if (cached_has_bits & 0x00000020u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->swift_prefix().data(), this->swift_prefix().length(), + this->swift_prefix().data(), static_cast<int>(this->swift_prefix().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.FileOptions.swift_prefix"); ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( @@ -8841,7 +8425,7 @@ void FileOptions::SerializeWithCachedSizes( // optional string php_class_prefix = 40; if (cached_has_bits & 0x00000040u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->php_class_prefix().data(), this->php_class_prefix().length(), + this->php_class_prefix().data(), static_cast<int>(this->php_class_prefix().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.FileOptions.php_class_prefix"); ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( @@ -8851,17 +8435,25 @@ void FileOptions::SerializeWithCachedSizes( // optional string php_namespace = 41; if (cached_has_bits & 0x00000080u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->php_namespace().data(), this->php_namespace().length(), + this->php_namespace().data(), static_cast<int>(this->php_namespace().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.FileOptions.php_namespace"); ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( 41, this->php_namespace(), output); } + // optional bool php_generic_services = 42 [default = false]; + if (cached_has_bits & 0x00008000u) { + ::google::protobuf::internal::WireFormatLite::WriteBool(42, this->php_generic_services(), output); + } + // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->uninterpreted_option_size()); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 999, this->uninterpreted_option(i), output); + 999, + this->uninterpreted_option(static_cast<int>(i)), + output); } // Extension range [1000, 536870912) @@ -8870,13 +8462,14 @@ void FileOptions::SerializeWithCachedSizes( if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); + _internal_metadata_.unknown_fields(), output); } // @@protoc_insertion_point(serialize_end:google.protobuf.FileOptions) } ::google::protobuf::uint8* FileOptions::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.FileOptions) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -8885,7 +8478,7 @@ void FileOptions::SerializeWithCachedSizes( // optional string java_package = 1; if (cached_has_bits & 0x00000001u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->java_package().data(), this->java_package().length(), + this->java_package().data(), static_cast<int>(this->java_package().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.FileOptions.java_package"); target = @@ -8896,7 +8489,7 @@ void FileOptions::SerializeWithCachedSizes( // optional string java_outer_classname = 8; if (cached_has_bits & 0x00000002u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->java_outer_classname().data(), this->java_outer_classname().length(), + this->java_outer_classname().data(), static_cast<int>(this->java_outer_classname().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.FileOptions.java_outer_classname"); target = @@ -8905,20 +8498,20 @@ void FileOptions::SerializeWithCachedSizes( } // optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED]; - if (cached_has_bits & 0x00010000u) { + if (cached_has_bits & 0x00020000u) { target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray( 9, this->optimize_for(), target); } // optional bool java_multiple_files = 10 [default = false]; - if (cached_has_bits & 0x00000100u) { + if (cached_has_bits & 0x00000200u) { target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(10, this->java_multiple_files(), target); } // optional string go_package = 11; if (cached_has_bits & 0x00000004u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->go_package().data(), this->go_package().length(), + this->go_package().data(), static_cast<int>(this->go_package().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.FileOptions.go_package"); target = @@ -8927,44 +8520,44 @@ void FileOptions::SerializeWithCachedSizes( } // optional bool cc_generic_services = 16 [default = false]; - if (cached_has_bits & 0x00000800u) { + if (cached_has_bits & 0x00001000u) { target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(16, this->cc_generic_services(), target); } // optional bool java_generic_services = 17 [default = false]; - if (cached_has_bits & 0x00001000u) { + if (cached_has_bits & 0x00002000u) { target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(17, this->java_generic_services(), target); } // optional bool py_generic_services = 18 [default = false]; - if (cached_has_bits & 0x00002000u) { + if (cached_has_bits & 0x00004000u) { target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(18, this->py_generic_services(), target); } // optional bool java_generate_equals_and_hash = 20 [deprecated = true]; - if (cached_has_bits & 0x00000200u) { + if (cached_has_bits & 0x00000400u) { target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(20, this->java_generate_equals_and_hash(), target); } // optional bool deprecated = 23 [default = false]; - if (cached_has_bits & 0x00004000u) { + if (cached_has_bits & 0x00010000u) { target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(23, this->deprecated(), target); } // optional bool java_string_check_utf8 = 27 [default = false]; - if (cached_has_bits & 0x00000400u) { + if (cached_has_bits & 0x00000800u) { target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(27, this->java_string_check_utf8(), target); } // optional bool cc_enable_arenas = 31 [default = false]; - if (cached_has_bits & 0x00008000u) { + if (cached_has_bits & 0x00000100u) { target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(31, this->cc_enable_arenas(), target); } // optional string objc_class_prefix = 36; if (cached_has_bits & 0x00000008u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->objc_class_prefix().data(), this->objc_class_prefix().length(), + this->objc_class_prefix().data(), static_cast<int>(this->objc_class_prefix().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.FileOptions.objc_class_prefix"); target = @@ -8975,7 +8568,7 @@ void FileOptions::SerializeWithCachedSizes( // optional string csharp_namespace = 37; if (cached_has_bits & 0x00000010u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->csharp_namespace().data(), this->csharp_namespace().length(), + this->csharp_namespace().data(), static_cast<int>(this->csharp_namespace().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.FileOptions.csharp_namespace"); target = @@ -8986,7 +8579,7 @@ void FileOptions::SerializeWithCachedSizes( // optional string swift_prefix = 39; if (cached_has_bits & 0x00000020u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->swift_prefix().data(), this->swift_prefix().length(), + this->swift_prefix().data(), static_cast<int>(this->swift_prefix().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.FileOptions.swift_prefix"); target = @@ -8997,7 +8590,7 @@ void FileOptions::SerializeWithCachedSizes( // optional string php_class_prefix = 40; if (cached_has_bits & 0x00000040u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->php_class_prefix().data(), this->php_class_prefix().length(), + this->php_class_prefix().data(), static_cast<int>(this->php_class_prefix().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.FileOptions.php_class_prefix"); target = @@ -9008,7 +8601,7 @@ void FileOptions::SerializeWithCachedSizes( // optional string php_namespace = 41; if (cached_has_bits & 0x00000080u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->php_namespace().data(), this->php_namespace().length(), + this->php_namespace().data(), static_cast<int>(this->php_namespace().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.FileOptions.php_namespace"); target = @@ -9016,11 +8609,17 @@ void FileOptions::SerializeWithCachedSizes( 41, this->php_namespace(), target); } + // optional bool php_generic_services = 42 [default = false]; + if (cached_has_bits & 0x00008000u) { + target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(42, this->php_generic_services(), target); + } + // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->uninterpreted_option_size()); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: - InternalWriteMessageNoVirtualToArray( - 999, this->uninterpreted_option(i), deterministic, target); + InternalWriteMessageToArray( + 999, this->uninterpreted_option(static_cast<int>(i)), deterministic, target); } // Extension range [1000, 536870912) @@ -9029,7 +8628,7 @@ void FileOptions::SerializeWithCachedSizes( if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); + _internal_metadata_.unknown_fields(), target); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.FileOptions) return target; @@ -9044,16 +8643,16 @@ size_t FileOptions::ByteSizeLong() const { if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); + _internal_metadata_.unknown_fields()); } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; { - unsigned int count = this->uninterpreted_option_size(); + unsigned int count = static_cast<unsigned int>(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)); + ::google::protobuf::internal::WireFormatLite::MessageSize( + this->uninterpreted_option(static_cast<int>(i))); } } @@ -9116,6 +8715,11 @@ size_t FileOptions::ByteSizeLong() const { } if (_has_bits_[8 / 32] & 65280u) { + // optional bool cc_enable_arenas = 31 [default = false]; + if (has_cc_enable_arenas()) { + total_size += 2 + 1; + } + // optional bool java_multiple_files = 10 [default = false]; if (has_java_multiple_files()) { total_size += 1 + 1; @@ -9146,23 +8750,25 @@ size_t FileOptions::ByteSizeLong() const { total_size += 2 + 1; } + // optional bool php_generic_services = 42 [default = false]; + if (has_php_generic_services()) { + total_size += 2 + 1; + } + + } + if (_has_bits_[16 / 32] & 196608u) { // optional bool deprecated = 23 [default = false]; if (has_deprecated()) { total_size += 2 + 1; } - // optional bool cc_enable_arenas = 31 [default = false]; - if (has_cc_enable_arenas()) { - total_size += 2 + 1; + // optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED]; + if (has_optimize_for()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::EnumSize(this->optimize_for()); } } - // optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED]; - if (has_optimize_for()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::EnumSize(this->optimize_for()); - } - int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = cached_size; @@ -9197,67 +8803,65 @@ void FileOptions::MergeFrom(const FileOptions& from) { cached_has_bits = from._has_bits_[0]; if (cached_has_bits & 255u) { if (cached_has_bits & 0x00000001u) { - set_has_java_package(); - java_package_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.java_package_); + set_java_package(from.java_package()); } if (cached_has_bits & 0x00000002u) { - set_has_java_outer_classname(); - java_outer_classname_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.java_outer_classname_); + set_java_outer_classname(from.java_outer_classname()); } if (cached_has_bits & 0x00000004u) { - set_has_go_package(); - go_package_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.go_package_); + set_go_package(from.go_package()); } if (cached_has_bits & 0x00000008u) { - set_has_objc_class_prefix(); - objc_class_prefix_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.objc_class_prefix_); + set_objc_class_prefix(from.objc_class_prefix()); } if (cached_has_bits & 0x00000010u) { - set_has_csharp_namespace(); - csharp_namespace_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.csharp_namespace_); + set_csharp_namespace(from.csharp_namespace()); } if (cached_has_bits & 0x00000020u) { - set_has_swift_prefix(); - swift_prefix_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.swift_prefix_); + set_swift_prefix(from.swift_prefix()); } if (cached_has_bits & 0x00000040u) { - set_has_php_class_prefix(); - php_class_prefix_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.php_class_prefix_); + set_php_class_prefix(from.php_class_prefix()); } if (cached_has_bits & 0x00000080u) { - set_has_php_namespace(); - php_namespace_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.php_namespace_); + set_php_namespace(from.php_namespace()); } } if (cached_has_bits & 65280u) { if (cached_has_bits & 0x00000100u) { - java_multiple_files_ = from.java_multiple_files_; + cc_enable_arenas_ = from.cc_enable_arenas_; } if (cached_has_bits & 0x00000200u) { - java_generate_equals_and_hash_ = from.java_generate_equals_and_hash_; + java_multiple_files_ = from.java_multiple_files_; } if (cached_has_bits & 0x00000400u) { - java_string_check_utf8_ = from.java_string_check_utf8_; + java_generate_equals_and_hash_ = from.java_generate_equals_and_hash_; } if (cached_has_bits & 0x00000800u) { - cc_generic_services_ = from.cc_generic_services_; + java_string_check_utf8_ = from.java_string_check_utf8_; } if (cached_has_bits & 0x00001000u) { - java_generic_services_ = from.java_generic_services_; + cc_generic_services_ = from.cc_generic_services_; } if (cached_has_bits & 0x00002000u) { - py_generic_services_ = from.py_generic_services_; + java_generic_services_ = from.java_generic_services_; } if (cached_has_bits & 0x00004000u) { - deprecated_ = from.deprecated_; + py_generic_services_ = from.py_generic_services_; } if (cached_has_bits & 0x00008000u) { - cc_enable_arenas_ = from.cc_enable_arenas_; + php_generic_services_ = from.php_generic_services_; } _has_bits_[0] |= cached_has_bits; } - if (cached_has_bits & 0x00010000u) { - set_optimize_for(from.optimize_for()); + if (cached_has_bits & 196608u) { + if (cached_has_bits & 0x00010000u) { + deprecated_ = from.deprecated_; + } + if (cached_has_bits & 0x00020000u) { + optimize_for_ = from.optimize_for_; + } + _has_bits_[0] |= cached_has_bits; } } @@ -9286,10 +8890,26 @@ bool FileOptions::IsInitialized() const { void FileOptions::Swap(FileOptions* other) { if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + FileOptions* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } + } +} +void FileOptions::UnsafeArenaSwap(FileOptions* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); InternalSwap(other); } void FileOptions::InternalSwap(FileOptions* other) { - uninterpreted_option_.InternalSwap(&other->uninterpreted_option_); + using std::swap; + CastToBase(&uninterpreted_option_)->InternalSwap(CastToBase(&other->uninterpreted_option_)); java_package_.Swap(&other->java_package_); java_outer_classname_.Swap(&other->java_outer_classname_); go_package_.Swap(&other->go_package_); @@ -9298,784 +8918,32 @@ void FileOptions::InternalSwap(FileOptions* other) { swift_prefix_.Swap(&other->swift_prefix_); php_class_prefix_.Swap(&other->php_class_prefix_); php_namespace_.Swap(&other->php_namespace_); - std::swap(java_multiple_files_, other->java_multiple_files_); - std::swap(java_generate_equals_and_hash_, other->java_generate_equals_and_hash_); - std::swap(java_string_check_utf8_, other->java_string_check_utf8_); - std::swap(cc_generic_services_, other->cc_generic_services_); - std::swap(java_generic_services_, other->java_generic_services_); - std::swap(py_generic_services_, other->py_generic_services_); - std::swap(deprecated_, other->deprecated_); - std::swap(cc_enable_arenas_, other->cc_enable_arenas_); - std::swap(optimize_for_, other->optimize_for_); - std::swap(_has_bits_[0], other->_has_bits_[0]); + swap(cc_enable_arenas_, other->cc_enable_arenas_); + swap(java_multiple_files_, other->java_multiple_files_); + swap(java_generate_equals_and_hash_, other->java_generate_equals_and_hash_); + swap(java_string_check_utf8_, other->java_string_check_utf8_); + swap(cc_generic_services_, other->cc_generic_services_); + swap(java_generic_services_, other->java_generic_services_); + swap(py_generic_services_, other->py_generic_services_); + swap(php_generic_services_, other->php_generic_services_); + swap(deprecated_, other->deprecated_); + swap(optimize_for_, other->optimize_for_); + swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); - std::swap(_cached_size_, other->_cached_size_); + swap(_cached_size_, other->_cached_size_); _extensions_.Swap(&other->_extensions_); } ::google::protobuf::Metadata FileOptions::GetMetadata() const { protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages]; -} - -#if PROTOBUF_INLINE_NOT_IN_HEADERS -// FileOptions - -// optional string java_package = 1; -bool FileOptions::has_java_package() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -void FileOptions::set_has_java_package() { - _has_bits_[0] |= 0x00000001u; -} -void FileOptions::clear_has_java_package() { - _has_bits_[0] &= ~0x00000001u; -} -void FileOptions::clear_java_package() { - java_package_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - clear_has_java_package(); -} -const ::std::string& FileOptions::java_package() const { - // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.java_package) - return java_package_.GetNoArena(); -} -void FileOptions::set_java_package(const ::std::string& value) { - set_has_java_package(); - java_package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_package) -} -#if LANG_CXX11 -void FileOptions::set_java_package(::std::string&& value) { - set_has_java_package(); - java_package_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.java_package) -} -#endif -void FileOptions::set_java_package(const char* value) { - GOOGLE_DCHECK(value != NULL); - 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) { - set_has_java_package(); - java_package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.java_package) -} -::std::string* FileOptions::mutable_java_package() { - 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() { - // @@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) { - if (java_package != NULL) { - set_has_java_package(); - } else { - clear_has_java_package(); - } - java_package_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), java_package); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.java_package) -} - -// optional string java_outer_classname = 8; -bool FileOptions::has_java_outer_classname() const { - return (_has_bits_[0] & 0x00000002u) != 0; -} -void FileOptions::set_has_java_outer_classname() { - _has_bits_[0] |= 0x00000002u; -} -void FileOptions::clear_has_java_outer_classname() { - _has_bits_[0] &= ~0x00000002u; -} -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 { - // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.java_outer_classname) - return java_outer_classname_.GetNoArena(); -} -void FileOptions::set_java_outer_classname(const ::std::string& value) { - set_has_java_outer_classname(); - java_outer_classname_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_outer_classname) -} -#if LANG_CXX11 -void FileOptions::set_java_outer_classname(::std::string&& value) { - set_has_java_outer_classname(); - java_outer_classname_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.java_outer_classname) -} -#endif -void FileOptions::set_java_outer_classname(const char* value) { - GOOGLE_DCHECK(value != NULL); - 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) { - set_has_java_outer_classname(); - java_outer_classname_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.java_outer_classname) -} -::std::string* FileOptions::mutable_java_outer_classname() { - 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() { - // @@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) { - if (java_outer_classname != NULL) { - set_has_java_outer_classname(); - } else { - clear_has_java_outer_classname(); - } - java_outer_classname_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), java_outer_classname); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.java_outer_classname) -} - -// optional bool java_multiple_files = 10 [default = false]; -bool FileOptions::has_java_multiple_files() const { - return (_has_bits_[0] & 0x00000100u) != 0; -} -void FileOptions::set_has_java_multiple_files() { - _has_bits_[0] |= 0x00000100u; -} -void FileOptions::clear_has_java_multiple_files() { - _has_bits_[0] &= ~0x00000100u; -} -void FileOptions::clear_java_multiple_files() { - java_multiple_files_ = false; - clear_has_java_multiple_files(); -} -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) { - 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 [deprecated = true]; -bool FileOptions::has_java_generate_equals_and_hash() const { - return (_has_bits_[0] & 0x00000200u) != 0; -} -void FileOptions::set_has_java_generate_equals_and_hash() { - _has_bits_[0] |= 0x00000200u; -} -void FileOptions::clear_has_java_generate_equals_and_hash() { - _has_bits_[0] &= ~0x00000200u; -} -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] & 0x00000400u) != 0; -} -void FileOptions::set_has_java_string_check_utf8() { - _has_bits_[0] |= 0x00000400u; -} -void FileOptions::clear_has_java_string_check_utf8() { - _has_bits_[0] &= ~0x00000400u; -} -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 { - // @@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) { - set_has_java_string_check_utf8(); - java_string_check_utf8_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_string_check_utf8) -} - -// optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED]; -bool FileOptions::has_optimize_for() const { - return (_has_bits_[0] & 0x00010000u) != 0; -} -void FileOptions::set_has_optimize_for() { - _has_bits_[0] |= 0x00010000u; -} -void FileOptions::clear_has_optimize_for() { - _has_bits_[0] &= ~0x00010000u; -} -void FileOptions::clear_optimize_for() { - optimize_for_ = 1; - clear_has_optimize_for(); -} -::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) { - assert(::google::protobuf::FileOptions_OptimizeMode_IsValid(value)); - set_has_optimize_for(); - optimize_for_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.optimize_for) -} - -// optional string go_package = 11; -bool FileOptions::has_go_package() const { - return (_has_bits_[0] & 0x00000004u) != 0; -} -void FileOptions::set_has_go_package() { - _has_bits_[0] |= 0x00000004u; -} -void FileOptions::clear_has_go_package() { - _has_bits_[0] &= ~0x00000004u; -} -void FileOptions::clear_go_package() { - go_package_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - clear_has_go_package(); -} -const ::std::string& FileOptions::go_package() const { - // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.go_package) - return go_package_.GetNoArena(); -} -void FileOptions::set_go_package(const ::std::string& value) { - set_has_go_package(); - go_package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.go_package) -} -#if LANG_CXX11 -void FileOptions::set_go_package(::std::string&& value) { - set_has_go_package(); - go_package_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.go_package) -} -#endif -void FileOptions::set_go_package(const char* value) { - GOOGLE_DCHECK(value != NULL); - 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) { - set_has_go_package(); - go_package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.go_package) -} -::std::string* FileOptions::mutable_go_package() { - 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() { - // @@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) { - if (go_package != NULL) { - set_has_go_package(); - } else { - clear_has_go_package(); - } - go_package_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), go_package); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.go_package) -} - -// optional bool cc_generic_services = 16 [default = false]; -bool FileOptions::has_cc_generic_services() const { - return (_has_bits_[0] & 0x00000800u) != 0; -} -void FileOptions::set_has_cc_generic_services() { - _has_bits_[0] |= 0x00000800u; -} -void FileOptions::clear_has_cc_generic_services() { - _has_bits_[0] &= ~0x00000800u; -} -void FileOptions::clear_cc_generic_services() { - cc_generic_services_ = false; - clear_has_cc_generic_services(); -} -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) { - set_has_cc_generic_services(); - cc_generic_services_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.cc_generic_services) + return ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages]; } -// optional bool java_generic_services = 17 [default = false]; -bool FileOptions::has_java_generic_services() const { - return (_has_bits_[0] & 0x00001000u) != 0; -} -void FileOptions::set_has_java_generic_services() { - _has_bits_[0] |= 0x00001000u; -} -void FileOptions::clear_has_java_generic_services() { - _has_bits_[0] &= ~0x00001000u; -} -void FileOptions::clear_java_generic_services() { - java_generic_services_ = false; - clear_has_java_generic_services(); -} -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) { - set_has_java_generic_services(); - java_generic_services_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_generic_services) -} - -// optional bool py_generic_services = 18 [default = false]; -bool FileOptions::has_py_generic_services() const { - return (_has_bits_[0] & 0x00002000u) != 0; -} -void FileOptions::set_has_py_generic_services() { - _has_bits_[0] |= 0x00002000u; -} -void FileOptions::clear_has_py_generic_services() { - _has_bits_[0] &= ~0x00002000u; -} -void FileOptions::clear_py_generic_services() { - py_generic_services_ = false; - clear_has_py_generic_services(); -} -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) { - set_has_py_generic_services(); - py_generic_services_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.py_generic_services) -} - -// optional bool deprecated = 23 [default = false]; -bool FileOptions::has_deprecated() const { - return (_has_bits_[0] & 0x00004000u) != 0; -} -void FileOptions::set_has_deprecated() { - _has_bits_[0] |= 0x00004000u; -} -void FileOptions::clear_has_deprecated() { - _has_bits_[0] &= ~0x00004000u; -} -void FileOptions::clear_deprecated() { - deprecated_ = false; - clear_has_deprecated(); -} -bool FileOptions::deprecated() const { - // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.deprecated) - return deprecated_; -} -void FileOptions::set_deprecated(bool value) { - set_has_deprecated(); - deprecated_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.deprecated) -} - -// optional bool cc_enable_arenas = 31 [default = false]; -bool FileOptions::has_cc_enable_arenas() const { - return (_has_bits_[0] & 0x00008000u) != 0; -} -void FileOptions::set_has_cc_enable_arenas() { - _has_bits_[0] |= 0x00008000u; -} -void FileOptions::clear_has_cc_enable_arenas() { - _has_bits_[0] &= ~0x00008000u; -} -void FileOptions::clear_cc_enable_arenas() { - cc_enable_arenas_ = false; - clear_has_cc_enable_arenas(); -} -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) { - set_has_cc_enable_arenas(); - cc_enable_arenas_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.cc_enable_arenas) -} - -// optional string objc_class_prefix = 36; -bool FileOptions::has_objc_class_prefix() const { - return (_has_bits_[0] & 0x00000008u) != 0; -} -void FileOptions::set_has_objc_class_prefix() { - _has_bits_[0] |= 0x00000008u; -} -void FileOptions::clear_has_objc_class_prefix() { - _has_bits_[0] &= ~0x00000008u; -} -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 { - // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.objc_class_prefix) - return objc_class_prefix_.GetNoArena(); -} -void FileOptions::set_objc_class_prefix(const ::std::string& value) { - set_has_objc_class_prefix(); - objc_class_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.objc_class_prefix) -} -#if LANG_CXX11 -void FileOptions::set_objc_class_prefix(::std::string&& value) { - set_has_objc_class_prefix(); - objc_class_prefix_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.objc_class_prefix) -} -#endif -void FileOptions::set_objc_class_prefix(const char* value) { - GOOGLE_DCHECK(value != NULL); - 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) { - set_has_objc_class_prefix(); - objc_class_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.objc_class_prefix) -} -::std::string* FileOptions::mutable_objc_class_prefix() { - 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() { - // @@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) { - if (objc_class_prefix != NULL) { - set_has_objc_class_prefix(); - } else { - clear_has_objc_class_prefix(); - } - objc_class_prefix_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), objc_class_prefix); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.objc_class_prefix) -} - -// optional string csharp_namespace = 37; -bool FileOptions::has_csharp_namespace() const { - return (_has_bits_[0] & 0x00000010u) != 0; -} -void FileOptions::set_has_csharp_namespace() { - _has_bits_[0] |= 0x00000010u; -} -void FileOptions::clear_has_csharp_namespace() { - _has_bits_[0] &= ~0x00000010u; -} -void FileOptions::clear_csharp_namespace() { - csharp_namespace_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - clear_has_csharp_namespace(); -} -const ::std::string& FileOptions::csharp_namespace() const { - // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.csharp_namespace) - return csharp_namespace_.GetNoArena(); -} -void FileOptions::set_csharp_namespace(const ::std::string& value) { - set_has_csharp_namespace(); - csharp_namespace_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_namespace) -} -#if LANG_CXX11 -void FileOptions::set_csharp_namespace(::std::string&& value) { - set_has_csharp_namespace(); - csharp_namespace_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.csharp_namespace) -} -#endif -void FileOptions::set_csharp_namespace(const char* value) { - GOOGLE_DCHECK(value != NULL); - 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) { - set_has_csharp_namespace(); - csharp_namespace_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.csharp_namespace) -} -::std::string* FileOptions::mutable_csharp_namespace() { - 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() { - // @@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) { - if (csharp_namespace != NULL) { - set_has_csharp_namespace(); - } else { - clear_has_csharp_namespace(); - } - csharp_namespace_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), csharp_namespace); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.csharp_namespace) -} - -// optional string swift_prefix = 39; -bool FileOptions::has_swift_prefix() const { - return (_has_bits_[0] & 0x00000020u) != 0; -} -void FileOptions::set_has_swift_prefix() { - _has_bits_[0] |= 0x00000020u; -} -void FileOptions::clear_has_swift_prefix() { - _has_bits_[0] &= ~0x00000020u; -} -void FileOptions::clear_swift_prefix() { - swift_prefix_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - clear_has_swift_prefix(); -} -const ::std::string& FileOptions::swift_prefix() const { - // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.swift_prefix) - return swift_prefix_.GetNoArena(); -} -void FileOptions::set_swift_prefix(const ::std::string& value) { - set_has_swift_prefix(); - swift_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.swift_prefix) -} -#if LANG_CXX11 -void FileOptions::set_swift_prefix(::std::string&& value) { - set_has_swift_prefix(); - swift_prefix_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.swift_prefix) -} -#endif -void FileOptions::set_swift_prefix(const char* value) { - GOOGLE_DCHECK(value != NULL); - set_has_swift_prefix(); - swift_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); - // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.swift_prefix) -} -void FileOptions::set_swift_prefix(const char* value, size_t size) { - set_has_swift_prefix(); - swift_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.swift_prefix) -} -::std::string* FileOptions::mutable_swift_prefix() { - set_has_swift_prefix(); - // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.swift_prefix) - return swift_prefix_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -::std::string* FileOptions::release_swift_prefix() { - // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.swift_prefix) - clear_has_swift_prefix(); - return swift_prefix_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -void FileOptions::set_allocated_swift_prefix(::std::string* swift_prefix) { - if (swift_prefix != NULL) { - set_has_swift_prefix(); - } else { - clear_has_swift_prefix(); - } - swift_prefix_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), swift_prefix); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.swift_prefix) -} - -// optional string php_class_prefix = 40; -bool FileOptions::has_php_class_prefix() const { - return (_has_bits_[0] & 0x00000040u) != 0; -} -void FileOptions::set_has_php_class_prefix() { - _has_bits_[0] |= 0x00000040u; -} -void FileOptions::clear_has_php_class_prefix() { - _has_bits_[0] &= ~0x00000040u; -} -void FileOptions::clear_php_class_prefix() { - php_class_prefix_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - clear_has_php_class_prefix(); -} -const ::std::string& FileOptions::php_class_prefix() const { - // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.php_class_prefix) - return php_class_prefix_.GetNoArena(); -} -void FileOptions::set_php_class_prefix(const ::std::string& value) { - set_has_php_class_prefix(); - php_class_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.php_class_prefix) -} -#if LANG_CXX11 -void FileOptions::set_php_class_prefix(::std::string&& value) { - set_has_php_class_prefix(); - php_class_prefix_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.php_class_prefix) -} -#endif -void FileOptions::set_php_class_prefix(const char* value) { - GOOGLE_DCHECK(value != NULL); - set_has_php_class_prefix(); - php_class_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); - // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.php_class_prefix) -} -void FileOptions::set_php_class_prefix(const char* value, size_t size) { - set_has_php_class_prefix(); - php_class_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.php_class_prefix) -} -::std::string* FileOptions::mutable_php_class_prefix() { - set_has_php_class_prefix(); - // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.php_class_prefix) - return php_class_prefix_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -::std::string* FileOptions::release_php_class_prefix() { - // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.php_class_prefix) - clear_has_php_class_prefix(); - return php_class_prefix_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -void FileOptions::set_allocated_php_class_prefix(::std::string* php_class_prefix) { - if (php_class_prefix != NULL) { - set_has_php_class_prefix(); - } else { - clear_has_php_class_prefix(); - } - php_class_prefix_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), php_class_prefix); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.php_class_prefix) -} - -// optional string php_namespace = 41; -bool FileOptions::has_php_namespace() const { - return (_has_bits_[0] & 0x00000080u) != 0; -} -void FileOptions::set_has_php_namespace() { - _has_bits_[0] |= 0x00000080u; -} -void FileOptions::clear_has_php_namespace() { - _has_bits_[0] &= ~0x00000080u; -} -void FileOptions::clear_php_namespace() { - php_namespace_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - clear_has_php_namespace(); -} -const ::std::string& FileOptions::php_namespace() const { - // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.php_namespace) - return php_namespace_.GetNoArena(); -} -void FileOptions::set_php_namespace(const ::std::string& value) { - set_has_php_namespace(); - php_namespace_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.php_namespace) -} -#if LANG_CXX11 -void FileOptions::set_php_namespace(::std::string&& value) { - set_has_php_namespace(); - php_namespace_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.php_namespace) -} -#endif -void FileOptions::set_php_namespace(const char* value) { - GOOGLE_DCHECK(value != NULL); - set_has_php_namespace(); - php_namespace_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); - // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.php_namespace) -} -void FileOptions::set_php_namespace(const char* value, size_t size) { - set_has_php_namespace(); - php_namespace_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.php_namespace) -} -::std::string* FileOptions::mutable_php_namespace() { - set_has_php_namespace(); - // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.php_namespace) - return php_namespace_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -::std::string* FileOptions::release_php_namespace() { - // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.php_namespace) - clear_has_php_namespace(); - return php_namespace_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -void FileOptions::set_allocated_php_namespace(::std::string* php_namespace) { - if (php_namespace != NULL) { - set_has_php_namespace(); - } else { - clear_has_php_namespace(); - } - php_namespace_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), php_namespace); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.php_namespace) -} - -// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; -int FileOptions::uninterpreted_option_size() const { - return uninterpreted_option_.size(); -} -void FileOptions::clear_uninterpreted_option() { - uninterpreted_option_.Clear(); -} -const ::google::protobuf::UninterpretedOption& FileOptions::uninterpreted_option(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.uninterpreted_option) - return uninterpreted_option_.Get(index); -} -::google::protobuf::UninterpretedOption* FileOptions::mutable_uninterpreted_option(int index) { - // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.uninterpreted_option) - return uninterpreted_option_.Mutable(index); -} -::google::protobuf::UninterpretedOption* FileOptions::add_uninterpreted_option() { - // @@protoc_insertion_point(field_add:google.protobuf.FileOptions.uninterpreted_option) - return uninterpreted_option_.Add(); -} -::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >* -FileOptions::mutable_uninterpreted_option() { - // @@protoc_insertion_point(field_mutable_list:google.protobuf.FileOptions.uninterpreted_option) - return &uninterpreted_option_; -} -const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >& -FileOptions::uninterpreted_option() const { - // @@protoc_insertion_point(field_list:google.protobuf.FileOptions.uninterpreted_option) - return uninterpreted_option_; -} - -#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== +void MessageOptions::InitAsDefaultInstance() { +} #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int MessageOptions::kMessageSetWireFormatFieldNumber; const int MessageOptions::kNoStandardDescriptorAccessorFieldNumber; @@ -10087,11 +8955,21 @@ const int MessageOptions::kUninterpretedOptionFieldNumber; MessageOptions::MessageOptions() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsMessageOptions(); } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.MessageOptions) } +MessageOptions::MessageOptions(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(), + _extensions_(arena), + _internal_metadata_(arena), + uninterpreted_option_(arena) { + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsMessageOptions(); + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:google.protobuf.MessageOptions) +} MessageOptions::MessageOptions(const MessageOptions& from) : ::google::protobuf::Message(), _internal_metadata_(NULL), @@ -10101,15 +8979,16 @@ MessageOptions::MessageOptions(const MessageOptions& from) _internal_metadata_.MergeFrom(from._internal_metadata_); _extensions_.MergeFrom(from._extensions_); ::memcpy(&message_set_wire_format_, &from.message_set_wire_format_, - reinterpret_cast<char*>(&map_entry_) - - reinterpret_cast<char*>(&message_set_wire_format_) + sizeof(map_entry_)); + static_cast<size_t>(reinterpret_cast<char*>(&map_entry_) - + reinterpret_cast<char*>(&message_set_wire_format_)) + sizeof(map_entry_)); // @@protoc_insertion_point(copy_constructor:google.protobuf.MessageOptions) } void MessageOptions::SharedCtor() { _cached_size_ = 0; - ::memset(&message_set_wire_format_, 0, reinterpret_cast<char*>(&map_entry_) - - reinterpret_cast<char*>(&message_set_wire_format_) + sizeof(map_entry_)); + ::memset(&message_set_wire_format_, 0, static_cast<size_t>( + reinterpret_cast<char*>(&map_entry_) - + reinterpret_cast<char*>(&message_set_wire_format_)) + sizeof(map_entry_)); } MessageOptions::~MessageOptions() { @@ -10118,39 +8997,42 @@ MessageOptions::~MessageOptions() { } void MessageOptions::SharedDtor() { + GOOGLE_DCHECK(GetArenaNoVirtual() == NULL); } +void MessageOptions::ArenaDtor(void* object) { + MessageOptions* _this = reinterpret_cast< MessageOptions* >(object); + (void)_this; +} +void MessageOptions::RegisterArenaDtor(::google::protobuf::Arena* arena) { +} void MessageOptions::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* MessageOptions::descriptor() { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const MessageOptions& MessageOptions::default_instance() { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsMessageOptions(); return *internal_default_instance(); } -MessageOptions* MessageOptions::New(::google::protobuf::Arena* arena) const { - MessageOptions* n = new MessageOptions; - if (arena != NULL) { - arena->Own(n); - } - return n; -} void MessageOptions::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.MessageOptions) + ::google::protobuf::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + _extensions_.Clear(); uninterpreted_option_.Clear(); - if (_has_bits_[0 / 32] & 15u) { - ::memset(&message_set_wire_format_, 0, reinterpret_cast<char*>(&map_entry_) - - reinterpret_cast<char*>(&message_set_wire_format_) + sizeof(map_entry_)); - } + ::memset(&message_set_wire_format_, 0, static_cast<size_t>( + reinterpret_cast<char*>(&map_entry_) - + reinterpret_cast<char*>(&message_set_wire_format_)) + sizeof(map_entry_)); _has_bits_.Clear(); _internal_metadata_.Clear(); } @@ -10168,7 +9050,7 @@ bool MessageOptions::MergePartialFromCodedStream( // optional bool message_set_wire_format = 1 [default = false]; case 1: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(8u)) { + static_cast< ::google::protobuf::uint8>(8u /* 8 & 0xFF */)) { set_has_message_set_wire_format(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -10182,7 +9064,7 @@ bool MessageOptions::MergePartialFromCodedStream( // optional bool no_standard_descriptor_accessor = 2 [default = false]; case 2: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(16u)) { + static_cast< ::google::protobuf::uint8>(16u /* 16 & 0xFF */)) { set_has_no_standard_descriptor_accessor(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -10196,7 +9078,7 @@ bool MessageOptions::MergePartialFromCodedStream( // optional bool deprecated = 3 [default = false]; case 3: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(24u)) { + static_cast< ::google::protobuf::uint8>(24u /* 24 & 0xFF */)) { set_has_deprecated(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -10210,7 +9092,7 @@ bool MessageOptions::MergePartialFromCodedStream( // optional bool map_entry = 7; case 7: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(56u)) { + static_cast< ::google::protobuf::uint8>(56u /* 56 & 0xFF */)) { set_has_map_entry(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -10224,8 +9106,8 @@ bool MessageOptions::MergePartialFromCodedStream( // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; case 999: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(7994u)) { - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + static_cast< ::google::protobuf::uint8>(58u /* 7994 & 0xFF */)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, add_uninterpreted_option())); } else { goto handle_unusual; @@ -10235,18 +9117,17 @@ bool MessageOptions::MergePartialFromCodedStream( default: { handle_unusual: - if (tag == 0 || - ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + if (tag == 0) { goto success; } if ((8000u <= tag)) { - DO_(_extensions_.ParseField(tag, input, internal_default_instance(), - mutable_unknown_fields())); + DO_(_extensions_.ParseField(tag, input, + internal_default_instance(), + _internal_metadata_.mutable_unknown_fields())); continue; } DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); + input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } @@ -10288,9 +9169,12 @@ void MessageOptions::SerializeWithCachedSizes( } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->uninterpreted_option_size()); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 999, this->uninterpreted_option(i), output); + 999, + this->uninterpreted_option(static_cast<int>(i)), + output); } // Extension range [1000, 536870912) @@ -10299,13 +9183,14 @@ void MessageOptions::SerializeWithCachedSizes( if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); + _internal_metadata_.unknown_fields(), output); } // @@protoc_insertion_point(serialize_end:google.protobuf.MessageOptions) } ::google::protobuf::uint8* MessageOptions::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.MessageOptions) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -10332,10 +9217,11 @@ void MessageOptions::SerializeWithCachedSizes( } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->uninterpreted_option_size()); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: - InternalWriteMessageNoVirtualToArray( - 999, this->uninterpreted_option(i), deterministic, target); + InternalWriteMessageToArray( + 999, this->uninterpreted_option(static_cast<int>(i)), deterministic, target); } // Extension range [1000, 536870912) @@ -10344,7 +9230,7 @@ void MessageOptions::SerializeWithCachedSizes( if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); + _internal_metadata_.unknown_fields(), target); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.MessageOptions) return target; @@ -10359,16 +9245,16 @@ size_t MessageOptions::ByteSizeLong() const { if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); + _internal_metadata_.unknown_fields()); } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; { - unsigned int count = this->uninterpreted_option_size(); + unsigned int count = static_cast<unsigned int>(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)); + ::google::protobuf::internal::WireFormatLite::MessageSize( + this->uninterpreted_option(static_cast<int>(i))); } } @@ -10468,158 +9354,46 @@ bool MessageOptions::IsInitialized() const { void MessageOptions::Swap(MessageOptions* other) { if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + MessageOptions* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } + } +} +void MessageOptions::UnsafeArenaSwap(MessageOptions* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); InternalSwap(other); } void MessageOptions::InternalSwap(MessageOptions* other) { - uninterpreted_option_.InternalSwap(&other->uninterpreted_option_); - std::swap(message_set_wire_format_, other->message_set_wire_format_); - std::swap(no_standard_descriptor_accessor_, other->no_standard_descriptor_accessor_); - std::swap(deprecated_, other->deprecated_); - std::swap(map_entry_, other->map_entry_); - std::swap(_has_bits_[0], other->_has_bits_[0]); + using std::swap; + CastToBase(&uninterpreted_option_)->InternalSwap(CastToBase(&other->uninterpreted_option_)); + swap(message_set_wire_format_, other->message_set_wire_format_); + swap(no_standard_descriptor_accessor_, other->no_standard_descriptor_accessor_); + swap(deprecated_, other->deprecated_); + swap(map_entry_, other->map_entry_); + swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); - std::swap(_cached_size_, other->_cached_size_); + swap(_cached_size_, other->_cached_size_); _extensions_.Swap(&other->_extensions_); } ::google::protobuf::Metadata MessageOptions::GetMetadata() const { protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages]; + return ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages]; } -#if PROTOBUF_INLINE_NOT_IN_HEADERS -// MessageOptions - -// optional bool message_set_wire_format = 1 [default = false]; -bool MessageOptions::has_message_set_wire_format() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -void MessageOptions::set_has_message_set_wire_format() { - _has_bits_[0] |= 0x00000001u; -} -void MessageOptions::clear_has_message_set_wire_format() { - _has_bits_[0] &= ~0x00000001u; -} -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 { - // @@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) { - set_has_message_set_wire_format(); - message_set_wire_format_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.MessageOptions.message_set_wire_format) -} - -// optional bool no_standard_descriptor_accessor = 2 [default = false]; -bool MessageOptions::has_no_standard_descriptor_accessor() const { - return (_has_bits_[0] & 0x00000002u) != 0; -} -void MessageOptions::set_has_no_standard_descriptor_accessor() { - _has_bits_[0] |= 0x00000002u; -} -void MessageOptions::clear_has_no_standard_descriptor_accessor() { - _has_bits_[0] &= ~0x00000002u; -} -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 { - // @@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) { - set_has_no_standard_descriptor_accessor(); - no_standard_descriptor_accessor_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.MessageOptions.no_standard_descriptor_accessor) -} - -// optional bool deprecated = 3 [default = false]; -bool MessageOptions::has_deprecated() const { - return (_has_bits_[0] & 0x00000004u) != 0; -} -void MessageOptions::set_has_deprecated() { - _has_bits_[0] |= 0x00000004u; -} -void MessageOptions::clear_has_deprecated() { - _has_bits_[0] &= ~0x00000004u; -} -void MessageOptions::clear_deprecated() { - deprecated_ = false; - clear_has_deprecated(); -} -bool MessageOptions::deprecated() const { - // @@protoc_insertion_point(field_get:google.protobuf.MessageOptions.deprecated) - return deprecated_; -} -void MessageOptions::set_deprecated(bool value) { - set_has_deprecated(); - deprecated_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.MessageOptions.deprecated) -} - -// optional bool map_entry = 7; -bool MessageOptions::has_map_entry() const { - return (_has_bits_[0] & 0x00000008u) != 0; -} -void MessageOptions::set_has_map_entry() { - _has_bits_[0] |= 0x00000008u; -} -void MessageOptions::clear_has_map_entry() { - _has_bits_[0] &= ~0x00000008u; -} -void MessageOptions::clear_map_entry() { - map_entry_ = false; - clear_has_map_entry(); -} -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) { - set_has_map_entry(); - map_entry_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.MessageOptions.map_entry) -} - -// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; -int MessageOptions::uninterpreted_option_size() const { - return uninterpreted_option_.size(); -} -void MessageOptions::clear_uninterpreted_option() { - uninterpreted_option_.Clear(); -} -const ::google::protobuf::UninterpretedOption& MessageOptions::uninterpreted_option(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.MessageOptions.uninterpreted_option) - return uninterpreted_option_.Get(index); -} -::google::protobuf::UninterpretedOption* MessageOptions::mutable_uninterpreted_option(int index) { - // @@protoc_insertion_point(field_mutable:google.protobuf.MessageOptions.uninterpreted_option) - return uninterpreted_option_.Mutable(index); -} -::google::protobuf::UninterpretedOption* MessageOptions::add_uninterpreted_option() { - // @@protoc_insertion_point(field_add:google.protobuf.MessageOptions.uninterpreted_option) - return uninterpreted_option_.Add(); -} -::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >* -MessageOptions::mutable_uninterpreted_option() { - // @@protoc_insertion_point(field_mutable_list:google.protobuf.MessageOptions.uninterpreted_option) - return &uninterpreted_option_; -} -const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >& -MessageOptions::uninterpreted_option() const { - // @@protoc_insertion_point(field_list:google.protobuf.MessageOptions.uninterpreted_option) - return uninterpreted_option_; -} - -#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== +void FieldOptions::InitAsDefaultInstance() { +} #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int FieldOptions::kCtypeFieldNumber; const int FieldOptions::kPackedFieldNumber; @@ -10633,11 +9407,21 @@ const int FieldOptions::kUninterpretedOptionFieldNumber; FieldOptions::FieldOptions() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsFieldOptions(); } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.FieldOptions) } +FieldOptions::FieldOptions(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(), + _extensions_(arena), + _internal_metadata_(arena), + uninterpreted_option_(arena) { + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsFieldOptions(); + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:google.protobuf.FieldOptions) +} FieldOptions::FieldOptions(const FieldOptions& from) : ::google::protobuf::Message(), _internal_metadata_(NULL), @@ -10647,15 +9431,16 @@ FieldOptions::FieldOptions(const FieldOptions& from) _internal_metadata_.MergeFrom(from._internal_metadata_); _extensions_.MergeFrom(from._extensions_); ::memcpy(&ctype_, &from.ctype_, - reinterpret_cast<char*>(&jstype_) - - reinterpret_cast<char*>(&ctype_) + sizeof(jstype_)); + static_cast<size_t>(reinterpret_cast<char*>(&jstype_) - + reinterpret_cast<char*>(&ctype_)) + sizeof(jstype_)); // @@protoc_insertion_point(copy_constructor:google.protobuf.FieldOptions) } void FieldOptions::SharedCtor() { _cached_size_ = 0; - ::memset(&ctype_, 0, reinterpret_cast<char*>(&jstype_) - - reinterpret_cast<char*>(&ctype_) + sizeof(jstype_)); + ::memset(&ctype_, 0, static_cast<size_t>( + reinterpret_cast<char*>(&jstype_) - + reinterpret_cast<char*>(&ctype_)) + sizeof(jstype_)); } FieldOptions::~FieldOptions() { @@ -10664,38 +9449,44 @@ FieldOptions::~FieldOptions() { } void FieldOptions::SharedDtor() { + GOOGLE_DCHECK(GetArenaNoVirtual() == NULL); } +void FieldOptions::ArenaDtor(void* object) { + FieldOptions* _this = reinterpret_cast< FieldOptions* >(object); + (void)_this; +} +void FieldOptions::RegisterArenaDtor(::google::protobuf::Arena* arena) { +} void FieldOptions::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* FieldOptions::descriptor() { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const FieldOptions& FieldOptions::default_instance() { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsFieldOptions(); return *internal_default_instance(); } -FieldOptions* FieldOptions::New(::google::protobuf::Arena* arena) const { - FieldOptions* n = new FieldOptions; - if (arena != NULL) { - arena->Own(n); - } - return n; -} void FieldOptions::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.FieldOptions) + ::google::protobuf::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + _extensions_.Clear(); uninterpreted_option_.Clear(); - if (_has_bits_[0 / 32] & 63u) { - ::memset(&ctype_, 0, reinterpret_cast<char*>(&jstype_) - - reinterpret_cast<char*>(&ctype_) + sizeof(jstype_)); + cached_has_bits = _has_bits_[0]; + if (cached_has_bits & 63u) { + ::memset(&ctype_, 0, static_cast<size_t>( + reinterpret_cast<char*>(&jstype_) - + reinterpret_cast<char*>(&ctype_)) + sizeof(jstype_)); } _has_bits_.Clear(); _internal_metadata_.Clear(); @@ -10714,7 +9505,7 @@ bool FieldOptions::MergePartialFromCodedStream( // optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING]; case 1: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(8u)) { + static_cast< ::google::protobuf::uint8>(8u /* 8 & 0xFF */)) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -10722,7 +9513,8 @@ bool FieldOptions::MergePartialFromCodedStream( if (::google::protobuf::FieldOptions_CType_IsValid(value)) { set_ctype(static_cast< ::google::protobuf::FieldOptions_CType >(value)); } else { - mutable_unknown_fields()->AddVarint(1, value); + mutable_unknown_fields()->AddVarint( + 1, static_cast< ::google::protobuf::uint64>(value)); } } else { goto handle_unusual; @@ -10733,7 +9525,7 @@ bool FieldOptions::MergePartialFromCodedStream( // optional bool packed = 2; case 2: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(16u)) { + static_cast< ::google::protobuf::uint8>(16u /* 16 & 0xFF */)) { set_has_packed(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -10747,7 +9539,7 @@ bool FieldOptions::MergePartialFromCodedStream( // optional bool deprecated = 3 [default = false]; case 3: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(24u)) { + static_cast< ::google::protobuf::uint8>(24u /* 24 & 0xFF */)) { set_has_deprecated(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -10761,7 +9553,7 @@ bool FieldOptions::MergePartialFromCodedStream( // optional bool lazy = 5 [default = false]; case 5: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(40u)) { + static_cast< ::google::protobuf::uint8>(40u /* 40 & 0xFF */)) { set_has_lazy(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -10775,7 +9567,7 @@ bool FieldOptions::MergePartialFromCodedStream( // optional .google.protobuf.FieldOptions.JSType jstype = 6 [default = JS_NORMAL]; case 6: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(48u)) { + static_cast< ::google::protobuf::uint8>(48u /* 48 & 0xFF */)) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -10783,7 +9575,8 @@ bool FieldOptions::MergePartialFromCodedStream( if (::google::protobuf::FieldOptions_JSType_IsValid(value)) { set_jstype(static_cast< ::google::protobuf::FieldOptions_JSType >(value)); } else { - mutable_unknown_fields()->AddVarint(6, value); + mutable_unknown_fields()->AddVarint( + 6, static_cast< ::google::protobuf::uint64>(value)); } } else { goto handle_unusual; @@ -10794,7 +9587,7 @@ bool FieldOptions::MergePartialFromCodedStream( // optional bool weak = 10 [default = false]; case 10: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(80u)) { + static_cast< ::google::protobuf::uint8>(80u /* 80 & 0xFF */)) { set_has_weak(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -10808,8 +9601,8 @@ bool FieldOptions::MergePartialFromCodedStream( // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; case 999: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(7994u)) { - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + static_cast< ::google::protobuf::uint8>(58u /* 7994 & 0xFF */)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, add_uninterpreted_option())); } else { goto handle_unusual; @@ -10819,18 +9612,17 @@ bool FieldOptions::MergePartialFromCodedStream( default: { handle_unusual: - if (tag == 0 || - ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + if (tag == 0) { goto success; } if ((8000u <= tag)) { - DO_(_extensions_.ParseField(tag, input, internal_default_instance(), - mutable_unknown_fields())); + DO_(_extensions_.ParseField(tag, input, + internal_default_instance(), + _internal_metadata_.mutable_unknown_fields())); continue; } DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); + input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } @@ -10884,9 +9676,12 @@ void FieldOptions::SerializeWithCachedSizes( } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->uninterpreted_option_size()); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 999, this->uninterpreted_option(i), output); + 999, + this->uninterpreted_option(static_cast<int>(i)), + output); } // Extension range [1000, 536870912) @@ -10895,13 +9690,14 @@ void FieldOptions::SerializeWithCachedSizes( if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); + _internal_metadata_.unknown_fields(), output); } // @@protoc_insertion_point(serialize_end:google.protobuf.FieldOptions) } ::google::protobuf::uint8* FieldOptions::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.FieldOptions) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -10940,10 +9736,11 @@ void FieldOptions::SerializeWithCachedSizes( } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->uninterpreted_option_size()); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: - InternalWriteMessageNoVirtualToArray( - 999, this->uninterpreted_option(i), deterministic, target); + InternalWriteMessageToArray( + 999, this->uninterpreted_option(static_cast<int>(i)), deterministic, target); } // Extension range [1000, 536870912) @@ -10952,7 +9749,7 @@ void FieldOptions::SerializeWithCachedSizes( if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); + _internal_metadata_.unknown_fields(), target); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.FieldOptions) return target; @@ -10967,16 +9764,16 @@ size_t FieldOptions::ByteSizeLong() const { if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); + _internal_metadata_.unknown_fields()); } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; { - unsigned int count = this->uninterpreted_option_size(); + unsigned int count = static_cast<unsigned int>(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)); + ::google::protobuf::internal::WireFormatLite::MessageSize( + this->uninterpreted_option(static_cast<int>(i))); } } @@ -11094,210 +9891,48 @@ bool FieldOptions::IsInitialized() const { void FieldOptions::Swap(FieldOptions* other) { if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + FieldOptions* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } + } +} +void FieldOptions::UnsafeArenaSwap(FieldOptions* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); InternalSwap(other); } void FieldOptions::InternalSwap(FieldOptions* other) { - uninterpreted_option_.InternalSwap(&other->uninterpreted_option_); - std::swap(ctype_, other->ctype_); - std::swap(packed_, other->packed_); - std::swap(lazy_, other->lazy_); - std::swap(deprecated_, other->deprecated_); - std::swap(weak_, other->weak_); - std::swap(jstype_, other->jstype_); - std::swap(_has_bits_[0], other->_has_bits_[0]); + using std::swap; + CastToBase(&uninterpreted_option_)->InternalSwap(CastToBase(&other->uninterpreted_option_)); + swap(ctype_, other->ctype_); + swap(packed_, other->packed_); + swap(lazy_, other->lazy_); + swap(deprecated_, other->deprecated_); + swap(weak_, other->weak_); + swap(jstype_, other->jstype_); + swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); - std::swap(_cached_size_, other->_cached_size_); + swap(_cached_size_, other->_cached_size_); _extensions_.Swap(&other->_extensions_); } ::google::protobuf::Metadata FieldOptions::GetMetadata() const { protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages]; + return ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages]; } -#if PROTOBUF_INLINE_NOT_IN_HEADERS -// FieldOptions - -// optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING]; -bool FieldOptions::has_ctype() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -void FieldOptions::set_has_ctype() { - _has_bits_[0] |= 0x00000001u; -} -void FieldOptions::clear_has_ctype() { - _has_bits_[0] &= ~0x00000001u; -} -void FieldOptions::clear_ctype() { - ctype_ = 0; - clear_has_ctype(); -} -::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) { - assert(::google::protobuf::FieldOptions_CType_IsValid(value)); - set_has_ctype(); - ctype_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.FieldOptions.ctype) -} - -// optional bool packed = 2; -bool FieldOptions::has_packed() const { - return (_has_bits_[0] & 0x00000002u) != 0; -} -void FieldOptions::set_has_packed() { - _has_bits_[0] |= 0x00000002u; -} -void FieldOptions::clear_has_packed() { - _has_bits_[0] &= ~0x00000002u; -} -void FieldOptions::clear_packed() { - packed_ = false; - clear_has_packed(); -} -bool FieldOptions::packed() const { - // @@protoc_insertion_point(field_get:google.protobuf.FieldOptions.packed) - return packed_; -} -void FieldOptions::set_packed(bool value) { - set_has_packed(); - packed_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.FieldOptions.packed) -} - -// optional .google.protobuf.FieldOptions.JSType jstype = 6 [default = JS_NORMAL]; -bool FieldOptions::has_jstype() const { - return (_has_bits_[0] & 0x00000020u) != 0; -} -void FieldOptions::set_has_jstype() { - _has_bits_[0] |= 0x00000020u; -} -void FieldOptions::clear_has_jstype() { - _has_bits_[0] &= ~0x00000020u; -} -void FieldOptions::clear_jstype() { - jstype_ = 0; - clear_has_jstype(); -} -::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) { - assert(::google::protobuf::FieldOptions_JSType_IsValid(value)); - set_has_jstype(); - jstype_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.FieldOptions.jstype) -} - -// optional bool lazy = 5 [default = false]; -bool FieldOptions::has_lazy() const { - return (_has_bits_[0] & 0x00000004u) != 0; -} -void FieldOptions::set_has_lazy() { - _has_bits_[0] |= 0x00000004u; -} -void FieldOptions::clear_has_lazy() { - _has_bits_[0] &= ~0x00000004u; -} -void FieldOptions::clear_lazy() { - lazy_ = false; - clear_has_lazy(); -} -bool FieldOptions::lazy() const { - // @@protoc_insertion_point(field_get:google.protobuf.FieldOptions.lazy) - return lazy_; -} -void FieldOptions::set_lazy(bool value) { - set_has_lazy(); - lazy_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.FieldOptions.lazy) -} - -// optional bool deprecated = 3 [default = false]; -bool FieldOptions::has_deprecated() const { - return (_has_bits_[0] & 0x00000008u) != 0; -} -void FieldOptions::set_has_deprecated() { - _has_bits_[0] |= 0x00000008u; -} -void FieldOptions::clear_has_deprecated() { - _has_bits_[0] &= ~0x00000008u; -} -void FieldOptions::clear_deprecated() { - deprecated_ = false; - clear_has_deprecated(); -} -bool FieldOptions::deprecated() const { - // @@protoc_insertion_point(field_get:google.protobuf.FieldOptions.deprecated) - return deprecated_; -} -void FieldOptions::set_deprecated(bool value) { - set_has_deprecated(); - deprecated_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.FieldOptions.deprecated) -} - -// optional bool weak = 10 [default = false]; -bool FieldOptions::has_weak() const { - return (_has_bits_[0] & 0x00000010u) != 0; -} -void FieldOptions::set_has_weak() { - _has_bits_[0] |= 0x00000010u; -} -void FieldOptions::clear_has_weak() { - _has_bits_[0] &= ~0x00000010u; -} -void FieldOptions::clear_weak() { - weak_ = false; - clear_has_weak(); -} -bool FieldOptions::weak() const { - // @@protoc_insertion_point(field_get:google.protobuf.FieldOptions.weak) - return weak_; -} -void FieldOptions::set_weak(bool value) { - set_has_weak(); - weak_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.FieldOptions.weak) -} - -// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; -int FieldOptions::uninterpreted_option_size() const { - return uninterpreted_option_.size(); -} -void FieldOptions::clear_uninterpreted_option() { - uninterpreted_option_.Clear(); -} -const ::google::protobuf::UninterpretedOption& FieldOptions::uninterpreted_option(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.FieldOptions.uninterpreted_option) - return uninterpreted_option_.Get(index); -} -::google::protobuf::UninterpretedOption* FieldOptions::mutable_uninterpreted_option(int index) { - // @@protoc_insertion_point(field_mutable:google.protobuf.FieldOptions.uninterpreted_option) - return uninterpreted_option_.Mutable(index); -} -::google::protobuf::UninterpretedOption* FieldOptions::add_uninterpreted_option() { - // @@protoc_insertion_point(field_add:google.protobuf.FieldOptions.uninterpreted_option) - return uninterpreted_option_.Add(); -} -::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >* -FieldOptions::mutable_uninterpreted_option() { - // @@protoc_insertion_point(field_mutable_list:google.protobuf.FieldOptions.uninterpreted_option) - return &uninterpreted_option_; -} -const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >& -FieldOptions::uninterpreted_option() const { - // @@protoc_insertion_point(field_list:google.protobuf.FieldOptions.uninterpreted_option) - return uninterpreted_option_; -} - -#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== +void OneofOptions::InitAsDefaultInstance() { +} #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int OneofOptions::kUninterpretedOptionFieldNumber; #endif // !defined(_MSC_VER) || _MSC_VER >= 1900 @@ -11305,11 +9940,21 @@ const int OneofOptions::kUninterpretedOptionFieldNumber; OneofOptions::OneofOptions() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsOneofOptions(); } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.OneofOptions) } +OneofOptions::OneofOptions(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(), + _extensions_(arena), + _internal_metadata_(arena), + uninterpreted_option_(arena) { + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsOneofOptions(); + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:google.protobuf.OneofOptions) +} OneofOptions::OneofOptions(const OneofOptions& from) : ::google::protobuf::Message(), _internal_metadata_(NULL), @@ -11331,33 +9976,37 @@ OneofOptions::~OneofOptions() { } void OneofOptions::SharedDtor() { + GOOGLE_DCHECK(GetArenaNoVirtual() == NULL); } +void OneofOptions::ArenaDtor(void* object) { + OneofOptions* _this = reinterpret_cast< OneofOptions* >(object); + (void)_this; +} +void OneofOptions::RegisterArenaDtor(::google::protobuf::Arena* arena) { +} void OneofOptions::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* OneofOptions::descriptor() { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const OneofOptions& OneofOptions::default_instance() { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsOneofOptions(); return *internal_default_instance(); } -OneofOptions* OneofOptions::New(::google::protobuf::Arena* arena) const { - OneofOptions* n = new OneofOptions; - if (arena != NULL) { - arena->Own(n); - } - return n; -} void OneofOptions::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.OneofOptions) + ::google::protobuf::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + _extensions_.Clear(); uninterpreted_option_.Clear(); _has_bits_.Clear(); @@ -11377,8 +10026,8 @@ bool OneofOptions::MergePartialFromCodedStream( // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; case 999: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(7994u)) { - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + static_cast< ::google::protobuf::uint8>(58u /* 7994 & 0xFF */)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, add_uninterpreted_option())); } else { goto handle_unusual; @@ -11388,18 +10037,17 @@ bool OneofOptions::MergePartialFromCodedStream( default: { handle_unusual: - if (tag == 0 || - ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + if (tag == 0) { goto success; } if ((8000u <= tag)) { - DO_(_extensions_.ParseField(tag, input, internal_default_instance(), - mutable_unknown_fields())); + DO_(_extensions_.ParseField(tag, input, + internal_default_instance(), + _internal_metadata_.mutable_unknown_fields())); continue; } DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); + input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } @@ -11420,9 +10068,12 @@ void OneofOptions::SerializeWithCachedSizes( (void) cached_has_bits; // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->uninterpreted_option_size()); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 999, this->uninterpreted_option(i), output); + 999, + this->uninterpreted_option(static_cast<int>(i)), + output); } // Extension range [1000, 536870912) @@ -11431,22 +10082,24 @@ void OneofOptions::SerializeWithCachedSizes( if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); + _internal_metadata_.unknown_fields(), output); } // @@protoc_insertion_point(serialize_end:google.protobuf.OneofOptions) } ::google::protobuf::uint8* OneofOptions::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.OneofOptions) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->uninterpreted_option_size()); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: - InternalWriteMessageNoVirtualToArray( - 999, this->uninterpreted_option(i), deterministic, target); + InternalWriteMessageToArray( + 999, this->uninterpreted_option(static_cast<int>(i)), deterministic, target); } // Extension range [1000, 536870912) @@ -11455,7 +10108,7 @@ void OneofOptions::SerializeWithCachedSizes( if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); + _internal_metadata_.unknown_fields(), target); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.OneofOptions) return target; @@ -11470,16 +10123,16 @@ size_t OneofOptions::ByteSizeLong() const { if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); + _internal_metadata_.unknown_fields()); } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; { - unsigned int count = this->uninterpreted_option_size(); + unsigned int count = static_cast<unsigned int>(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)); + ::google::protobuf::internal::WireFormatLite::MessageSize( + this->uninterpreted_option(static_cast<int>(i))); } } @@ -11541,58 +10194,42 @@ bool OneofOptions::IsInitialized() const { void OneofOptions::Swap(OneofOptions* other) { if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + OneofOptions* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } + } +} +void OneofOptions::UnsafeArenaSwap(OneofOptions* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); InternalSwap(other); } void OneofOptions::InternalSwap(OneofOptions* other) { - uninterpreted_option_.InternalSwap(&other->uninterpreted_option_); - std::swap(_has_bits_[0], other->_has_bits_[0]); + using std::swap; + CastToBase(&uninterpreted_option_)->InternalSwap(CastToBase(&other->uninterpreted_option_)); + swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); - std::swap(_cached_size_, other->_cached_size_); + swap(_cached_size_, other->_cached_size_); _extensions_.Swap(&other->_extensions_); } ::google::protobuf::Metadata OneofOptions::GetMetadata() const { protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages]; -} - -#if PROTOBUF_INLINE_NOT_IN_HEADERS -// OneofOptions - -// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; -int OneofOptions::uninterpreted_option_size() const { - return uninterpreted_option_.size(); -} -void OneofOptions::clear_uninterpreted_option() { - uninterpreted_option_.Clear(); -} -const ::google::protobuf::UninterpretedOption& OneofOptions::uninterpreted_option(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.OneofOptions.uninterpreted_option) - return uninterpreted_option_.Get(index); -} -::google::protobuf::UninterpretedOption* OneofOptions::mutable_uninterpreted_option(int index) { - // @@protoc_insertion_point(field_mutable:google.protobuf.OneofOptions.uninterpreted_option) - return uninterpreted_option_.Mutable(index); -} -::google::protobuf::UninterpretedOption* OneofOptions::add_uninterpreted_option() { - // @@protoc_insertion_point(field_add:google.protobuf.OneofOptions.uninterpreted_option) - return uninterpreted_option_.Add(); -} -::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >* -OneofOptions::mutable_uninterpreted_option() { - // @@protoc_insertion_point(field_mutable_list:google.protobuf.OneofOptions.uninterpreted_option) - return &uninterpreted_option_; -} -const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >& -OneofOptions::uninterpreted_option() const { - // @@protoc_insertion_point(field_list:google.protobuf.OneofOptions.uninterpreted_option) - return uninterpreted_option_; + return ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages]; } -#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== +void EnumOptions::InitAsDefaultInstance() { +} #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int EnumOptions::kAllowAliasFieldNumber; const int EnumOptions::kDeprecatedFieldNumber; @@ -11602,11 +10239,21 @@ const int EnumOptions::kUninterpretedOptionFieldNumber; EnumOptions::EnumOptions() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsEnumOptions(); } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.EnumOptions) } +EnumOptions::EnumOptions(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(), + _extensions_(arena), + _internal_metadata_(arena), + uninterpreted_option_(arena) { + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsEnumOptions(); + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:google.protobuf.EnumOptions) +} EnumOptions::EnumOptions(const EnumOptions& from) : ::google::protobuf::Message(), _internal_metadata_(NULL), @@ -11616,15 +10263,16 @@ EnumOptions::EnumOptions(const EnumOptions& from) _internal_metadata_.MergeFrom(from._internal_metadata_); _extensions_.MergeFrom(from._extensions_); ::memcpy(&allow_alias_, &from.allow_alias_, - reinterpret_cast<char*>(&deprecated_) - - reinterpret_cast<char*>(&allow_alias_) + sizeof(deprecated_)); + static_cast<size_t>(reinterpret_cast<char*>(&deprecated_) - + reinterpret_cast<char*>(&allow_alias_)) + sizeof(deprecated_)); // @@protoc_insertion_point(copy_constructor:google.protobuf.EnumOptions) } void EnumOptions::SharedCtor() { _cached_size_ = 0; - ::memset(&allow_alias_, 0, reinterpret_cast<char*>(&deprecated_) - - reinterpret_cast<char*>(&allow_alias_) + sizeof(deprecated_)); + ::memset(&allow_alias_, 0, static_cast<size_t>( + reinterpret_cast<char*>(&deprecated_) - + reinterpret_cast<char*>(&allow_alias_)) + sizeof(deprecated_)); } EnumOptions::~EnumOptions() { @@ -11633,39 +10281,42 @@ EnumOptions::~EnumOptions() { } void EnumOptions::SharedDtor() { + GOOGLE_DCHECK(GetArenaNoVirtual() == NULL); } +void EnumOptions::ArenaDtor(void* object) { + EnumOptions* _this = reinterpret_cast< EnumOptions* >(object); + (void)_this; +} +void EnumOptions::RegisterArenaDtor(::google::protobuf::Arena* arena) { +} void EnumOptions::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* EnumOptions::descriptor() { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const EnumOptions& EnumOptions::default_instance() { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsEnumOptions(); return *internal_default_instance(); } -EnumOptions* EnumOptions::New(::google::protobuf::Arena* arena) const { - EnumOptions* n = new EnumOptions; - if (arena != NULL) { - arena->Own(n); - } - return n; -} void EnumOptions::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.EnumOptions) + ::google::protobuf::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + _extensions_.Clear(); uninterpreted_option_.Clear(); - if (_has_bits_[0 / 32] & 3u) { - ::memset(&allow_alias_, 0, reinterpret_cast<char*>(&deprecated_) - - reinterpret_cast<char*>(&allow_alias_) + sizeof(deprecated_)); - } + ::memset(&allow_alias_, 0, static_cast<size_t>( + reinterpret_cast<char*>(&deprecated_) - + reinterpret_cast<char*>(&allow_alias_)) + sizeof(deprecated_)); _has_bits_.Clear(); _internal_metadata_.Clear(); } @@ -11683,7 +10334,7 @@ bool EnumOptions::MergePartialFromCodedStream( // optional bool allow_alias = 2; case 2: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(16u)) { + static_cast< ::google::protobuf::uint8>(16u /* 16 & 0xFF */)) { set_has_allow_alias(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -11697,7 +10348,7 @@ bool EnumOptions::MergePartialFromCodedStream( // optional bool deprecated = 3 [default = false]; case 3: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(24u)) { + static_cast< ::google::protobuf::uint8>(24u /* 24 & 0xFF */)) { set_has_deprecated(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -11711,8 +10362,8 @@ bool EnumOptions::MergePartialFromCodedStream( // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; case 999: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(7994u)) { - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + static_cast< ::google::protobuf::uint8>(58u /* 7994 & 0xFF */)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, add_uninterpreted_option())); } else { goto handle_unusual; @@ -11722,18 +10373,17 @@ bool EnumOptions::MergePartialFromCodedStream( default: { handle_unusual: - if (tag == 0 || - ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + if (tag == 0) { goto success; } if ((8000u <= tag)) { - DO_(_extensions_.ParseField(tag, input, internal_default_instance(), - mutable_unknown_fields())); + DO_(_extensions_.ParseField(tag, input, + internal_default_instance(), + _internal_metadata_.mutable_unknown_fields())); continue; } DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); + input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } @@ -11765,9 +10415,12 @@ void EnumOptions::SerializeWithCachedSizes( } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->uninterpreted_option_size()); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 999, this->uninterpreted_option(i), output); + 999, + this->uninterpreted_option(static_cast<int>(i)), + output); } // Extension range [1000, 536870912) @@ -11776,13 +10429,14 @@ void EnumOptions::SerializeWithCachedSizes( if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); + _internal_metadata_.unknown_fields(), output); } // @@protoc_insertion_point(serialize_end:google.protobuf.EnumOptions) } ::google::protobuf::uint8* EnumOptions::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.EnumOptions) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -11799,10 +10453,11 @@ void EnumOptions::SerializeWithCachedSizes( } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->uninterpreted_option_size()); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: - InternalWriteMessageNoVirtualToArray( - 999, this->uninterpreted_option(i), deterministic, target); + InternalWriteMessageToArray( + 999, this->uninterpreted_option(static_cast<int>(i)), deterministic, target); } // Extension range [1000, 536870912) @@ -11811,7 +10466,7 @@ void EnumOptions::SerializeWithCachedSizes( if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); + _internal_metadata_.unknown_fields(), target); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.EnumOptions) return target; @@ -11826,16 +10481,16 @@ size_t EnumOptions::ByteSizeLong() const { if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); + _internal_metadata_.unknown_fields()); } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; { - unsigned int count = this->uninterpreted_option_size(); + unsigned int count = static_cast<unsigned int>(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)); + ::google::protobuf::internal::WireFormatLite::MessageSize( + this->uninterpreted_option(static_cast<int>(i))); } } @@ -11919,108 +10574,44 @@ bool EnumOptions::IsInitialized() const { void EnumOptions::Swap(EnumOptions* other) { if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + EnumOptions* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } + } +} +void EnumOptions::UnsafeArenaSwap(EnumOptions* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); InternalSwap(other); } void EnumOptions::InternalSwap(EnumOptions* other) { - uninterpreted_option_.InternalSwap(&other->uninterpreted_option_); - std::swap(allow_alias_, other->allow_alias_); - std::swap(deprecated_, other->deprecated_); - std::swap(_has_bits_[0], other->_has_bits_[0]); + using std::swap; + CastToBase(&uninterpreted_option_)->InternalSwap(CastToBase(&other->uninterpreted_option_)); + swap(allow_alias_, other->allow_alias_); + swap(deprecated_, other->deprecated_); + swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); - std::swap(_cached_size_, other->_cached_size_); + swap(_cached_size_, other->_cached_size_); _extensions_.Swap(&other->_extensions_); } ::google::protobuf::Metadata EnumOptions::GetMetadata() const { protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages]; -} - -#if PROTOBUF_INLINE_NOT_IN_HEADERS -// EnumOptions - -// optional bool allow_alias = 2; -bool EnumOptions::has_allow_alias() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -void EnumOptions::set_has_allow_alias() { - _has_bits_[0] |= 0x00000001u; -} -void EnumOptions::clear_has_allow_alias() { - _has_bits_[0] &= ~0x00000001u; -} -void EnumOptions::clear_allow_alias() { - allow_alias_ = false; - clear_has_allow_alias(); -} -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) { - set_has_allow_alias(); - allow_alias_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.EnumOptions.allow_alias) + return ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages]; } -// optional bool deprecated = 3 [default = false]; -bool EnumOptions::has_deprecated() const { - return (_has_bits_[0] & 0x00000002u) != 0; -} -void EnumOptions::set_has_deprecated() { - _has_bits_[0] |= 0x00000002u; -} -void EnumOptions::clear_has_deprecated() { - _has_bits_[0] &= ~0x00000002u; -} -void EnumOptions::clear_deprecated() { - deprecated_ = false; - clear_has_deprecated(); -} -bool EnumOptions::deprecated() const { - // @@protoc_insertion_point(field_get:google.protobuf.EnumOptions.deprecated) - return deprecated_; -} -void EnumOptions::set_deprecated(bool value) { - set_has_deprecated(); - deprecated_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.EnumOptions.deprecated) -} - -// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; -int EnumOptions::uninterpreted_option_size() const { - return uninterpreted_option_.size(); -} -void EnumOptions::clear_uninterpreted_option() { - uninterpreted_option_.Clear(); -} -const ::google::protobuf::UninterpretedOption& EnumOptions::uninterpreted_option(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.EnumOptions.uninterpreted_option) - return uninterpreted_option_.Get(index); -} -::google::protobuf::UninterpretedOption* EnumOptions::mutable_uninterpreted_option(int index) { - // @@protoc_insertion_point(field_mutable:google.protobuf.EnumOptions.uninterpreted_option) - return uninterpreted_option_.Mutable(index); -} -::google::protobuf::UninterpretedOption* EnumOptions::add_uninterpreted_option() { - // @@protoc_insertion_point(field_add:google.protobuf.EnumOptions.uninterpreted_option) - return uninterpreted_option_.Add(); -} -::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >* -EnumOptions::mutable_uninterpreted_option() { - // @@protoc_insertion_point(field_mutable_list:google.protobuf.EnumOptions.uninterpreted_option) - return &uninterpreted_option_; -} -const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >& -EnumOptions::uninterpreted_option() const { - // @@protoc_insertion_point(field_list:google.protobuf.EnumOptions.uninterpreted_option) - return uninterpreted_option_; -} - -#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== +void EnumValueOptions::InitAsDefaultInstance() { +} #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int EnumValueOptions::kDeprecatedFieldNumber; const int EnumValueOptions::kUninterpretedOptionFieldNumber; @@ -12029,11 +10620,21 @@ const int EnumValueOptions::kUninterpretedOptionFieldNumber; EnumValueOptions::EnumValueOptions() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsEnumValueOptions(); } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.EnumValueOptions) } +EnumValueOptions::EnumValueOptions(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(), + _extensions_(arena), + _internal_metadata_(arena), + uninterpreted_option_(arena) { + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsEnumValueOptions(); + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:google.protobuf.EnumValueOptions) +} EnumValueOptions::EnumValueOptions(const EnumValueOptions& from) : ::google::protobuf::Message(), _internal_metadata_(NULL), @@ -12057,33 +10658,37 @@ EnumValueOptions::~EnumValueOptions() { } void EnumValueOptions::SharedDtor() { + GOOGLE_DCHECK(GetArenaNoVirtual() == NULL); } +void EnumValueOptions::ArenaDtor(void* object) { + EnumValueOptions* _this = reinterpret_cast< EnumValueOptions* >(object); + (void)_this; +} +void EnumValueOptions::RegisterArenaDtor(::google::protobuf::Arena* arena) { +} void EnumValueOptions::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* EnumValueOptions::descriptor() { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const EnumValueOptions& EnumValueOptions::default_instance() { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsEnumValueOptions(); return *internal_default_instance(); } -EnumValueOptions* EnumValueOptions::New(::google::protobuf::Arena* arena) const { - EnumValueOptions* n = new EnumValueOptions; - if (arena != NULL) { - arena->Own(n); - } - return n; -} void EnumValueOptions::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.EnumValueOptions) + ::google::protobuf::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + _extensions_.Clear(); uninterpreted_option_.Clear(); deprecated_ = false; @@ -12104,7 +10709,7 @@ bool EnumValueOptions::MergePartialFromCodedStream( // optional bool deprecated = 1 [default = false]; case 1: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(8u)) { + static_cast< ::google::protobuf::uint8>(8u /* 8 & 0xFF */)) { set_has_deprecated(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -12118,8 +10723,8 @@ bool EnumValueOptions::MergePartialFromCodedStream( // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; case 999: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(7994u)) { - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + static_cast< ::google::protobuf::uint8>(58u /* 7994 & 0xFF */)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, add_uninterpreted_option())); } else { goto handle_unusual; @@ -12129,18 +10734,17 @@ bool EnumValueOptions::MergePartialFromCodedStream( default: { handle_unusual: - if (tag == 0 || - ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + if (tag == 0) { goto success; } if ((8000u <= tag)) { - DO_(_extensions_.ParseField(tag, input, internal_default_instance(), - mutable_unknown_fields())); + DO_(_extensions_.ParseField(tag, input, + internal_default_instance(), + _internal_metadata_.mutable_unknown_fields())); continue; } DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); + input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } @@ -12167,9 +10771,12 @@ void EnumValueOptions::SerializeWithCachedSizes( } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->uninterpreted_option_size()); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 999, this->uninterpreted_option(i), output); + 999, + this->uninterpreted_option(static_cast<int>(i)), + output); } // Extension range [1000, 536870912) @@ -12178,13 +10785,14 @@ void EnumValueOptions::SerializeWithCachedSizes( if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); + _internal_metadata_.unknown_fields(), output); } // @@protoc_insertion_point(serialize_end:google.protobuf.EnumValueOptions) } ::google::protobuf::uint8* EnumValueOptions::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.EnumValueOptions) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -12196,10 +10804,11 @@ void EnumValueOptions::SerializeWithCachedSizes( } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->uninterpreted_option_size()); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: - InternalWriteMessageNoVirtualToArray( - 999, this->uninterpreted_option(i), deterministic, target); + InternalWriteMessageToArray( + 999, this->uninterpreted_option(static_cast<int>(i)), deterministic, target); } // Extension range [1000, 536870912) @@ -12208,7 +10817,7 @@ void EnumValueOptions::SerializeWithCachedSizes( if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); + _internal_metadata_.unknown_fields(), target); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.EnumValueOptions) return target; @@ -12223,16 +10832,16 @@ size_t EnumValueOptions::ByteSizeLong() const { if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); + _internal_metadata_.unknown_fields()); } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; { - unsigned int count = this->uninterpreted_option_size(); + unsigned int count = static_cast<unsigned int>(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)); + ::google::protobuf::internal::WireFormatLite::MessageSize( + this->uninterpreted_option(static_cast<int>(i))); } } @@ -12302,83 +10911,43 @@ bool EnumValueOptions::IsInitialized() const { void EnumValueOptions::Swap(EnumValueOptions* other) { if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + EnumValueOptions* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } + } +} +void EnumValueOptions::UnsafeArenaSwap(EnumValueOptions* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); InternalSwap(other); } void EnumValueOptions::InternalSwap(EnumValueOptions* other) { - uninterpreted_option_.InternalSwap(&other->uninterpreted_option_); - std::swap(deprecated_, other->deprecated_); - std::swap(_has_bits_[0], other->_has_bits_[0]); + using std::swap; + CastToBase(&uninterpreted_option_)->InternalSwap(CastToBase(&other->uninterpreted_option_)); + swap(deprecated_, other->deprecated_); + swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); - std::swap(_cached_size_, other->_cached_size_); + swap(_cached_size_, other->_cached_size_); _extensions_.Swap(&other->_extensions_); } ::google::protobuf::Metadata EnumValueOptions::GetMetadata() const { protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages]; -} - -#if PROTOBUF_INLINE_NOT_IN_HEADERS -// EnumValueOptions - -// optional bool deprecated = 1 [default = false]; -bool EnumValueOptions::has_deprecated() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -void EnumValueOptions::set_has_deprecated() { - _has_bits_[0] |= 0x00000001u; -} -void EnumValueOptions::clear_has_deprecated() { - _has_bits_[0] &= ~0x00000001u; -} -void EnumValueOptions::clear_deprecated() { - deprecated_ = false; - clear_has_deprecated(); -} -bool EnumValueOptions::deprecated() const { - // @@protoc_insertion_point(field_get:google.protobuf.EnumValueOptions.deprecated) - return deprecated_; -} -void EnumValueOptions::set_deprecated(bool value) { - set_has_deprecated(); - deprecated_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.EnumValueOptions.deprecated) + return ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages]; } -// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; -int EnumValueOptions::uninterpreted_option_size() const { - return uninterpreted_option_.size(); -} -void EnumValueOptions::clear_uninterpreted_option() { - uninterpreted_option_.Clear(); -} -const ::google::protobuf::UninterpretedOption& EnumValueOptions::uninterpreted_option(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.EnumValueOptions.uninterpreted_option) - return uninterpreted_option_.Get(index); -} -::google::protobuf::UninterpretedOption* EnumValueOptions::mutable_uninterpreted_option(int index) { - // @@protoc_insertion_point(field_mutable:google.protobuf.EnumValueOptions.uninterpreted_option) - return uninterpreted_option_.Mutable(index); -} -::google::protobuf::UninterpretedOption* EnumValueOptions::add_uninterpreted_option() { - // @@protoc_insertion_point(field_add:google.protobuf.EnumValueOptions.uninterpreted_option) - return uninterpreted_option_.Add(); -} -::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >* -EnumValueOptions::mutable_uninterpreted_option() { - // @@protoc_insertion_point(field_mutable_list:google.protobuf.EnumValueOptions.uninterpreted_option) - return &uninterpreted_option_; -} -const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >& -EnumValueOptions::uninterpreted_option() const { - // @@protoc_insertion_point(field_list:google.protobuf.EnumValueOptions.uninterpreted_option) - return uninterpreted_option_; -} - -#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== +void ServiceOptions::InitAsDefaultInstance() { +} #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int ServiceOptions::kDeprecatedFieldNumber; const int ServiceOptions::kUninterpretedOptionFieldNumber; @@ -12387,11 +10956,21 @@ const int ServiceOptions::kUninterpretedOptionFieldNumber; ServiceOptions::ServiceOptions() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsServiceOptions(); } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.ServiceOptions) } +ServiceOptions::ServiceOptions(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(), + _extensions_(arena), + _internal_metadata_(arena), + uninterpreted_option_(arena) { + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsServiceOptions(); + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:google.protobuf.ServiceOptions) +} ServiceOptions::ServiceOptions(const ServiceOptions& from) : ::google::protobuf::Message(), _internal_metadata_(NULL), @@ -12415,33 +10994,37 @@ ServiceOptions::~ServiceOptions() { } void ServiceOptions::SharedDtor() { + GOOGLE_DCHECK(GetArenaNoVirtual() == NULL); } +void ServiceOptions::ArenaDtor(void* object) { + ServiceOptions* _this = reinterpret_cast< ServiceOptions* >(object); + (void)_this; +} +void ServiceOptions::RegisterArenaDtor(::google::protobuf::Arena* arena) { +} void ServiceOptions::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* ServiceOptions::descriptor() { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const ServiceOptions& ServiceOptions::default_instance() { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsServiceOptions(); return *internal_default_instance(); } -ServiceOptions* ServiceOptions::New(::google::protobuf::Arena* arena) const { - ServiceOptions* n = new ServiceOptions; - if (arena != NULL) { - arena->Own(n); - } - return n; -} void ServiceOptions::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.ServiceOptions) + ::google::protobuf::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + _extensions_.Clear(); uninterpreted_option_.Clear(); deprecated_ = false; @@ -12462,7 +11045,7 @@ bool ServiceOptions::MergePartialFromCodedStream( // optional bool deprecated = 33 [default = false]; case 33: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(264u)) { + static_cast< ::google::protobuf::uint8>(8u /* 264 & 0xFF */)) { set_has_deprecated(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -12476,8 +11059,8 @@ bool ServiceOptions::MergePartialFromCodedStream( // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; case 999: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(7994u)) { - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + static_cast< ::google::protobuf::uint8>(58u /* 7994 & 0xFF */)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, add_uninterpreted_option())); } else { goto handle_unusual; @@ -12487,18 +11070,17 @@ bool ServiceOptions::MergePartialFromCodedStream( default: { handle_unusual: - if (tag == 0 || - ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + if (tag == 0) { goto success; } if ((8000u <= tag)) { - DO_(_extensions_.ParseField(tag, input, internal_default_instance(), - mutable_unknown_fields())); + DO_(_extensions_.ParseField(tag, input, + internal_default_instance(), + _internal_metadata_.mutable_unknown_fields())); continue; } DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); + input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } @@ -12525,9 +11107,12 @@ void ServiceOptions::SerializeWithCachedSizes( } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->uninterpreted_option_size()); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 999, this->uninterpreted_option(i), output); + 999, + this->uninterpreted_option(static_cast<int>(i)), + output); } // Extension range [1000, 536870912) @@ -12536,13 +11121,14 @@ void ServiceOptions::SerializeWithCachedSizes( if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); + _internal_metadata_.unknown_fields(), output); } // @@protoc_insertion_point(serialize_end:google.protobuf.ServiceOptions) } ::google::protobuf::uint8* ServiceOptions::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.ServiceOptions) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -12554,10 +11140,11 @@ void ServiceOptions::SerializeWithCachedSizes( } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->uninterpreted_option_size()); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: - InternalWriteMessageNoVirtualToArray( - 999, this->uninterpreted_option(i), deterministic, target); + InternalWriteMessageToArray( + 999, this->uninterpreted_option(static_cast<int>(i)), deterministic, target); } // Extension range [1000, 536870912) @@ -12566,7 +11153,7 @@ void ServiceOptions::SerializeWithCachedSizes( if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); + _internal_metadata_.unknown_fields(), target); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.ServiceOptions) return target; @@ -12581,16 +11168,16 @@ size_t ServiceOptions::ByteSizeLong() const { if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); + _internal_metadata_.unknown_fields()); } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; { - unsigned int count = this->uninterpreted_option_size(); + unsigned int count = static_cast<unsigned int>(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)); + ::google::protobuf::internal::WireFormatLite::MessageSize( + this->uninterpreted_option(static_cast<int>(i))); } } @@ -12660,83 +11247,43 @@ bool ServiceOptions::IsInitialized() const { void ServiceOptions::Swap(ServiceOptions* other) { if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + ServiceOptions* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } + } +} +void ServiceOptions::UnsafeArenaSwap(ServiceOptions* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); InternalSwap(other); } void ServiceOptions::InternalSwap(ServiceOptions* other) { - uninterpreted_option_.InternalSwap(&other->uninterpreted_option_); - std::swap(deprecated_, other->deprecated_); - std::swap(_has_bits_[0], other->_has_bits_[0]); + using std::swap; + CastToBase(&uninterpreted_option_)->InternalSwap(CastToBase(&other->uninterpreted_option_)); + swap(deprecated_, other->deprecated_); + swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); - std::swap(_cached_size_, other->_cached_size_); + swap(_cached_size_, other->_cached_size_); _extensions_.Swap(&other->_extensions_); } ::google::protobuf::Metadata ServiceOptions::GetMetadata() const { protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages]; + return ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages]; } -#if PROTOBUF_INLINE_NOT_IN_HEADERS -// ServiceOptions - -// optional bool deprecated = 33 [default = false]; -bool ServiceOptions::has_deprecated() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -void ServiceOptions::set_has_deprecated() { - _has_bits_[0] |= 0x00000001u; -} -void ServiceOptions::clear_has_deprecated() { - _has_bits_[0] &= ~0x00000001u; -} -void ServiceOptions::clear_deprecated() { - deprecated_ = false; - clear_has_deprecated(); -} -bool ServiceOptions::deprecated() const { - // @@protoc_insertion_point(field_get:google.protobuf.ServiceOptions.deprecated) - return deprecated_; -} -void ServiceOptions::set_deprecated(bool value) { - set_has_deprecated(); - deprecated_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.ServiceOptions.deprecated) -} - -// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; -int ServiceOptions::uninterpreted_option_size() const { - return uninterpreted_option_.size(); -} -void ServiceOptions::clear_uninterpreted_option() { - uninterpreted_option_.Clear(); -} -const ::google::protobuf::UninterpretedOption& ServiceOptions::uninterpreted_option(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.ServiceOptions.uninterpreted_option) - return uninterpreted_option_.Get(index); -} -::google::protobuf::UninterpretedOption* ServiceOptions::mutable_uninterpreted_option(int index) { - // @@protoc_insertion_point(field_mutable:google.protobuf.ServiceOptions.uninterpreted_option) - return uninterpreted_option_.Mutable(index); -} -::google::protobuf::UninterpretedOption* ServiceOptions::add_uninterpreted_option() { - // @@protoc_insertion_point(field_add:google.protobuf.ServiceOptions.uninterpreted_option) - return uninterpreted_option_.Add(); -} -::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >* -ServiceOptions::mutable_uninterpreted_option() { - // @@protoc_insertion_point(field_mutable_list:google.protobuf.ServiceOptions.uninterpreted_option) - return &uninterpreted_option_; -} -const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >& -ServiceOptions::uninterpreted_option() const { - // @@protoc_insertion_point(field_list:google.protobuf.ServiceOptions.uninterpreted_option) - return uninterpreted_option_; -} - -#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== +void MethodOptions::InitAsDefaultInstance() { +} #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int MethodOptions::kDeprecatedFieldNumber; const int MethodOptions::kIdempotencyLevelFieldNumber; @@ -12746,11 +11293,21 @@ const int MethodOptions::kUninterpretedOptionFieldNumber; MethodOptions::MethodOptions() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsMethodOptions(); } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.MethodOptions) } +MethodOptions::MethodOptions(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(), + _extensions_(arena), + _internal_metadata_(arena), + uninterpreted_option_(arena) { + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsMethodOptions(); + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:google.protobuf.MethodOptions) +} MethodOptions::MethodOptions(const MethodOptions& from) : ::google::protobuf::Message(), _internal_metadata_(NULL), @@ -12760,15 +11317,16 @@ MethodOptions::MethodOptions(const MethodOptions& from) _internal_metadata_.MergeFrom(from._internal_metadata_); _extensions_.MergeFrom(from._extensions_); ::memcpy(&deprecated_, &from.deprecated_, - reinterpret_cast<char*>(&idempotency_level_) - - reinterpret_cast<char*>(&deprecated_) + sizeof(idempotency_level_)); + static_cast<size_t>(reinterpret_cast<char*>(&idempotency_level_) - + reinterpret_cast<char*>(&deprecated_)) + sizeof(idempotency_level_)); // @@protoc_insertion_point(copy_constructor:google.protobuf.MethodOptions) } void MethodOptions::SharedCtor() { _cached_size_ = 0; - ::memset(&deprecated_, 0, reinterpret_cast<char*>(&idempotency_level_) - - reinterpret_cast<char*>(&deprecated_) + sizeof(idempotency_level_)); + ::memset(&deprecated_, 0, static_cast<size_t>( + reinterpret_cast<char*>(&idempotency_level_) - + reinterpret_cast<char*>(&deprecated_)) + sizeof(idempotency_level_)); } MethodOptions::~MethodOptions() { @@ -12777,38 +11335,44 @@ MethodOptions::~MethodOptions() { } void MethodOptions::SharedDtor() { + GOOGLE_DCHECK(GetArenaNoVirtual() == NULL); } +void MethodOptions::ArenaDtor(void* object) { + MethodOptions* _this = reinterpret_cast< MethodOptions* >(object); + (void)_this; +} +void MethodOptions::RegisterArenaDtor(::google::protobuf::Arena* arena) { +} void MethodOptions::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* MethodOptions::descriptor() { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const MethodOptions& MethodOptions::default_instance() { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsMethodOptions(); return *internal_default_instance(); } -MethodOptions* MethodOptions::New(::google::protobuf::Arena* arena) const { - MethodOptions* n = new MethodOptions; - if (arena != NULL) { - arena->Own(n); - } - return n; -} void MethodOptions::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.MethodOptions) + ::google::protobuf::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + _extensions_.Clear(); uninterpreted_option_.Clear(); - if (_has_bits_[0 / 32] & 3u) { - ::memset(&deprecated_, 0, reinterpret_cast<char*>(&idempotency_level_) - - reinterpret_cast<char*>(&deprecated_) + sizeof(idempotency_level_)); + cached_has_bits = _has_bits_[0]; + if (cached_has_bits & 3u) { + ::memset(&deprecated_, 0, static_cast<size_t>( + reinterpret_cast<char*>(&idempotency_level_) - + reinterpret_cast<char*>(&deprecated_)) + sizeof(idempotency_level_)); } _has_bits_.Clear(); _internal_metadata_.Clear(); @@ -12827,7 +11391,7 @@ bool MethodOptions::MergePartialFromCodedStream( // optional bool deprecated = 33 [default = false]; case 33: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(264u)) { + static_cast< ::google::protobuf::uint8>(8u /* 264 & 0xFF */)) { set_has_deprecated(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -12841,7 +11405,7 @@ bool MethodOptions::MergePartialFromCodedStream( // optional .google.protobuf.MethodOptions.IdempotencyLevel idempotency_level = 34 [default = IDEMPOTENCY_UNKNOWN]; case 34: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(272u)) { + static_cast< ::google::protobuf::uint8>(16u /* 272 & 0xFF */)) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -12849,7 +11413,8 @@ bool MethodOptions::MergePartialFromCodedStream( if (::google::protobuf::MethodOptions_IdempotencyLevel_IsValid(value)) { set_idempotency_level(static_cast< ::google::protobuf::MethodOptions_IdempotencyLevel >(value)); } else { - mutable_unknown_fields()->AddVarint(34, value); + mutable_unknown_fields()->AddVarint( + 34, static_cast< ::google::protobuf::uint64>(value)); } } else { goto handle_unusual; @@ -12860,8 +11425,8 @@ bool MethodOptions::MergePartialFromCodedStream( // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; case 999: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(7994u)) { - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + static_cast< ::google::protobuf::uint8>(58u /* 7994 & 0xFF */)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, add_uninterpreted_option())); } else { goto handle_unusual; @@ -12871,18 +11436,17 @@ bool MethodOptions::MergePartialFromCodedStream( default: { handle_unusual: - if (tag == 0 || - ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + if (tag == 0) { goto success; } if ((8000u <= tag)) { - DO_(_extensions_.ParseField(tag, input, internal_default_instance(), - mutable_unknown_fields())); + DO_(_extensions_.ParseField(tag, input, + internal_default_instance(), + _internal_metadata_.mutable_unknown_fields())); continue; } DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); + input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } @@ -12915,9 +11479,12 @@ void MethodOptions::SerializeWithCachedSizes( } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->uninterpreted_option_size()); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 999, this->uninterpreted_option(i), output); + 999, + this->uninterpreted_option(static_cast<int>(i)), + output); } // Extension range [1000, 536870912) @@ -12926,13 +11493,14 @@ void MethodOptions::SerializeWithCachedSizes( if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); + _internal_metadata_.unknown_fields(), output); } // @@protoc_insertion_point(serialize_end:google.protobuf.MethodOptions) } ::google::protobuf::uint8* MethodOptions::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.MethodOptions) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -12950,10 +11518,11 @@ void MethodOptions::SerializeWithCachedSizes( } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->uninterpreted_option_size()); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: - InternalWriteMessageNoVirtualToArray( - 999, this->uninterpreted_option(i), deterministic, target); + InternalWriteMessageToArray( + 999, this->uninterpreted_option(static_cast<int>(i)), deterministic, target); } // Extension range [1000, 536870912) @@ -12962,7 +11531,7 @@ void MethodOptions::SerializeWithCachedSizes( if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); + _internal_metadata_.unknown_fields(), target); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.MethodOptions) return target; @@ -12977,16 +11546,16 @@ size_t MethodOptions::ByteSizeLong() const { if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); + _internal_metadata_.unknown_fields()); } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; { - unsigned int count = this->uninterpreted_option_size(); + unsigned int count = static_cast<unsigned int>(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)); + ::google::protobuf::internal::WireFormatLite::MessageSize( + this->uninterpreted_option(static_cast<int>(i))); } } @@ -13071,109 +11640,44 @@ bool MethodOptions::IsInitialized() const { void MethodOptions::Swap(MethodOptions* other) { if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + MethodOptions* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } + } +} +void MethodOptions::UnsafeArenaSwap(MethodOptions* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); InternalSwap(other); } void MethodOptions::InternalSwap(MethodOptions* other) { - uninterpreted_option_.InternalSwap(&other->uninterpreted_option_); - std::swap(deprecated_, other->deprecated_); - std::swap(idempotency_level_, other->idempotency_level_); - std::swap(_has_bits_[0], other->_has_bits_[0]); + using std::swap; + CastToBase(&uninterpreted_option_)->InternalSwap(CastToBase(&other->uninterpreted_option_)); + swap(deprecated_, other->deprecated_); + swap(idempotency_level_, other->idempotency_level_); + swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); - std::swap(_cached_size_, other->_cached_size_); + swap(_cached_size_, other->_cached_size_); _extensions_.Swap(&other->_extensions_); } ::google::protobuf::Metadata MethodOptions::GetMetadata() const { protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages]; + return ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages]; } -#if PROTOBUF_INLINE_NOT_IN_HEADERS -// MethodOptions - -// optional bool deprecated = 33 [default = false]; -bool MethodOptions::has_deprecated() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -void MethodOptions::set_has_deprecated() { - _has_bits_[0] |= 0x00000001u; -} -void MethodOptions::clear_has_deprecated() { - _has_bits_[0] &= ~0x00000001u; -} -void MethodOptions::clear_deprecated() { - deprecated_ = false; - clear_has_deprecated(); -} -bool MethodOptions::deprecated() const { - // @@protoc_insertion_point(field_get:google.protobuf.MethodOptions.deprecated) - return deprecated_; -} -void MethodOptions::set_deprecated(bool value) { - set_has_deprecated(); - deprecated_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.MethodOptions.deprecated) -} - -// optional .google.protobuf.MethodOptions.IdempotencyLevel idempotency_level = 34 [default = IDEMPOTENCY_UNKNOWN]; -bool MethodOptions::has_idempotency_level() const { - return (_has_bits_[0] & 0x00000002u) != 0; -} -void MethodOptions::set_has_idempotency_level() { - _has_bits_[0] |= 0x00000002u; -} -void MethodOptions::clear_has_idempotency_level() { - _has_bits_[0] &= ~0x00000002u; -} -void MethodOptions::clear_idempotency_level() { - idempotency_level_ = 0; - clear_has_idempotency_level(); -} -::google::protobuf::MethodOptions_IdempotencyLevel MethodOptions::idempotency_level() const { - // @@protoc_insertion_point(field_get:google.protobuf.MethodOptions.idempotency_level) - return static_cast< ::google::protobuf::MethodOptions_IdempotencyLevel >(idempotency_level_); -} -void MethodOptions::set_idempotency_level(::google::protobuf::MethodOptions_IdempotencyLevel value) { - assert(::google::protobuf::MethodOptions_IdempotencyLevel_IsValid(value)); - set_has_idempotency_level(); - idempotency_level_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.MethodOptions.idempotency_level) -} - -// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; -int MethodOptions::uninterpreted_option_size() const { - return uninterpreted_option_.size(); -} -void MethodOptions::clear_uninterpreted_option() { - uninterpreted_option_.Clear(); -} -const ::google::protobuf::UninterpretedOption& MethodOptions::uninterpreted_option(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.MethodOptions.uninterpreted_option) - return uninterpreted_option_.Get(index); -} -::google::protobuf::UninterpretedOption* MethodOptions::mutable_uninterpreted_option(int index) { - // @@protoc_insertion_point(field_mutable:google.protobuf.MethodOptions.uninterpreted_option) - return uninterpreted_option_.Mutable(index); -} -::google::protobuf::UninterpretedOption* MethodOptions::add_uninterpreted_option() { - // @@protoc_insertion_point(field_add:google.protobuf.MethodOptions.uninterpreted_option) - return uninterpreted_option_.Add(); -} -::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >* -MethodOptions::mutable_uninterpreted_option() { - // @@protoc_insertion_point(field_mutable_list:google.protobuf.MethodOptions.uninterpreted_option) - return &uninterpreted_option_; -} -const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >& -MethodOptions::uninterpreted_option() const { - // @@protoc_insertion_point(field_list:google.protobuf.MethodOptions.uninterpreted_option) - return uninterpreted_option_; -} - -#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== +void UninterpretedOption_NamePart::InitAsDefaultInstance() { +} #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int UninterpretedOption_NamePart::kNamePartFieldNumber; const int UninterpretedOption_NamePart::kIsExtensionFieldNumber; @@ -13182,11 +11686,19 @@ const int UninterpretedOption_NamePart::kIsExtensionFieldNumber; UninterpretedOption_NamePart::UninterpretedOption_NamePart() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsUninterpretedOption_NamePart(); } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.UninterpretedOption.NamePart) } +UninterpretedOption_NamePart::UninterpretedOption_NamePart(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(), + _internal_metadata_(arena) { + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsUninterpretedOption_NamePart(); + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:google.protobuf.UninterpretedOption.NamePart) +} UninterpretedOption_NamePart::UninterpretedOption_NamePart(const UninterpretedOption_NamePart& from) : ::google::protobuf::Message(), _internal_metadata_(NULL), @@ -13195,7 +11707,8 @@ UninterpretedOption_NamePart::UninterpretedOption_NamePart(const UninterpretedOp _internal_metadata_.MergeFrom(from._internal_metadata_); name_part_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); if (from.has_name_part()) { - name_part_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_part_); + name_part_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_part(), + GetArenaNoVirtual()); } is_extension_ = from.is_extension_; // @@protoc_insertion_point(copy_constructor:google.protobuf.UninterpretedOption.NamePart) @@ -13213,37 +11726,42 @@ UninterpretedOption_NamePart::~UninterpretedOption_NamePart() { } void UninterpretedOption_NamePart::SharedDtor() { + GOOGLE_DCHECK(GetArenaNoVirtual() == NULL); name_part_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } +void UninterpretedOption_NamePart::ArenaDtor(void* object) { + UninterpretedOption_NamePart* _this = reinterpret_cast< UninterpretedOption_NamePart* >(object); + (void)_this; +} +void UninterpretedOption_NamePart::RegisterArenaDtor(::google::protobuf::Arena* arena) { +} void UninterpretedOption_NamePart::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* UninterpretedOption_NamePart::descriptor() { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const UninterpretedOption_NamePart& UninterpretedOption_NamePart::default_instance() { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsUninterpretedOption_NamePart(); return *internal_default_instance(); } -UninterpretedOption_NamePart* UninterpretedOption_NamePart::New(::google::protobuf::Arena* arena) const { - UninterpretedOption_NamePart* n = new UninterpretedOption_NamePart; - if (arena != NULL) { - arena->Own(n); - } - return n; -} void UninterpretedOption_NamePart::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.UninterpretedOption.NamePart) - if (has_name_part()) { + ::google::protobuf::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + cached_has_bits = _has_bits_[0]; + if (cached_has_bits & 0x00000001u) { GOOGLE_DCHECK(!name_part_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); - (*name_part_.UnsafeRawStringPointer())->clear(); + name_part_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } is_extension_ = false; _has_bits_.Clear(); @@ -13263,11 +11781,11 @@ bool UninterpretedOption_NamePart::MergePartialFromCodedStream( // required string name_part = 1; case 1: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(10u)) { + static_cast< ::google::protobuf::uint8>(10u /* 10 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name_part())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->name_part().data(), this->name_part().length(), + this->name_part().data(), static_cast<int>(this->name_part().length()), ::google::protobuf::internal::WireFormat::PARSE, "google.protobuf.UninterpretedOption.NamePart.name_part"); } else { @@ -13279,7 +11797,7 @@ bool UninterpretedOption_NamePart::MergePartialFromCodedStream( // required bool is_extension = 2; case 2: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(16u)) { + static_cast< ::google::protobuf::uint8>(16u /* 16 & 0xFF */)) { set_has_is_extension(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -13292,13 +11810,11 @@ bool UninterpretedOption_NamePart::MergePartialFromCodedStream( default: { handle_unusual: - if (tag == 0 || - ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + if (tag == 0) { goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); + input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } @@ -13322,7 +11838,7 @@ void UninterpretedOption_NamePart::SerializeWithCachedSizes( // required string name_part = 1; if (cached_has_bits & 0x00000001u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->name_part().data(), this->name_part().length(), + this->name_part().data(), static_cast<int>(this->name_part().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.UninterpretedOption.NamePart.name_part"); ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( @@ -13336,13 +11852,14 @@ void UninterpretedOption_NamePart::SerializeWithCachedSizes( if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); + _internal_metadata_.unknown_fields(), output); } // @@protoc_insertion_point(serialize_end:google.protobuf.UninterpretedOption.NamePart) } ::google::protobuf::uint8* UninterpretedOption_NamePart::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.UninterpretedOption.NamePart) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -13351,7 +11868,7 @@ void UninterpretedOption_NamePart::SerializeWithCachedSizes( // required string name_part = 1; if (cached_has_bits & 0x00000001u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->name_part().data(), this->name_part().length(), + this->name_part().data(), static_cast<int>(this->name_part().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.UninterpretedOption.NamePart.name_part"); target = @@ -13366,7 +11883,7 @@ void UninterpretedOption_NamePart::SerializeWithCachedSizes( if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); + _internal_metadata_.unknown_fields(), target); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.UninterpretedOption.NamePart) return target; @@ -13397,7 +11914,7 @@ size_t UninterpretedOption_NamePart::ByteSizeLong() const { if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); + _internal_metadata_.unknown_fields()); } if (((_has_bits_[0] & 0x00000003) ^ 0x00000003) == 0) { // All required fields are present. // required string name_part = 1; @@ -13443,8 +11960,7 @@ void UninterpretedOption_NamePart::MergeFrom(const UninterpretedOption_NamePart& cached_has_bits = from._has_bits_[0]; if (cached_has_bits & 3u) { if (cached_has_bits & 0x00000001u) { - set_has_name_part(); - name_part_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_part_); + set_name_part(from.name_part()); } if (cached_has_bits & 0x00000002u) { is_extension_ = from.is_extension_; @@ -13474,115 +11990,42 @@ bool UninterpretedOption_NamePart::IsInitialized() const { void UninterpretedOption_NamePart::Swap(UninterpretedOption_NamePart* other) { if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + UninterpretedOption_NamePart* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } + } +} +void UninterpretedOption_NamePart::UnsafeArenaSwap(UninterpretedOption_NamePart* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); InternalSwap(other); } void UninterpretedOption_NamePart::InternalSwap(UninterpretedOption_NamePart* other) { + using std::swap; name_part_.Swap(&other->name_part_); - std::swap(is_extension_, other->is_extension_); - std::swap(_has_bits_[0], other->_has_bits_[0]); + swap(is_extension_, other->is_extension_); + swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); - std::swap(_cached_size_, other->_cached_size_); + swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata UninterpretedOption_NamePart::GetMetadata() const { protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages]; -} - -#if PROTOBUF_INLINE_NOT_IN_HEADERS -// UninterpretedOption_NamePart - -// required string name_part = 1; -bool UninterpretedOption_NamePart::has_name_part() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -void UninterpretedOption_NamePart::set_has_name_part() { - _has_bits_[0] |= 0x00000001u; -} -void UninterpretedOption_NamePart::clear_has_name_part() { - _has_bits_[0] &= ~0x00000001u; -} -void UninterpretedOption_NamePart::clear_name_part() { - name_part_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - clear_has_name_part(); -} -const ::std::string& UninterpretedOption_NamePart::name_part() const { - // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.NamePart.name_part) - return name_part_.GetNoArena(); -} -void UninterpretedOption_NamePart::set_name_part(const ::std::string& value) { - set_has_name_part(); - name_part_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.NamePart.name_part) -} -#if LANG_CXX11 -void UninterpretedOption_NamePart::set_name_part(::std::string&& value) { - set_has_name_part(); - name_part_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.UninterpretedOption.NamePart.name_part) -} -#endif -void UninterpretedOption_NamePart::set_name_part(const char* value) { - GOOGLE_DCHECK(value != NULL); - set_has_name_part(); - name_part_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); - // @@protoc_insertion_point(field_set_char:google.protobuf.UninterpretedOption.NamePart.name_part) -} -void UninterpretedOption_NamePart::set_name_part(const char* value, size_t size) { - set_has_name_part(); - name_part_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.UninterpretedOption.NamePart.name_part) -} -::std::string* UninterpretedOption_NamePart::mutable_name_part() { - set_has_name_part(); - // @@protoc_insertion_point(field_mutable:google.protobuf.UninterpretedOption.NamePart.name_part) - return name_part_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -::std::string* UninterpretedOption_NamePart::release_name_part() { - // @@protoc_insertion_point(field_release:google.protobuf.UninterpretedOption.NamePart.name_part) - clear_has_name_part(); - return name_part_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -void UninterpretedOption_NamePart::set_allocated_name_part(::std::string* name_part) { - if (name_part != NULL) { - set_has_name_part(); - } else { - clear_has_name_part(); - } - name_part_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name_part); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.UninterpretedOption.NamePart.name_part) + return ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages]; } -// required bool is_extension = 2; -bool UninterpretedOption_NamePart::has_is_extension() const { - return (_has_bits_[0] & 0x00000002u) != 0; -} -void UninterpretedOption_NamePart::set_has_is_extension() { - _has_bits_[0] |= 0x00000002u; -} -void UninterpretedOption_NamePart::clear_has_is_extension() { - _has_bits_[0] &= ~0x00000002u; -} -void UninterpretedOption_NamePart::clear_is_extension() { - is_extension_ = false; - clear_has_is_extension(); -} -bool UninterpretedOption_NamePart::is_extension() const { - // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.NamePart.is_extension) - return is_extension_; -} -void UninterpretedOption_NamePart::set_is_extension(bool value) { - set_has_is_extension(); - is_extension_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.NamePart.is_extension) -} - -#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== +void UninterpretedOption::InitAsDefaultInstance() { +} #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int UninterpretedOption::kNameFieldNumber; const int UninterpretedOption::kIdentifierValueFieldNumber; @@ -13596,11 +12039,20 @@ const int UninterpretedOption::kAggregateValueFieldNumber; UninterpretedOption::UninterpretedOption() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsUninterpretedOption(); } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.UninterpretedOption) } +UninterpretedOption::UninterpretedOption(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(), + _internal_metadata_(arena), + name_(arena) { + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsUninterpretedOption(); + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:google.protobuf.UninterpretedOption) +} UninterpretedOption::UninterpretedOption(const UninterpretedOption& from) : ::google::protobuf::Message(), _internal_metadata_(NULL), @@ -13610,19 +12062,22 @@ UninterpretedOption::UninterpretedOption(const UninterpretedOption& from) _internal_metadata_.MergeFrom(from._internal_metadata_); identifier_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); if (from.has_identifier_value()) { - identifier_value_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.identifier_value_); + identifier_value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.identifier_value(), + GetArenaNoVirtual()); } string_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); if (from.has_string_value()) { - string_value_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.string_value_); + string_value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.string_value(), + GetArenaNoVirtual()); } aggregate_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); if (from.has_aggregate_value()) { - aggregate_value_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.aggregate_value_); + aggregate_value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.aggregate_value(), + GetArenaNoVirtual()); } ::memcpy(&positive_int_value_, &from.positive_int_value_, - reinterpret_cast<char*>(&double_value_) - - reinterpret_cast<char*>(&positive_int_value_) + sizeof(double_value_)); + static_cast<size_t>(reinterpret_cast<char*>(&double_value_) - + reinterpret_cast<char*>(&positive_int_value_)) + sizeof(double_value_)); // @@protoc_insertion_point(copy_constructor:google.protobuf.UninterpretedOption) } @@ -13631,8 +12086,9 @@ void UninterpretedOption::SharedCtor() { identifier_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); string_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); aggregate_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - ::memset(&positive_int_value_, 0, reinterpret_cast<char*>(&double_value_) - - reinterpret_cast<char*>(&positive_int_value_) + sizeof(double_value_)); + ::memset(&positive_int_value_, 0, static_cast<size_t>( + reinterpret_cast<char*>(&double_value_) - + reinterpret_cast<char*>(&positive_int_value_)) + sizeof(double_value_)); } UninterpretedOption::~UninterpretedOption() { @@ -13641,54 +12097,60 @@ UninterpretedOption::~UninterpretedOption() { } void UninterpretedOption::SharedDtor() { + GOOGLE_DCHECK(GetArenaNoVirtual() == NULL); identifier_value_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); string_value_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); aggregate_value_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } +void UninterpretedOption::ArenaDtor(void* object) { + UninterpretedOption* _this = reinterpret_cast< UninterpretedOption* >(object); + (void)_this; +} +void UninterpretedOption::RegisterArenaDtor(::google::protobuf::Arena* arena) { +} void UninterpretedOption::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* UninterpretedOption::descriptor() { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const UninterpretedOption& UninterpretedOption::default_instance() { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsUninterpretedOption(); return *internal_default_instance(); } -UninterpretedOption* UninterpretedOption::New(::google::protobuf::Arena* arena) const { - UninterpretedOption* n = new UninterpretedOption; - if (arena != NULL) { - arena->Own(n); - } - return n; -} void UninterpretedOption::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.UninterpretedOption) + ::google::protobuf::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + name_.Clear(); - if (_has_bits_[0 / 32] & 7u) { - if (has_identifier_value()) { + cached_has_bits = _has_bits_[0]; + if (cached_has_bits & 7u) { + if (cached_has_bits & 0x00000001u) { GOOGLE_DCHECK(!identifier_value_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); - (*identifier_value_.UnsafeRawStringPointer())->clear(); + identifier_value_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - if (has_string_value()) { + if (cached_has_bits & 0x00000002u) { GOOGLE_DCHECK(!string_value_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); - (*string_value_.UnsafeRawStringPointer())->clear(); + string_value_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - if (has_aggregate_value()) { + if (cached_has_bits & 0x00000004u) { GOOGLE_DCHECK(!aggregate_value_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); - (*aggregate_value_.UnsafeRawStringPointer())->clear(); + aggregate_value_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } } - if (_has_bits_[0 / 32] & 56u) { - ::memset(&positive_int_value_, 0, reinterpret_cast<char*>(&double_value_) - - reinterpret_cast<char*>(&positive_int_value_) + sizeof(double_value_)); + if (cached_has_bits & 56u) { + ::memset(&positive_int_value_, 0, static_cast<size_t>( + reinterpret_cast<char*>(&double_value_) - + reinterpret_cast<char*>(&positive_int_value_)) + sizeof(double_value_)); } _has_bits_.Clear(); _internal_metadata_.Clear(); @@ -13707,8 +12169,8 @@ bool UninterpretedOption::MergePartialFromCodedStream( // repeated .google.protobuf.UninterpretedOption.NamePart name = 2; case 2: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(18u)) { - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + static_cast< ::google::protobuf::uint8>(18u /* 18 & 0xFF */)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, add_name())); } else { goto handle_unusual; @@ -13719,11 +12181,11 @@ bool UninterpretedOption::MergePartialFromCodedStream( // optional string identifier_value = 3; case 3: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(26u)) { + static_cast< ::google::protobuf::uint8>(26u /* 26 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_identifier_value())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->identifier_value().data(), this->identifier_value().length(), + this->identifier_value().data(), static_cast<int>(this->identifier_value().length()), ::google::protobuf::internal::WireFormat::PARSE, "google.protobuf.UninterpretedOption.identifier_value"); } else { @@ -13735,7 +12197,7 @@ bool UninterpretedOption::MergePartialFromCodedStream( // optional uint64 positive_int_value = 4; case 4: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(32u)) { + static_cast< ::google::protobuf::uint8>(32u /* 32 & 0xFF */)) { set_has_positive_int_value(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint64, ::google::protobuf::internal::WireFormatLite::TYPE_UINT64>( @@ -13749,7 +12211,7 @@ bool UninterpretedOption::MergePartialFromCodedStream( // optional int64 negative_int_value = 5; case 5: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(40u)) { + static_cast< ::google::protobuf::uint8>(40u /* 40 & 0xFF */)) { set_has_negative_int_value(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>( @@ -13763,7 +12225,7 @@ bool UninterpretedOption::MergePartialFromCodedStream( // optional double double_value = 6; case 6: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(49u)) { + static_cast< ::google::protobuf::uint8>(49u /* 49 & 0xFF */)) { set_has_double_value(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< double, ::google::protobuf::internal::WireFormatLite::TYPE_DOUBLE>( @@ -13777,7 +12239,7 @@ bool UninterpretedOption::MergePartialFromCodedStream( // optional bytes string_value = 7; case 7: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(58u)) { + static_cast< ::google::protobuf::uint8>(58u /* 58 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadBytes( input, this->mutable_string_value())); } else { @@ -13789,11 +12251,11 @@ bool UninterpretedOption::MergePartialFromCodedStream( // optional string aggregate_value = 8; case 8: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(66u)) { + static_cast< ::google::protobuf::uint8>(66u /* 66 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_aggregate_value())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->aggregate_value().data(), this->aggregate_value().length(), + this->aggregate_value().data(), static_cast<int>(this->aggregate_value().length()), ::google::protobuf::internal::WireFormat::PARSE, "google.protobuf.UninterpretedOption.aggregate_value"); } else { @@ -13804,13 +12266,11 @@ bool UninterpretedOption::MergePartialFromCodedStream( default: { handle_unusual: - if (tag == 0 || - ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + if (tag == 0) { goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); + input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } @@ -13831,16 +12291,19 @@ void UninterpretedOption::SerializeWithCachedSizes( (void) cached_has_bits; // repeated .google.protobuf.UninterpretedOption.NamePart name = 2; - for (unsigned int i = 0, n = this->name_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->name_size()); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 2, this->name(i), output); + 2, + this->name(static_cast<int>(i)), + output); } cached_has_bits = _has_bits_[0]; // optional string identifier_value = 3; if (cached_has_bits & 0x00000001u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->identifier_value().data(), this->identifier_value().length(), + this->identifier_value().data(), static_cast<int>(this->identifier_value().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.UninterpretedOption.identifier_value"); ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( @@ -13871,7 +12334,7 @@ void UninterpretedOption::SerializeWithCachedSizes( // optional string aggregate_value = 8; if (cached_has_bits & 0x00000004u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->aggregate_value().data(), this->aggregate_value().length(), + this->aggregate_value().data(), static_cast<int>(this->aggregate_value().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.UninterpretedOption.aggregate_value"); ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( @@ -13880,29 +12343,31 @@ void UninterpretedOption::SerializeWithCachedSizes( if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); + _internal_metadata_.unknown_fields(), output); } // @@protoc_insertion_point(serialize_end:google.protobuf.UninterpretedOption) } ::google::protobuf::uint8* UninterpretedOption::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.UninterpretedOption) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; // repeated .google.protobuf.UninterpretedOption.NamePart name = 2; - for (unsigned int i = 0, n = this->name_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->name_size()); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: - InternalWriteMessageNoVirtualToArray( - 2, this->name(i), deterministic, target); + InternalWriteMessageToArray( + 2, this->name(static_cast<int>(i)), deterministic, target); } cached_has_bits = _has_bits_[0]; // optional string identifier_value = 3; if (cached_has_bits & 0x00000001u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->identifier_value().data(), this->identifier_value().length(), + this->identifier_value().data(), static_cast<int>(this->identifier_value().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.UninterpretedOption.identifier_value"); target = @@ -13935,7 +12400,7 @@ void UninterpretedOption::SerializeWithCachedSizes( // optional string aggregate_value = 8; if (cached_has_bits & 0x00000004u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->aggregate_value().data(), this->aggregate_value().length(), + this->aggregate_value().data(), static_cast<int>(this->aggregate_value().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.UninterpretedOption.aggregate_value"); target = @@ -13945,7 +12410,7 @@ void UninterpretedOption::SerializeWithCachedSizes( if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); + _internal_metadata_.unknown_fields(), target); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.UninterpretedOption) return target; @@ -13958,16 +12423,16 @@ size_t UninterpretedOption::ByteSizeLong() const { if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); + _internal_metadata_.unknown_fields()); } // repeated .google.protobuf.UninterpretedOption.NamePart name = 2; { - unsigned int count = this->name_size(); + unsigned int count = static_cast<unsigned int>(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)); + ::google::protobuf::internal::WireFormatLite::MessageSize( + this->name(static_cast<int>(i))); } } @@ -14046,16 +12511,13 @@ void UninterpretedOption::MergeFrom(const UninterpretedOption& from) { cached_has_bits = from._has_bits_[0]; if (cached_has_bits & 63u) { if (cached_has_bits & 0x00000001u) { - set_has_identifier_value(); - identifier_value_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.identifier_value_); + set_identifier_value(from.identifier_value()); } if (cached_has_bits & 0x00000002u) { - set_has_string_value(); - string_value_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.string_value_); + set_string_value(from.string_value()); } if (cached_has_bits & 0x00000004u) { - set_has_aggregate_value(); - aggregate_value_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.aggregate_value_); + set_aggregate_value(from.aggregate_value()); } if (cached_has_bits & 0x00000008u) { positive_int_value_ = from.positive_int_value_; @@ -14091,324 +12553,47 @@ bool UninterpretedOption::IsInitialized() const { void UninterpretedOption::Swap(UninterpretedOption* other) { if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + UninterpretedOption* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } + } +} +void UninterpretedOption::UnsafeArenaSwap(UninterpretedOption* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); InternalSwap(other); } void UninterpretedOption::InternalSwap(UninterpretedOption* other) { - name_.InternalSwap(&other->name_); + using std::swap; + CastToBase(&name_)->InternalSwap(CastToBase(&other->name_)); identifier_value_.Swap(&other->identifier_value_); string_value_.Swap(&other->string_value_); aggregate_value_.Swap(&other->aggregate_value_); - std::swap(positive_int_value_, other->positive_int_value_); - std::swap(negative_int_value_, other->negative_int_value_); - std::swap(double_value_, other->double_value_); - std::swap(_has_bits_[0], other->_has_bits_[0]); + swap(positive_int_value_, other->positive_int_value_); + swap(negative_int_value_, other->negative_int_value_); + swap(double_value_, other->double_value_); + swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); - std::swap(_cached_size_, other->_cached_size_); + swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata UninterpretedOption::GetMetadata() const { protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages]; -} - -#if PROTOBUF_INLINE_NOT_IN_HEADERS -// UninterpretedOption - -// repeated .google.protobuf.UninterpretedOption.NamePart name = 2; -int UninterpretedOption::name_size() const { - return name_.size(); -} -void UninterpretedOption::clear_name() { - name_.Clear(); -} -const ::google::protobuf::UninterpretedOption_NamePart& UninterpretedOption::name(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.name) - return name_.Get(index); -} -::google::protobuf::UninterpretedOption_NamePart* UninterpretedOption::mutable_name(int index) { - // @@protoc_insertion_point(field_mutable:google.protobuf.UninterpretedOption.name) - return name_.Mutable(index); -} -::google::protobuf::UninterpretedOption_NamePart* UninterpretedOption::add_name() { - // @@protoc_insertion_point(field_add:google.protobuf.UninterpretedOption.name) - return name_.Add(); -} -::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption_NamePart >* -UninterpretedOption::mutable_name() { - // @@protoc_insertion_point(field_mutable_list:google.protobuf.UninterpretedOption.name) - return &name_; -} -const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption_NamePart >& -UninterpretedOption::name() const { - // @@protoc_insertion_point(field_list:google.protobuf.UninterpretedOption.name) - return name_; + return ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages]; } -// optional string identifier_value = 3; -bool UninterpretedOption::has_identifier_value() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -void UninterpretedOption::set_has_identifier_value() { - _has_bits_[0] |= 0x00000001u; -} -void UninterpretedOption::clear_has_identifier_value() { - _has_bits_[0] &= ~0x00000001u; -} -void UninterpretedOption::clear_identifier_value() { - identifier_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - clear_has_identifier_value(); -} -const ::std::string& UninterpretedOption::identifier_value() const { - // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.identifier_value) - return identifier_value_.GetNoArena(); -} -void UninterpretedOption::set_identifier_value(const ::std::string& value) { - set_has_identifier_value(); - identifier_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.identifier_value) -} -#if LANG_CXX11 -void UninterpretedOption::set_identifier_value(::std::string&& value) { - set_has_identifier_value(); - identifier_value_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.UninterpretedOption.identifier_value) -} -#endif -void UninterpretedOption::set_identifier_value(const char* value) { - GOOGLE_DCHECK(value != NULL); - 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) { - set_has_identifier_value(); - identifier_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.UninterpretedOption.identifier_value) -} -::std::string* UninterpretedOption::mutable_identifier_value() { - 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() { - // @@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) { - if (identifier_value != NULL) { - set_has_identifier_value(); - } else { - clear_has_identifier_value(); - } - identifier_value_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), identifier_value); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.UninterpretedOption.identifier_value) -} - -// optional uint64 positive_int_value = 4; -bool UninterpretedOption::has_positive_int_value() const { - return (_has_bits_[0] & 0x00000008u) != 0; -} -void UninterpretedOption::set_has_positive_int_value() { - _has_bits_[0] |= 0x00000008u; -} -void UninterpretedOption::clear_has_positive_int_value() { - _has_bits_[0] &= ~0x00000008u; -} -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 { - // @@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) { - set_has_positive_int_value(); - positive_int_value_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.positive_int_value) -} - -// optional int64 negative_int_value = 5; -bool UninterpretedOption::has_negative_int_value() const { - return (_has_bits_[0] & 0x00000010u) != 0; -} -void UninterpretedOption::set_has_negative_int_value() { - _has_bits_[0] |= 0x00000010u; -} -void UninterpretedOption::clear_has_negative_int_value() { - _has_bits_[0] &= ~0x00000010u; -} -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 { - // @@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) { - set_has_negative_int_value(); - negative_int_value_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.negative_int_value) -} - -// optional double double_value = 6; -bool UninterpretedOption::has_double_value() const { - return (_has_bits_[0] & 0x00000020u) != 0; -} -void UninterpretedOption::set_has_double_value() { - _has_bits_[0] |= 0x00000020u; -} -void UninterpretedOption::clear_has_double_value() { - _has_bits_[0] &= ~0x00000020u; -} -void UninterpretedOption::clear_double_value() { - double_value_ = 0; - clear_has_double_value(); -} -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) { - set_has_double_value(); - double_value_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.double_value) -} - -// optional bytes string_value = 7; -bool UninterpretedOption::has_string_value() const { - return (_has_bits_[0] & 0x00000002u) != 0; -} -void UninterpretedOption::set_has_string_value() { - _has_bits_[0] |= 0x00000002u; -} -void UninterpretedOption::clear_has_string_value() { - _has_bits_[0] &= ~0x00000002u; -} -void UninterpretedOption::clear_string_value() { - string_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - clear_has_string_value(); -} -const ::std::string& UninterpretedOption::string_value() const { - // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.string_value) - return string_value_.GetNoArena(); -} -void UninterpretedOption::set_string_value(const ::std::string& value) { - set_has_string_value(); - string_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.string_value) -} -#if LANG_CXX11 -void UninterpretedOption::set_string_value(::std::string&& value) { - set_has_string_value(); - string_value_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.UninterpretedOption.string_value) -} -#endif -void UninterpretedOption::set_string_value(const char* value) { - GOOGLE_DCHECK(value != NULL); - 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) { - set_has_string_value(); - string_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.UninterpretedOption.string_value) -} -::std::string* UninterpretedOption::mutable_string_value() { - 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() { - // @@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) { - if (string_value != NULL) { - set_has_string_value(); - } else { - clear_has_string_value(); - } - string_value_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), string_value); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.UninterpretedOption.string_value) -} - -// optional string aggregate_value = 8; -bool UninterpretedOption::has_aggregate_value() const { - return (_has_bits_[0] & 0x00000004u) != 0; -} -void UninterpretedOption::set_has_aggregate_value() { - _has_bits_[0] |= 0x00000004u; -} -void UninterpretedOption::clear_has_aggregate_value() { - _has_bits_[0] &= ~0x00000004u; -} -void UninterpretedOption::clear_aggregate_value() { - aggregate_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - clear_has_aggregate_value(); -} -const ::std::string& UninterpretedOption::aggregate_value() const { - // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.aggregate_value) - return aggregate_value_.GetNoArena(); -} -void UninterpretedOption::set_aggregate_value(const ::std::string& value) { - set_has_aggregate_value(); - aggregate_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.aggregate_value) -} -#if LANG_CXX11 -void UninterpretedOption::set_aggregate_value(::std::string&& value) { - set_has_aggregate_value(); - aggregate_value_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.UninterpretedOption.aggregate_value) -} -#endif -void UninterpretedOption::set_aggregate_value(const char* value) { - GOOGLE_DCHECK(value != NULL); - 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) { - set_has_aggregate_value(); - aggregate_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.UninterpretedOption.aggregate_value) -} -::std::string* UninterpretedOption::mutable_aggregate_value() { - 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() { - // @@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) { - if (aggregate_value != NULL) { - set_has_aggregate_value(); - } else { - clear_has_aggregate_value(); - } - aggregate_value_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), aggregate_value); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.UninterpretedOption.aggregate_value) -} - -#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== +void SourceCodeInfo_Location::InitAsDefaultInstance() { +} #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int SourceCodeInfo_Location::kPathFieldNumber; const int SourceCodeInfo_Location::kSpanFieldNumber; @@ -14420,11 +12605,22 @@ const int SourceCodeInfo_Location::kLeadingDetachedCommentsFieldNumber; SourceCodeInfo_Location::SourceCodeInfo_Location() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsSourceCodeInfo_Location(); } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.SourceCodeInfo.Location) } +SourceCodeInfo_Location::SourceCodeInfo_Location(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(), + _internal_metadata_(arena), + path_(arena), + span_(arena), + leading_detached_comments_(arena) { + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsSourceCodeInfo_Location(); + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:google.protobuf.SourceCodeInfo.Location) +} SourceCodeInfo_Location::SourceCodeInfo_Location(const SourceCodeInfo_Location& from) : ::google::protobuf::Message(), _internal_metadata_(NULL), @@ -14436,11 +12632,13 @@ SourceCodeInfo_Location::SourceCodeInfo_Location(const SourceCodeInfo_Location& _internal_metadata_.MergeFrom(from._internal_metadata_); leading_comments_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); if (from.has_leading_comments()) { - leading_comments_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.leading_comments_); + leading_comments_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.leading_comments(), + GetArenaNoVirtual()); } trailing_comments_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); if (from.has_trailing_comments()) { - trailing_comments_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.trailing_comments_); + trailing_comments_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.trailing_comments(), + GetArenaNoVirtual()); } // @@protoc_insertion_point(copy_constructor:google.protobuf.SourceCodeInfo.Location) } @@ -14457,46 +12655,51 @@ SourceCodeInfo_Location::~SourceCodeInfo_Location() { } void SourceCodeInfo_Location::SharedDtor() { + GOOGLE_DCHECK(GetArenaNoVirtual() == NULL); leading_comments_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); trailing_comments_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } +void SourceCodeInfo_Location::ArenaDtor(void* object) { + SourceCodeInfo_Location* _this = reinterpret_cast< SourceCodeInfo_Location* >(object); + (void)_this; +} +void SourceCodeInfo_Location::RegisterArenaDtor(::google::protobuf::Arena* arena) { +} void SourceCodeInfo_Location::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* SourceCodeInfo_Location::descriptor() { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const SourceCodeInfo_Location& SourceCodeInfo_Location::default_instance() { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsSourceCodeInfo_Location(); return *internal_default_instance(); } -SourceCodeInfo_Location* SourceCodeInfo_Location::New(::google::protobuf::Arena* arena) const { - SourceCodeInfo_Location* n = new SourceCodeInfo_Location; - if (arena != NULL) { - arena->Own(n); - } - return n; -} void SourceCodeInfo_Location::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.SourceCodeInfo.Location) + ::google::protobuf::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + path_.Clear(); span_.Clear(); leading_detached_comments_.Clear(); - if (_has_bits_[0 / 32] & 3u) { - if (has_leading_comments()) { + cached_has_bits = _has_bits_[0]; + if (cached_has_bits & 3u) { + if (cached_has_bits & 0x00000001u) { GOOGLE_DCHECK(!leading_comments_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); - (*leading_comments_.UnsafeRawStringPointer())->clear(); + leading_comments_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - if (has_trailing_comments()) { + if (cached_has_bits & 0x00000002u) { GOOGLE_DCHECK(!trailing_comments_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); - (*trailing_comments_.UnsafeRawStringPointer())->clear(); + trailing_comments_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } } _has_bits_.Clear(); @@ -14516,12 +12719,13 @@ bool SourceCodeInfo_Location::MergePartialFromCodedStream( // repeated int32 path = 1 [packed = true]; case 1: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(10u)) { + static_cast< ::google::protobuf::uint8>(10u /* 10 & 0xFF */)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, this->mutable_path()))); - } else if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(8u)) { + } else if ( + static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(8u /* 8 & 0xFF */)) { DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitiveNoInline< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( 1, 10u, input, this->mutable_path()))); @@ -14534,12 +12738,13 @@ bool SourceCodeInfo_Location::MergePartialFromCodedStream( // repeated int32 span = 2 [packed = true]; case 2: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(18u)) { + static_cast< ::google::protobuf::uint8>(18u /* 18 & 0xFF */)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, this->mutable_span()))); - } else if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(16u)) { + } else if ( + static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(16u /* 16 & 0xFF */)) { DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitiveNoInline< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( 1, 18u, input, this->mutable_span()))); @@ -14552,11 +12757,11 @@ bool SourceCodeInfo_Location::MergePartialFromCodedStream( // optional string leading_comments = 3; case 3: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(26u)) { + static_cast< ::google::protobuf::uint8>(26u /* 26 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_leading_comments())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->leading_comments().data(), this->leading_comments().length(), + this->leading_comments().data(), static_cast<int>(this->leading_comments().length()), ::google::protobuf::internal::WireFormat::PARSE, "google.protobuf.SourceCodeInfo.Location.leading_comments"); } else { @@ -14568,11 +12773,11 @@ bool SourceCodeInfo_Location::MergePartialFromCodedStream( // optional string trailing_comments = 4; case 4: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(34u)) { + static_cast< ::google::protobuf::uint8>(34u /* 34 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_trailing_comments())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->trailing_comments().data(), this->trailing_comments().length(), + this->trailing_comments().data(), static_cast<int>(this->trailing_comments().length()), ::google::protobuf::internal::WireFormat::PARSE, "google.protobuf.SourceCodeInfo.Location.trailing_comments"); } else { @@ -14584,12 +12789,12 @@ bool SourceCodeInfo_Location::MergePartialFromCodedStream( // repeated string leading_detached_comments = 6; case 6: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(50u)) { + static_cast< ::google::protobuf::uint8>(50u /* 50 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->add_leading_detached_comments())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->leading_detached_comments(this->leading_detached_comments_size() - 1).data(), - this->leading_detached_comments(this->leading_detached_comments_size() - 1).length(), + static_cast<int>(this->leading_detached_comments(this->leading_detached_comments_size() - 1).length()), ::google::protobuf::internal::WireFormat::PARSE, "google.protobuf.SourceCodeInfo.Location.leading_detached_comments"); } else { @@ -14600,13 +12805,11 @@ bool SourceCodeInfo_Location::MergePartialFromCodedStream( default: { handle_unusual: - if (tag == 0 || - ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + if (tag == 0) { goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); + input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } @@ -14629,7 +12832,8 @@ void SourceCodeInfo_Location::SerializeWithCachedSizes( // repeated int32 path = 1 [packed = true]; if (this->path_size() > 0) { ::google::protobuf::internal::WireFormatLite::WriteTag(1, ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED, output); - output->WriteVarint32(_path_cached_byte_size_); + output->WriteVarint32(static_cast< ::google::protobuf::uint32>( + _path_cached_byte_size_)); } for (int i = 0, n = this->path_size(); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteInt32NoTag( @@ -14639,7 +12843,8 @@ void SourceCodeInfo_Location::SerializeWithCachedSizes( // repeated int32 span = 2 [packed = true]; if (this->span_size() > 0) { ::google::protobuf::internal::WireFormatLite::WriteTag(2, ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED, output); - output->WriteVarint32(_span_cached_byte_size_); + output->WriteVarint32(static_cast< ::google::protobuf::uint32>( + _span_cached_byte_size_)); } for (int i = 0, n = this->span_size(); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteInt32NoTag( @@ -14650,7 +12855,7 @@ void SourceCodeInfo_Location::SerializeWithCachedSizes( // optional string leading_comments = 3; if (cached_has_bits & 0x00000001u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->leading_comments().data(), this->leading_comments().length(), + this->leading_comments().data(), static_cast<int>(this->leading_comments().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.SourceCodeInfo.Location.leading_comments"); ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( @@ -14660,7 +12865,7 @@ void SourceCodeInfo_Location::SerializeWithCachedSizes( // optional string trailing_comments = 4; if (cached_has_bits & 0x00000002u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->trailing_comments().data(), this->trailing_comments().length(), + this->trailing_comments().data(), static_cast<int>(this->trailing_comments().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.SourceCodeInfo.Location.trailing_comments"); ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( @@ -14670,7 +12875,7 @@ void SourceCodeInfo_Location::SerializeWithCachedSizes( // repeated string leading_detached_comments = 6; for (int i = 0, n = this->leading_detached_comments_size(); i < n; i++) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->leading_detached_comments(i).data(), this->leading_detached_comments(i).length(), + this->leading_detached_comments(i).data(), static_cast<int>(this->leading_detached_comments(i).length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.SourceCodeInfo.Location.leading_detached_comments"); ::google::protobuf::internal::WireFormatLite::WriteString( @@ -14679,13 +12884,14 @@ void SourceCodeInfo_Location::SerializeWithCachedSizes( if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); + _internal_metadata_.unknown_fields(), output); } // @@protoc_insertion_point(serialize_end:google.protobuf.SourceCodeInfo.Location) } ::google::protobuf::uint8* SourceCodeInfo_Location::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.SourceCodeInfo.Location) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -14697,7 +12903,8 @@ void SourceCodeInfo_Location::SerializeWithCachedSizes( ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED, target); target = ::google::protobuf::io::CodedOutputStream::WriteVarint32ToArray( - _path_cached_byte_size_, target); + static_cast< ::google::protobuf::int32>( + _path_cached_byte_size_), target); target = ::google::protobuf::internal::WireFormatLite:: WriteInt32NoTagToArray(this->path_, target); } @@ -14709,7 +12916,8 @@ void SourceCodeInfo_Location::SerializeWithCachedSizes( ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED, target); target = ::google::protobuf::io::CodedOutputStream::WriteVarint32ToArray( - _span_cached_byte_size_, target); + static_cast< ::google::protobuf::int32>( + _span_cached_byte_size_), target); target = ::google::protobuf::internal::WireFormatLite:: WriteInt32NoTagToArray(this->span_, target); } @@ -14718,7 +12926,7 @@ void SourceCodeInfo_Location::SerializeWithCachedSizes( // optional string leading_comments = 3; if (cached_has_bits & 0x00000001u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->leading_comments().data(), this->leading_comments().length(), + this->leading_comments().data(), static_cast<int>(this->leading_comments().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.SourceCodeInfo.Location.leading_comments"); target = @@ -14729,7 +12937,7 @@ void SourceCodeInfo_Location::SerializeWithCachedSizes( // optional string trailing_comments = 4; if (cached_has_bits & 0x00000002u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->trailing_comments().data(), this->trailing_comments().length(), + this->trailing_comments().data(), static_cast<int>(this->trailing_comments().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.SourceCodeInfo.Location.trailing_comments"); target = @@ -14740,7 +12948,7 @@ void SourceCodeInfo_Location::SerializeWithCachedSizes( // repeated string leading_detached_comments = 6; for (int i = 0, n = this->leading_detached_comments_size(); i < n; i++) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->leading_detached_comments(i).data(), this->leading_detached_comments(i).length(), + this->leading_detached_comments(i).data(), static_cast<int>(this->leading_detached_comments(i).length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.SourceCodeInfo.Location.leading_detached_comments"); target = ::google::protobuf::internal::WireFormatLite:: @@ -14749,7 +12957,7 @@ void SourceCodeInfo_Location::SerializeWithCachedSizes( if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); + _internal_metadata_.unknown_fields(), target); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.SourceCodeInfo.Location) return target; @@ -14762,7 +12970,7 @@ size_t SourceCodeInfo_Location::ByteSizeLong() const { if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); + _internal_metadata_.unknown_fields()); } // repeated int32 path = 1 [packed = true]; { @@ -14770,7 +12978,8 @@ size_t SourceCodeInfo_Location::ByteSizeLong() const { Int32Size(this->path_); if (data_size > 0) { total_size += 1 + - ::google::protobuf::internal::WireFormatLite::Int32Size(data_size); + ::google::protobuf::internal::WireFormatLite::Int32Size( + static_cast< ::google::protobuf::int32>(data_size)); } int cached_size = ::google::protobuf::internal::ToCachedSize(data_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); @@ -14785,7 +12994,8 @@ size_t SourceCodeInfo_Location::ByteSizeLong() const { Int32Size(this->span_); if (data_size > 0) { total_size += 1 + - ::google::protobuf::internal::WireFormatLite::Int32Size(data_size); + ::google::protobuf::internal::WireFormatLite::Int32Size( + static_cast< ::google::protobuf::int32>(data_size)); } int cached_size = ::google::protobuf::internal::ToCachedSize(data_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); @@ -14853,12 +13063,10 @@ void SourceCodeInfo_Location::MergeFrom(const SourceCodeInfo_Location& from) { cached_has_bits = from._has_bits_[0]; if (cached_has_bits & 3u) { if (cached_has_bits & 0x00000001u) { - set_has_leading_comments(); - leading_comments_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.leading_comments_); + set_leading_comments(from.leading_comments()); } if (cached_has_bits & 0x00000002u) { - set_has_trailing_comments(); - trailing_comments_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.trailing_comments_); + set_trailing_comments(from.trailing_comments()); } } } @@ -14883,286 +13091,45 @@ bool SourceCodeInfo_Location::IsInitialized() const { void SourceCodeInfo_Location::Swap(SourceCodeInfo_Location* other) { if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + SourceCodeInfo_Location* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } + } +} +void SourceCodeInfo_Location::UnsafeArenaSwap(SourceCodeInfo_Location* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); InternalSwap(other); } void SourceCodeInfo_Location::InternalSwap(SourceCodeInfo_Location* other) { + using std::swap; path_.InternalSwap(&other->path_); span_.InternalSwap(&other->span_); - leading_detached_comments_.InternalSwap(&other->leading_detached_comments_); + leading_detached_comments_.InternalSwap(CastToBase(&other->leading_detached_comments_)); leading_comments_.Swap(&other->leading_comments_); trailing_comments_.Swap(&other->trailing_comments_); - std::swap(_has_bits_[0], other->_has_bits_[0]); + swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); - std::swap(_cached_size_, other->_cached_size_); + swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata SourceCodeInfo_Location::GetMetadata() const { protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages]; -} - -#if PROTOBUF_INLINE_NOT_IN_HEADERS -// SourceCodeInfo_Location - -// repeated int32 path = 1 [packed = true]; -int SourceCodeInfo_Location::path_size() const { - return path_.size(); -} -void SourceCodeInfo_Location::clear_path() { - path_.Clear(); -} -::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) { - path_.Set(index, value); - // @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.path) -} -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 >& -SourceCodeInfo_Location::path() const { - // @@protoc_insertion_point(field_list:google.protobuf.SourceCodeInfo.Location.path) - return path_; -} -::google::protobuf::RepeatedField< ::google::protobuf::int32 >* -SourceCodeInfo_Location::mutable_path() { - // @@protoc_insertion_point(field_mutable_list:google.protobuf.SourceCodeInfo.Location.path) - return &path_; -} - -// repeated int32 span = 2 [packed = true]; -int SourceCodeInfo_Location::span_size() const { - return span_.size(); -} -void SourceCodeInfo_Location::clear_span() { - span_.Clear(); -} -::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) { - span_.Set(index, value); - // @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.span) -} -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 >& -SourceCodeInfo_Location::span() const { - // @@protoc_insertion_point(field_list:google.protobuf.SourceCodeInfo.Location.span) - return span_; -} -::google::protobuf::RepeatedField< ::google::protobuf::int32 >* -SourceCodeInfo_Location::mutable_span() { - // @@protoc_insertion_point(field_mutable_list:google.protobuf.SourceCodeInfo.Location.span) - return &span_; -} - -// optional string leading_comments = 3; -bool SourceCodeInfo_Location::has_leading_comments() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -void SourceCodeInfo_Location::set_has_leading_comments() { - _has_bits_[0] |= 0x00000001u; -} -void SourceCodeInfo_Location::clear_has_leading_comments() { - _has_bits_[0] &= ~0x00000001u; -} -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 { - // @@protoc_insertion_point(field_get:google.protobuf.SourceCodeInfo.Location.leading_comments) - return leading_comments_.GetNoArena(); -} -void SourceCodeInfo_Location::set_leading_comments(const ::std::string& value) { - set_has_leading_comments(); - leading_comments_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.leading_comments) -} -#if LANG_CXX11 -void SourceCodeInfo_Location::set_leading_comments(::std::string&& value) { - set_has_leading_comments(); - leading_comments_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.SourceCodeInfo.Location.leading_comments) -} -#endif -void SourceCodeInfo_Location::set_leading_comments(const char* value) { - GOOGLE_DCHECK(value != NULL); - 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) { - set_has_leading_comments(); - leading_comments_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.SourceCodeInfo.Location.leading_comments) -} -::std::string* SourceCodeInfo_Location::mutable_leading_comments() { - 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() { - // @@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) { - if (leading_comments != NULL) { - set_has_leading_comments(); - } else { - clear_has_leading_comments(); - } - leading_comments_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), leading_comments); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.SourceCodeInfo.Location.leading_comments) + return ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages]; } -// optional string trailing_comments = 4; -bool SourceCodeInfo_Location::has_trailing_comments() const { - return (_has_bits_[0] & 0x00000002u) != 0; -} -void SourceCodeInfo_Location::set_has_trailing_comments() { - _has_bits_[0] |= 0x00000002u; -} -void SourceCodeInfo_Location::clear_has_trailing_comments() { - _has_bits_[0] &= ~0x00000002u; -} -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 { - // @@protoc_insertion_point(field_get:google.protobuf.SourceCodeInfo.Location.trailing_comments) - return trailing_comments_.GetNoArena(); -} -void SourceCodeInfo_Location::set_trailing_comments(const ::std::string& value) { - set_has_trailing_comments(); - trailing_comments_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.trailing_comments) -} -#if LANG_CXX11 -void SourceCodeInfo_Location::set_trailing_comments(::std::string&& value) { - set_has_trailing_comments(); - trailing_comments_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.SourceCodeInfo.Location.trailing_comments) -} -#endif -void SourceCodeInfo_Location::set_trailing_comments(const char* value) { - GOOGLE_DCHECK(value != NULL); - 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) { - set_has_trailing_comments(); - trailing_comments_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.SourceCodeInfo.Location.trailing_comments) -} -::std::string* SourceCodeInfo_Location::mutable_trailing_comments() { - 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() { - // @@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) { - if (trailing_comments != NULL) { - set_has_trailing_comments(); - } else { - clear_has_trailing_comments(); - } - trailing_comments_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), trailing_comments); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.SourceCodeInfo.Location.trailing_comments) -} - -// repeated string leading_detached_comments = 6; -int SourceCodeInfo_Location::leading_detached_comments_size() const { - return leading_detached_comments_.size(); -} -void SourceCodeInfo_Location::clear_leading_detached_comments() { - leading_detached_comments_.Clear(); -} -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) { - // @@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) { - // @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) - leading_detached_comments_.Mutable(index)->assign(value); -} -#if LANG_CXX11 -void SourceCodeInfo_Location::set_leading_detached_comments(int index, ::std::string&& value) { - // @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) - leading_detached_comments_.Mutable(index)->assign(std::move(value)); -} -#endif -void SourceCodeInfo_Location::set_leading_detached_comments(int index, const char* value) { - GOOGLE_DCHECK(value != NULL); - 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) { - leading_detached_comments_.Mutable(index)->assign( - reinterpret_cast<const char*>(value), size); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) -} -::std::string* SourceCodeInfo_Location::add_leading_detached_comments() { - // @@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) { - leading_detached_comments_.Add()->assign(value); - // @@protoc_insertion_point(field_add:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) -} -#if LANG_CXX11 -void SourceCodeInfo_Location::add_leading_detached_comments(::std::string&& value) { - leading_detached_comments_.Add(std::move(value)); - // @@protoc_insertion_point(field_add:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) -} -#endif -void SourceCodeInfo_Location::add_leading_detached_comments(const char* value) { - GOOGLE_DCHECK(value != NULL); - 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) { - leading_detached_comments_.Add()->assign(reinterpret_cast<const char*>(value), size); - // @@protoc_insertion_point(field_add_pointer:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) -} -const ::google::protobuf::RepeatedPtrField< ::std::string>& -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>* -SourceCodeInfo_Location::mutable_leading_detached_comments() { - // @@protoc_insertion_point(field_mutable_list:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) - return &leading_detached_comments_; -} - -#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== +void SourceCodeInfo::InitAsDefaultInstance() { +} #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int SourceCodeInfo::kLocationFieldNumber; #endif // !defined(_MSC_VER) || _MSC_VER >= 1900 @@ -15170,11 +13137,20 @@ const int SourceCodeInfo::kLocationFieldNumber; SourceCodeInfo::SourceCodeInfo() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsSourceCodeInfo(); } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.SourceCodeInfo) } +SourceCodeInfo::SourceCodeInfo(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(), + _internal_metadata_(arena), + location_(arena) { + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsSourceCodeInfo(); + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:google.protobuf.SourceCodeInfo) +} SourceCodeInfo::SourceCodeInfo(const SourceCodeInfo& from) : ::google::protobuf::Message(), _internal_metadata_(NULL), @@ -15195,33 +13171,37 @@ SourceCodeInfo::~SourceCodeInfo() { } void SourceCodeInfo::SharedDtor() { + GOOGLE_DCHECK(GetArenaNoVirtual() == NULL); } +void SourceCodeInfo::ArenaDtor(void* object) { + SourceCodeInfo* _this = reinterpret_cast< SourceCodeInfo* >(object); + (void)_this; +} +void SourceCodeInfo::RegisterArenaDtor(::google::protobuf::Arena* arena) { +} void SourceCodeInfo::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* SourceCodeInfo::descriptor() { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const SourceCodeInfo& SourceCodeInfo::default_instance() { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsSourceCodeInfo(); return *internal_default_instance(); } -SourceCodeInfo* SourceCodeInfo::New(::google::protobuf::Arena* arena) const { - SourceCodeInfo* n = new SourceCodeInfo; - if (arena != NULL) { - arena->Own(n); - } - return n; -} void SourceCodeInfo::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.SourceCodeInfo) + ::google::protobuf::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + location_.Clear(); _has_bits_.Clear(); _internal_metadata_.Clear(); @@ -15240,8 +13220,8 @@ bool SourceCodeInfo::MergePartialFromCodedStream( // repeated .google.protobuf.SourceCodeInfo.Location location = 1; case 1: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(10u)) { - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + static_cast< ::google::protobuf::uint8>(10u /* 10 & 0xFF */)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, add_location())); } else { goto handle_unusual; @@ -15251,13 +13231,11 @@ bool SourceCodeInfo::MergePartialFromCodedStream( default: { handle_unusual: - if (tag == 0 || - ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + if (tag == 0) { goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); + input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } @@ -15278,34 +13256,39 @@ void SourceCodeInfo::SerializeWithCachedSizes( (void) cached_has_bits; // repeated .google.protobuf.SourceCodeInfo.Location location = 1; - for (unsigned int i = 0, n = this->location_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->location_size()); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 1, this->location(i), output); + 1, + this->location(static_cast<int>(i)), + output); } if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); + _internal_metadata_.unknown_fields(), output); } // @@protoc_insertion_point(serialize_end:google.protobuf.SourceCodeInfo) } ::google::protobuf::uint8* SourceCodeInfo::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.SourceCodeInfo) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; // repeated .google.protobuf.SourceCodeInfo.Location location = 1; - for (unsigned int i = 0, n = this->location_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->location_size()); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: - InternalWriteMessageNoVirtualToArray( - 1, this->location(i), deterministic, target); + InternalWriteMessageToArray( + 1, this->location(static_cast<int>(i)), deterministic, target); } if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); + _internal_metadata_.unknown_fields(), target); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.SourceCodeInfo) return target; @@ -15318,16 +13301,16 @@ size_t SourceCodeInfo::ByteSizeLong() const { if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); + _internal_metadata_.unknown_fields()); } // repeated .google.protobuf.SourceCodeInfo.Location location = 1; { - unsigned int count = this->location_size(); + unsigned int count = static_cast<unsigned int>(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)); + ::google::protobuf::internal::WireFormatLite::MessageSize( + this->location(static_cast<int>(i))); } } @@ -15383,57 +13366,41 @@ bool SourceCodeInfo::IsInitialized() const { void SourceCodeInfo::Swap(SourceCodeInfo* other) { if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + SourceCodeInfo* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } + } +} +void SourceCodeInfo::UnsafeArenaSwap(SourceCodeInfo* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); InternalSwap(other); } void SourceCodeInfo::InternalSwap(SourceCodeInfo* other) { - location_.InternalSwap(&other->location_); - std::swap(_has_bits_[0], other->_has_bits_[0]); + using std::swap; + CastToBase(&location_)->InternalSwap(CastToBase(&other->location_)); + swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); - std::swap(_cached_size_, other->_cached_size_); + swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata SourceCodeInfo::GetMetadata() const { protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages]; + return ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages]; } -#if PROTOBUF_INLINE_NOT_IN_HEADERS -// SourceCodeInfo - -// repeated .google.protobuf.SourceCodeInfo.Location location = 1; -int SourceCodeInfo::location_size() const { - return location_.size(); -} -void SourceCodeInfo::clear_location() { - location_.Clear(); -} -const ::google::protobuf::SourceCodeInfo_Location& SourceCodeInfo::location(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.SourceCodeInfo.location) - return location_.Get(index); -} -::google::protobuf::SourceCodeInfo_Location* SourceCodeInfo::mutable_location(int index) { - // @@protoc_insertion_point(field_mutable:google.protobuf.SourceCodeInfo.location) - return location_.Mutable(index); -} -::google::protobuf::SourceCodeInfo_Location* SourceCodeInfo::add_location() { - // @@protoc_insertion_point(field_add:google.protobuf.SourceCodeInfo.location) - return location_.Add(); -} -::google::protobuf::RepeatedPtrField< ::google::protobuf::SourceCodeInfo_Location >* -SourceCodeInfo::mutable_location() { - // @@protoc_insertion_point(field_mutable_list:google.protobuf.SourceCodeInfo.location) - return &location_; -} -const ::google::protobuf::RepeatedPtrField< ::google::protobuf::SourceCodeInfo_Location >& -SourceCodeInfo::location() const { - // @@protoc_insertion_point(field_list:google.protobuf.SourceCodeInfo.location) - return location_; -} - -#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== +void GeneratedCodeInfo_Annotation::InitAsDefaultInstance() { +} #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int GeneratedCodeInfo_Annotation::kPathFieldNumber; const int GeneratedCodeInfo_Annotation::kSourceFileFieldNumber; @@ -15444,11 +13411,20 @@ const int GeneratedCodeInfo_Annotation::kEndFieldNumber; GeneratedCodeInfo_Annotation::GeneratedCodeInfo_Annotation() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsGeneratedCodeInfo_Annotation(); } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.GeneratedCodeInfo.Annotation) } +GeneratedCodeInfo_Annotation::GeneratedCodeInfo_Annotation(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(), + _internal_metadata_(arena), + path_(arena) { + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsGeneratedCodeInfo_Annotation(); + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:google.protobuf.GeneratedCodeInfo.Annotation) +} GeneratedCodeInfo_Annotation::GeneratedCodeInfo_Annotation(const GeneratedCodeInfo_Annotation& from) : ::google::protobuf::Message(), _internal_metadata_(NULL), @@ -15458,19 +13434,21 @@ GeneratedCodeInfo_Annotation::GeneratedCodeInfo_Annotation(const GeneratedCodeIn _internal_metadata_.MergeFrom(from._internal_metadata_); source_file_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); if (from.has_source_file()) { - source_file_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.source_file_); + source_file_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.source_file(), + GetArenaNoVirtual()); } ::memcpy(&begin_, &from.begin_, - reinterpret_cast<char*>(&end_) - - reinterpret_cast<char*>(&begin_) + sizeof(end_)); + static_cast<size_t>(reinterpret_cast<char*>(&end_) - + reinterpret_cast<char*>(&begin_)) + sizeof(end_)); // @@protoc_insertion_point(copy_constructor:google.protobuf.GeneratedCodeInfo.Annotation) } void GeneratedCodeInfo_Annotation::SharedCtor() { _cached_size_ = 0; source_file_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - ::memset(&begin_, 0, reinterpret_cast<char*>(&end_) - - reinterpret_cast<char*>(&begin_) + sizeof(end_)); + ::memset(&begin_, 0, static_cast<size_t>( + reinterpret_cast<char*>(&end_) - + reinterpret_cast<char*>(&begin_)) + sizeof(end_)); } GeneratedCodeInfo_Annotation::~GeneratedCodeInfo_Annotation() { @@ -15479,42 +13457,48 @@ GeneratedCodeInfo_Annotation::~GeneratedCodeInfo_Annotation() { } void GeneratedCodeInfo_Annotation::SharedDtor() { + GOOGLE_DCHECK(GetArenaNoVirtual() == NULL); source_file_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } +void GeneratedCodeInfo_Annotation::ArenaDtor(void* object) { + GeneratedCodeInfo_Annotation* _this = reinterpret_cast< GeneratedCodeInfo_Annotation* >(object); + (void)_this; +} +void GeneratedCodeInfo_Annotation::RegisterArenaDtor(::google::protobuf::Arena* arena) { +} void GeneratedCodeInfo_Annotation::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* GeneratedCodeInfo_Annotation::descriptor() { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const GeneratedCodeInfo_Annotation& GeneratedCodeInfo_Annotation::default_instance() { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsGeneratedCodeInfo_Annotation(); return *internal_default_instance(); } -GeneratedCodeInfo_Annotation* GeneratedCodeInfo_Annotation::New(::google::protobuf::Arena* arena) const { - GeneratedCodeInfo_Annotation* n = new GeneratedCodeInfo_Annotation; - if (arena != NULL) { - arena->Own(n); - } - return n; -} void GeneratedCodeInfo_Annotation::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.GeneratedCodeInfo.Annotation) + ::google::protobuf::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + path_.Clear(); - if (has_source_file()) { + cached_has_bits = _has_bits_[0]; + if (cached_has_bits & 0x00000001u) { GOOGLE_DCHECK(!source_file_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); - (*source_file_.UnsafeRawStringPointer())->clear(); + source_file_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - if (_has_bits_[0 / 32] & 6u) { - ::memset(&begin_, 0, reinterpret_cast<char*>(&end_) - - reinterpret_cast<char*>(&begin_) + sizeof(end_)); + if (cached_has_bits & 6u) { + ::memset(&begin_, 0, static_cast<size_t>( + reinterpret_cast<char*>(&end_) - + reinterpret_cast<char*>(&begin_)) + sizeof(end_)); } _has_bits_.Clear(); _internal_metadata_.Clear(); @@ -15533,12 +13517,13 @@ bool GeneratedCodeInfo_Annotation::MergePartialFromCodedStream( // repeated int32 path = 1 [packed = true]; case 1: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(10u)) { + static_cast< ::google::protobuf::uint8>(10u /* 10 & 0xFF */)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, this->mutable_path()))); - } else if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(8u)) { + } else if ( + static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(8u /* 8 & 0xFF */)) { DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitiveNoInline< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( 1, 10u, input, this->mutable_path()))); @@ -15551,11 +13536,11 @@ bool GeneratedCodeInfo_Annotation::MergePartialFromCodedStream( // optional string source_file = 2; case 2: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(18u)) { + static_cast< ::google::protobuf::uint8>(18u /* 18 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_source_file())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->source_file().data(), this->source_file().length(), + this->source_file().data(), static_cast<int>(this->source_file().length()), ::google::protobuf::internal::WireFormat::PARSE, "google.protobuf.GeneratedCodeInfo.Annotation.source_file"); } else { @@ -15567,7 +13552,7 @@ bool GeneratedCodeInfo_Annotation::MergePartialFromCodedStream( // optional int32 begin = 3; case 3: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(24u)) { + static_cast< ::google::protobuf::uint8>(24u /* 24 & 0xFF */)) { set_has_begin(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -15581,7 +13566,7 @@ bool GeneratedCodeInfo_Annotation::MergePartialFromCodedStream( // optional int32 end = 4; case 4: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(32u)) { + static_cast< ::google::protobuf::uint8>(32u /* 32 & 0xFF */)) { set_has_end(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -15594,13 +13579,11 @@ bool GeneratedCodeInfo_Annotation::MergePartialFromCodedStream( default: { handle_unusual: - if (tag == 0 || - ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + if (tag == 0) { goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); + input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } @@ -15623,7 +13606,8 @@ void GeneratedCodeInfo_Annotation::SerializeWithCachedSizes( // repeated int32 path = 1 [packed = true]; if (this->path_size() > 0) { ::google::protobuf::internal::WireFormatLite::WriteTag(1, ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED, output); - output->WriteVarint32(_path_cached_byte_size_); + output->WriteVarint32(static_cast< ::google::protobuf::uint32>( + _path_cached_byte_size_)); } for (int i = 0, n = this->path_size(); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteInt32NoTag( @@ -15634,7 +13618,7 @@ void GeneratedCodeInfo_Annotation::SerializeWithCachedSizes( // optional string source_file = 2; if (cached_has_bits & 0x00000001u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->source_file().data(), this->source_file().length(), + this->source_file().data(), static_cast<int>(this->source_file().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.GeneratedCodeInfo.Annotation.source_file"); ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( @@ -15653,13 +13637,14 @@ void GeneratedCodeInfo_Annotation::SerializeWithCachedSizes( if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); + _internal_metadata_.unknown_fields(), output); } // @@protoc_insertion_point(serialize_end:google.protobuf.GeneratedCodeInfo.Annotation) } ::google::protobuf::uint8* GeneratedCodeInfo_Annotation::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.GeneratedCodeInfo.Annotation) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -15671,7 +13656,8 @@ void GeneratedCodeInfo_Annotation::SerializeWithCachedSizes( ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED, target); target = ::google::protobuf::io::CodedOutputStream::WriteVarint32ToArray( - _path_cached_byte_size_, target); + static_cast< ::google::protobuf::int32>( + _path_cached_byte_size_), target); target = ::google::protobuf::internal::WireFormatLite:: WriteInt32NoTagToArray(this->path_, target); } @@ -15680,7 +13666,7 @@ void GeneratedCodeInfo_Annotation::SerializeWithCachedSizes( // optional string source_file = 2; if (cached_has_bits & 0x00000001u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->source_file().data(), this->source_file().length(), + this->source_file().data(), static_cast<int>(this->source_file().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.GeneratedCodeInfo.Annotation.source_file"); target = @@ -15700,7 +13686,7 @@ void GeneratedCodeInfo_Annotation::SerializeWithCachedSizes( if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); + _internal_metadata_.unknown_fields(), target); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.GeneratedCodeInfo.Annotation) return target; @@ -15713,7 +13699,7 @@ size_t GeneratedCodeInfo_Annotation::ByteSizeLong() const { if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); + _internal_metadata_.unknown_fields()); } // repeated int32 path = 1 [packed = true]; { @@ -15721,7 +13707,8 @@ size_t GeneratedCodeInfo_Annotation::ByteSizeLong() const { Int32Size(this->path_); if (data_size > 0) { total_size += 1 + - ::google::protobuf::internal::WireFormatLite::Int32Size(data_size); + ::google::protobuf::internal::WireFormatLite::Int32Size( + static_cast< ::google::protobuf::int32>(data_size)); } int cached_size = ::google::protobuf::internal::ToCachedSize(data_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); @@ -15786,8 +13773,7 @@ void GeneratedCodeInfo_Annotation::MergeFrom(const GeneratedCodeInfo_Annotation& cached_has_bits = from._has_bits_[0]; if (cached_has_bits & 7u) { if (cached_has_bits & 0x00000001u) { - set_has_source_file(); - source_file_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.source_file_); + set_source_file(from.source_file()); } if (cached_has_bits & 0x00000002u) { begin_ = from.begin_; @@ -15819,171 +13805,44 @@ bool GeneratedCodeInfo_Annotation::IsInitialized() const { void GeneratedCodeInfo_Annotation::Swap(GeneratedCodeInfo_Annotation* other) { if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + GeneratedCodeInfo_Annotation* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } + } +} +void GeneratedCodeInfo_Annotation::UnsafeArenaSwap(GeneratedCodeInfo_Annotation* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); InternalSwap(other); } void GeneratedCodeInfo_Annotation::InternalSwap(GeneratedCodeInfo_Annotation* other) { + using std::swap; path_.InternalSwap(&other->path_); source_file_.Swap(&other->source_file_); - std::swap(begin_, other->begin_); - std::swap(end_, other->end_); - std::swap(_has_bits_[0], other->_has_bits_[0]); + swap(begin_, other->begin_); + swap(end_, other->end_); + swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); - std::swap(_cached_size_, other->_cached_size_); + swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata GeneratedCodeInfo_Annotation::GetMetadata() const { protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages]; + return ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages]; } -#if PROTOBUF_INLINE_NOT_IN_HEADERS -// GeneratedCodeInfo_Annotation - -// repeated int32 path = 1 [packed = true]; -int GeneratedCodeInfo_Annotation::path_size() const { - return path_.size(); -} -void GeneratedCodeInfo_Annotation::clear_path() { - path_.Clear(); -} -::google::protobuf::int32 GeneratedCodeInfo_Annotation::path(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.GeneratedCodeInfo.Annotation.path) - return path_.Get(index); -} -void GeneratedCodeInfo_Annotation::set_path(int index, ::google::protobuf::int32 value) { - path_.Set(index, value); - // @@protoc_insertion_point(field_set:google.protobuf.GeneratedCodeInfo.Annotation.path) -} -void GeneratedCodeInfo_Annotation::add_path(::google::protobuf::int32 value) { - path_.Add(value); - // @@protoc_insertion_point(field_add:google.protobuf.GeneratedCodeInfo.Annotation.path) -} -const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >& -GeneratedCodeInfo_Annotation::path() const { - // @@protoc_insertion_point(field_list:google.protobuf.GeneratedCodeInfo.Annotation.path) - return path_; -} -::google::protobuf::RepeatedField< ::google::protobuf::int32 >* -GeneratedCodeInfo_Annotation::mutable_path() { - // @@protoc_insertion_point(field_mutable_list:google.protobuf.GeneratedCodeInfo.Annotation.path) - return &path_; -} - -// optional string source_file = 2; -bool GeneratedCodeInfo_Annotation::has_source_file() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -void GeneratedCodeInfo_Annotation::set_has_source_file() { - _has_bits_[0] |= 0x00000001u; -} -void GeneratedCodeInfo_Annotation::clear_has_source_file() { - _has_bits_[0] &= ~0x00000001u; -} -void GeneratedCodeInfo_Annotation::clear_source_file() { - source_file_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - clear_has_source_file(); -} -const ::std::string& GeneratedCodeInfo_Annotation::source_file() const { - // @@protoc_insertion_point(field_get:google.protobuf.GeneratedCodeInfo.Annotation.source_file) - return source_file_.GetNoArena(); -} -void GeneratedCodeInfo_Annotation::set_source_file(const ::std::string& value) { - set_has_source_file(); - source_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.GeneratedCodeInfo.Annotation.source_file) -} -#if LANG_CXX11 -void GeneratedCodeInfo_Annotation::set_source_file(::std::string&& value) { - set_has_source_file(); - source_file_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.GeneratedCodeInfo.Annotation.source_file) -} -#endif -void GeneratedCodeInfo_Annotation::set_source_file(const char* value) { - GOOGLE_DCHECK(value != NULL); - set_has_source_file(); - source_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); - // @@protoc_insertion_point(field_set_char:google.protobuf.GeneratedCodeInfo.Annotation.source_file) -} -void GeneratedCodeInfo_Annotation::set_source_file(const char* value, size_t size) { - set_has_source_file(); - source_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.GeneratedCodeInfo.Annotation.source_file) -} -::std::string* GeneratedCodeInfo_Annotation::mutable_source_file() { - set_has_source_file(); - // @@protoc_insertion_point(field_mutable:google.protobuf.GeneratedCodeInfo.Annotation.source_file) - return source_file_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -::std::string* GeneratedCodeInfo_Annotation::release_source_file() { - // @@protoc_insertion_point(field_release:google.protobuf.GeneratedCodeInfo.Annotation.source_file) - clear_has_source_file(); - return source_file_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -void GeneratedCodeInfo_Annotation::set_allocated_source_file(::std::string* source_file) { - if (source_file != NULL) { - set_has_source_file(); - } else { - clear_has_source_file(); - } - source_file_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), source_file); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.GeneratedCodeInfo.Annotation.source_file) -} - -// optional int32 begin = 3; -bool GeneratedCodeInfo_Annotation::has_begin() const { - return (_has_bits_[0] & 0x00000002u) != 0; -} -void GeneratedCodeInfo_Annotation::set_has_begin() { - _has_bits_[0] |= 0x00000002u; -} -void GeneratedCodeInfo_Annotation::clear_has_begin() { - _has_bits_[0] &= ~0x00000002u; -} -void GeneratedCodeInfo_Annotation::clear_begin() { - begin_ = 0; - clear_has_begin(); -} -::google::protobuf::int32 GeneratedCodeInfo_Annotation::begin() const { - // @@protoc_insertion_point(field_get:google.protobuf.GeneratedCodeInfo.Annotation.begin) - return begin_; -} -void GeneratedCodeInfo_Annotation::set_begin(::google::protobuf::int32 value) { - set_has_begin(); - begin_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.GeneratedCodeInfo.Annotation.begin) -} - -// optional int32 end = 4; -bool GeneratedCodeInfo_Annotation::has_end() const { - return (_has_bits_[0] & 0x00000004u) != 0; -} -void GeneratedCodeInfo_Annotation::set_has_end() { - _has_bits_[0] |= 0x00000004u; -} -void GeneratedCodeInfo_Annotation::clear_has_end() { - _has_bits_[0] &= ~0x00000004u; -} -void GeneratedCodeInfo_Annotation::clear_end() { - end_ = 0; - clear_has_end(); -} -::google::protobuf::int32 GeneratedCodeInfo_Annotation::end() const { - // @@protoc_insertion_point(field_get:google.protobuf.GeneratedCodeInfo.Annotation.end) - return end_; -} -void GeneratedCodeInfo_Annotation::set_end(::google::protobuf::int32 value) { - set_has_end(); - end_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.GeneratedCodeInfo.Annotation.end) -} - -#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== +void GeneratedCodeInfo::InitAsDefaultInstance() { +} #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int GeneratedCodeInfo::kAnnotationFieldNumber; #endif // !defined(_MSC_VER) || _MSC_VER >= 1900 @@ -15991,11 +13850,20 @@ const int GeneratedCodeInfo::kAnnotationFieldNumber; GeneratedCodeInfo::GeneratedCodeInfo() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsGeneratedCodeInfo(); } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.GeneratedCodeInfo) } +GeneratedCodeInfo::GeneratedCodeInfo(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(), + _internal_metadata_(arena), + annotation_(arena) { + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsGeneratedCodeInfo(); + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:google.protobuf.GeneratedCodeInfo) +} GeneratedCodeInfo::GeneratedCodeInfo(const GeneratedCodeInfo& from) : ::google::protobuf::Message(), _internal_metadata_(NULL), @@ -16016,33 +13884,37 @@ GeneratedCodeInfo::~GeneratedCodeInfo() { } void GeneratedCodeInfo::SharedDtor() { + GOOGLE_DCHECK(GetArenaNoVirtual() == NULL); } +void GeneratedCodeInfo::ArenaDtor(void* object) { + GeneratedCodeInfo* _this = reinterpret_cast< GeneratedCodeInfo* >(object); + (void)_this; +} +void GeneratedCodeInfo::RegisterArenaDtor(::google::protobuf::Arena* arena) { +} void GeneratedCodeInfo::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* GeneratedCodeInfo::descriptor() { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const GeneratedCodeInfo& GeneratedCodeInfo::default_instance() { - protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsGeneratedCodeInfo(); return *internal_default_instance(); } -GeneratedCodeInfo* GeneratedCodeInfo::New(::google::protobuf::Arena* arena) const { - GeneratedCodeInfo* n = new GeneratedCodeInfo; - if (arena != NULL) { - arena->Own(n); - } - return n; -} void GeneratedCodeInfo::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.GeneratedCodeInfo) + ::google::protobuf::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + annotation_.Clear(); _has_bits_.Clear(); _internal_metadata_.Clear(); @@ -16061,8 +13933,8 @@ bool GeneratedCodeInfo::MergePartialFromCodedStream( // repeated .google.protobuf.GeneratedCodeInfo.Annotation annotation = 1; case 1: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(10u)) { - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + static_cast< ::google::protobuf::uint8>(10u /* 10 & 0xFF */)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, add_annotation())); } else { goto handle_unusual; @@ -16072,13 +13944,11 @@ bool GeneratedCodeInfo::MergePartialFromCodedStream( default: { handle_unusual: - if (tag == 0 || - ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + if (tag == 0) { goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); + input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } @@ -16099,34 +13969,39 @@ void GeneratedCodeInfo::SerializeWithCachedSizes( (void) cached_has_bits; // repeated .google.protobuf.GeneratedCodeInfo.Annotation annotation = 1; - for (unsigned int i = 0, n = this->annotation_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->annotation_size()); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 1, this->annotation(i), output); + 1, + this->annotation(static_cast<int>(i)), + output); } if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); + _internal_metadata_.unknown_fields(), output); } // @@protoc_insertion_point(serialize_end:google.protobuf.GeneratedCodeInfo) } ::google::protobuf::uint8* GeneratedCodeInfo::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.GeneratedCodeInfo) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; // repeated .google.protobuf.GeneratedCodeInfo.Annotation annotation = 1; - for (unsigned int i = 0, n = this->annotation_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->annotation_size()); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: - InternalWriteMessageNoVirtualToArray( - 1, this->annotation(i), deterministic, target); + InternalWriteMessageToArray( + 1, this->annotation(static_cast<int>(i)), deterministic, target); } if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); + _internal_metadata_.unknown_fields(), target); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.GeneratedCodeInfo) return target; @@ -16139,16 +14014,16 @@ size_t GeneratedCodeInfo::ByteSizeLong() const { if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); + _internal_metadata_.unknown_fields()); } // repeated .google.protobuf.GeneratedCodeInfo.Annotation annotation = 1; { - unsigned int count = this->annotation_size(); + unsigned int count = static_cast<unsigned int>(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)); + ::google::protobuf::internal::WireFormatLite::MessageSize( + this->annotation(static_cast<int>(i))); } } @@ -16204,57 +14079,123 @@ bool GeneratedCodeInfo::IsInitialized() const { void GeneratedCodeInfo::Swap(GeneratedCodeInfo* other) { if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + GeneratedCodeInfo* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } + } +} +void GeneratedCodeInfo::UnsafeArenaSwap(GeneratedCodeInfo* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); InternalSwap(other); } void GeneratedCodeInfo::InternalSwap(GeneratedCodeInfo* other) { - annotation_.InternalSwap(&other->annotation_); - std::swap(_has_bits_[0], other->_has_bits_[0]); + using std::swap; + CastToBase(&annotation_)->InternalSwap(CastToBase(&other->annotation_)); + swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); - std::swap(_cached_size_, other->_cached_size_); + swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata GeneratedCodeInfo::GetMetadata() const { protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages]; + return ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages]; } -#if PROTOBUF_INLINE_NOT_IN_HEADERS -// GeneratedCodeInfo -// repeated .google.protobuf.GeneratedCodeInfo.Annotation annotation = 1; -int GeneratedCodeInfo::annotation_size() const { - return annotation_.size(); +// @@protoc_insertion_point(namespace_scope) +} // namespace protobuf +} // namespace google +namespace google { +namespace protobuf { +template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::FileDescriptorSet* Arena::CreateMessage< ::google::protobuf::FileDescriptorSet >(Arena* arena) { + return Arena::CreateMessageInternal< ::google::protobuf::FileDescriptorSet >(arena); } -void GeneratedCodeInfo::clear_annotation() { - annotation_.Clear(); +template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::FileDescriptorProto* Arena::CreateMessage< ::google::protobuf::FileDescriptorProto >(Arena* arena) { + return Arena::CreateMessageInternal< ::google::protobuf::FileDescriptorProto >(arena); } -const ::google::protobuf::GeneratedCodeInfo_Annotation& GeneratedCodeInfo::annotation(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.GeneratedCodeInfo.annotation) - return annotation_.Get(index); +template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::DescriptorProto_ExtensionRange* Arena::CreateMessage< ::google::protobuf::DescriptorProto_ExtensionRange >(Arena* arena) { + return Arena::CreateMessageInternal< ::google::protobuf::DescriptorProto_ExtensionRange >(arena); } -::google::protobuf::GeneratedCodeInfo_Annotation* GeneratedCodeInfo::mutable_annotation(int index) { - // @@protoc_insertion_point(field_mutable:google.protobuf.GeneratedCodeInfo.annotation) - return annotation_.Mutable(index); +template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::DescriptorProto_ReservedRange* Arena::CreateMessage< ::google::protobuf::DescriptorProto_ReservedRange >(Arena* arena) { + return Arena::CreateMessageInternal< ::google::protobuf::DescriptorProto_ReservedRange >(arena); } -::google::protobuf::GeneratedCodeInfo_Annotation* GeneratedCodeInfo::add_annotation() { - // @@protoc_insertion_point(field_add:google.protobuf.GeneratedCodeInfo.annotation) - return annotation_.Add(); +template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::DescriptorProto* Arena::CreateMessage< ::google::protobuf::DescriptorProto >(Arena* arena) { + return Arena::CreateMessageInternal< ::google::protobuf::DescriptorProto >(arena); } -::google::protobuf::RepeatedPtrField< ::google::protobuf::GeneratedCodeInfo_Annotation >* -GeneratedCodeInfo::mutable_annotation() { - // @@protoc_insertion_point(field_mutable_list:google.protobuf.GeneratedCodeInfo.annotation) - return &annotation_; +template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::ExtensionRangeOptions* Arena::CreateMessage< ::google::protobuf::ExtensionRangeOptions >(Arena* arena) { + return Arena::CreateMessageInternal< ::google::protobuf::ExtensionRangeOptions >(arena); } -const ::google::protobuf::RepeatedPtrField< ::google::protobuf::GeneratedCodeInfo_Annotation >& -GeneratedCodeInfo::annotation() const { - // @@protoc_insertion_point(field_list:google.protobuf.GeneratedCodeInfo.annotation) - return annotation_; +template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::FieldDescriptorProto* Arena::CreateMessage< ::google::protobuf::FieldDescriptorProto >(Arena* arena) { + return Arena::CreateMessageInternal< ::google::protobuf::FieldDescriptorProto >(arena); +} +template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::OneofDescriptorProto* Arena::CreateMessage< ::google::protobuf::OneofDescriptorProto >(Arena* arena) { + return Arena::CreateMessageInternal< ::google::protobuf::OneofDescriptorProto >(arena); +} +template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::EnumDescriptorProto_EnumReservedRange* Arena::CreateMessage< ::google::protobuf::EnumDescriptorProto_EnumReservedRange >(Arena* arena) { + return Arena::CreateMessageInternal< ::google::protobuf::EnumDescriptorProto_EnumReservedRange >(arena); +} +template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::EnumDescriptorProto* Arena::CreateMessage< ::google::protobuf::EnumDescriptorProto >(Arena* arena) { + return Arena::CreateMessageInternal< ::google::protobuf::EnumDescriptorProto >(arena); +} +template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::EnumValueDescriptorProto* Arena::CreateMessage< ::google::protobuf::EnumValueDescriptorProto >(Arena* arena) { + return Arena::CreateMessageInternal< ::google::protobuf::EnumValueDescriptorProto >(arena); +} +template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::ServiceDescriptorProto* Arena::CreateMessage< ::google::protobuf::ServiceDescriptorProto >(Arena* arena) { + return Arena::CreateMessageInternal< ::google::protobuf::ServiceDescriptorProto >(arena); +} +template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::MethodDescriptorProto* Arena::CreateMessage< ::google::protobuf::MethodDescriptorProto >(Arena* arena) { + return Arena::CreateMessageInternal< ::google::protobuf::MethodDescriptorProto >(arena); +} +template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::FileOptions* Arena::CreateMessage< ::google::protobuf::FileOptions >(Arena* arena) { + return Arena::CreateMessageInternal< ::google::protobuf::FileOptions >(arena); +} +template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::MessageOptions* Arena::CreateMessage< ::google::protobuf::MessageOptions >(Arena* arena) { + return Arena::CreateMessageInternal< ::google::protobuf::MessageOptions >(arena); +} +template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::FieldOptions* Arena::CreateMessage< ::google::protobuf::FieldOptions >(Arena* arena) { + return Arena::CreateMessageInternal< ::google::protobuf::FieldOptions >(arena); +} +template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::OneofOptions* Arena::CreateMessage< ::google::protobuf::OneofOptions >(Arena* arena) { + return Arena::CreateMessageInternal< ::google::protobuf::OneofOptions >(arena); +} +template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::EnumOptions* Arena::CreateMessage< ::google::protobuf::EnumOptions >(Arena* arena) { + return Arena::CreateMessageInternal< ::google::protobuf::EnumOptions >(arena); +} +template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::EnumValueOptions* Arena::CreateMessage< ::google::protobuf::EnumValueOptions >(Arena* arena) { + return Arena::CreateMessageInternal< ::google::protobuf::EnumValueOptions >(arena); +} +template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::ServiceOptions* Arena::CreateMessage< ::google::protobuf::ServiceOptions >(Arena* arena) { + return Arena::CreateMessageInternal< ::google::protobuf::ServiceOptions >(arena); +} +template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::MethodOptions* Arena::CreateMessage< ::google::protobuf::MethodOptions >(Arena* arena) { + return Arena::CreateMessageInternal< ::google::protobuf::MethodOptions >(arena); +} +template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::UninterpretedOption_NamePart* Arena::CreateMessage< ::google::protobuf::UninterpretedOption_NamePart >(Arena* arena) { + return Arena::CreateMessageInternal< ::google::protobuf::UninterpretedOption_NamePart >(arena); +} +template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::UninterpretedOption* Arena::CreateMessage< ::google::protobuf::UninterpretedOption >(Arena* arena) { + return Arena::CreateMessageInternal< ::google::protobuf::UninterpretedOption >(arena); +} +template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::SourceCodeInfo_Location* Arena::CreateMessage< ::google::protobuf::SourceCodeInfo_Location >(Arena* arena) { + return Arena::CreateMessageInternal< ::google::protobuf::SourceCodeInfo_Location >(arena); +} +template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::SourceCodeInfo* Arena::CreateMessage< ::google::protobuf::SourceCodeInfo >(Arena* arena) { + return Arena::CreateMessageInternal< ::google::protobuf::SourceCodeInfo >(arena); +} +template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::GeneratedCodeInfo_Annotation* Arena::CreateMessage< ::google::protobuf::GeneratedCodeInfo_Annotation >(Arena* arena) { + return Arena::CreateMessageInternal< ::google::protobuf::GeneratedCodeInfo_Annotation >(arena); +} +template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::GeneratedCodeInfo* Arena::CreateMessage< ::google::protobuf::GeneratedCodeInfo >(Arena* arena) { + return Arena::CreateMessageInternal< ::google::protobuf::GeneratedCodeInfo >(arena); } - -#endif // PROTOBUF_INLINE_NOT_IN_HEADERS - -// @@protoc_insertion_point(namespace_scope) - } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/descriptor.pb.h b/src/google/protobuf/descriptor.pb.h index f64a339c..4ec0a5b4 100644 --- a/src/google/protobuf/descriptor.pb.h +++ b/src/google/protobuf/descriptor.pb.h @@ -1,19 +1,19 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/protobuf/descriptor.proto -#ifndef PROTOBUF_google_2fprotobuf_2fdescriptor_2eproto__INCLUDED -#define PROTOBUF_google_2fprotobuf_2fdescriptor_2eproto__INCLUDED +#ifndef PROTOBUF_google_2fprotobuf_2fdescriptor_2eproto_INCLUDED +#define PROTOBUF_google_2fprotobuf_2fdescriptor_2eproto_INCLUDED #include <string> #include <google/protobuf/stubs/common.h> -#if GOOGLE_PROTOBUF_VERSION < 3003000 +#if GOOGLE_PROTOBUF_VERSION < 3005000 #error This file was generated by a newer version of protoc which is #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3003000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION +#if 3005001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. @@ -31,6 +31,102 @@ #include <google/protobuf/generated_enum_reflection.h> #include <google/protobuf/unknown_field_set.h> // @@protoc_insertion_point(includes) + +namespace protobuf_google_2fprotobuf_2fdescriptor_2eproto { +// Internal implementation detail -- do not use these members. +struct LIBPROTOBUF_EXPORT TableStruct { + static const ::google::protobuf::internal::ParseTableField entries[]; + static const ::google::protobuf::internal::AuxillaryParseTableField aux[]; + static const ::google::protobuf::internal::ParseTable schema[27]; + static const ::google::protobuf::internal::FieldMetadata field_metadata[]; + static const ::google::protobuf::internal::SerializationTable serialization_table[]; + static const ::google::protobuf::uint32 offsets[]; +}; +void LIBPROTOBUF_EXPORT AddDescriptors(); +void LIBPROTOBUF_EXPORT InitDefaultsFileDescriptorSetImpl(); +void LIBPROTOBUF_EXPORT InitDefaultsFileDescriptorSet(); +void LIBPROTOBUF_EXPORT InitDefaultsFileDescriptorProtoImpl(); +void LIBPROTOBUF_EXPORT InitDefaultsFileDescriptorProto(); +void LIBPROTOBUF_EXPORT InitDefaultsDescriptorProto_ExtensionRangeImpl(); +void LIBPROTOBUF_EXPORT InitDefaultsDescriptorProto_ExtensionRange(); +void LIBPROTOBUF_EXPORT InitDefaultsDescriptorProto_ReservedRangeImpl(); +void LIBPROTOBUF_EXPORT InitDefaultsDescriptorProto_ReservedRange(); +void LIBPROTOBUF_EXPORT InitDefaultsDescriptorProtoImpl(); +void LIBPROTOBUF_EXPORT InitDefaultsDescriptorProto(); +void LIBPROTOBUF_EXPORT InitDefaultsExtensionRangeOptionsImpl(); +void LIBPROTOBUF_EXPORT InitDefaultsExtensionRangeOptions(); +void LIBPROTOBUF_EXPORT InitDefaultsFieldDescriptorProtoImpl(); +void LIBPROTOBUF_EXPORT InitDefaultsFieldDescriptorProto(); +void LIBPROTOBUF_EXPORT InitDefaultsOneofDescriptorProtoImpl(); +void LIBPROTOBUF_EXPORT InitDefaultsOneofDescriptorProto(); +void LIBPROTOBUF_EXPORT InitDefaultsEnumDescriptorProto_EnumReservedRangeImpl(); +void LIBPROTOBUF_EXPORT InitDefaultsEnumDescriptorProto_EnumReservedRange(); +void LIBPROTOBUF_EXPORT InitDefaultsEnumDescriptorProtoImpl(); +void LIBPROTOBUF_EXPORT InitDefaultsEnumDescriptorProto(); +void LIBPROTOBUF_EXPORT InitDefaultsEnumValueDescriptorProtoImpl(); +void LIBPROTOBUF_EXPORT InitDefaultsEnumValueDescriptorProto(); +void LIBPROTOBUF_EXPORT InitDefaultsServiceDescriptorProtoImpl(); +void LIBPROTOBUF_EXPORT InitDefaultsServiceDescriptorProto(); +void LIBPROTOBUF_EXPORT InitDefaultsMethodDescriptorProtoImpl(); +void LIBPROTOBUF_EXPORT InitDefaultsMethodDescriptorProto(); +void LIBPROTOBUF_EXPORT InitDefaultsFileOptionsImpl(); +void LIBPROTOBUF_EXPORT InitDefaultsFileOptions(); +void LIBPROTOBUF_EXPORT InitDefaultsMessageOptionsImpl(); +void LIBPROTOBUF_EXPORT InitDefaultsMessageOptions(); +void LIBPROTOBUF_EXPORT InitDefaultsFieldOptionsImpl(); +void LIBPROTOBUF_EXPORT InitDefaultsFieldOptions(); +void LIBPROTOBUF_EXPORT InitDefaultsOneofOptionsImpl(); +void LIBPROTOBUF_EXPORT InitDefaultsOneofOptions(); +void LIBPROTOBUF_EXPORT InitDefaultsEnumOptionsImpl(); +void LIBPROTOBUF_EXPORT InitDefaultsEnumOptions(); +void LIBPROTOBUF_EXPORT InitDefaultsEnumValueOptionsImpl(); +void LIBPROTOBUF_EXPORT InitDefaultsEnumValueOptions(); +void LIBPROTOBUF_EXPORT InitDefaultsServiceOptionsImpl(); +void LIBPROTOBUF_EXPORT InitDefaultsServiceOptions(); +void LIBPROTOBUF_EXPORT InitDefaultsMethodOptionsImpl(); +void LIBPROTOBUF_EXPORT InitDefaultsMethodOptions(); +void LIBPROTOBUF_EXPORT InitDefaultsUninterpretedOption_NamePartImpl(); +void LIBPROTOBUF_EXPORT InitDefaultsUninterpretedOption_NamePart(); +void LIBPROTOBUF_EXPORT InitDefaultsUninterpretedOptionImpl(); +void LIBPROTOBUF_EXPORT InitDefaultsUninterpretedOption(); +void LIBPROTOBUF_EXPORT InitDefaultsSourceCodeInfo_LocationImpl(); +void LIBPROTOBUF_EXPORT InitDefaultsSourceCodeInfo_Location(); +void LIBPROTOBUF_EXPORT InitDefaultsSourceCodeInfoImpl(); +void LIBPROTOBUF_EXPORT InitDefaultsSourceCodeInfo(); +void LIBPROTOBUF_EXPORT InitDefaultsGeneratedCodeInfo_AnnotationImpl(); +void LIBPROTOBUF_EXPORT InitDefaultsGeneratedCodeInfo_Annotation(); +void LIBPROTOBUF_EXPORT InitDefaultsGeneratedCodeInfoImpl(); +void LIBPROTOBUF_EXPORT InitDefaultsGeneratedCodeInfo(); +inline void LIBPROTOBUF_EXPORT InitDefaults() { + InitDefaultsFileDescriptorSet(); + InitDefaultsFileDescriptorProto(); + InitDefaultsDescriptorProto_ExtensionRange(); + InitDefaultsDescriptorProto_ReservedRange(); + InitDefaultsDescriptorProto(); + InitDefaultsExtensionRangeOptions(); + InitDefaultsFieldDescriptorProto(); + InitDefaultsOneofDescriptorProto(); + InitDefaultsEnumDescriptorProto_EnumReservedRange(); + InitDefaultsEnumDescriptorProto(); + InitDefaultsEnumValueDescriptorProto(); + InitDefaultsServiceDescriptorProto(); + InitDefaultsMethodDescriptorProto(); + InitDefaultsFileOptions(); + InitDefaultsMessageOptions(); + InitDefaultsFieldOptions(); + InitDefaultsOneofOptions(); + InitDefaultsEnumOptions(); + InitDefaultsEnumValueOptions(); + InitDefaultsServiceOptions(); + InitDefaultsMethodOptions(); + InitDefaultsUninterpretedOption_NamePart(); + InitDefaultsUninterpretedOption(); + InitDefaultsSourceCodeInfo_Location(); + InitDefaultsSourceCodeInfo(); + InitDefaultsGeneratedCodeInfo_Annotation(); + InitDefaultsGeneratedCodeInfo(); +} +} // namespace protobuf_google_2fprotobuf_2fdescriptor_2eproto namespace google { namespace protobuf { class DescriptorProto; @@ -45,6 +141,9 @@ LIBPROTOBUF_EXPORT extern DescriptorProto_ReservedRangeDefaultTypeInternal _Desc class EnumDescriptorProto; class EnumDescriptorProtoDefaultTypeInternal; LIBPROTOBUF_EXPORT extern EnumDescriptorProtoDefaultTypeInternal _EnumDescriptorProto_default_instance_; +class EnumDescriptorProto_EnumReservedRange; +class EnumDescriptorProto_EnumReservedRangeDefaultTypeInternal; +LIBPROTOBUF_EXPORT extern EnumDescriptorProto_EnumReservedRangeDefaultTypeInternal _EnumDescriptorProto_EnumReservedRange_default_instance_; class EnumOptions; class EnumOptionsDefaultTypeInternal; LIBPROTOBUF_EXPORT extern EnumOptionsDefaultTypeInternal _EnumOptions_default_instance_; @@ -54,6 +153,9 @@ LIBPROTOBUF_EXPORT extern EnumValueDescriptorProtoDefaultTypeInternal _EnumValue class EnumValueOptions; class EnumValueOptionsDefaultTypeInternal; LIBPROTOBUF_EXPORT extern EnumValueOptionsDefaultTypeInternal _EnumValueOptions_default_instance_; +class ExtensionRangeOptions; +class ExtensionRangeOptionsDefaultTypeInternal; +LIBPROTOBUF_EXPORT extern ExtensionRangeOptionsDefaultTypeInternal _ExtensionRangeOptions_default_instance_; class FieldDescriptorProto; class FieldDescriptorProtoDefaultTypeInternal; LIBPROTOBUF_EXPORT extern FieldDescriptorProtoDefaultTypeInternal _FieldDescriptorProto_default_instance_; @@ -110,23 +212,39 @@ class UninterpretedOption_NamePartDefaultTypeInternal; LIBPROTOBUF_EXPORT extern UninterpretedOption_NamePartDefaultTypeInternal _UninterpretedOption_NamePart_default_instance_; } // namespace protobuf } // namespace google - namespace google { namespace protobuf { - -namespace protobuf_google_2fprotobuf_2fdescriptor_2eproto { -// Internal implementation detail -- do not call these. -struct LIBPROTOBUF_EXPORT TableStruct { - static const ::google::protobuf::internal::ParseTableField entries[]; - static const ::google::protobuf::internal::AuxillaryParseTableField aux[]; - static const ::google::protobuf::internal::ParseTable schema[]; - static const ::google::protobuf::uint32 offsets[]; - static void InitDefaultsImpl(); - static void Shutdown(); -}; -void LIBPROTOBUF_EXPORT AddDescriptors(); -void LIBPROTOBUF_EXPORT InitDefaults(); -} // namespace protobuf_google_2fprotobuf_2fdescriptor_2eproto +template<> LIBPROTOBUF_EXPORT ::google::protobuf::DescriptorProto* Arena::CreateMessage< ::google::protobuf::DescriptorProto>(Arena*); +template<> LIBPROTOBUF_EXPORT ::google::protobuf::DescriptorProto_ExtensionRange* Arena::CreateMessage< ::google::protobuf::DescriptorProto_ExtensionRange>(Arena*); +template<> LIBPROTOBUF_EXPORT ::google::protobuf::DescriptorProto_ReservedRange* Arena::CreateMessage< ::google::protobuf::DescriptorProto_ReservedRange>(Arena*); +template<> LIBPROTOBUF_EXPORT ::google::protobuf::EnumDescriptorProto* Arena::CreateMessage< ::google::protobuf::EnumDescriptorProto>(Arena*); +template<> LIBPROTOBUF_EXPORT ::google::protobuf::EnumDescriptorProto_EnumReservedRange* Arena::CreateMessage< ::google::protobuf::EnumDescriptorProto_EnumReservedRange>(Arena*); +template<> LIBPROTOBUF_EXPORT ::google::protobuf::EnumOptions* Arena::CreateMessage< ::google::protobuf::EnumOptions>(Arena*); +template<> LIBPROTOBUF_EXPORT ::google::protobuf::EnumValueDescriptorProto* Arena::CreateMessage< ::google::protobuf::EnumValueDescriptorProto>(Arena*); +template<> LIBPROTOBUF_EXPORT ::google::protobuf::EnumValueOptions* Arena::CreateMessage< ::google::protobuf::EnumValueOptions>(Arena*); +template<> LIBPROTOBUF_EXPORT ::google::protobuf::ExtensionRangeOptions* Arena::CreateMessage< ::google::protobuf::ExtensionRangeOptions>(Arena*); +template<> LIBPROTOBUF_EXPORT ::google::protobuf::FieldDescriptorProto* Arena::CreateMessage< ::google::protobuf::FieldDescriptorProto>(Arena*); +template<> LIBPROTOBUF_EXPORT ::google::protobuf::FieldOptions* Arena::CreateMessage< ::google::protobuf::FieldOptions>(Arena*); +template<> LIBPROTOBUF_EXPORT ::google::protobuf::FileDescriptorProto* Arena::CreateMessage< ::google::protobuf::FileDescriptorProto>(Arena*); +template<> LIBPROTOBUF_EXPORT ::google::protobuf::FileDescriptorSet* Arena::CreateMessage< ::google::protobuf::FileDescriptorSet>(Arena*); +template<> LIBPROTOBUF_EXPORT ::google::protobuf::FileOptions* Arena::CreateMessage< ::google::protobuf::FileOptions>(Arena*); +template<> LIBPROTOBUF_EXPORT ::google::protobuf::GeneratedCodeInfo* Arena::CreateMessage< ::google::protobuf::GeneratedCodeInfo>(Arena*); +template<> LIBPROTOBUF_EXPORT ::google::protobuf::GeneratedCodeInfo_Annotation* Arena::CreateMessage< ::google::protobuf::GeneratedCodeInfo_Annotation>(Arena*); +template<> LIBPROTOBUF_EXPORT ::google::protobuf::MessageOptions* Arena::CreateMessage< ::google::protobuf::MessageOptions>(Arena*); +template<> LIBPROTOBUF_EXPORT ::google::protobuf::MethodDescriptorProto* Arena::CreateMessage< ::google::protobuf::MethodDescriptorProto>(Arena*); +template<> LIBPROTOBUF_EXPORT ::google::protobuf::MethodOptions* Arena::CreateMessage< ::google::protobuf::MethodOptions>(Arena*); +template<> LIBPROTOBUF_EXPORT ::google::protobuf::OneofDescriptorProto* Arena::CreateMessage< ::google::protobuf::OneofDescriptorProto>(Arena*); +template<> LIBPROTOBUF_EXPORT ::google::protobuf::OneofOptions* Arena::CreateMessage< ::google::protobuf::OneofOptions>(Arena*); +template<> LIBPROTOBUF_EXPORT ::google::protobuf::ServiceDescriptorProto* Arena::CreateMessage< ::google::protobuf::ServiceDescriptorProto>(Arena*); +template<> LIBPROTOBUF_EXPORT ::google::protobuf::ServiceOptions* Arena::CreateMessage< ::google::protobuf::ServiceOptions>(Arena*); +template<> LIBPROTOBUF_EXPORT ::google::protobuf::SourceCodeInfo* Arena::CreateMessage< ::google::protobuf::SourceCodeInfo>(Arena*); +template<> LIBPROTOBUF_EXPORT ::google::protobuf::SourceCodeInfo_Location* Arena::CreateMessage< ::google::protobuf::SourceCodeInfo_Location>(Arena*); +template<> LIBPROTOBUF_EXPORT ::google::protobuf::UninterpretedOption* Arena::CreateMessage< ::google::protobuf::UninterpretedOption>(Arena*); +template<> LIBPROTOBUF_EXPORT ::google::protobuf::UninterpretedOption_NamePart* Arena::CreateMessage< ::google::protobuf::UninterpretedOption_NamePart>(Arena*); +} // namespace protobuf +} // namespace google +namespace google { +namespace protobuf { enum FieldDescriptorProto_Type { FieldDescriptorProto_Type_TYPE_DOUBLE = 1, @@ -276,18 +394,38 @@ class LIBPROTOBUF_EXPORT FileDescriptorSet : public ::google::protobuf::Message CopyFrom(from); return *this; } + #if LANG_CXX11 + FileDescriptorSet(FileDescriptorSet&& from) noexcept + : FileDescriptorSet() { + *this = ::std::move(from); + } + inline FileDescriptorSet& operator=(FileDescriptorSet&& from) noexcept { + if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + #endif inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { return _internal_metadata_.unknown_fields(); } - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { return _internal_metadata_.mutable_unknown_fields(); } + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { + return MaybeArenaPtr(); + } static const ::google::protobuf::Descriptor* descriptor(); static const FileDescriptorSet& default_instance(); + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY static inline const FileDescriptorSet* internal_default_instance() { return reinterpret_cast<const FileDescriptorSet*>( &_FileDescriptorSet_default_instance_); @@ -295,13 +433,21 @@ class LIBPROTOBUF_EXPORT FileDescriptorSet : public ::google::protobuf::Message static PROTOBUF_CONSTEXPR int const kIndexInFileMessages = 0; + void UnsafeArenaSwap(FileDescriptorSet* other); void Swap(FileDescriptorSet* other); + friend void swap(FileDescriptorSet& a, FileDescriptorSet& b) { + a.Swap(&b); + } // implements Message ---------------------------------------------- - inline FileDescriptorSet* New() const PROTOBUF_FINAL { return New(NULL); } + inline FileDescriptorSet* New() const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<FileDescriptorSet>(NULL); + } - FileDescriptorSet* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + FileDescriptorSet* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<FileDescriptorSet>(arena); + } void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const FileDescriptorSet& from); @@ -322,12 +468,17 @@ class LIBPROTOBUF_EXPORT FileDescriptorSet : public ::google::protobuf::Message void SharedDtor(); void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(FileDescriptorSet* other); + protected: + explicit FileDescriptorSet(::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 NULL; + return _internal_metadata_.arena(); } inline void* MaybeArenaPtr() const { - return NULL; + return _internal_metadata_.raw_arena_ptr(); } public: @@ -341,11 +492,11 @@ class LIBPROTOBUF_EXPORT FileDescriptorSet : public ::google::protobuf::Message int file_size() const; void clear_file(); static const int kFileFieldNumber = 1; - const ::google::protobuf::FileDescriptorProto& file(int index) const; ::google::protobuf::FileDescriptorProto* mutable_file(int index); - ::google::protobuf::FileDescriptorProto* add_file(); ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto >* mutable_file(); + const ::google::protobuf::FileDescriptorProto& file(int index) const; + ::google::protobuf::FileDescriptorProto* add_file(); const ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto >& file() const; @@ -353,10 +504,14 @@ class LIBPROTOBUF_EXPORT FileDescriptorSet : public ::google::protobuf::Message private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + template <typename T> friend class ::google::protobuf::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto > file_; - friend struct protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend struct ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend void ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsFileDescriptorSetImpl(); }; // ------------------------------------------------------------------- @@ -371,18 +526,38 @@ class LIBPROTOBUF_EXPORT FileDescriptorProto : public ::google::protobuf::Messag CopyFrom(from); return *this; } + #if LANG_CXX11 + FileDescriptorProto(FileDescriptorProto&& from) noexcept + : FileDescriptorProto() { + *this = ::std::move(from); + } + inline FileDescriptorProto& operator=(FileDescriptorProto&& from) noexcept { + if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + #endif inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { return _internal_metadata_.unknown_fields(); } - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { return _internal_metadata_.mutable_unknown_fields(); } + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { + return MaybeArenaPtr(); + } static const ::google::protobuf::Descriptor* descriptor(); static const FileDescriptorProto& default_instance(); + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY static inline const FileDescriptorProto* internal_default_instance() { return reinterpret_cast<const FileDescriptorProto*>( &_FileDescriptorProto_default_instance_); @@ -390,13 +565,21 @@ class LIBPROTOBUF_EXPORT FileDescriptorProto : public ::google::protobuf::Messag static PROTOBUF_CONSTEXPR int const kIndexInFileMessages = 1; + void UnsafeArenaSwap(FileDescriptorProto* other); void Swap(FileDescriptorProto* other); + friend void swap(FileDescriptorProto& a, FileDescriptorProto& b) { + a.Swap(&b); + } // implements Message ---------------------------------------------- - inline FileDescriptorProto* New() const PROTOBUF_FINAL { return New(NULL); } + inline FileDescriptorProto* New() const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<FileDescriptorProto>(NULL); + } - FileDescriptorProto* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + FileDescriptorProto* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<FileDescriptorProto>(arena); + } void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const FileDescriptorProto& from); @@ -417,12 +600,17 @@ class LIBPROTOBUF_EXPORT FileDescriptorProto : public ::google::protobuf::Messag void SharedDtor(); void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(FileDescriptorProto* other); + protected: + explicit FileDescriptorProto(::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 NULL; + return _internal_metadata_.arena(); } inline void* MaybeArenaPtr() const { - return NULL; + return _internal_metadata_.raw_arena_ptr(); } public: @@ -458,11 +646,11 @@ class LIBPROTOBUF_EXPORT FileDescriptorProto : public ::google::protobuf::Messag int message_type_size() const; void clear_message_type(); static const int kMessageTypeFieldNumber = 4; - const ::google::protobuf::DescriptorProto& message_type(int index) const; ::google::protobuf::DescriptorProto* mutable_message_type(int index); - ::google::protobuf::DescriptorProto* add_message_type(); ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto >* mutable_message_type(); + const ::google::protobuf::DescriptorProto& message_type(int index) const; + ::google::protobuf::DescriptorProto* add_message_type(); const ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto >& message_type() const; @@ -470,11 +658,11 @@ class LIBPROTOBUF_EXPORT FileDescriptorProto : public ::google::protobuf::Messag int enum_type_size() const; void clear_enum_type(); static const int kEnumTypeFieldNumber = 5; - const ::google::protobuf::EnumDescriptorProto& enum_type(int index) const; ::google::protobuf::EnumDescriptorProto* mutable_enum_type(int index); - ::google::protobuf::EnumDescriptorProto* add_enum_type(); ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumDescriptorProto >* mutable_enum_type(); + const ::google::protobuf::EnumDescriptorProto& enum_type(int index) const; + ::google::protobuf::EnumDescriptorProto* add_enum_type(); const ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumDescriptorProto >& enum_type() const; @@ -482,11 +670,11 @@ class LIBPROTOBUF_EXPORT FileDescriptorProto : public ::google::protobuf::Messag int service_size() const; void clear_service(); static const int kServiceFieldNumber = 6; - const ::google::protobuf::ServiceDescriptorProto& service(int index) const; ::google::protobuf::ServiceDescriptorProto* mutable_service(int index); - ::google::protobuf::ServiceDescriptorProto* add_service(); ::google::protobuf::RepeatedPtrField< ::google::protobuf::ServiceDescriptorProto >* mutable_service(); + const ::google::protobuf::ServiceDescriptorProto& service(int index) const; + ::google::protobuf::ServiceDescriptorProto* add_service(); const ::google::protobuf::RepeatedPtrField< ::google::protobuf::ServiceDescriptorProto >& service() const; @@ -494,11 +682,11 @@ class LIBPROTOBUF_EXPORT FileDescriptorProto : public ::google::protobuf::Messag int extension_size() const; void clear_extension(); static const int kExtensionFieldNumber = 7; - const ::google::protobuf::FieldDescriptorProto& extension(int index) const; ::google::protobuf::FieldDescriptorProto* mutable_extension(int index); - ::google::protobuf::FieldDescriptorProto* add_extension(); ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >* mutable_extension(); + const ::google::protobuf::FieldDescriptorProto& extension(int index) const; + ::google::protobuf::FieldDescriptorProto* add_extension(); const ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >& extension() const; @@ -540,6 +728,15 @@ class LIBPROTOBUF_EXPORT FileDescriptorProto : public ::google::protobuf::Messag ::std::string* mutable_name(); ::std::string* release_name(); void set_allocated_name(::std::string* name); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + ::std::string* unsafe_arena_release_name(); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + void unsafe_arena_set_allocated_name( + ::std::string* name); // optional string package = 2; bool has_package() const; @@ -555,6 +752,15 @@ class LIBPROTOBUF_EXPORT FileDescriptorProto : public ::google::protobuf::Messag ::std::string* mutable_package(); ::std::string* release_package(); void set_allocated_package(::std::string* package); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + ::std::string* unsafe_arena_release_package(); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + void unsafe_arena_set_allocated_package( + ::std::string* package); // optional string syntax = 12; bool has_syntax() const; @@ -570,24 +776,39 @@ class LIBPROTOBUF_EXPORT FileDescriptorProto : public ::google::protobuf::Messag ::std::string* mutable_syntax(); ::std::string* release_syntax(); void set_allocated_syntax(::std::string* syntax); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + ::std::string* unsafe_arena_release_syntax(); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + void unsafe_arena_set_allocated_syntax( + ::std::string* syntax); // optional .google.protobuf.FileOptions options = 8; bool has_options() const; void clear_options(); static const int kOptionsFieldNumber = 8; const ::google::protobuf::FileOptions& options() const; - ::google::protobuf::FileOptions* mutable_options(); ::google::protobuf::FileOptions* release_options(); + ::google::protobuf::FileOptions* mutable_options(); void set_allocated_options(::google::protobuf::FileOptions* options); + void unsafe_arena_set_allocated_options( + ::google::protobuf::FileOptions* options); + ::google::protobuf::FileOptions* unsafe_arena_release_options(); // optional .google.protobuf.SourceCodeInfo source_code_info = 9; bool has_source_code_info() const; void clear_source_code_info(); static const int kSourceCodeInfoFieldNumber = 9; const ::google::protobuf::SourceCodeInfo& source_code_info() const; - ::google::protobuf::SourceCodeInfo* mutable_source_code_info(); ::google::protobuf::SourceCodeInfo* release_source_code_info(); + ::google::protobuf::SourceCodeInfo* mutable_source_code_info(); void set_allocated_source_code_info(::google::protobuf::SourceCodeInfo* source_code_info); + void unsafe_arena_set_allocated_source_code_info( + ::google::protobuf::SourceCodeInfo* source_code_info); + ::google::protobuf::SourceCodeInfo* unsafe_arena_release_source_code_info(); // @@protoc_insertion_point(class_scope:google.protobuf.FileDescriptorProto) private: @@ -603,6 +824,9 @@ class LIBPROTOBUF_EXPORT FileDescriptorProto : public ::google::protobuf::Messag void clear_has_syntax(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + template <typename T> friend class ::google::protobuf::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::RepeatedPtrField< ::std::string> dependency_; @@ -617,7 +841,8 @@ class LIBPROTOBUF_EXPORT FileDescriptorProto : public ::google::protobuf::Messag ::google::protobuf::internal::ArenaStringPtr syntax_; ::google::protobuf::FileOptions* options_; ::google::protobuf::SourceCodeInfo* source_code_info_; - friend struct protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend struct ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend void ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsFileDescriptorProtoImpl(); }; // ------------------------------------------------------------------- @@ -632,18 +857,38 @@ class LIBPROTOBUF_EXPORT DescriptorProto_ExtensionRange : public ::google::proto CopyFrom(from); return *this; } + #if LANG_CXX11 + DescriptorProto_ExtensionRange(DescriptorProto_ExtensionRange&& from) noexcept + : DescriptorProto_ExtensionRange() { + *this = ::std::move(from); + } + inline DescriptorProto_ExtensionRange& operator=(DescriptorProto_ExtensionRange&& from) noexcept { + if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + #endif inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { return _internal_metadata_.unknown_fields(); } - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { return _internal_metadata_.mutable_unknown_fields(); } + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { + return MaybeArenaPtr(); + } static const ::google::protobuf::Descriptor* descriptor(); static const DescriptorProto_ExtensionRange& default_instance(); + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY static inline const DescriptorProto_ExtensionRange* internal_default_instance() { return reinterpret_cast<const DescriptorProto_ExtensionRange*>( &_DescriptorProto_ExtensionRange_default_instance_); @@ -651,13 +896,21 @@ class LIBPROTOBUF_EXPORT DescriptorProto_ExtensionRange : public ::google::proto static PROTOBUF_CONSTEXPR int const kIndexInFileMessages = 2; + void UnsafeArenaSwap(DescriptorProto_ExtensionRange* other); void Swap(DescriptorProto_ExtensionRange* other); + friend void swap(DescriptorProto_ExtensionRange& a, DescriptorProto_ExtensionRange& b) { + a.Swap(&b); + } // implements Message ---------------------------------------------- - inline DescriptorProto_ExtensionRange* New() const PROTOBUF_FINAL { return New(NULL); } + inline DescriptorProto_ExtensionRange* New() const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<DescriptorProto_ExtensionRange>(NULL); + } - DescriptorProto_ExtensionRange* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + DescriptorProto_ExtensionRange* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<DescriptorProto_ExtensionRange>(arena); + } void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const DescriptorProto_ExtensionRange& from); @@ -678,12 +931,17 @@ class LIBPROTOBUF_EXPORT DescriptorProto_ExtensionRange : public ::google::proto void SharedDtor(); void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(DescriptorProto_ExtensionRange* other); + protected: + explicit DescriptorProto_ExtensionRange(::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 NULL; + return _internal_metadata_.arena(); } inline void* MaybeArenaPtr() const { - return NULL; + return _internal_metadata_.raw_arena_ptr(); } public: @@ -693,6 +951,18 @@ class LIBPROTOBUF_EXPORT DescriptorProto_ExtensionRange : public ::google::proto // accessors ------------------------------------------------------- + // optional .google.protobuf.ExtensionRangeOptions options = 3; + bool has_options() const; + void clear_options(); + static const int kOptionsFieldNumber = 3; + const ::google::protobuf::ExtensionRangeOptions& options() const; + ::google::protobuf::ExtensionRangeOptions* release_options(); + ::google::protobuf::ExtensionRangeOptions* mutable_options(); + void set_allocated_options(::google::protobuf::ExtensionRangeOptions* options); + void unsafe_arena_set_allocated_options( + ::google::protobuf::ExtensionRangeOptions* options); + ::google::protobuf::ExtensionRangeOptions* unsafe_arena_release_options(); + // optional int32 start = 1; bool has_start() const; void clear_start(); @@ -713,13 +983,20 @@ class LIBPROTOBUF_EXPORT DescriptorProto_ExtensionRange : public ::google::proto void clear_has_start(); void set_has_end(); void clear_has_end(); + void set_has_options(); + void clear_has_options(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + template <typename T> friend class ::google::protobuf::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; + ::google::protobuf::ExtensionRangeOptions* options_; ::google::protobuf::int32 start_; ::google::protobuf::int32 end_; - friend struct protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend struct ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend void ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsDescriptorProto_ExtensionRangeImpl(); }; // ------------------------------------------------------------------- @@ -734,18 +1011,38 @@ class LIBPROTOBUF_EXPORT DescriptorProto_ReservedRange : public ::google::protob CopyFrom(from); return *this; } + #if LANG_CXX11 + DescriptorProto_ReservedRange(DescriptorProto_ReservedRange&& from) noexcept + : DescriptorProto_ReservedRange() { + *this = ::std::move(from); + } + inline DescriptorProto_ReservedRange& operator=(DescriptorProto_ReservedRange&& from) noexcept { + if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + #endif inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { return _internal_metadata_.unknown_fields(); } - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { return _internal_metadata_.mutable_unknown_fields(); } + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { + return MaybeArenaPtr(); + } static const ::google::protobuf::Descriptor* descriptor(); static const DescriptorProto_ReservedRange& default_instance(); + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY static inline const DescriptorProto_ReservedRange* internal_default_instance() { return reinterpret_cast<const DescriptorProto_ReservedRange*>( &_DescriptorProto_ReservedRange_default_instance_); @@ -753,13 +1050,21 @@ class LIBPROTOBUF_EXPORT DescriptorProto_ReservedRange : public ::google::protob static PROTOBUF_CONSTEXPR int const kIndexInFileMessages = 3; + void UnsafeArenaSwap(DescriptorProto_ReservedRange* other); void Swap(DescriptorProto_ReservedRange* other); + friend void swap(DescriptorProto_ReservedRange& a, DescriptorProto_ReservedRange& b) { + a.Swap(&b); + } // implements Message ---------------------------------------------- - inline DescriptorProto_ReservedRange* New() const PROTOBUF_FINAL { return New(NULL); } + inline DescriptorProto_ReservedRange* New() const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<DescriptorProto_ReservedRange>(NULL); + } - DescriptorProto_ReservedRange* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + DescriptorProto_ReservedRange* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<DescriptorProto_ReservedRange>(arena); + } void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const DescriptorProto_ReservedRange& from); @@ -780,12 +1085,17 @@ class LIBPROTOBUF_EXPORT DescriptorProto_ReservedRange : public ::google::protob void SharedDtor(); void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(DescriptorProto_ReservedRange* other); + protected: + explicit DescriptorProto_ReservedRange(::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 NULL; + return _internal_metadata_.arena(); } inline void* MaybeArenaPtr() const { - return NULL; + return _internal_metadata_.raw_arena_ptr(); } public: @@ -817,11 +1127,15 @@ class LIBPROTOBUF_EXPORT DescriptorProto_ReservedRange : public ::google::protob void clear_has_end(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + template <typename T> friend class ::google::protobuf::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::int32 start_; ::google::protobuf::int32 end_; - friend struct protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend struct ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend void ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsDescriptorProto_ReservedRangeImpl(); }; // ------------------------------------------------------------------- @@ -836,18 +1150,38 @@ class LIBPROTOBUF_EXPORT DescriptorProto : public ::google::protobuf::Message /* CopyFrom(from); return *this; } + #if LANG_CXX11 + DescriptorProto(DescriptorProto&& from) noexcept + : DescriptorProto() { + *this = ::std::move(from); + } + inline DescriptorProto& operator=(DescriptorProto&& from) noexcept { + if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + #endif inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { return _internal_metadata_.unknown_fields(); } - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { return _internal_metadata_.mutable_unknown_fields(); } + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { + return MaybeArenaPtr(); + } static const ::google::protobuf::Descriptor* descriptor(); static const DescriptorProto& default_instance(); + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY static inline const DescriptorProto* internal_default_instance() { return reinterpret_cast<const DescriptorProto*>( &_DescriptorProto_default_instance_); @@ -855,13 +1189,21 @@ class LIBPROTOBUF_EXPORT DescriptorProto : public ::google::protobuf::Message /* static PROTOBUF_CONSTEXPR int const kIndexInFileMessages = 4; + void UnsafeArenaSwap(DescriptorProto* other); void Swap(DescriptorProto* other); + friend void swap(DescriptorProto& a, DescriptorProto& b) { + a.Swap(&b); + } // implements Message ---------------------------------------------- - inline DescriptorProto* New() const PROTOBUF_FINAL { return New(NULL); } + inline DescriptorProto* New() const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<DescriptorProto>(NULL); + } - DescriptorProto* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + DescriptorProto* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<DescriptorProto>(arena); + } void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const DescriptorProto& from); @@ -882,12 +1224,17 @@ class LIBPROTOBUF_EXPORT DescriptorProto : public ::google::protobuf::Message /* void SharedDtor(); void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(DescriptorProto* other); + protected: + explicit DescriptorProto(::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 NULL; + return _internal_metadata_.arena(); } inline void* MaybeArenaPtr() const { - return NULL; + return _internal_metadata_.raw_arena_ptr(); } public: @@ -904,11 +1251,11 @@ class LIBPROTOBUF_EXPORT DescriptorProto : public ::google::protobuf::Message /* int field_size() const; void clear_field(); static const int kFieldFieldNumber = 2; - const ::google::protobuf::FieldDescriptorProto& field(int index) const; ::google::protobuf::FieldDescriptorProto* mutable_field(int index); - ::google::protobuf::FieldDescriptorProto* add_field(); ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >* mutable_field(); + const ::google::protobuf::FieldDescriptorProto& field(int index) const; + ::google::protobuf::FieldDescriptorProto* add_field(); const ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >& field() const; @@ -916,11 +1263,11 @@ class LIBPROTOBUF_EXPORT DescriptorProto : public ::google::protobuf::Message /* int nested_type_size() const; void clear_nested_type(); static const int kNestedTypeFieldNumber = 3; - const ::google::protobuf::DescriptorProto& nested_type(int index) const; ::google::protobuf::DescriptorProto* mutable_nested_type(int index); - ::google::protobuf::DescriptorProto* add_nested_type(); ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto >* mutable_nested_type(); + const ::google::protobuf::DescriptorProto& nested_type(int index) const; + ::google::protobuf::DescriptorProto* add_nested_type(); const ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto >& nested_type() const; @@ -928,11 +1275,11 @@ class LIBPROTOBUF_EXPORT DescriptorProto : public ::google::protobuf::Message /* int enum_type_size() const; void clear_enum_type(); static const int kEnumTypeFieldNumber = 4; - const ::google::protobuf::EnumDescriptorProto& enum_type(int index) const; ::google::protobuf::EnumDescriptorProto* mutable_enum_type(int index); - ::google::protobuf::EnumDescriptorProto* add_enum_type(); ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumDescriptorProto >* mutable_enum_type(); + const ::google::protobuf::EnumDescriptorProto& enum_type(int index) const; + ::google::protobuf::EnumDescriptorProto* add_enum_type(); const ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumDescriptorProto >& enum_type() const; @@ -940,11 +1287,11 @@ class LIBPROTOBUF_EXPORT DescriptorProto : public ::google::protobuf::Message /* int extension_range_size() const; void clear_extension_range(); static const int kExtensionRangeFieldNumber = 5; - const ::google::protobuf::DescriptorProto_ExtensionRange& extension_range(int index) const; ::google::protobuf::DescriptorProto_ExtensionRange* mutable_extension_range(int index); - ::google::protobuf::DescriptorProto_ExtensionRange* add_extension_range(); ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto_ExtensionRange >* mutable_extension_range(); + const ::google::protobuf::DescriptorProto_ExtensionRange& extension_range(int index) const; + ::google::protobuf::DescriptorProto_ExtensionRange* add_extension_range(); const ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto_ExtensionRange >& extension_range() const; @@ -952,11 +1299,11 @@ class LIBPROTOBUF_EXPORT DescriptorProto : public ::google::protobuf::Message /* int extension_size() const; void clear_extension(); static const int kExtensionFieldNumber = 6; - const ::google::protobuf::FieldDescriptorProto& extension(int index) const; ::google::protobuf::FieldDescriptorProto* mutable_extension(int index); - ::google::protobuf::FieldDescriptorProto* add_extension(); ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >* mutable_extension(); + const ::google::protobuf::FieldDescriptorProto& extension(int index) const; + ::google::protobuf::FieldDescriptorProto* add_extension(); const ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >& extension() const; @@ -964,11 +1311,11 @@ class LIBPROTOBUF_EXPORT DescriptorProto : public ::google::protobuf::Message /* int oneof_decl_size() const; void clear_oneof_decl(); static const int kOneofDeclFieldNumber = 8; - const ::google::protobuf::OneofDescriptorProto& oneof_decl(int index) const; ::google::protobuf::OneofDescriptorProto* mutable_oneof_decl(int index); - ::google::protobuf::OneofDescriptorProto* add_oneof_decl(); ::google::protobuf::RepeatedPtrField< ::google::protobuf::OneofDescriptorProto >* mutable_oneof_decl(); + const ::google::protobuf::OneofDescriptorProto& oneof_decl(int index) const; + ::google::protobuf::OneofDescriptorProto* add_oneof_decl(); const ::google::protobuf::RepeatedPtrField< ::google::protobuf::OneofDescriptorProto >& oneof_decl() const; @@ -976,11 +1323,11 @@ class LIBPROTOBUF_EXPORT DescriptorProto : public ::google::protobuf::Message /* int reserved_range_size() const; void clear_reserved_range(); static const int kReservedRangeFieldNumber = 9; - const ::google::protobuf::DescriptorProto_ReservedRange& reserved_range(int index) const; ::google::protobuf::DescriptorProto_ReservedRange* mutable_reserved_range(int index); - ::google::protobuf::DescriptorProto_ReservedRange* add_reserved_range(); ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto_ReservedRange >* mutable_reserved_range(); + const ::google::protobuf::DescriptorProto_ReservedRange& reserved_range(int index) const; + ::google::protobuf::DescriptorProto_ReservedRange* add_reserved_range(); const ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto_ReservedRange >& reserved_range() const; @@ -1020,15 +1367,27 @@ class LIBPROTOBUF_EXPORT DescriptorProto : public ::google::protobuf::Message /* ::std::string* mutable_name(); ::std::string* release_name(); void set_allocated_name(::std::string* name); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + ::std::string* unsafe_arena_release_name(); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + void unsafe_arena_set_allocated_name( + ::std::string* name); // optional .google.protobuf.MessageOptions options = 7; bool has_options() const; void clear_options(); static const int kOptionsFieldNumber = 7; const ::google::protobuf::MessageOptions& options() const; - ::google::protobuf::MessageOptions* mutable_options(); ::google::protobuf::MessageOptions* release_options(); + ::google::protobuf::MessageOptions* mutable_options(); void set_allocated_options(::google::protobuf::MessageOptions* options); + void unsafe_arena_set_allocated_options( + ::google::protobuf::MessageOptions* options); + ::google::protobuf::MessageOptions* unsafe_arena_release_options(); // @@protoc_insertion_point(class_scope:google.protobuf.DescriptorProto) private: @@ -1038,6 +1397,9 @@ class LIBPROTOBUF_EXPORT DescriptorProto : public ::google::protobuf::Message /* void clear_has_options(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + template <typename T> friend class ::google::protobuf::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto > field_; @@ -1050,7 +1412,143 @@ class LIBPROTOBUF_EXPORT DescriptorProto : public ::google::protobuf::Message /* ::google::protobuf::RepeatedPtrField< ::std::string> reserved_name_; ::google::protobuf::internal::ArenaStringPtr name_; ::google::protobuf::MessageOptions* options_; - friend struct protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend struct ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend void ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsDescriptorProtoImpl(); +}; +// ------------------------------------------------------------------- + +class LIBPROTOBUF_EXPORT ExtensionRangeOptions : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.ExtensionRangeOptions) */ { + public: + ExtensionRangeOptions(); + virtual ~ExtensionRangeOptions(); + + ExtensionRangeOptions(const ExtensionRangeOptions& from); + + inline ExtensionRangeOptions& operator=(const ExtensionRangeOptions& from) { + CopyFrom(from); + return *this; + } + #if LANG_CXX11 + ExtensionRangeOptions(ExtensionRangeOptions&& from) noexcept + : ExtensionRangeOptions() { + *this = ::std::move(from); + } + + inline ExtensionRangeOptions& operator=(ExtensionRangeOptions&& from) noexcept { + if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + #endif + inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields(); + } + inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields(); + } + + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { + return MaybeArenaPtr(); + } + static const ::google::protobuf::Descriptor* descriptor(); + static const ExtensionRangeOptions& default_instance(); + + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY + static inline const ExtensionRangeOptions* internal_default_instance() { + return reinterpret_cast<const ExtensionRangeOptions*>( + &_ExtensionRangeOptions_default_instance_); + } + static PROTOBUF_CONSTEXPR int const kIndexInFileMessages = + 5; + + void UnsafeArenaSwap(ExtensionRangeOptions* other); + void Swap(ExtensionRangeOptions* other); + friend void swap(ExtensionRangeOptions& a, ExtensionRangeOptions& b) { + a.Swap(&b); + } + + // implements Message ---------------------------------------------- + + inline ExtensionRangeOptions* New() const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<ExtensionRangeOptions>(NULL); + } + + ExtensionRangeOptions* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<ExtensionRangeOptions>(arena); + } + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void CopyFrom(const ExtensionRangeOptions& from); + void MergeFrom(const ExtensionRangeOptions& from); + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; + + size_t ByteSizeLong() const PROTOBUF_FINAL; + bool MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; + void SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } + private: + void SharedCtor(); + void SharedDtor(); + void SetCachedSize(int size) const PROTOBUF_FINAL; + void InternalSwap(ExtensionRangeOptions* other); + protected: + explicit ExtensionRangeOptions(::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(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } + public: + + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; + int uninterpreted_option_size() const; + void clear_uninterpreted_option(); + static const int kUninterpretedOptionFieldNumber = 999; + ::google::protobuf::UninterpretedOption* mutable_uninterpreted_option(int index); + ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >* + mutable_uninterpreted_option(); + const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const; + ::google::protobuf::UninterpretedOption* add_uninterpreted_option(); + const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >& + uninterpreted_option() const; + + GOOGLE_PROTOBUF_EXTENSION_ACCESSORS(ExtensionRangeOptions) + // @@protoc_insertion_point(class_scope:google.protobuf.ExtensionRangeOptions) + private: + + ::google::protobuf::internal::ExtensionSet _extensions_; + + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + template <typename T> friend class ::google::protobuf::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + ::google::protobuf::internal::HasBits<1> _has_bits_; + mutable int _cached_size_; + ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; + friend struct ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend void ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsExtensionRangeOptionsImpl(); }; // ------------------------------------------------------------------- @@ -1065,32 +1563,60 @@ class LIBPROTOBUF_EXPORT FieldDescriptorProto : public ::google::protobuf::Messa CopyFrom(from); return *this; } + #if LANG_CXX11 + FieldDescriptorProto(FieldDescriptorProto&& from) noexcept + : FieldDescriptorProto() { + *this = ::std::move(from); + } + inline FieldDescriptorProto& operator=(FieldDescriptorProto&& from) noexcept { + if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + #endif inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { return _internal_metadata_.unknown_fields(); } - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { return _internal_metadata_.mutable_unknown_fields(); } + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { + return MaybeArenaPtr(); + } static const ::google::protobuf::Descriptor* descriptor(); static const FieldDescriptorProto& default_instance(); + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY static inline const FieldDescriptorProto* internal_default_instance() { return reinterpret_cast<const FieldDescriptorProto*>( &_FieldDescriptorProto_default_instance_); } static PROTOBUF_CONSTEXPR int const kIndexInFileMessages = - 5; + 6; + void UnsafeArenaSwap(FieldDescriptorProto* other); void Swap(FieldDescriptorProto* other); + friend void swap(FieldDescriptorProto& a, FieldDescriptorProto& b) { + a.Swap(&b); + } // implements Message ---------------------------------------------- - inline FieldDescriptorProto* New() const PROTOBUF_FINAL { return New(NULL); } + inline FieldDescriptorProto* New() const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<FieldDescriptorProto>(NULL); + } - FieldDescriptorProto* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + FieldDescriptorProto* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<FieldDescriptorProto>(arena); + } void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const FieldDescriptorProto& from); @@ -1111,12 +1637,17 @@ class LIBPROTOBUF_EXPORT FieldDescriptorProto : public ::google::protobuf::Messa void SharedDtor(); void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(FieldDescriptorProto* other); + protected: + explicit FieldDescriptorProto(::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 NULL; + return _internal_metadata_.arena(); } inline void* MaybeArenaPtr() const { - return NULL; + return _internal_metadata_.raw_arena_ptr(); } public: @@ -1226,6 +1757,15 @@ class LIBPROTOBUF_EXPORT FieldDescriptorProto : public ::google::protobuf::Messa ::std::string* mutable_name(); ::std::string* release_name(); void set_allocated_name(::std::string* name); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + ::std::string* unsafe_arena_release_name(); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + void unsafe_arena_set_allocated_name( + ::std::string* name); // optional string extendee = 2; bool has_extendee() const; @@ -1241,6 +1781,15 @@ class LIBPROTOBUF_EXPORT FieldDescriptorProto : public ::google::protobuf::Messa ::std::string* mutable_extendee(); ::std::string* release_extendee(); void set_allocated_extendee(::std::string* extendee); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + ::std::string* unsafe_arena_release_extendee(); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + void unsafe_arena_set_allocated_extendee( + ::std::string* extendee); // optional string type_name = 6; bool has_type_name() const; @@ -1256,6 +1805,15 @@ class LIBPROTOBUF_EXPORT FieldDescriptorProto : public ::google::protobuf::Messa ::std::string* mutable_type_name(); ::std::string* release_type_name(); void set_allocated_type_name(::std::string* type_name); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + ::std::string* unsafe_arena_release_type_name(); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + void unsafe_arena_set_allocated_type_name( + ::std::string* type_name); // optional string default_value = 7; bool has_default_value() const; @@ -1271,6 +1829,15 @@ class LIBPROTOBUF_EXPORT FieldDescriptorProto : public ::google::protobuf::Messa ::std::string* mutable_default_value(); ::std::string* release_default_value(); void set_allocated_default_value(::std::string* default_value); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + ::std::string* unsafe_arena_release_default_value(); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + void unsafe_arena_set_allocated_default_value( + ::std::string* default_value); // optional string json_name = 10; bool has_json_name() const; @@ -1286,15 +1853,27 @@ class LIBPROTOBUF_EXPORT FieldDescriptorProto : public ::google::protobuf::Messa ::std::string* mutable_json_name(); ::std::string* release_json_name(); void set_allocated_json_name(::std::string* json_name); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + ::std::string* unsafe_arena_release_json_name(); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + void unsafe_arena_set_allocated_json_name( + ::std::string* json_name); // optional .google.protobuf.FieldOptions options = 8; bool has_options() const; void clear_options(); static const int kOptionsFieldNumber = 8; const ::google::protobuf::FieldOptions& options() const; - ::google::protobuf::FieldOptions* mutable_options(); ::google::protobuf::FieldOptions* release_options(); + ::google::protobuf::FieldOptions* mutable_options(); void set_allocated_options(::google::protobuf::FieldOptions* options); + void unsafe_arena_set_allocated_options( + ::google::protobuf::FieldOptions* options); + ::google::protobuf::FieldOptions* unsafe_arena_release_options(); // optional int32 number = 3; bool has_number() const; @@ -1348,6 +1927,9 @@ class LIBPROTOBUF_EXPORT FieldDescriptorProto : public ::google::protobuf::Messa void clear_has_options(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + template <typename T> friend class ::google::protobuf::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::internal::ArenaStringPtr name_; @@ -1360,7 +1942,8 @@ class LIBPROTOBUF_EXPORT FieldDescriptorProto : public ::google::protobuf::Messa ::google::protobuf::int32 oneof_index_; int label_; int type_; - friend struct protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend struct ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend void ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsFieldDescriptorProtoImpl(); }; // ------------------------------------------------------------------- @@ -1375,32 +1958,60 @@ class LIBPROTOBUF_EXPORT OneofDescriptorProto : public ::google::protobuf::Messa CopyFrom(from); return *this; } + #if LANG_CXX11 + OneofDescriptorProto(OneofDescriptorProto&& from) noexcept + : OneofDescriptorProto() { + *this = ::std::move(from); + } + inline OneofDescriptorProto& operator=(OneofDescriptorProto&& from) noexcept { + if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + #endif inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { return _internal_metadata_.unknown_fields(); } - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { return _internal_metadata_.mutable_unknown_fields(); } + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { + return MaybeArenaPtr(); + } static const ::google::protobuf::Descriptor* descriptor(); static const OneofDescriptorProto& default_instance(); + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY static inline const OneofDescriptorProto* internal_default_instance() { return reinterpret_cast<const OneofDescriptorProto*>( &_OneofDescriptorProto_default_instance_); } static PROTOBUF_CONSTEXPR int const kIndexInFileMessages = - 6; + 7; + void UnsafeArenaSwap(OneofDescriptorProto* other); void Swap(OneofDescriptorProto* other); + friend void swap(OneofDescriptorProto& a, OneofDescriptorProto& b) { + a.Swap(&b); + } // implements Message ---------------------------------------------- - inline OneofDescriptorProto* New() const PROTOBUF_FINAL { return New(NULL); } + inline OneofDescriptorProto* New() const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<OneofDescriptorProto>(NULL); + } - OneofDescriptorProto* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + OneofDescriptorProto* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<OneofDescriptorProto>(arena); + } void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const OneofDescriptorProto& from); @@ -1421,12 +2032,17 @@ class LIBPROTOBUF_EXPORT OneofDescriptorProto : public ::google::protobuf::Messa void SharedDtor(); void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(OneofDescriptorProto* other); + protected: + explicit OneofDescriptorProto(::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 NULL; + return _internal_metadata_.arena(); } inline void* MaybeArenaPtr() const { - return NULL; + return _internal_metadata_.raw_arena_ptr(); } public: @@ -1450,15 +2066,27 @@ class LIBPROTOBUF_EXPORT OneofDescriptorProto : public ::google::protobuf::Messa ::std::string* mutable_name(); ::std::string* release_name(); void set_allocated_name(::std::string* name); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + ::std::string* unsafe_arena_release_name(); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + void unsafe_arena_set_allocated_name( + ::std::string* name); // optional .google.protobuf.OneofOptions options = 2; bool has_options() const; void clear_options(); static const int kOptionsFieldNumber = 2; const ::google::protobuf::OneofOptions& options() const; - ::google::protobuf::OneofOptions* mutable_options(); ::google::protobuf::OneofOptions* release_options(); + ::google::protobuf::OneofOptions* mutable_options(); void set_allocated_options(::google::protobuf::OneofOptions* options); + void unsafe_arena_set_allocated_options( + ::google::protobuf::OneofOptions* options); + ::google::protobuf::OneofOptions* unsafe_arena_release_options(); // @@protoc_insertion_point(class_scope:google.protobuf.OneofDescriptorProto) private: @@ -1468,11 +2096,154 @@ class LIBPROTOBUF_EXPORT OneofDescriptorProto : public ::google::protobuf::Messa void clear_has_options(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + template <typename T> friend class ::google::protobuf::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::internal::ArenaStringPtr name_; ::google::protobuf::OneofOptions* options_; - friend struct protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend struct ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend void ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsOneofDescriptorProtoImpl(); +}; +// ------------------------------------------------------------------- + +class LIBPROTOBUF_EXPORT EnumDescriptorProto_EnumReservedRange : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumDescriptorProto.EnumReservedRange) */ { + public: + EnumDescriptorProto_EnumReservedRange(); + virtual ~EnumDescriptorProto_EnumReservedRange(); + + EnumDescriptorProto_EnumReservedRange(const EnumDescriptorProto_EnumReservedRange& from); + + inline EnumDescriptorProto_EnumReservedRange& operator=(const EnumDescriptorProto_EnumReservedRange& from) { + CopyFrom(from); + return *this; + } + #if LANG_CXX11 + EnumDescriptorProto_EnumReservedRange(EnumDescriptorProto_EnumReservedRange&& from) noexcept + : EnumDescriptorProto_EnumReservedRange() { + *this = ::std::move(from); + } + + inline EnumDescriptorProto_EnumReservedRange& operator=(EnumDescriptorProto_EnumReservedRange&& from) noexcept { + if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + #endif + inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields(); + } + inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields(); + } + + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { + return MaybeArenaPtr(); + } + static const ::google::protobuf::Descriptor* descriptor(); + static const EnumDescriptorProto_EnumReservedRange& default_instance(); + + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY + static inline const EnumDescriptorProto_EnumReservedRange* internal_default_instance() { + return reinterpret_cast<const EnumDescriptorProto_EnumReservedRange*>( + &_EnumDescriptorProto_EnumReservedRange_default_instance_); + } + static PROTOBUF_CONSTEXPR int const kIndexInFileMessages = + 8; + + void UnsafeArenaSwap(EnumDescriptorProto_EnumReservedRange* other); + void Swap(EnumDescriptorProto_EnumReservedRange* other); + friend void swap(EnumDescriptorProto_EnumReservedRange& a, EnumDescriptorProto_EnumReservedRange& b) { + a.Swap(&b); + } + + // implements Message ---------------------------------------------- + + inline EnumDescriptorProto_EnumReservedRange* New() const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<EnumDescriptorProto_EnumReservedRange>(NULL); + } + + EnumDescriptorProto_EnumReservedRange* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<EnumDescriptorProto_EnumReservedRange>(arena); + } + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void CopyFrom(const EnumDescriptorProto_EnumReservedRange& from); + void MergeFrom(const EnumDescriptorProto_EnumReservedRange& from); + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; + + size_t ByteSizeLong() const PROTOBUF_FINAL; + bool MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; + void SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } + private: + void SharedCtor(); + void SharedDtor(); + void SetCachedSize(int size) const PROTOBUF_FINAL; + void InternalSwap(EnumDescriptorProto_EnumReservedRange* other); + protected: + explicit EnumDescriptorProto_EnumReservedRange(::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(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } + public: + + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + // optional int32 start = 1; + bool has_start() const; + void clear_start(); + static const int kStartFieldNumber = 1; + ::google::protobuf::int32 start() const; + void set_start(::google::protobuf::int32 value); + + // optional int32 end = 2; + bool has_end() const; + void clear_end(); + static const int kEndFieldNumber = 2; + ::google::protobuf::int32 end() const; + void set_end(::google::protobuf::int32 value); + + // @@protoc_insertion_point(class_scope:google.protobuf.EnumDescriptorProto.EnumReservedRange) + private: + void set_has_start(); + void clear_has_start(); + void set_has_end(); + void clear_has_end(); + + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + template <typename T> friend class ::google::protobuf::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + ::google::protobuf::internal::HasBits<1> _has_bits_; + mutable int _cached_size_; + ::google::protobuf::int32 start_; + ::google::protobuf::int32 end_; + friend struct ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend void ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsEnumDescriptorProto_EnumReservedRangeImpl(); }; // ------------------------------------------------------------------- @@ -1487,32 +2258,60 @@ class LIBPROTOBUF_EXPORT EnumDescriptorProto : public ::google::protobuf::Messag CopyFrom(from); return *this; } + #if LANG_CXX11 + EnumDescriptorProto(EnumDescriptorProto&& from) noexcept + : EnumDescriptorProto() { + *this = ::std::move(from); + } + inline EnumDescriptorProto& operator=(EnumDescriptorProto&& from) noexcept { + if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + #endif inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { return _internal_metadata_.unknown_fields(); } - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { return _internal_metadata_.mutable_unknown_fields(); } + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { + return MaybeArenaPtr(); + } static const ::google::protobuf::Descriptor* descriptor(); static const EnumDescriptorProto& default_instance(); + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY static inline const EnumDescriptorProto* internal_default_instance() { return reinterpret_cast<const EnumDescriptorProto*>( &_EnumDescriptorProto_default_instance_); } static PROTOBUF_CONSTEXPR int const kIndexInFileMessages = - 7; + 9; + void UnsafeArenaSwap(EnumDescriptorProto* other); void Swap(EnumDescriptorProto* other); + friend void swap(EnumDescriptorProto& a, EnumDescriptorProto& b) { + a.Swap(&b); + } // implements Message ---------------------------------------------- - inline EnumDescriptorProto* New() const PROTOBUF_FINAL { return New(NULL); } + inline EnumDescriptorProto* New() const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<EnumDescriptorProto>(NULL); + } - EnumDescriptorProto* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + EnumDescriptorProto* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<EnumDescriptorProto>(arena); + } void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const EnumDescriptorProto& from); @@ -1533,12 +2332,17 @@ class LIBPROTOBUF_EXPORT EnumDescriptorProto : public ::google::protobuf::Messag void SharedDtor(); void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(EnumDescriptorProto* other); + protected: + explicit EnumDescriptorProto(::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 NULL; + return _internal_metadata_.arena(); } inline void* MaybeArenaPtr() const { - return NULL; + return _internal_metadata_.raw_arena_ptr(); } public: @@ -1546,20 +2350,56 @@ class LIBPROTOBUF_EXPORT EnumDescriptorProto : public ::google::protobuf::Messag // nested types ---------------------------------------------------- + typedef EnumDescriptorProto_EnumReservedRange EnumReservedRange; + // accessors ------------------------------------------------------- // repeated .google.protobuf.EnumValueDescriptorProto value = 2; int value_size() const; void clear_value(); static const int kValueFieldNumber = 2; - const ::google::protobuf::EnumValueDescriptorProto& value(int index) const; ::google::protobuf::EnumValueDescriptorProto* mutable_value(int index); - ::google::protobuf::EnumValueDescriptorProto* add_value(); ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumValueDescriptorProto >* mutable_value(); + const ::google::protobuf::EnumValueDescriptorProto& value(int index) const; + ::google::protobuf::EnumValueDescriptorProto* add_value(); const ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumValueDescriptorProto >& value() const; + // repeated .google.protobuf.EnumDescriptorProto.EnumReservedRange reserved_range = 4; + int reserved_range_size() const; + void clear_reserved_range(); + static const int kReservedRangeFieldNumber = 4; + ::google::protobuf::EnumDescriptorProto_EnumReservedRange* mutable_reserved_range(int index); + ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumDescriptorProto_EnumReservedRange >* + mutable_reserved_range(); + const ::google::protobuf::EnumDescriptorProto_EnumReservedRange& reserved_range(int index) const; + ::google::protobuf::EnumDescriptorProto_EnumReservedRange* add_reserved_range(); + const ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumDescriptorProto_EnumReservedRange >& + reserved_range() const; + + // repeated string reserved_name = 5; + int reserved_name_size() const; + void clear_reserved_name(); + static const int kReservedNameFieldNumber = 5; + const ::std::string& reserved_name(int index) const; + ::std::string* mutable_reserved_name(int index); + void set_reserved_name(int index, const ::std::string& value); + #if LANG_CXX11 + void set_reserved_name(int index, ::std::string&& value); + #endif + void set_reserved_name(int index, const char* value); + void set_reserved_name(int index, const char* value, size_t size); + ::std::string* add_reserved_name(); + void add_reserved_name(const ::std::string& value); + #if LANG_CXX11 + void add_reserved_name(::std::string&& value); + #endif + void add_reserved_name(const char* value); + void add_reserved_name(const char* value, size_t size); + const ::google::protobuf::RepeatedPtrField< ::std::string>& reserved_name() const; + ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_reserved_name(); + // optional string name = 1; bool has_name() const; void clear_name(); @@ -1574,15 +2414,27 @@ class LIBPROTOBUF_EXPORT EnumDescriptorProto : public ::google::protobuf::Messag ::std::string* mutable_name(); ::std::string* release_name(); void set_allocated_name(::std::string* name); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + ::std::string* unsafe_arena_release_name(); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + void unsafe_arena_set_allocated_name( + ::std::string* name); // optional .google.protobuf.EnumOptions options = 3; bool has_options() const; void clear_options(); static const int kOptionsFieldNumber = 3; const ::google::protobuf::EnumOptions& options() const; - ::google::protobuf::EnumOptions* mutable_options(); ::google::protobuf::EnumOptions* release_options(); + ::google::protobuf::EnumOptions* mutable_options(); void set_allocated_options(::google::protobuf::EnumOptions* options); + void unsafe_arena_set_allocated_options( + ::google::protobuf::EnumOptions* options); + ::google::protobuf::EnumOptions* unsafe_arena_release_options(); // @@protoc_insertion_point(class_scope:google.protobuf.EnumDescriptorProto) private: @@ -1592,12 +2444,18 @@ class LIBPROTOBUF_EXPORT EnumDescriptorProto : public ::google::protobuf::Messag void clear_has_options(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + template <typename T> friend class ::google::protobuf::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumValueDescriptorProto > value_; + ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumDescriptorProto_EnumReservedRange > reserved_range_; + ::google::protobuf::RepeatedPtrField< ::std::string> reserved_name_; ::google::protobuf::internal::ArenaStringPtr name_; ::google::protobuf::EnumOptions* options_; - friend struct protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend struct ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend void ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsEnumDescriptorProtoImpl(); }; // ------------------------------------------------------------------- @@ -1612,32 +2470,60 @@ class LIBPROTOBUF_EXPORT EnumValueDescriptorProto : public ::google::protobuf::M CopyFrom(from); return *this; } + #if LANG_CXX11 + EnumValueDescriptorProto(EnumValueDescriptorProto&& from) noexcept + : EnumValueDescriptorProto() { + *this = ::std::move(from); + } + inline EnumValueDescriptorProto& operator=(EnumValueDescriptorProto&& from) noexcept { + if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + #endif inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { return _internal_metadata_.unknown_fields(); } - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { return _internal_metadata_.mutable_unknown_fields(); } + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { + return MaybeArenaPtr(); + } static const ::google::protobuf::Descriptor* descriptor(); static const EnumValueDescriptorProto& default_instance(); + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY static inline const EnumValueDescriptorProto* internal_default_instance() { return reinterpret_cast<const EnumValueDescriptorProto*>( &_EnumValueDescriptorProto_default_instance_); } static PROTOBUF_CONSTEXPR int const kIndexInFileMessages = - 8; + 10; + void UnsafeArenaSwap(EnumValueDescriptorProto* other); void Swap(EnumValueDescriptorProto* other); + friend void swap(EnumValueDescriptorProto& a, EnumValueDescriptorProto& b) { + a.Swap(&b); + } // implements Message ---------------------------------------------- - inline EnumValueDescriptorProto* New() const PROTOBUF_FINAL { return New(NULL); } + inline EnumValueDescriptorProto* New() const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<EnumValueDescriptorProto>(NULL); + } - EnumValueDescriptorProto* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + EnumValueDescriptorProto* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<EnumValueDescriptorProto>(arena); + } void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const EnumValueDescriptorProto& from); @@ -1658,12 +2544,17 @@ class LIBPROTOBUF_EXPORT EnumValueDescriptorProto : public ::google::protobuf::M void SharedDtor(); void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(EnumValueDescriptorProto* other); + protected: + explicit EnumValueDescriptorProto(::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 NULL; + return _internal_metadata_.arena(); } inline void* MaybeArenaPtr() const { - return NULL; + return _internal_metadata_.raw_arena_ptr(); } public: @@ -1687,15 +2578,27 @@ class LIBPROTOBUF_EXPORT EnumValueDescriptorProto : public ::google::protobuf::M ::std::string* mutable_name(); ::std::string* release_name(); void set_allocated_name(::std::string* name); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + ::std::string* unsafe_arena_release_name(); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + void unsafe_arena_set_allocated_name( + ::std::string* name); // optional .google.protobuf.EnumValueOptions options = 3; bool has_options() const; void clear_options(); static const int kOptionsFieldNumber = 3; const ::google::protobuf::EnumValueOptions& options() const; - ::google::protobuf::EnumValueOptions* mutable_options(); ::google::protobuf::EnumValueOptions* release_options(); + ::google::protobuf::EnumValueOptions* mutable_options(); void set_allocated_options(::google::protobuf::EnumValueOptions* options); + void unsafe_arena_set_allocated_options( + ::google::protobuf::EnumValueOptions* options); + ::google::protobuf::EnumValueOptions* unsafe_arena_release_options(); // optional int32 number = 2; bool has_number() const; @@ -1714,12 +2617,16 @@ class LIBPROTOBUF_EXPORT EnumValueDescriptorProto : public ::google::protobuf::M void clear_has_options(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + template <typename T> friend class ::google::protobuf::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; ::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 struct protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend struct ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend void ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsEnumValueDescriptorProtoImpl(); }; // ------------------------------------------------------------------- @@ -1734,32 +2641,60 @@ class LIBPROTOBUF_EXPORT ServiceDescriptorProto : public ::google::protobuf::Mes CopyFrom(from); return *this; } + #if LANG_CXX11 + ServiceDescriptorProto(ServiceDescriptorProto&& from) noexcept + : ServiceDescriptorProto() { + *this = ::std::move(from); + } + inline ServiceDescriptorProto& operator=(ServiceDescriptorProto&& from) noexcept { + if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + #endif inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { return _internal_metadata_.unknown_fields(); } - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { return _internal_metadata_.mutable_unknown_fields(); } + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { + return MaybeArenaPtr(); + } static const ::google::protobuf::Descriptor* descriptor(); static const ServiceDescriptorProto& default_instance(); + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY static inline const ServiceDescriptorProto* internal_default_instance() { return reinterpret_cast<const ServiceDescriptorProto*>( &_ServiceDescriptorProto_default_instance_); } static PROTOBUF_CONSTEXPR int const kIndexInFileMessages = - 9; + 11; + void UnsafeArenaSwap(ServiceDescriptorProto* other); void Swap(ServiceDescriptorProto* other); + friend void swap(ServiceDescriptorProto& a, ServiceDescriptorProto& b) { + a.Swap(&b); + } // implements Message ---------------------------------------------- - inline ServiceDescriptorProto* New() const PROTOBUF_FINAL { return New(NULL); } + inline ServiceDescriptorProto* New() const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<ServiceDescriptorProto>(NULL); + } - ServiceDescriptorProto* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + ServiceDescriptorProto* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<ServiceDescriptorProto>(arena); + } void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const ServiceDescriptorProto& from); @@ -1780,12 +2715,17 @@ class LIBPROTOBUF_EXPORT ServiceDescriptorProto : public ::google::protobuf::Mes void SharedDtor(); void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(ServiceDescriptorProto* other); + protected: + explicit ServiceDescriptorProto(::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 NULL; + return _internal_metadata_.arena(); } inline void* MaybeArenaPtr() const { - return NULL; + return _internal_metadata_.raw_arena_ptr(); } public: @@ -1799,11 +2739,11 @@ class LIBPROTOBUF_EXPORT ServiceDescriptorProto : public ::google::protobuf::Mes int method_size() const; void clear_method(); static const int kMethodFieldNumber = 2; - const ::google::protobuf::MethodDescriptorProto& method(int index) const; ::google::protobuf::MethodDescriptorProto* mutable_method(int index); - ::google::protobuf::MethodDescriptorProto* add_method(); ::google::protobuf::RepeatedPtrField< ::google::protobuf::MethodDescriptorProto >* mutable_method(); + const ::google::protobuf::MethodDescriptorProto& method(int index) const; + ::google::protobuf::MethodDescriptorProto* add_method(); const ::google::protobuf::RepeatedPtrField< ::google::protobuf::MethodDescriptorProto >& method() const; @@ -1821,15 +2761,27 @@ class LIBPROTOBUF_EXPORT ServiceDescriptorProto : public ::google::protobuf::Mes ::std::string* mutable_name(); ::std::string* release_name(); void set_allocated_name(::std::string* name); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + ::std::string* unsafe_arena_release_name(); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + void unsafe_arena_set_allocated_name( + ::std::string* name); // optional .google.protobuf.ServiceOptions options = 3; bool has_options() const; void clear_options(); static const int kOptionsFieldNumber = 3; const ::google::protobuf::ServiceOptions& options() const; - ::google::protobuf::ServiceOptions* mutable_options(); ::google::protobuf::ServiceOptions* release_options(); + ::google::protobuf::ServiceOptions* mutable_options(); void set_allocated_options(::google::protobuf::ServiceOptions* options); + void unsafe_arena_set_allocated_options( + ::google::protobuf::ServiceOptions* options); + ::google::protobuf::ServiceOptions* unsafe_arena_release_options(); // @@protoc_insertion_point(class_scope:google.protobuf.ServiceDescriptorProto) private: @@ -1839,12 +2791,16 @@ class LIBPROTOBUF_EXPORT ServiceDescriptorProto : public ::google::protobuf::Mes void clear_has_options(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + template <typename T> friend class ::google::protobuf::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::MethodDescriptorProto > method_; ::google::protobuf::internal::ArenaStringPtr name_; ::google::protobuf::ServiceOptions* options_; - friend struct protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend struct ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend void ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsServiceDescriptorProtoImpl(); }; // ------------------------------------------------------------------- @@ -1859,32 +2815,60 @@ class LIBPROTOBUF_EXPORT MethodDescriptorProto : public ::google::protobuf::Mess CopyFrom(from); return *this; } + #if LANG_CXX11 + MethodDescriptorProto(MethodDescriptorProto&& from) noexcept + : MethodDescriptorProto() { + *this = ::std::move(from); + } + inline MethodDescriptorProto& operator=(MethodDescriptorProto&& from) noexcept { + if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + #endif inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { return _internal_metadata_.unknown_fields(); } - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { return _internal_metadata_.mutable_unknown_fields(); } + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { + return MaybeArenaPtr(); + } static const ::google::protobuf::Descriptor* descriptor(); static const MethodDescriptorProto& default_instance(); + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY static inline const MethodDescriptorProto* internal_default_instance() { return reinterpret_cast<const MethodDescriptorProto*>( &_MethodDescriptorProto_default_instance_); } static PROTOBUF_CONSTEXPR int const kIndexInFileMessages = - 10; + 12; + void UnsafeArenaSwap(MethodDescriptorProto* other); void Swap(MethodDescriptorProto* other); + friend void swap(MethodDescriptorProto& a, MethodDescriptorProto& b) { + a.Swap(&b); + } // implements Message ---------------------------------------------- - inline MethodDescriptorProto* New() const PROTOBUF_FINAL { return New(NULL); } + inline MethodDescriptorProto* New() const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<MethodDescriptorProto>(NULL); + } - MethodDescriptorProto* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + MethodDescriptorProto* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<MethodDescriptorProto>(arena); + } void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const MethodDescriptorProto& from); @@ -1905,12 +2889,17 @@ class LIBPROTOBUF_EXPORT MethodDescriptorProto : public ::google::protobuf::Mess void SharedDtor(); void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(MethodDescriptorProto* other); + protected: + explicit MethodDescriptorProto(::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 NULL; + return _internal_metadata_.arena(); } inline void* MaybeArenaPtr() const { - return NULL; + return _internal_metadata_.raw_arena_ptr(); } public: @@ -1934,6 +2923,15 @@ class LIBPROTOBUF_EXPORT MethodDescriptorProto : public ::google::protobuf::Mess ::std::string* mutable_name(); ::std::string* release_name(); void set_allocated_name(::std::string* name); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + ::std::string* unsafe_arena_release_name(); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + void unsafe_arena_set_allocated_name( + ::std::string* name); // optional string input_type = 2; bool has_input_type() const; @@ -1949,6 +2947,15 @@ class LIBPROTOBUF_EXPORT MethodDescriptorProto : public ::google::protobuf::Mess ::std::string* mutable_input_type(); ::std::string* release_input_type(); void set_allocated_input_type(::std::string* input_type); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + ::std::string* unsafe_arena_release_input_type(); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + void unsafe_arena_set_allocated_input_type( + ::std::string* input_type); // optional string output_type = 3; bool has_output_type() const; @@ -1964,15 +2971,27 @@ class LIBPROTOBUF_EXPORT MethodDescriptorProto : public ::google::protobuf::Mess ::std::string* mutable_output_type(); ::std::string* release_output_type(); void set_allocated_output_type(::std::string* output_type); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + ::std::string* unsafe_arena_release_output_type(); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + void unsafe_arena_set_allocated_output_type( + ::std::string* output_type); // optional .google.protobuf.MethodOptions options = 4; bool has_options() const; void clear_options(); static const int kOptionsFieldNumber = 4; const ::google::protobuf::MethodOptions& options() const; - ::google::protobuf::MethodOptions* mutable_options(); ::google::protobuf::MethodOptions* release_options(); + ::google::protobuf::MethodOptions* mutable_options(); void set_allocated_options(::google::protobuf::MethodOptions* options); + void unsafe_arena_set_allocated_options( + ::google::protobuf::MethodOptions* options); + ::google::protobuf::MethodOptions* unsafe_arena_release_options(); // optional bool client_streaming = 5 [default = false]; bool has_client_streaming() const; @@ -2004,6 +3023,9 @@ class LIBPROTOBUF_EXPORT MethodDescriptorProto : public ::google::protobuf::Mess void clear_has_server_streaming(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + template <typename T> friend class ::google::protobuf::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::internal::ArenaStringPtr name_; @@ -2012,7 +3034,8 @@ class LIBPROTOBUF_EXPORT MethodDescriptorProto : public ::google::protobuf::Mess ::google::protobuf::MethodOptions* options_; bool client_streaming_; bool server_streaming_; - friend struct protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend struct ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend void ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsMethodDescriptorProtoImpl(); }; // ------------------------------------------------------------------- @@ -2027,32 +3050,60 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p CopyFrom(from); return *this; } + #if LANG_CXX11 + FileOptions(FileOptions&& from) noexcept + : FileOptions() { + *this = ::std::move(from); + } + inline FileOptions& operator=(FileOptions&& from) noexcept { + if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + #endif inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { return _internal_metadata_.unknown_fields(); } - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { return _internal_metadata_.mutable_unknown_fields(); } + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { + return MaybeArenaPtr(); + } static const ::google::protobuf::Descriptor* descriptor(); static const FileOptions& default_instance(); + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY static inline const FileOptions* internal_default_instance() { return reinterpret_cast<const FileOptions*>( &_FileOptions_default_instance_); } static PROTOBUF_CONSTEXPR int const kIndexInFileMessages = - 11; + 13; + void UnsafeArenaSwap(FileOptions* other); void Swap(FileOptions* other); + friend void swap(FileOptions& a, FileOptions& b) { + a.Swap(&b); + } // implements Message ---------------------------------------------- - inline FileOptions* New() const PROTOBUF_FINAL { return New(NULL); } + inline FileOptions* New() const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<FileOptions>(NULL); + } - FileOptions* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + FileOptions* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<FileOptions>(arena); + } void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const FileOptions& from); @@ -2073,12 +3124,17 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p void SharedDtor(); void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(FileOptions* other); + protected: + explicit FileOptions(::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 NULL; + return _internal_metadata_.arena(); } inline void* MaybeArenaPtr() const { - return NULL; + return _internal_metadata_.raw_arena_ptr(); } public: @@ -2120,11 +3176,11 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p int uninterpreted_option_size() const; void clear_uninterpreted_option(); static const int kUninterpretedOptionFieldNumber = 999; - const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const; ::google::protobuf::UninterpretedOption* mutable_uninterpreted_option(int index); - ::google::protobuf::UninterpretedOption* add_uninterpreted_option(); ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >* mutable_uninterpreted_option(); + const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const; + ::google::protobuf::UninterpretedOption* add_uninterpreted_option(); const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >& uninterpreted_option() const; @@ -2142,6 +3198,15 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p ::std::string* mutable_java_package(); ::std::string* release_java_package(); void set_allocated_java_package(::std::string* java_package); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + ::std::string* unsafe_arena_release_java_package(); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + void unsafe_arena_set_allocated_java_package( + ::std::string* java_package); // optional string java_outer_classname = 8; bool has_java_outer_classname() const; @@ -2157,6 +3222,15 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p ::std::string* mutable_java_outer_classname(); ::std::string* release_java_outer_classname(); void set_allocated_java_outer_classname(::std::string* java_outer_classname); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + ::std::string* unsafe_arena_release_java_outer_classname(); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + void unsafe_arena_set_allocated_java_outer_classname( + ::std::string* java_outer_classname); // optional string go_package = 11; bool has_go_package() const; @@ -2172,6 +3246,15 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p ::std::string* mutable_go_package(); ::std::string* release_go_package(); void set_allocated_go_package(::std::string* go_package); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + ::std::string* unsafe_arena_release_go_package(); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + void unsafe_arena_set_allocated_go_package( + ::std::string* go_package); // optional string objc_class_prefix = 36; bool has_objc_class_prefix() const; @@ -2187,6 +3270,15 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p ::std::string* mutable_objc_class_prefix(); ::std::string* release_objc_class_prefix(); void set_allocated_objc_class_prefix(::std::string* objc_class_prefix); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + ::std::string* unsafe_arena_release_objc_class_prefix(); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + void unsafe_arena_set_allocated_objc_class_prefix( + ::std::string* objc_class_prefix); // optional string csharp_namespace = 37; bool has_csharp_namespace() const; @@ -2202,6 +3294,15 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p ::std::string* mutable_csharp_namespace(); ::std::string* release_csharp_namespace(); void set_allocated_csharp_namespace(::std::string* csharp_namespace); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + ::std::string* unsafe_arena_release_csharp_namespace(); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + void unsafe_arena_set_allocated_csharp_namespace( + ::std::string* csharp_namespace); // optional string swift_prefix = 39; bool has_swift_prefix() const; @@ -2217,6 +3318,15 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p ::std::string* mutable_swift_prefix(); ::std::string* release_swift_prefix(); void set_allocated_swift_prefix(::std::string* swift_prefix); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + ::std::string* unsafe_arena_release_swift_prefix(); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + void unsafe_arena_set_allocated_swift_prefix( + ::std::string* swift_prefix); // optional string php_class_prefix = 40; bool has_php_class_prefix() const; @@ -2232,6 +3342,15 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p ::std::string* mutable_php_class_prefix(); ::std::string* release_php_class_prefix(); void set_allocated_php_class_prefix(::std::string* php_class_prefix); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + ::std::string* unsafe_arena_release_php_class_prefix(); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + void unsafe_arena_set_allocated_php_class_prefix( + ::std::string* php_class_prefix); // optional string php_namespace = 41; bool has_php_namespace() const; @@ -2247,6 +3366,22 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p ::std::string* mutable_php_namespace(); ::std::string* release_php_namespace(); void set_allocated_php_namespace(::std::string* php_namespace); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + ::std::string* unsafe_arena_release_php_namespace(); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + void unsafe_arena_set_allocated_php_namespace( + ::std::string* php_namespace); + + // optional bool cc_enable_arenas = 31 [default = false]; + bool has_cc_enable_arenas() const; + void clear_cc_enable_arenas(); + static const int kCcEnableArenasFieldNumber = 31; + bool cc_enable_arenas() const; + void set_cc_enable_arenas(bool value); // optional bool java_multiple_files = 10 [default = false]; bool has_java_multiple_files() const; @@ -2290,6 +3425,13 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p bool py_generic_services() const; void set_py_generic_services(bool value); + // optional bool php_generic_services = 42 [default = false]; + bool has_php_generic_services() const; + void clear_php_generic_services(); + static const int kPhpGenericServicesFieldNumber = 42; + bool php_generic_services() const; + void set_php_generic_services(bool value); + // optional bool deprecated = 23 [default = false]; bool has_deprecated() const; void clear_deprecated(); @@ -2297,13 +3439,6 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p bool deprecated() const; void set_deprecated(bool value); - // optional bool cc_enable_arenas = 31 [default = false]; - bool has_cc_enable_arenas() const; - void clear_cc_enable_arenas(); - static const int kCcEnableArenasFieldNumber = 31; - bool cc_enable_arenas() const; - void set_cc_enable_arenas(bool value); - // optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED]; bool has_optimize_for() const; void clear_optimize_for(); @@ -2334,6 +3469,8 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p void clear_has_java_generic_services(); void set_has_py_generic_services(); void clear_has_py_generic_services(); + void set_has_php_generic_services(); + void clear_has_php_generic_services(); void set_has_deprecated(); void clear_has_deprecated(); void set_has_cc_enable_arenas(); @@ -2352,6 +3489,9 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p ::google::protobuf::internal::ExtensionSet _extensions_; ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + template <typename T> friend class ::google::protobuf::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; @@ -2363,16 +3503,18 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p ::google::protobuf::internal::ArenaStringPtr swift_prefix_; ::google::protobuf::internal::ArenaStringPtr php_class_prefix_; ::google::protobuf::internal::ArenaStringPtr php_namespace_; + bool cc_enable_arenas_; bool java_multiple_files_; bool java_generate_equals_and_hash_; bool java_string_check_utf8_; bool cc_generic_services_; bool java_generic_services_; bool py_generic_services_; + bool php_generic_services_; bool deprecated_; - bool cc_enable_arenas_; int optimize_for_; - friend struct protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend struct ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend void ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsFileOptionsImpl(); }; // ------------------------------------------------------------------- @@ -2387,32 +3529,60 @@ class LIBPROTOBUF_EXPORT MessageOptions : public ::google::protobuf::Message /* CopyFrom(from); return *this; } + #if LANG_CXX11 + MessageOptions(MessageOptions&& from) noexcept + : MessageOptions() { + *this = ::std::move(from); + } + inline MessageOptions& operator=(MessageOptions&& from) noexcept { + if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + #endif inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { return _internal_metadata_.unknown_fields(); } - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { return _internal_metadata_.mutable_unknown_fields(); } + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { + return MaybeArenaPtr(); + } static const ::google::protobuf::Descriptor* descriptor(); static const MessageOptions& default_instance(); + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY static inline const MessageOptions* internal_default_instance() { return reinterpret_cast<const MessageOptions*>( &_MessageOptions_default_instance_); } static PROTOBUF_CONSTEXPR int const kIndexInFileMessages = - 12; + 14; + void UnsafeArenaSwap(MessageOptions* other); void Swap(MessageOptions* other); + friend void swap(MessageOptions& a, MessageOptions& b) { + a.Swap(&b); + } // implements Message ---------------------------------------------- - inline MessageOptions* New() const PROTOBUF_FINAL { return New(NULL); } + inline MessageOptions* New() const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<MessageOptions>(NULL); + } - MessageOptions* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + MessageOptions* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<MessageOptions>(arena); + } void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const MessageOptions& from); @@ -2433,12 +3603,17 @@ class LIBPROTOBUF_EXPORT MessageOptions : public ::google::protobuf::Message /* void SharedDtor(); void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(MessageOptions* other); + protected: + explicit MessageOptions(::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 NULL; + return _internal_metadata_.arena(); } inline void* MaybeArenaPtr() const { - return NULL; + return _internal_metadata_.raw_arena_ptr(); } public: @@ -2452,11 +3627,11 @@ class LIBPROTOBUF_EXPORT MessageOptions : public ::google::protobuf::Message /* int uninterpreted_option_size() const; void clear_uninterpreted_option(); static const int kUninterpretedOptionFieldNumber = 999; - const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const; ::google::protobuf::UninterpretedOption* mutable_uninterpreted_option(int index); - ::google::protobuf::UninterpretedOption* add_uninterpreted_option(); ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >* mutable_uninterpreted_option(); + const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const; + ::google::protobuf::UninterpretedOption* add_uninterpreted_option(); const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >& uninterpreted_option() const; @@ -2503,6 +3678,9 @@ class LIBPROTOBUF_EXPORT MessageOptions : public ::google::protobuf::Message /* ::google::protobuf::internal::ExtensionSet _extensions_; ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + template <typename T> friend class ::google::protobuf::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; @@ -2510,7 +3688,8 @@ class LIBPROTOBUF_EXPORT MessageOptions : public ::google::protobuf::Message /* bool no_standard_descriptor_accessor_; bool deprecated_; bool map_entry_; - friend struct protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend struct ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend void ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsMessageOptionsImpl(); }; // ------------------------------------------------------------------- @@ -2525,32 +3704,60 @@ class LIBPROTOBUF_EXPORT FieldOptions : public ::google::protobuf::Message /* @@ CopyFrom(from); return *this; } + #if LANG_CXX11 + FieldOptions(FieldOptions&& from) noexcept + : FieldOptions() { + *this = ::std::move(from); + } + inline FieldOptions& operator=(FieldOptions&& from) noexcept { + if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + #endif inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { return _internal_metadata_.unknown_fields(); } - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { return _internal_metadata_.mutable_unknown_fields(); } + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { + return MaybeArenaPtr(); + } static const ::google::protobuf::Descriptor* descriptor(); static const FieldOptions& default_instance(); + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY static inline const FieldOptions* internal_default_instance() { return reinterpret_cast<const FieldOptions*>( &_FieldOptions_default_instance_); } static PROTOBUF_CONSTEXPR int const kIndexInFileMessages = - 13; + 15; + void UnsafeArenaSwap(FieldOptions* other); void Swap(FieldOptions* other); + friend void swap(FieldOptions& a, FieldOptions& b) { + a.Swap(&b); + } // implements Message ---------------------------------------------- - inline FieldOptions* New() const PROTOBUF_FINAL { return New(NULL); } + inline FieldOptions* New() const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<FieldOptions>(NULL); + } - FieldOptions* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + FieldOptions* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<FieldOptions>(arena); + } void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const FieldOptions& from); @@ -2571,12 +3778,17 @@ class LIBPROTOBUF_EXPORT FieldOptions : public ::google::protobuf::Message /* @@ void SharedDtor(); void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(FieldOptions* other); + protected: + explicit FieldOptions(::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 NULL; + return _internal_metadata_.arena(); } inline void* MaybeArenaPtr() const { - return NULL; + return _internal_metadata_.raw_arena_ptr(); } public: @@ -2646,11 +3858,11 @@ class LIBPROTOBUF_EXPORT FieldOptions : public ::google::protobuf::Message /* @@ int uninterpreted_option_size() const; void clear_uninterpreted_option(); static const int kUninterpretedOptionFieldNumber = 999; - const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const; ::google::protobuf::UninterpretedOption* mutable_uninterpreted_option(int index); - ::google::protobuf::UninterpretedOption* add_uninterpreted_option(); ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >* mutable_uninterpreted_option(); + const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const; + ::google::protobuf::UninterpretedOption* add_uninterpreted_option(); const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >& uninterpreted_option() const; @@ -2715,6 +3927,9 @@ class LIBPROTOBUF_EXPORT FieldOptions : public ::google::protobuf::Message /* @@ ::google::protobuf::internal::ExtensionSet _extensions_; ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + template <typename T> friend class ::google::protobuf::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; @@ -2724,7 +3939,8 @@ class LIBPROTOBUF_EXPORT FieldOptions : public ::google::protobuf::Message /* @@ bool deprecated_; bool weak_; int jstype_; - friend struct protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend struct ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend void ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsFieldOptionsImpl(); }; // ------------------------------------------------------------------- @@ -2739,32 +3955,60 @@ class LIBPROTOBUF_EXPORT OneofOptions : public ::google::protobuf::Message /* @@ CopyFrom(from); return *this; } + #if LANG_CXX11 + OneofOptions(OneofOptions&& from) noexcept + : OneofOptions() { + *this = ::std::move(from); + } + inline OneofOptions& operator=(OneofOptions&& from) noexcept { + if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + #endif inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { return _internal_metadata_.unknown_fields(); } - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { return _internal_metadata_.mutable_unknown_fields(); } + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { + return MaybeArenaPtr(); + } static const ::google::protobuf::Descriptor* descriptor(); static const OneofOptions& default_instance(); + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY static inline const OneofOptions* internal_default_instance() { return reinterpret_cast<const OneofOptions*>( &_OneofOptions_default_instance_); } static PROTOBUF_CONSTEXPR int const kIndexInFileMessages = - 14; + 16; + void UnsafeArenaSwap(OneofOptions* other); void Swap(OneofOptions* other); + friend void swap(OneofOptions& a, OneofOptions& b) { + a.Swap(&b); + } // implements Message ---------------------------------------------- - inline OneofOptions* New() const PROTOBUF_FINAL { return New(NULL); } + inline OneofOptions* New() const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<OneofOptions>(NULL); + } - OneofOptions* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + OneofOptions* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<OneofOptions>(arena); + } void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const OneofOptions& from); @@ -2785,12 +4029,17 @@ class LIBPROTOBUF_EXPORT OneofOptions : public ::google::protobuf::Message /* @@ void SharedDtor(); void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(OneofOptions* other); + protected: + explicit OneofOptions(::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 NULL; + return _internal_metadata_.arena(); } inline void* MaybeArenaPtr() const { - return NULL; + return _internal_metadata_.raw_arena_ptr(); } public: @@ -2804,11 +4053,11 @@ class LIBPROTOBUF_EXPORT OneofOptions : public ::google::protobuf::Message /* @@ int uninterpreted_option_size() const; void clear_uninterpreted_option(); static const int kUninterpretedOptionFieldNumber = 999; - const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const; ::google::protobuf::UninterpretedOption* mutable_uninterpreted_option(int index); - ::google::protobuf::UninterpretedOption* add_uninterpreted_option(); ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >* mutable_uninterpreted_option(); + const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const; + ::google::protobuf::UninterpretedOption* add_uninterpreted_option(); const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >& uninterpreted_option() const; @@ -2819,10 +4068,14 @@ class LIBPROTOBUF_EXPORT OneofOptions : public ::google::protobuf::Message /* @@ ::google::protobuf::internal::ExtensionSet _extensions_; ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + template <typename T> friend class ::google::protobuf::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; - friend struct protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend struct ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend void ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsOneofOptionsImpl(); }; // ------------------------------------------------------------------- @@ -2837,32 +4090,60 @@ class LIBPROTOBUF_EXPORT EnumOptions : public ::google::protobuf::Message /* @@p CopyFrom(from); return *this; } + #if LANG_CXX11 + EnumOptions(EnumOptions&& from) noexcept + : EnumOptions() { + *this = ::std::move(from); + } + inline EnumOptions& operator=(EnumOptions&& from) noexcept { + if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + #endif inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { return _internal_metadata_.unknown_fields(); } - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { return _internal_metadata_.mutable_unknown_fields(); } + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { + return MaybeArenaPtr(); + } static const ::google::protobuf::Descriptor* descriptor(); static const EnumOptions& default_instance(); + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY static inline const EnumOptions* internal_default_instance() { return reinterpret_cast<const EnumOptions*>( &_EnumOptions_default_instance_); } static PROTOBUF_CONSTEXPR int const kIndexInFileMessages = - 15; + 17; + void UnsafeArenaSwap(EnumOptions* other); void Swap(EnumOptions* other); + friend void swap(EnumOptions& a, EnumOptions& b) { + a.Swap(&b); + } // implements Message ---------------------------------------------- - inline EnumOptions* New() const PROTOBUF_FINAL { return New(NULL); } + inline EnumOptions* New() const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<EnumOptions>(NULL); + } - EnumOptions* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + EnumOptions* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<EnumOptions>(arena); + } void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const EnumOptions& from); @@ -2883,12 +4164,17 @@ class LIBPROTOBUF_EXPORT EnumOptions : public ::google::protobuf::Message /* @@p void SharedDtor(); void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(EnumOptions* other); + protected: + explicit EnumOptions(::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 NULL; + return _internal_metadata_.arena(); } inline void* MaybeArenaPtr() const { - return NULL; + return _internal_metadata_.raw_arena_ptr(); } public: @@ -2902,11 +4188,11 @@ class LIBPROTOBUF_EXPORT EnumOptions : public ::google::protobuf::Message /* @@p int uninterpreted_option_size() const; void clear_uninterpreted_option(); static const int kUninterpretedOptionFieldNumber = 999; - const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const; ::google::protobuf::UninterpretedOption* mutable_uninterpreted_option(int index); - ::google::protobuf::UninterpretedOption* add_uninterpreted_option(); ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >* mutable_uninterpreted_option(); + const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const; + ::google::protobuf::UninterpretedOption* add_uninterpreted_option(); const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >& uninterpreted_option() const; @@ -2935,12 +4221,16 @@ class LIBPROTOBUF_EXPORT EnumOptions : public ::google::protobuf::Message /* @@p ::google::protobuf::internal::ExtensionSet _extensions_; ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + template <typename T> friend class ::google::protobuf::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; ::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 struct protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend struct ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend void ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsEnumOptionsImpl(); }; // ------------------------------------------------------------------- @@ -2955,32 +4245,60 @@ class LIBPROTOBUF_EXPORT EnumValueOptions : public ::google::protobuf::Message / CopyFrom(from); return *this; } + #if LANG_CXX11 + EnumValueOptions(EnumValueOptions&& from) noexcept + : EnumValueOptions() { + *this = ::std::move(from); + } + inline EnumValueOptions& operator=(EnumValueOptions&& from) noexcept { + if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + #endif inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { return _internal_metadata_.unknown_fields(); } - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { return _internal_metadata_.mutable_unknown_fields(); } + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { + return MaybeArenaPtr(); + } static const ::google::protobuf::Descriptor* descriptor(); static const EnumValueOptions& default_instance(); + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY static inline const EnumValueOptions* internal_default_instance() { return reinterpret_cast<const EnumValueOptions*>( &_EnumValueOptions_default_instance_); } static PROTOBUF_CONSTEXPR int const kIndexInFileMessages = - 16; + 18; + void UnsafeArenaSwap(EnumValueOptions* other); void Swap(EnumValueOptions* other); + friend void swap(EnumValueOptions& a, EnumValueOptions& b) { + a.Swap(&b); + } // implements Message ---------------------------------------------- - inline EnumValueOptions* New() const PROTOBUF_FINAL { return New(NULL); } + inline EnumValueOptions* New() const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<EnumValueOptions>(NULL); + } - EnumValueOptions* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + EnumValueOptions* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<EnumValueOptions>(arena); + } void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const EnumValueOptions& from); @@ -3001,12 +4319,17 @@ class LIBPROTOBUF_EXPORT EnumValueOptions : public ::google::protobuf::Message / void SharedDtor(); void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(EnumValueOptions* other); + protected: + explicit EnumValueOptions(::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 NULL; + return _internal_metadata_.arena(); } inline void* MaybeArenaPtr() const { - return NULL; + return _internal_metadata_.raw_arena_ptr(); } public: @@ -3020,11 +4343,11 @@ class LIBPROTOBUF_EXPORT EnumValueOptions : public ::google::protobuf::Message / int uninterpreted_option_size() const; void clear_uninterpreted_option(); static const int kUninterpretedOptionFieldNumber = 999; - const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const; ::google::protobuf::UninterpretedOption* mutable_uninterpreted_option(int index); - ::google::protobuf::UninterpretedOption* add_uninterpreted_option(); ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >* mutable_uninterpreted_option(); + const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const; + ::google::protobuf::UninterpretedOption* add_uninterpreted_option(); const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >& uninterpreted_option() const; @@ -3044,11 +4367,15 @@ class LIBPROTOBUF_EXPORT EnumValueOptions : public ::google::protobuf::Message / ::google::protobuf::internal::ExtensionSet _extensions_; ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + template <typename T> friend class ::google::protobuf::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; bool deprecated_; - friend struct protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend struct ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend void ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsEnumValueOptionsImpl(); }; // ------------------------------------------------------------------- @@ -3063,32 +4390,60 @@ class LIBPROTOBUF_EXPORT ServiceOptions : public ::google::protobuf::Message /* CopyFrom(from); return *this; } + #if LANG_CXX11 + ServiceOptions(ServiceOptions&& from) noexcept + : ServiceOptions() { + *this = ::std::move(from); + } + inline ServiceOptions& operator=(ServiceOptions&& from) noexcept { + if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + #endif inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { return _internal_metadata_.unknown_fields(); } - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { return _internal_metadata_.mutable_unknown_fields(); } + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { + return MaybeArenaPtr(); + } static const ::google::protobuf::Descriptor* descriptor(); static const ServiceOptions& default_instance(); + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY static inline const ServiceOptions* internal_default_instance() { return reinterpret_cast<const ServiceOptions*>( &_ServiceOptions_default_instance_); } static PROTOBUF_CONSTEXPR int const kIndexInFileMessages = - 17; + 19; + void UnsafeArenaSwap(ServiceOptions* other); void Swap(ServiceOptions* other); + friend void swap(ServiceOptions& a, ServiceOptions& b) { + a.Swap(&b); + } // implements Message ---------------------------------------------- - inline ServiceOptions* New() const PROTOBUF_FINAL { return New(NULL); } + inline ServiceOptions* New() const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<ServiceOptions>(NULL); + } - ServiceOptions* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + ServiceOptions* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<ServiceOptions>(arena); + } void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const ServiceOptions& from); @@ -3109,12 +4464,17 @@ class LIBPROTOBUF_EXPORT ServiceOptions : public ::google::protobuf::Message /* void SharedDtor(); void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(ServiceOptions* other); + protected: + explicit ServiceOptions(::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 NULL; + return _internal_metadata_.arena(); } inline void* MaybeArenaPtr() const { - return NULL; + return _internal_metadata_.raw_arena_ptr(); } public: @@ -3128,11 +4488,11 @@ class LIBPROTOBUF_EXPORT ServiceOptions : public ::google::protobuf::Message /* int uninterpreted_option_size() const; void clear_uninterpreted_option(); static const int kUninterpretedOptionFieldNumber = 999; - const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const; ::google::protobuf::UninterpretedOption* mutable_uninterpreted_option(int index); - ::google::protobuf::UninterpretedOption* add_uninterpreted_option(); ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >* mutable_uninterpreted_option(); + const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const; + ::google::protobuf::UninterpretedOption* add_uninterpreted_option(); const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >& uninterpreted_option() const; @@ -3152,11 +4512,15 @@ class LIBPROTOBUF_EXPORT ServiceOptions : public ::google::protobuf::Message /* ::google::protobuf::internal::ExtensionSet _extensions_; ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + template <typename T> friend class ::google::protobuf::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; bool deprecated_; - friend struct protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend struct ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend void ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsServiceOptionsImpl(); }; // ------------------------------------------------------------------- @@ -3171,32 +4535,60 @@ class LIBPROTOBUF_EXPORT MethodOptions : public ::google::protobuf::Message /* @ CopyFrom(from); return *this; } + #if LANG_CXX11 + MethodOptions(MethodOptions&& from) noexcept + : MethodOptions() { + *this = ::std::move(from); + } + inline MethodOptions& operator=(MethodOptions&& from) noexcept { + if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + #endif inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { return _internal_metadata_.unknown_fields(); } - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { return _internal_metadata_.mutable_unknown_fields(); } + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { + return MaybeArenaPtr(); + } static const ::google::protobuf::Descriptor* descriptor(); static const MethodOptions& default_instance(); + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY static inline const MethodOptions* internal_default_instance() { return reinterpret_cast<const MethodOptions*>( &_MethodOptions_default_instance_); } static PROTOBUF_CONSTEXPR int const kIndexInFileMessages = - 18; + 20; + void UnsafeArenaSwap(MethodOptions* other); void Swap(MethodOptions* other); + friend void swap(MethodOptions& a, MethodOptions& b) { + a.Swap(&b); + } // implements Message ---------------------------------------------- - inline MethodOptions* New() const PROTOBUF_FINAL { return New(NULL); } + inline MethodOptions* New() const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<MethodOptions>(NULL); + } - MethodOptions* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + MethodOptions* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<MethodOptions>(arena); + } void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const MethodOptions& from); @@ -3217,12 +4609,17 @@ class LIBPROTOBUF_EXPORT MethodOptions : public ::google::protobuf::Message /* @ void SharedDtor(); void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(MethodOptions* other); + protected: + explicit MethodOptions(::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 NULL; + return _internal_metadata_.arena(); } inline void* MaybeArenaPtr() const { - return NULL; + return _internal_metadata_.raw_arena_ptr(); } public: @@ -3264,11 +4661,11 @@ class LIBPROTOBUF_EXPORT MethodOptions : public ::google::protobuf::Message /* @ int uninterpreted_option_size() const; void clear_uninterpreted_option(); static const int kUninterpretedOptionFieldNumber = 999; - const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const; ::google::protobuf::UninterpretedOption* mutable_uninterpreted_option(int index); - ::google::protobuf::UninterpretedOption* add_uninterpreted_option(); ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >* mutable_uninterpreted_option(); + const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const; + ::google::protobuf::UninterpretedOption* add_uninterpreted_option(); const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >& uninterpreted_option() const; @@ -3297,12 +4694,16 @@ class LIBPROTOBUF_EXPORT MethodOptions : public ::google::protobuf::Message /* @ ::google::protobuf::internal::ExtensionSet _extensions_; ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + template <typename T> friend class ::google::protobuf::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; bool deprecated_; int idempotency_level_; - friend struct protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend struct ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend void ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsMethodOptionsImpl(); }; // ------------------------------------------------------------------- @@ -3317,32 +4718,60 @@ class LIBPROTOBUF_EXPORT UninterpretedOption_NamePart : public ::google::protobu CopyFrom(from); return *this; } + #if LANG_CXX11 + UninterpretedOption_NamePart(UninterpretedOption_NamePart&& from) noexcept + : UninterpretedOption_NamePart() { + *this = ::std::move(from); + } + inline UninterpretedOption_NamePart& operator=(UninterpretedOption_NamePart&& from) noexcept { + if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + #endif inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { return _internal_metadata_.unknown_fields(); } - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { return _internal_metadata_.mutable_unknown_fields(); } + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { + return MaybeArenaPtr(); + } static const ::google::protobuf::Descriptor* descriptor(); static const UninterpretedOption_NamePart& default_instance(); + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY static inline const UninterpretedOption_NamePart* internal_default_instance() { return reinterpret_cast<const UninterpretedOption_NamePart*>( &_UninterpretedOption_NamePart_default_instance_); } static PROTOBUF_CONSTEXPR int const kIndexInFileMessages = - 19; + 21; + void UnsafeArenaSwap(UninterpretedOption_NamePart* other); void Swap(UninterpretedOption_NamePart* other); + friend void swap(UninterpretedOption_NamePart& a, UninterpretedOption_NamePart& b) { + a.Swap(&b); + } // implements Message ---------------------------------------------- - inline UninterpretedOption_NamePart* New() const PROTOBUF_FINAL { return New(NULL); } + inline UninterpretedOption_NamePart* New() const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<UninterpretedOption_NamePart>(NULL); + } - UninterpretedOption_NamePart* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + UninterpretedOption_NamePart* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<UninterpretedOption_NamePart>(arena); + } void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const UninterpretedOption_NamePart& from); @@ -3363,12 +4792,17 @@ class LIBPROTOBUF_EXPORT UninterpretedOption_NamePart : public ::google::protobu void SharedDtor(); void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(UninterpretedOption_NamePart* other); + protected: + explicit UninterpretedOption_NamePart(::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 NULL; + return _internal_metadata_.arena(); } inline void* MaybeArenaPtr() const { - return NULL; + return _internal_metadata_.raw_arena_ptr(); } public: @@ -3392,6 +4826,15 @@ class LIBPROTOBUF_EXPORT UninterpretedOption_NamePart : public ::google::protobu ::std::string* mutable_name_part(); ::std::string* release_name_part(); void set_allocated_name_part(::std::string* name_part); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + ::std::string* unsafe_arena_release_name_part(); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + void unsafe_arena_set_allocated_name_part( + ::std::string* name_part); // required bool is_extension = 2; bool has_is_extension() const; @@ -3411,11 +4854,15 @@ class LIBPROTOBUF_EXPORT UninterpretedOption_NamePart : public ::google::protobu size_t RequiredFieldsByteSizeFallback() const; ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + template <typename T> friend class ::google::protobuf::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::internal::ArenaStringPtr name_part_; bool is_extension_; - friend struct protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend struct ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend void ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsUninterpretedOption_NamePartImpl(); }; // ------------------------------------------------------------------- @@ -3430,32 +4877,60 @@ class LIBPROTOBUF_EXPORT UninterpretedOption : public ::google::protobuf::Messag CopyFrom(from); return *this; } + #if LANG_CXX11 + UninterpretedOption(UninterpretedOption&& from) noexcept + : UninterpretedOption() { + *this = ::std::move(from); + } + inline UninterpretedOption& operator=(UninterpretedOption&& from) noexcept { + if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + #endif inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { return _internal_metadata_.unknown_fields(); } - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { return _internal_metadata_.mutable_unknown_fields(); } + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { + return MaybeArenaPtr(); + } static const ::google::protobuf::Descriptor* descriptor(); static const UninterpretedOption& default_instance(); + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY static inline const UninterpretedOption* internal_default_instance() { return reinterpret_cast<const UninterpretedOption*>( &_UninterpretedOption_default_instance_); } static PROTOBUF_CONSTEXPR int const kIndexInFileMessages = - 20; + 22; + void UnsafeArenaSwap(UninterpretedOption* other); void Swap(UninterpretedOption* other); + friend void swap(UninterpretedOption& a, UninterpretedOption& b) { + a.Swap(&b); + } // implements Message ---------------------------------------------- - inline UninterpretedOption* New() const PROTOBUF_FINAL { return New(NULL); } + inline UninterpretedOption* New() const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<UninterpretedOption>(NULL); + } - UninterpretedOption* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + UninterpretedOption* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<UninterpretedOption>(arena); + } void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const UninterpretedOption& from); @@ -3476,12 +4951,17 @@ class LIBPROTOBUF_EXPORT UninterpretedOption : public ::google::protobuf::Messag void SharedDtor(); void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(UninterpretedOption* other); + protected: + explicit UninterpretedOption(::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 NULL; + return _internal_metadata_.arena(); } inline void* MaybeArenaPtr() const { - return NULL; + return _internal_metadata_.raw_arena_ptr(); } public: @@ -3497,11 +4977,11 @@ class LIBPROTOBUF_EXPORT UninterpretedOption : public ::google::protobuf::Messag int name_size() const; void clear_name(); static const int kNameFieldNumber = 2; - const ::google::protobuf::UninterpretedOption_NamePart& name(int index) const; ::google::protobuf::UninterpretedOption_NamePart* mutable_name(int index); - ::google::protobuf::UninterpretedOption_NamePart* add_name(); ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption_NamePart >* mutable_name(); + const ::google::protobuf::UninterpretedOption_NamePart& name(int index) const; + ::google::protobuf::UninterpretedOption_NamePart* add_name(); const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption_NamePart >& name() const; @@ -3519,6 +4999,15 @@ class LIBPROTOBUF_EXPORT UninterpretedOption : public ::google::protobuf::Messag ::std::string* mutable_identifier_value(); ::std::string* release_identifier_value(); void set_allocated_identifier_value(::std::string* identifier_value); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + ::std::string* unsafe_arena_release_identifier_value(); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + void unsafe_arena_set_allocated_identifier_value( + ::std::string* identifier_value); // optional bytes string_value = 7; bool has_string_value() const; @@ -3534,6 +5023,15 @@ class LIBPROTOBUF_EXPORT UninterpretedOption : public ::google::protobuf::Messag ::std::string* mutable_string_value(); ::std::string* release_string_value(); void set_allocated_string_value(::std::string* string_value); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + ::std::string* unsafe_arena_release_string_value(); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + void unsafe_arena_set_allocated_string_value( + ::std::string* string_value); // optional string aggregate_value = 8; bool has_aggregate_value() const; @@ -3549,6 +5047,15 @@ class LIBPROTOBUF_EXPORT UninterpretedOption : public ::google::protobuf::Messag ::std::string* mutable_aggregate_value(); ::std::string* release_aggregate_value(); void set_allocated_aggregate_value(::std::string* aggregate_value); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + ::std::string* unsafe_arena_release_aggregate_value(); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + void unsafe_arena_set_allocated_aggregate_value( + ::std::string* aggregate_value); // optional uint64 positive_int_value = 4; bool has_positive_int_value() const; @@ -3587,6 +5094,9 @@ class LIBPROTOBUF_EXPORT UninterpretedOption : public ::google::protobuf::Messag void clear_has_aggregate_value(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + template <typename T> friend class ::google::protobuf::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption_NamePart > name_; @@ -3596,7 +5106,8 @@ class LIBPROTOBUF_EXPORT UninterpretedOption : public ::google::protobuf::Messag ::google::protobuf::uint64 positive_int_value_; ::google::protobuf::int64 negative_int_value_; double double_value_; - friend struct protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend struct ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend void ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsUninterpretedOptionImpl(); }; // ------------------------------------------------------------------- @@ -3611,32 +5122,60 @@ class LIBPROTOBUF_EXPORT SourceCodeInfo_Location : public ::google::protobuf::Me CopyFrom(from); return *this; } + #if LANG_CXX11 + SourceCodeInfo_Location(SourceCodeInfo_Location&& from) noexcept + : SourceCodeInfo_Location() { + *this = ::std::move(from); + } + inline SourceCodeInfo_Location& operator=(SourceCodeInfo_Location&& from) noexcept { + if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + #endif inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { return _internal_metadata_.unknown_fields(); } - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { return _internal_metadata_.mutable_unknown_fields(); } + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { + return MaybeArenaPtr(); + } static const ::google::protobuf::Descriptor* descriptor(); static const SourceCodeInfo_Location& default_instance(); + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY static inline const SourceCodeInfo_Location* internal_default_instance() { return reinterpret_cast<const SourceCodeInfo_Location*>( &_SourceCodeInfo_Location_default_instance_); } static PROTOBUF_CONSTEXPR int const kIndexInFileMessages = - 21; + 23; + void UnsafeArenaSwap(SourceCodeInfo_Location* other); void Swap(SourceCodeInfo_Location* other); + friend void swap(SourceCodeInfo_Location& a, SourceCodeInfo_Location& b) { + a.Swap(&b); + } // implements Message ---------------------------------------------- - inline SourceCodeInfo_Location* New() const PROTOBUF_FINAL { return New(NULL); } + inline SourceCodeInfo_Location* New() const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<SourceCodeInfo_Location>(NULL); + } - SourceCodeInfo_Location* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + SourceCodeInfo_Location* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<SourceCodeInfo_Location>(arena); + } void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const SourceCodeInfo_Location& from); @@ -3657,12 +5196,17 @@ class LIBPROTOBUF_EXPORT SourceCodeInfo_Location : public ::google::protobuf::Me void SharedDtor(); void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(SourceCodeInfo_Location* other); + protected: + explicit SourceCodeInfo_Location(::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 NULL; + return _internal_metadata_.arena(); } inline void* MaybeArenaPtr() const { - return NULL; + return _internal_metadata_.raw_arena_ptr(); } public: @@ -3732,6 +5276,15 @@ class LIBPROTOBUF_EXPORT SourceCodeInfo_Location : public ::google::protobuf::Me ::std::string* mutable_leading_comments(); ::std::string* release_leading_comments(); void set_allocated_leading_comments(::std::string* leading_comments); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + ::std::string* unsafe_arena_release_leading_comments(); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + void unsafe_arena_set_allocated_leading_comments( + ::std::string* leading_comments); // optional string trailing_comments = 4; bool has_trailing_comments() const; @@ -3747,6 +5300,15 @@ class LIBPROTOBUF_EXPORT SourceCodeInfo_Location : public ::google::protobuf::Me ::std::string* mutable_trailing_comments(); ::std::string* release_trailing_comments(); void set_allocated_trailing_comments(::std::string* trailing_comments); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + ::std::string* unsafe_arena_release_trailing_comments(); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + void unsafe_arena_set_allocated_trailing_comments( + ::std::string* trailing_comments); // @@protoc_insertion_point(class_scope:google.protobuf.SourceCodeInfo.Location) private: @@ -3756,6 +5318,9 @@ class LIBPROTOBUF_EXPORT SourceCodeInfo_Location : public ::google::protobuf::Me void clear_has_trailing_comments(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + template <typename T> friend class ::google::protobuf::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::RepeatedField< ::google::protobuf::int32 > path_; @@ -3765,7 +5330,8 @@ class LIBPROTOBUF_EXPORT SourceCodeInfo_Location : public ::google::protobuf::Me ::google::protobuf::RepeatedPtrField< ::std::string> leading_detached_comments_; ::google::protobuf::internal::ArenaStringPtr leading_comments_; ::google::protobuf::internal::ArenaStringPtr trailing_comments_; - friend struct protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend struct ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend void ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsSourceCodeInfo_LocationImpl(); }; // ------------------------------------------------------------------- @@ -3780,32 +5346,60 @@ class LIBPROTOBUF_EXPORT SourceCodeInfo : public ::google::protobuf::Message /* CopyFrom(from); return *this; } + #if LANG_CXX11 + SourceCodeInfo(SourceCodeInfo&& from) noexcept + : SourceCodeInfo() { + *this = ::std::move(from); + } + inline SourceCodeInfo& operator=(SourceCodeInfo&& from) noexcept { + if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + #endif inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { return _internal_metadata_.unknown_fields(); } - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { return _internal_metadata_.mutable_unknown_fields(); } + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { + return MaybeArenaPtr(); + } static const ::google::protobuf::Descriptor* descriptor(); static const SourceCodeInfo& default_instance(); + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY static inline const SourceCodeInfo* internal_default_instance() { return reinterpret_cast<const SourceCodeInfo*>( &_SourceCodeInfo_default_instance_); } static PROTOBUF_CONSTEXPR int const kIndexInFileMessages = - 22; + 24; + void UnsafeArenaSwap(SourceCodeInfo* other); void Swap(SourceCodeInfo* other); + friend void swap(SourceCodeInfo& a, SourceCodeInfo& b) { + a.Swap(&b); + } // implements Message ---------------------------------------------- - inline SourceCodeInfo* New() const PROTOBUF_FINAL { return New(NULL); } + inline SourceCodeInfo* New() const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<SourceCodeInfo>(NULL); + } - SourceCodeInfo* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + SourceCodeInfo* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<SourceCodeInfo>(arena); + } void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const SourceCodeInfo& from); @@ -3826,12 +5420,17 @@ class LIBPROTOBUF_EXPORT SourceCodeInfo : public ::google::protobuf::Message /* void SharedDtor(); void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(SourceCodeInfo* other); + protected: + explicit SourceCodeInfo(::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 NULL; + return _internal_metadata_.arena(); } inline void* MaybeArenaPtr() const { - return NULL; + return _internal_metadata_.raw_arena_ptr(); } public: @@ -3847,11 +5446,11 @@ class LIBPROTOBUF_EXPORT SourceCodeInfo : public ::google::protobuf::Message /* int location_size() const; void clear_location(); static const int kLocationFieldNumber = 1; - const ::google::protobuf::SourceCodeInfo_Location& location(int index) const; ::google::protobuf::SourceCodeInfo_Location* mutable_location(int index); - ::google::protobuf::SourceCodeInfo_Location* add_location(); ::google::protobuf::RepeatedPtrField< ::google::protobuf::SourceCodeInfo_Location >* mutable_location(); + const ::google::protobuf::SourceCodeInfo_Location& location(int index) const; + ::google::protobuf::SourceCodeInfo_Location* add_location(); const ::google::protobuf::RepeatedPtrField< ::google::protobuf::SourceCodeInfo_Location >& location() const; @@ -3859,10 +5458,14 @@ class LIBPROTOBUF_EXPORT SourceCodeInfo : public ::google::protobuf::Message /* private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + template <typename T> friend class ::google::protobuf::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::SourceCodeInfo_Location > location_; - friend struct protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend struct ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend void ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsSourceCodeInfoImpl(); }; // ------------------------------------------------------------------- @@ -3877,32 +5480,60 @@ class LIBPROTOBUF_EXPORT GeneratedCodeInfo_Annotation : public ::google::protobu CopyFrom(from); return *this; } + #if LANG_CXX11 + GeneratedCodeInfo_Annotation(GeneratedCodeInfo_Annotation&& from) noexcept + : GeneratedCodeInfo_Annotation() { + *this = ::std::move(from); + } + inline GeneratedCodeInfo_Annotation& operator=(GeneratedCodeInfo_Annotation&& from) noexcept { + if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + #endif inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { return _internal_metadata_.unknown_fields(); } - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { return _internal_metadata_.mutable_unknown_fields(); } + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { + return MaybeArenaPtr(); + } static const ::google::protobuf::Descriptor* descriptor(); static const GeneratedCodeInfo_Annotation& default_instance(); + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY static inline const GeneratedCodeInfo_Annotation* internal_default_instance() { return reinterpret_cast<const GeneratedCodeInfo_Annotation*>( &_GeneratedCodeInfo_Annotation_default_instance_); } static PROTOBUF_CONSTEXPR int const kIndexInFileMessages = - 23; + 25; + void UnsafeArenaSwap(GeneratedCodeInfo_Annotation* other); void Swap(GeneratedCodeInfo_Annotation* other); + friend void swap(GeneratedCodeInfo_Annotation& a, GeneratedCodeInfo_Annotation& b) { + a.Swap(&b); + } // implements Message ---------------------------------------------- - inline GeneratedCodeInfo_Annotation* New() const PROTOBUF_FINAL { return New(NULL); } + inline GeneratedCodeInfo_Annotation* New() const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<GeneratedCodeInfo_Annotation>(NULL); + } - GeneratedCodeInfo_Annotation* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + GeneratedCodeInfo_Annotation* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<GeneratedCodeInfo_Annotation>(arena); + } void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const GeneratedCodeInfo_Annotation& from); @@ -3923,12 +5554,17 @@ class LIBPROTOBUF_EXPORT GeneratedCodeInfo_Annotation : public ::google::protobu void SharedDtor(); void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(GeneratedCodeInfo_Annotation* other); + protected: + explicit GeneratedCodeInfo_Annotation(::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 NULL; + return _internal_metadata_.arena(); } inline void* MaybeArenaPtr() const { - return NULL; + return _internal_metadata_.raw_arena_ptr(); } public: @@ -3964,6 +5600,15 @@ class LIBPROTOBUF_EXPORT GeneratedCodeInfo_Annotation : public ::google::protobu ::std::string* mutable_source_file(); ::std::string* release_source_file(); void set_allocated_source_file(::std::string* source_file); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + ::std::string* unsafe_arena_release_source_file(); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + void unsafe_arena_set_allocated_source_file( + ::std::string* source_file); // optional int32 begin = 3; bool has_begin() const; @@ -3989,6 +5634,9 @@ class LIBPROTOBUF_EXPORT GeneratedCodeInfo_Annotation : public ::google::protobu void clear_has_end(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + template <typename T> friend class ::google::protobuf::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::RepeatedField< ::google::protobuf::int32 > path_; @@ -3996,7 +5644,8 @@ class LIBPROTOBUF_EXPORT GeneratedCodeInfo_Annotation : public ::google::protobu ::google::protobuf::internal::ArenaStringPtr source_file_; ::google::protobuf::int32 begin_; ::google::protobuf::int32 end_; - friend struct protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend struct ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend void ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsGeneratedCodeInfo_AnnotationImpl(); }; // ------------------------------------------------------------------- @@ -4011,32 +5660,60 @@ class LIBPROTOBUF_EXPORT GeneratedCodeInfo : public ::google::protobuf::Message CopyFrom(from); return *this; } + #if LANG_CXX11 + GeneratedCodeInfo(GeneratedCodeInfo&& from) noexcept + : GeneratedCodeInfo() { + *this = ::std::move(from); + } + inline GeneratedCodeInfo& operator=(GeneratedCodeInfo&& from) noexcept { + if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + #endif inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { return _internal_metadata_.unknown_fields(); } - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { return _internal_metadata_.mutable_unknown_fields(); } + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { + return MaybeArenaPtr(); + } static const ::google::protobuf::Descriptor* descriptor(); static const GeneratedCodeInfo& default_instance(); + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY static inline const GeneratedCodeInfo* internal_default_instance() { return reinterpret_cast<const GeneratedCodeInfo*>( &_GeneratedCodeInfo_default_instance_); } static PROTOBUF_CONSTEXPR int const kIndexInFileMessages = - 24; + 26; + void UnsafeArenaSwap(GeneratedCodeInfo* other); void Swap(GeneratedCodeInfo* other); + friend void swap(GeneratedCodeInfo& a, GeneratedCodeInfo& b) { + a.Swap(&b); + } // implements Message ---------------------------------------------- - inline GeneratedCodeInfo* New() const PROTOBUF_FINAL { return New(NULL); } + inline GeneratedCodeInfo* New() const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<GeneratedCodeInfo>(NULL); + } - GeneratedCodeInfo* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + GeneratedCodeInfo* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<GeneratedCodeInfo>(arena); + } void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const GeneratedCodeInfo& from); @@ -4057,12 +5734,17 @@ class LIBPROTOBUF_EXPORT GeneratedCodeInfo : public ::google::protobuf::Message void SharedDtor(); void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(GeneratedCodeInfo* other); + protected: + explicit GeneratedCodeInfo(::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 NULL; + return _internal_metadata_.arena(); } inline void* MaybeArenaPtr() const { - return NULL; + return _internal_metadata_.raw_arena_ptr(); } public: @@ -4078,11 +5760,11 @@ class LIBPROTOBUF_EXPORT GeneratedCodeInfo : public ::google::protobuf::Message int annotation_size() const; void clear_annotation(); static const int kAnnotationFieldNumber = 1; - const ::google::protobuf::GeneratedCodeInfo_Annotation& annotation(int index) const; ::google::protobuf::GeneratedCodeInfo_Annotation* mutable_annotation(int index); - ::google::protobuf::GeneratedCodeInfo_Annotation* add_annotation(); ::google::protobuf::RepeatedPtrField< ::google::protobuf::GeneratedCodeInfo_Annotation >* mutable_annotation(); + const ::google::protobuf::GeneratedCodeInfo_Annotation& annotation(int index) const; + ::google::protobuf::GeneratedCodeInfo_Annotation* add_annotation(); const ::google::protobuf::RepeatedPtrField< ::google::protobuf::GeneratedCodeInfo_Annotation >& annotation() const; @@ -4090,17 +5772,24 @@ class LIBPROTOBUF_EXPORT GeneratedCodeInfo : public ::google::protobuf::Message private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + template <typename T> friend class ::google::protobuf::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::GeneratedCodeInfo_Annotation > annotation_; - friend struct protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend struct ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend void ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaultsGeneratedCodeInfoImpl(); }; // =================================================================== // =================================================================== -#if !PROTOBUF_INLINE_NOT_IN_HEADERS +#ifdef __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif // __GNUC__ // FileDescriptorSet // repeated .google.protobuf.FileDescriptorProto file = 1; @@ -4110,23 +5799,23 @@ inline int FileDescriptorSet::file_size() const { inline void FileDescriptorSet::clear_file() { file_.Clear(); } -inline const ::google::protobuf::FileDescriptorProto& FileDescriptorSet::file(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorSet.file) - return file_.Get(index); -} inline ::google::protobuf::FileDescriptorProto* FileDescriptorSet::mutable_file(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorSet.file) return file_.Mutable(index); } -inline ::google::protobuf::FileDescriptorProto* FileDescriptorSet::add_file() { - // @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorSet.file) - return file_.Add(); -} inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto >* FileDescriptorSet::mutable_file() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.FileDescriptorSet.file) return &file_; } +inline const ::google::protobuf::FileDescriptorProto& FileDescriptorSet::file(int index) const { + // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorSet.file) + return file_.Get(index); +} +inline ::google::protobuf::FileDescriptorProto* FileDescriptorSet::add_file() { + // @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorSet.file) + return file_.Add(); +} inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto >& FileDescriptorSet::file() const { // @@protoc_insertion_point(field_list:google.protobuf.FileDescriptorSet.file) @@ -4148,47 +5837,49 @@ inline void FileDescriptorProto::clear_has_name() { _has_bits_[0] &= ~0x00000001u; } inline void FileDescriptorProto::clear_name() { - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); clear_has_name(); } inline const ::std::string& FileDescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.name) - return name_.GetNoArena(); + return name_.Get(); } inline void FileDescriptorProto::set_name(const ::std::string& value) { set_has_name(); - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.name) } #if LANG_CXX11 inline void FileDescriptorProto::set_name(::std::string&& value) { set_has_name(); - name_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + name_.Set( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileDescriptorProto.name) } #endif inline void FileDescriptorProto::set_name(const char* value) { GOOGLE_DCHECK(value != NULL); set_has_name(); - 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.FileDescriptorProto.name) } -inline void FileDescriptorProto::set_name(const char* value, size_t size) { +inline void FileDescriptorProto::set_name(const char* value, + size_t size) { set_has_name(); - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileDescriptorProto.name) } inline ::std::string* FileDescriptorProto::mutable_name() { set_has_name(); // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.name) - return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* FileDescriptorProto::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.FileDescriptorProto.name) clear_has_name(); - return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline void FileDescriptorProto::set_allocated_name(::std::string* name) { if (name != NULL) { @@ -4196,9 +5887,29 @@ inline void FileDescriptorProto::set_allocated_name(::std::string* name) { } else { clear_has_name(); } - name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name); + name_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name, + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileDescriptorProto.name) } +inline ::std::string* FileDescriptorProto::unsafe_arena_release_name() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.FileDescriptorProto.name) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + clear_has_name(); + return name_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); +} +inline void FileDescriptorProto::unsafe_arena_set_allocated_name( + ::std::string* name) { + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + if (name != NULL) { + set_has_name(); + } else { + clear_has_name(); + } + name_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + name, GetArenaNoVirtual()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.FileDescriptorProto.name) +} // optional string package = 2; inline bool FileDescriptorProto::has_package() const { @@ -4211,47 +5922,49 @@ inline void FileDescriptorProto::clear_has_package() { _has_bits_[0] &= ~0x00000002u; } inline void FileDescriptorProto::clear_package() { - package_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + package_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); clear_has_package(); } inline const ::std::string& FileDescriptorProto::package() const { // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.package) - return package_.GetNoArena(); + return package_.Get(); } inline void FileDescriptorProto::set_package(const ::std::string& value) { set_has_package(); - package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + package_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.package) } #if LANG_CXX11 inline void FileDescriptorProto::set_package(::std::string&& value) { set_has_package(); - package_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + package_.Set( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileDescriptorProto.package) } #endif inline void FileDescriptorProto::set_package(const char* value) { GOOGLE_DCHECK(value != NULL); set_has_package(); - package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + package_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.protobuf.FileDescriptorProto.package) } -inline void FileDescriptorProto::set_package(const char* value, size_t size) { +inline void FileDescriptorProto::set_package(const char* value, + size_t size) { set_has_package(); - package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); + package_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileDescriptorProto.package) } inline ::std::string* FileDescriptorProto::mutable_package() { set_has_package(); // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.package) - return package_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return package_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* FileDescriptorProto::release_package() { // @@protoc_insertion_point(field_release:google.protobuf.FileDescriptorProto.package) clear_has_package(); - return package_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return package_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline void FileDescriptorProto::set_allocated_package(::std::string* package) { if (package != NULL) { @@ -4259,9 +5972,29 @@ inline void FileDescriptorProto::set_allocated_package(::std::string* package) { } else { clear_has_package(); } - package_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), package); + package_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), package, + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileDescriptorProto.package) } +inline ::std::string* FileDescriptorProto::unsafe_arena_release_package() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.FileDescriptorProto.package) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + clear_has_package(); + return package_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); +} +inline void FileDescriptorProto::unsafe_arena_set_allocated_package( + ::std::string* package) { + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + if (package != NULL) { + set_has_package(); + } else { + clear_has_package(); + } + package_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + package, GetArenaNoVirtual()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.FileDescriptorProto.package) +} // repeated string dependency = 3; inline int FileDescriptorProto::dependency_size() const { @@ -4399,23 +6132,23 @@ inline int FileDescriptorProto::message_type_size() const { inline void FileDescriptorProto::clear_message_type() { message_type_.Clear(); } -inline const ::google::protobuf::DescriptorProto& FileDescriptorProto::message_type(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.message_type) - return message_type_.Get(index); -} inline ::google::protobuf::DescriptorProto* FileDescriptorProto::mutable_message_type(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.message_type) return message_type_.Mutable(index); } -inline ::google::protobuf::DescriptorProto* FileDescriptorProto::add_message_type() { - // @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.message_type) - return message_type_.Add(); -} inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto >* FileDescriptorProto::mutable_message_type() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.FileDescriptorProto.message_type) return &message_type_; } +inline const ::google::protobuf::DescriptorProto& FileDescriptorProto::message_type(int index) const { + // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.message_type) + return message_type_.Get(index); +} +inline ::google::protobuf::DescriptorProto* FileDescriptorProto::add_message_type() { + // @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.message_type) + return message_type_.Add(); +} inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto >& FileDescriptorProto::message_type() const { // @@protoc_insertion_point(field_list:google.protobuf.FileDescriptorProto.message_type) @@ -4429,23 +6162,23 @@ inline int FileDescriptorProto::enum_type_size() const { inline void FileDescriptorProto::clear_enum_type() { enum_type_.Clear(); } -inline const ::google::protobuf::EnumDescriptorProto& FileDescriptorProto::enum_type(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.enum_type) - return enum_type_.Get(index); -} inline ::google::protobuf::EnumDescriptorProto* FileDescriptorProto::mutable_enum_type(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.enum_type) return enum_type_.Mutable(index); } -inline ::google::protobuf::EnumDescriptorProto* FileDescriptorProto::add_enum_type() { - // @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.enum_type) - return enum_type_.Add(); -} inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumDescriptorProto >* FileDescriptorProto::mutable_enum_type() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.FileDescriptorProto.enum_type) return &enum_type_; } +inline const ::google::protobuf::EnumDescriptorProto& FileDescriptorProto::enum_type(int index) const { + // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.enum_type) + return enum_type_.Get(index); +} +inline ::google::protobuf::EnumDescriptorProto* FileDescriptorProto::add_enum_type() { + // @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.enum_type) + return enum_type_.Add(); +} inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumDescriptorProto >& FileDescriptorProto::enum_type() const { // @@protoc_insertion_point(field_list:google.protobuf.FileDescriptorProto.enum_type) @@ -4459,23 +6192,23 @@ inline int FileDescriptorProto::service_size() const { inline void FileDescriptorProto::clear_service() { service_.Clear(); } -inline const ::google::protobuf::ServiceDescriptorProto& FileDescriptorProto::service(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.service) - return service_.Get(index); -} inline ::google::protobuf::ServiceDescriptorProto* FileDescriptorProto::mutable_service(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.service) return service_.Mutable(index); } -inline ::google::protobuf::ServiceDescriptorProto* FileDescriptorProto::add_service() { - // @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.service) - return service_.Add(); -} inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::ServiceDescriptorProto >* FileDescriptorProto::mutable_service() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.FileDescriptorProto.service) return &service_; } +inline const ::google::protobuf::ServiceDescriptorProto& FileDescriptorProto::service(int index) const { + // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.service) + return service_.Get(index); +} +inline ::google::protobuf::ServiceDescriptorProto* FileDescriptorProto::add_service() { + // @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.service) + return service_.Add(); +} inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::ServiceDescriptorProto >& FileDescriptorProto::service() const { // @@protoc_insertion_point(field_list:google.protobuf.FileDescriptorProto.service) @@ -4489,23 +6222,23 @@ inline int FileDescriptorProto::extension_size() const { inline void FileDescriptorProto::clear_extension() { extension_.Clear(); } -inline const ::google::protobuf::FieldDescriptorProto& FileDescriptorProto::extension(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.extension) - return extension_.Get(index); -} inline ::google::protobuf::FieldDescriptorProto* FileDescriptorProto::mutable_extension(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.extension) return extension_.Mutable(index); } -inline ::google::protobuf::FieldDescriptorProto* FileDescriptorProto::add_extension() { - // @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.extension) - return extension_.Add(); -} inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >* FileDescriptorProto::mutable_extension() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.FileDescriptorProto.extension) return &extension_; } +inline const ::google::protobuf::FieldDescriptorProto& FileDescriptorProto::extension(int index) const { + // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.extension) + return extension_.Get(index); +} +inline ::google::protobuf::FieldDescriptorProto* FileDescriptorProto::add_extension() { + // @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.extension) + return extension_.Add(); +} inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >& FileDescriptorProto::extension() const { // @@protoc_insertion_point(field_list:google.protobuf.FileDescriptorProto.extension) @@ -4523,37 +6256,58 @@ inline void FileDescriptorProto::clear_has_options() { _has_bits_[0] &= ~0x00000008u; } inline void FileDescriptorProto::clear_options() { - if (options_ != NULL) options_->::google::protobuf::FileOptions::Clear(); + if (options_ != NULL) options_->Clear(); clear_has_options(); } inline const ::google::protobuf::FileOptions& FileDescriptorProto::options() const { + const ::google::protobuf::FileOptions* p = options_; // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.options) - return options_ != NULL ? *options_ - : *::google::protobuf::FileOptions::internal_default_instance(); -} -inline ::google::protobuf::FileOptions* FileDescriptorProto::mutable_options() { - set_has_options(); - if (options_ == NULL) { - options_ = new ::google::protobuf::FileOptions; - } - // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.options) - return options_; + return p != NULL ? *p : *reinterpret_cast<const ::google::protobuf::FileOptions*>( + &::google::protobuf::_FileOptions_default_instance_); } inline ::google::protobuf::FileOptions* FileDescriptorProto::release_options() { // @@protoc_insertion_point(field_release:google.protobuf.FileDescriptorProto.options) clear_has_options(); ::google::protobuf::FileOptions* temp = options_; + if (GetArenaNoVirtual() != NULL) { + temp = ::google::protobuf::internal::DuplicateIfNonNull(temp, NULL); + } + options_ = NULL; + return temp; +} +inline ::google::protobuf::FileOptions* FileDescriptorProto::unsafe_arena_release_options() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.FileDescriptorProto.options) + clear_has_options(); + ::google::protobuf::FileOptions* temp = options_; options_ = NULL; return temp; } +inline ::google::protobuf::FileOptions* FileDescriptorProto::mutable_options() { + set_has_options(); + if (options_ == NULL) { + options_ = ::google::protobuf::Arena::CreateMessage< ::google::protobuf::FileOptions >( + GetArenaNoVirtual()); + } + // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.options) + return options_; +} inline void FileDescriptorProto::set_allocated_options(::google::protobuf::FileOptions* options) { - delete options_; - options_ = options; + ::google::protobuf::Arena* message_arena = GetArenaNoVirtual(); + if (message_arena == NULL) { + delete options_; + } if (options) { + ::google::protobuf::Arena* submessage_arena = + ::google::protobuf::Arena::GetArena(options); + if (message_arena != submessage_arena) { + options = ::google::protobuf::internal::GetOwnedMessage( + message_arena, options, submessage_arena); + } set_has_options(); } else { clear_has_options(); } + options_ = options; // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileDescriptorProto.options) } @@ -4568,37 +6322,58 @@ inline void FileDescriptorProto::clear_has_source_code_info() { _has_bits_[0] &= ~0x00000010u; } inline void FileDescriptorProto::clear_source_code_info() { - if (source_code_info_ != NULL) source_code_info_->::google::protobuf::SourceCodeInfo::Clear(); + if (source_code_info_ != NULL) source_code_info_->Clear(); clear_has_source_code_info(); } inline const ::google::protobuf::SourceCodeInfo& FileDescriptorProto::source_code_info() const { + const ::google::protobuf::SourceCodeInfo* p = source_code_info_; // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.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(); - if (source_code_info_ == NULL) { - source_code_info_ = new ::google::protobuf::SourceCodeInfo; - } - // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.source_code_info) - return source_code_info_; + return p != NULL ? *p : *reinterpret_cast<const ::google::protobuf::SourceCodeInfo*>( + &::google::protobuf::_SourceCodeInfo_default_instance_); } inline ::google::protobuf::SourceCodeInfo* FileDescriptorProto::release_source_code_info() { // @@protoc_insertion_point(field_release:google.protobuf.FileDescriptorProto.source_code_info) clear_has_source_code_info(); ::google::protobuf::SourceCodeInfo* temp = source_code_info_; + if (GetArenaNoVirtual() != NULL) { + temp = ::google::protobuf::internal::DuplicateIfNonNull(temp, NULL); + } source_code_info_ = NULL; return temp; } +inline ::google::protobuf::SourceCodeInfo* FileDescriptorProto::unsafe_arena_release_source_code_info() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.FileDescriptorProto.source_code_info) + clear_has_source_code_info(); + ::google::protobuf::SourceCodeInfo* temp = source_code_info_; + source_code_info_ = NULL; + return temp; +} +inline ::google::protobuf::SourceCodeInfo* FileDescriptorProto::mutable_source_code_info() { + set_has_source_code_info(); + if (source_code_info_ == NULL) { + source_code_info_ = ::google::protobuf::Arena::CreateMessage< ::google::protobuf::SourceCodeInfo >( + GetArenaNoVirtual()); + } + // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.source_code_info) + return source_code_info_; +} inline void FileDescriptorProto::set_allocated_source_code_info(::google::protobuf::SourceCodeInfo* source_code_info) { - delete source_code_info_; - source_code_info_ = source_code_info; + ::google::protobuf::Arena* message_arena = GetArenaNoVirtual(); + if (message_arena == NULL) { + delete source_code_info_; + } if (source_code_info) { + ::google::protobuf::Arena* submessage_arena = + ::google::protobuf::Arena::GetArena(source_code_info); + if (message_arena != submessage_arena) { + source_code_info = ::google::protobuf::internal::GetOwnedMessage( + message_arena, source_code_info, submessage_arena); + } set_has_source_code_info(); } else { clear_has_source_code_info(); } + source_code_info_ = source_code_info; // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileDescriptorProto.source_code_info) } @@ -4613,47 +6388,49 @@ inline void FileDescriptorProto::clear_has_syntax() { _has_bits_[0] &= ~0x00000004u; } inline void FileDescriptorProto::clear_syntax() { - syntax_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + syntax_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); clear_has_syntax(); } inline const ::std::string& FileDescriptorProto::syntax() const { // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.syntax) - return syntax_.GetNoArena(); + return syntax_.Get(); } inline void FileDescriptorProto::set_syntax(const ::std::string& value) { set_has_syntax(); - syntax_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + syntax_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.syntax) } #if LANG_CXX11 inline void FileDescriptorProto::set_syntax(::std::string&& value) { set_has_syntax(); - syntax_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + syntax_.Set( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileDescriptorProto.syntax) } #endif inline void FileDescriptorProto::set_syntax(const char* value) { GOOGLE_DCHECK(value != NULL); set_has_syntax(); - syntax_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + syntax_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.protobuf.FileDescriptorProto.syntax) } -inline void FileDescriptorProto::set_syntax(const char* value, size_t size) { +inline void FileDescriptorProto::set_syntax(const char* value, + size_t size) { set_has_syntax(); - syntax_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); + syntax_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileDescriptorProto.syntax) } inline ::std::string* FileDescriptorProto::mutable_syntax() { set_has_syntax(); // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.syntax) - return syntax_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return syntax_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* FileDescriptorProto::release_syntax() { // @@protoc_insertion_point(field_release:google.protobuf.FileDescriptorProto.syntax) clear_has_syntax(); - return syntax_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return syntax_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline void FileDescriptorProto::set_allocated_syntax(::std::string* syntax) { if (syntax != NULL) { @@ -4661,9 +6438,29 @@ inline void FileDescriptorProto::set_allocated_syntax(::std::string* syntax) { } else { clear_has_syntax(); } - syntax_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), syntax); + syntax_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), syntax, + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileDescriptorProto.syntax) } +inline ::std::string* FileDescriptorProto::unsafe_arena_release_syntax() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.FileDescriptorProto.syntax) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + clear_has_syntax(); + return syntax_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); +} +inline void FileDescriptorProto::unsafe_arena_set_allocated_syntax( + ::std::string* syntax) { + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + if (syntax != NULL) { + set_has_syntax(); + } else { + clear_has_syntax(); + } + syntax_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + syntax, GetArenaNoVirtual()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.FileDescriptorProto.syntax) +} // ------------------------------------------------------------------- @@ -4671,13 +6468,13 @@ inline void FileDescriptorProto::set_allocated_syntax(::std::string* syntax) { // optional int32 start = 1; inline bool DescriptorProto_ExtensionRange::has_start() const { - return (_has_bits_[0] & 0x00000001u) != 0; + return (_has_bits_[0] & 0x00000002u) != 0; } inline void DescriptorProto_ExtensionRange::set_has_start() { - _has_bits_[0] |= 0x00000001u; + _has_bits_[0] |= 0x00000002u; } inline void DescriptorProto_ExtensionRange::clear_has_start() { - _has_bits_[0] &= ~0x00000001u; + _has_bits_[0] &= ~0x00000002u; } inline void DescriptorProto_ExtensionRange::clear_start() { start_ = 0; @@ -4695,13 +6492,13 @@ inline void DescriptorProto_ExtensionRange::set_start(::google::protobuf::int32 // optional int32 end = 2; inline bool DescriptorProto_ExtensionRange::has_end() const { - return (_has_bits_[0] & 0x00000002u) != 0; + return (_has_bits_[0] & 0x00000004u) != 0; } inline void DescriptorProto_ExtensionRange::set_has_end() { - _has_bits_[0] |= 0x00000002u; + _has_bits_[0] |= 0x00000004u; } inline void DescriptorProto_ExtensionRange::clear_has_end() { - _has_bits_[0] &= ~0x00000002u; + _has_bits_[0] &= ~0x00000004u; } inline void DescriptorProto_ExtensionRange::clear_end() { end_ = 0; @@ -4717,6 +6514,72 @@ inline void DescriptorProto_ExtensionRange::set_end(::google::protobuf::int32 va // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.ExtensionRange.end) } +// optional .google.protobuf.ExtensionRangeOptions options = 3; +inline bool DescriptorProto_ExtensionRange::has_options() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +inline void DescriptorProto_ExtensionRange::set_has_options() { + _has_bits_[0] |= 0x00000001u; +} +inline void DescriptorProto_ExtensionRange::clear_has_options() { + _has_bits_[0] &= ~0x00000001u; +} +inline void DescriptorProto_ExtensionRange::clear_options() { + if (options_ != NULL) options_->Clear(); + clear_has_options(); +} +inline const ::google::protobuf::ExtensionRangeOptions& DescriptorProto_ExtensionRange::options() const { + const ::google::protobuf::ExtensionRangeOptions* p = options_; + // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.ExtensionRange.options) + return p != NULL ? *p : *reinterpret_cast<const ::google::protobuf::ExtensionRangeOptions*>( + &::google::protobuf::_ExtensionRangeOptions_default_instance_); +} +inline ::google::protobuf::ExtensionRangeOptions* DescriptorProto_ExtensionRange::release_options() { + // @@protoc_insertion_point(field_release:google.protobuf.DescriptorProto.ExtensionRange.options) + clear_has_options(); + ::google::protobuf::ExtensionRangeOptions* temp = options_; + if (GetArenaNoVirtual() != NULL) { + temp = ::google::protobuf::internal::DuplicateIfNonNull(temp, NULL); + } + options_ = NULL; + return temp; +} +inline ::google::protobuf::ExtensionRangeOptions* DescriptorProto_ExtensionRange::unsafe_arena_release_options() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.DescriptorProto.ExtensionRange.options) + clear_has_options(); + ::google::protobuf::ExtensionRangeOptions* temp = options_; + options_ = NULL; + return temp; +} +inline ::google::protobuf::ExtensionRangeOptions* DescriptorProto_ExtensionRange::mutable_options() { + set_has_options(); + if (options_ == NULL) { + options_ = ::google::protobuf::Arena::CreateMessage< ::google::protobuf::ExtensionRangeOptions >( + GetArenaNoVirtual()); + } + // @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.ExtensionRange.options) + return options_; +} +inline void DescriptorProto_ExtensionRange::set_allocated_options(::google::protobuf::ExtensionRangeOptions* options) { + ::google::protobuf::Arena* message_arena = GetArenaNoVirtual(); + if (message_arena == NULL) { + delete options_; + } + if (options) { + ::google::protobuf::Arena* submessage_arena = + ::google::protobuf::Arena::GetArena(options); + if (message_arena != submessage_arena) { + options = ::google::protobuf::internal::GetOwnedMessage( + message_arena, options, submessage_arena); + } + set_has_options(); + } else { + clear_has_options(); + } + options_ = options; + // @@protoc_insertion_point(field_set_allocated:google.protobuf.DescriptorProto.ExtensionRange.options) +} + // ------------------------------------------------------------------- // DescriptorProto_ReservedRange @@ -4784,47 +6647,49 @@ inline void DescriptorProto::clear_has_name() { _has_bits_[0] &= ~0x00000001u; } inline void DescriptorProto::clear_name() { - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); clear_has_name(); } inline const ::std::string& DescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.name) - return name_.GetNoArena(); + return name_.Get(); } inline void DescriptorProto::set_name(const ::std::string& value) { set_has_name(); - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.name) } #if LANG_CXX11 inline void DescriptorProto::set_name(::std::string&& value) { set_has_name(); - name_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + name_.Set( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.DescriptorProto.name) } #endif inline void DescriptorProto::set_name(const char* value) { GOOGLE_DCHECK(value != NULL); set_has_name(); - 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.DescriptorProto.name) } -inline void DescriptorProto::set_name(const char* value, size_t size) { +inline void DescriptorProto::set_name(const char* value, + size_t size) { set_has_name(); - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.DescriptorProto.name) } inline ::std::string* DescriptorProto::mutable_name() { set_has_name(); // @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.name) - return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* DescriptorProto::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.DescriptorProto.name) clear_has_name(); - return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline void DescriptorProto::set_allocated_name(::std::string* name) { if (name != NULL) { @@ -4832,9 +6697,29 @@ inline void DescriptorProto::set_allocated_name(::std::string* name) { } else { clear_has_name(); } - name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name); + name_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name, + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.DescriptorProto.name) } +inline ::std::string* DescriptorProto::unsafe_arena_release_name() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.DescriptorProto.name) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + clear_has_name(); + return name_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); +} +inline void DescriptorProto::unsafe_arena_set_allocated_name( + ::std::string* name) { + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + if (name != NULL) { + set_has_name(); + } else { + clear_has_name(); + } + name_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + name, GetArenaNoVirtual()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.DescriptorProto.name) +} // repeated .google.protobuf.FieldDescriptorProto field = 2; inline int DescriptorProto::field_size() const { @@ -4843,23 +6728,23 @@ inline int DescriptorProto::field_size() const { inline void DescriptorProto::clear_field() { field_.Clear(); } -inline const ::google::protobuf::FieldDescriptorProto& DescriptorProto::field(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.field) - return field_.Get(index); -} inline ::google::protobuf::FieldDescriptorProto* DescriptorProto::mutable_field(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.field) return field_.Mutable(index); } -inline ::google::protobuf::FieldDescriptorProto* DescriptorProto::add_field() { - // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.field) - return field_.Add(); -} inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >* DescriptorProto::mutable_field() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.DescriptorProto.field) return &field_; } +inline const ::google::protobuf::FieldDescriptorProto& DescriptorProto::field(int index) const { + // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.field) + return field_.Get(index); +} +inline ::google::protobuf::FieldDescriptorProto* DescriptorProto::add_field() { + // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.field) + return field_.Add(); +} inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >& DescriptorProto::field() const { // @@protoc_insertion_point(field_list:google.protobuf.DescriptorProto.field) @@ -4873,23 +6758,23 @@ inline int DescriptorProto::extension_size() const { inline void DescriptorProto::clear_extension() { extension_.Clear(); } -inline const ::google::protobuf::FieldDescriptorProto& DescriptorProto::extension(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.extension) - return extension_.Get(index); -} inline ::google::protobuf::FieldDescriptorProto* DescriptorProto::mutable_extension(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.extension) return extension_.Mutable(index); } -inline ::google::protobuf::FieldDescriptorProto* DescriptorProto::add_extension() { - // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.extension) - return extension_.Add(); -} inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >* DescriptorProto::mutable_extension() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.DescriptorProto.extension) return &extension_; } +inline const ::google::protobuf::FieldDescriptorProto& DescriptorProto::extension(int index) const { + // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.extension) + return extension_.Get(index); +} +inline ::google::protobuf::FieldDescriptorProto* DescriptorProto::add_extension() { + // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.extension) + return extension_.Add(); +} inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >& DescriptorProto::extension() const { // @@protoc_insertion_point(field_list:google.protobuf.DescriptorProto.extension) @@ -4903,23 +6788,23 @@ inline int DescriptorProto::nested_type_size() const { inline void DescriptorProto::clear_nested_type() { nested_type_.Clear(); } -inline const ::google::protobuf::DescriptorProto& DescriptorProto::nested_type(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.nested_type) - return nested_type_.Get(index); -} inline ::google::protobuf::DescriptorProto* DescriptorProto::mutable_nested_type(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.nested_type) return nested_type_.Mutable(index); } -inline ::google::protobuf::DescriptorProto* DescriptorProto::add_nested_type() { - // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.nested_type) - return nested_type_.Add(); -} inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto >* DescriptorProto::mutable_nested_type() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.DescriptorProto.nested_type) return &nested_type_; } +inline const ::google::protobuf::DescriptorProto& DescriptorProto::nested_type(int index) const { + // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.nested_type) + return nested_type_.Get(index); +} +inline ::google::protobuf::DescriptorProto* DescriptorProto::add_nested_type() { + // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.nested_type) + return nested_type_.Add(); +} inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto >& DescriptorProto::nested_type() const { // @@protoc_insertion_point(field_list:google.protobuf.DescriptorProto.nested_type) @@ -4933,23 +6818,23 @@ inline int DescriptorProto::enum_type_size() const { inline void DescriptorProto::clear_enum_type() { enum_type_.Clear(); } -inline const ::google::protobuf::EnumDescriptorProto& DescriptorProto::enum_type(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.enum_type) - return enum_type_.Get(index); -} inline ::google::protobuf::EnumDescriptorProto* DescriptorProto::mutable_enum_type(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.enum_type) return enum_type_.Mutable(index); } -inline ::google::protobuf::EnumDescriptorProto* DescriptorProto::add_enum_type() { - // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.enum_type) - return enum_type_.Add(); -} inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumDescriptorProto >* DescriptorProto::mutable_enum_type() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.DescriptorProto.enum_type) return &enum_type_; } +inline const ::google::protobuf::EnumDescriptorProto& DescriptorProto::enum_type(int index) const { + // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.enum_type) + return enum_type_.Get(index); +} +inline ::google::protobuf::EnumDescriptorProto* DescriptorProto::add_enum_type() { + // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.enum_type) + return enum_type_.Add(); +} inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumDescriptorProto >& DescriptorProto::enum_type() const { // @@protoc_insertion_point(field_list:google.protobuf.DescriptorProto.enum_type) @@ -4963,23 +6848,23 @@ inline int DescriptorProto::extension_range_size() const { inline void DescriptorProto::clear_extension_range() { extension_range_.Clear(); } -inline const ::google::protobuf::DescriptorProto_ExtensionRange& DescriptorProto::extension_range(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.extension_range) - return extension_range_.Get(index); -} inline ::google::protobuf::DescriptorProto_ExtensionRange* DescriptorProto::mutable_extension_range(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.extension_range) return extension_range_.Mutable(index); } -inline ::google::protobuf::DescriptorProto_ExtensionRange* DescriptorProto::add_extension_range() { - // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.extension_range) - return extension_range_.Add(); -} inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto_ExtensionRange >* DescriptorProto::mutable_extension_range() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.DescriptorProto.extension_range) return &extension_range_; } +inline const ::google::protobuf::DescriptorProto_ExtensionRange& DescriptorProto::extension_range(int index) const { + // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.extension_range) + return extension_range_.Get(index); +} +inline ::google::protobuf::DescriptorProto_ExtensionRange* DescriptorProto::add_extension_range() { + // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.extension_range) + return extension_range_.Add(); +} inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto_ExtensionRange >& DescriptorProto::extension_range() const { // @@protoc_insertion_point(field_list:google.protobuf.DescriptorProto.extension_range) @@ -4993,23 +6878,23 @@ inline int DescriptorProto::oneof_decl_size() const { inline void DescriptorProto::clear_oneof_decl() { oneof_decl_.Clear(); } -inline const ::google::protobuf::OneofDescriptorProto& DescriptorProto::oneof_decl(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.oneof_decl) - return oneof_decl_.Get(index); -} inline ::google::protobuf::OneofDescriptorProto* DescriptorProto::mutable_oneof_decl(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.oneof_decl) return oneof_decl_.Mutable(index); } -inline ::google::protobuf::OneofDescriptorProto* DescriptorProto::add_oneof_decl() { - // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.oneof_decl) - return oneof_decl_.Add(); -} inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::OneofDescriptorProto >* DescriptorProto::mutable_oneof_decl() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.DescriptorProto.oneof_decl) return &oneof_decl_; } +inline const ::google::protobuf::OneofDescriptorProto& DescriptorProto::oneof_decl(int index) const { + // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.oneof_decl) + return oneof_decl_.Get(index); +} +inline ::google::protobuf::OneofDescriptorProto* DescriptorProto::add_oneof_decl() { + // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.oneof_decl) + return oneof_decl_.Add(); +} inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::OneofDescriptorProto >& DescriptorProto::oneof_decl() const { // @@protoc_insertion_point(field_list:google.protobuf.DescriptorProto.oneof_decl) @@ -5027,37 +6912,58 @@ inline void DescriptorProto::clear_has_options() { _has_bits_[0] &= ~0x00000002u; } inline void DescriptorProto::clear_options() { - if (options_ != NULL) options_->::google::protobuf::MessageOptions::Clear(); + if (options_ != NULL) options_->Clear(); clear_has_options(); } inline const ::google::protobuf::MessageOptions& DescriptorProto::options() const { + const ::google::protobuf::MessageOptions* p = options_; // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.options) - return options_ != NULL ? *options_ - : *::google::protobuf::MessageOptions::internal_default_instance(); -} -inline ::google::protobuf::MessageOptions* DescriptorProto::mutable_options() { - set_has_options(); - if (options_ == NULL) { - options_ = new ::google::protobuf::MessageOptions; - } - // @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.options) - return options_; + return p != NULL ? *p : *reinterpret_cast<const ::google::protobuf::MessageOptions*>( + &::google::protobuf::_MessageOptions_default_instance_); } inline ::google::protobuf::MessageOptions* DescriptorProto::release_options() { // @@protoc_insertion_point(field_release:google.protobuf.DescriptorProto.options) clear_has_options(); ::google::protobuf::MessageOptions* temp = options_; + if (GetArenaNoVirtual() != NULL) { + temp = ::google::protobuf::internal::DuplicateIfNonNull(temp, NULL); + } + options_ = NULL; + return temp; +} +inline ::google::protobuf::MessageOptions* DescriptorProto::unsafe_arena_release_options() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.DescriptorProto.options) + clear_has_options(); + ::google::protobuf::MessageOptions* temp = options_; options_ = NULL; return temp; } +inline ::google::protobuf::MessageOptions* DescriptorProto::mutable_options() { + set_has_options(); + if (options_ == NULL) { + options_ = ::google::protobuf::Arena::CreateMessage< ::google::protobuf::MessageOptions >( + GetArenaNoVirtual()); + } + // @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.options) + return options_; +} inline void DescriptorProto::set_allocated_options(::google::protobuf::MessageOptions* options) { - delete options_; - options_ = options; + ::google::protobuf::Arena* message_arena = GetArenaNoVirtual(); + if (message_arena == NULL) { + delete options_; + } if (options) { + ::google::protobuf::Arena* submessage_arena = + ::google::protobuf::Arena::GetArena(options); + if (message_arena != submessage_arena) { + options = ::google::protobuf::internal::GetOwnedMessage( + message_arena, options, submessage_arena); + } set_has_options(); } else { clear_has_options(); } + options_ = options; // @@protoc_insertion_point(field_set_allocated:google.protobuf.DescriptorProto.options) } @@ -5068,23 +6974,23 @@ inline int DescriptorProto::reserved_range_size() const { inline void DescriptorProto::clear_reserved_range() { reserved_range_.Clear(); } -inline const ::google::protobuf::DescriptorProto_ReservedRange& DescriptorProto::reserved_range(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.reserved_range) - return reserved_range_.Get(index); -} inline ::google::protobuf::DescriptorProto_ReservedRange* DescriptorProto::mutable_reserved_range(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.reserved_range) return reserved_range_.Mutable(index); } -inline ::google::protobuf::DescriptorProto_ReservedRange* DescriptorProto::add_reserved_range() { - // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.reserved_range) - return reserved_range_.Add(); -} inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto_ReservedRange >* DescriptorProto::mutable_reserved_range() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.DescriptorProto.reserved_range) return &reserved_range_; } +inline const ::google::protobuf::DescriptorProto_ReservedRange& DescriptorProto::reserved_range(int index) const { + // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.reserved_range) + return reserved_range_.Get(index); +} +inline ::google::protobuf::DescriptorProto_ReservedRange* DescriptorProto::add_reserved_range() { + // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.reserved_range) + return reserved_range_.Add(); +} inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto_ReservedRange >& DescriptorProto::reserved_range() const { // @@protoc_insertion_point(field_list:google.protobuf.DescriptorProto.reserved_range) @@ -5162,6 +7068,40 @@ DescriptorProto::mutable_reserved_name() { // ------------------------------------------------------------------- +// ExtensionRangeOptions + +// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; +inline int ExtensionRangeOptions::uninterpreted_option_size() const { + return uninterpreted_option_.size(); +} +inline void ExtensionRangeOptions::clear_uninterpreted_option() { + uninterpreted_option_.Clear(); +} +inline ::google::protobuf::UninterpretedOption* ExtensionRangeOptions::mutable_uninterpreted_option(int index) { + // @@protoc_insertion_point(field_mutable:google.protobuf.ExtensionRangeOptions.uninterpreted_option) + return uninterpreted_option_.Mutable(index); +} +inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >* +ExtensionRangeOptions::mutable_uninterpreted_option() { + // @@protoc_insertion_point(field_mutable_list:google.protobuf.ExtensionRangeOptions.uninterpreted_option) + return &uninterpreted_option_; +} +inline const ::google::protobuf::UninterpretedOption& ExtensionRangeOptions::uninterpreted_option(int index) const { + // @@protoc_insertion_point(field_get:google.protobuf.ExtensionRangeOptions.uninterpreted_option) + return uninterpreted_option_.Get(index); +} +inline ::google::protobuf::UninterpretedOption* ExtensionRangeOptions::add_uninterpreted_option() { + // @@protoc_insertion_point(field_add:google.protobuf.ExtensionRangeOptions.uninterpreted_option) + return uninterpreted_option_.Add(); +} +inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >& +ExtensionRangeOptions::uninterpreted_option() const { + // @@protoc_insertion_point(field_list:google.protobuf.ExtensionRangeOptions.uninterpreted_option) + return uninterpreted_option_; +} + +// ------------------------------------------------------------------- + // FieldDescriptorProto // optional string name = 1; @@ -5175,47 +7115,49 @@ inline void FieldDescriptorProto::clear_has_name() { _has_bits_[0] &= ~0x00000001u; } inline void FieldDescriptorProto::clear_name() { - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); clear_has_name(); } inline const ::std::string& FieldDescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.name) - return name_.GetNoArena(); + return name_.Get(); } inline void FieldDescriptorProto::set_name(const ::std::string& value) { set_has_name(); - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.name) } #if LANG_CXX11 inline void FieldDescriptorProto::set_name(::std::string&& value) { set_has_name(); - name_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + name_.Set( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FieldDescriptorProto.name) } #endif inline void FieldDescriptorProto::set_name(const char* value) { GOOGLE_DCHECK(value != NULL); set_has_name(); - 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.FieldDescriptorProto.name) } -inline void FieldDescriptorProto::set_name(const char* value, size_t size) { +inline void FieldDescriptorProto::set_name(const char* value, + size_t size) { set_has_name(); - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FieldDescriptorProto.name) } inline ::std::string* FieldDescriptorProto::mutable_name() { set_has_name(); // @@protoc_insertion_point(field_mutable:google.protobuf.FieldDescriptorProto.name) - return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* FieldDescriptorProto::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.FieldDescriptorProto.name) clear_has_name(); - return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline void FieldDescriptorProto::set_allocated_name(::std::string* name) { if (name != NULL) { @@ -5223,9 +7165,29 @@ inline void FieldDescriptorProto::set_allocated_name(::std::string* name) { } else { clear_has_name(); } - name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name); + name_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name, + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.FieldDescriptorProto.name) } +inline ::std::string* FieldDescriptorProto::unsafe_arena_release_name() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.FieldDescriptorProto.name) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + clear_has_name(); + return name_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); +} +inline void FieldDescriptorProto::unsafe_arena_set_allocated_name( + ::std::string* name) { + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + if (name != NULL) { + set_has_name(); + } else { + clear_has_name(); + } + name_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + name, GetArenaNoVirtual()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.FieldDescriptorProto.name) +} // optional int32 number = 3; inline bool FieldDescriptorProto::has_number() const { @@ -5312,47 +7274,49 @@ inline void FieldDescriptorProto::clear_has_type_name() { _has_bits_[0] &= ~0x00000004u; } inline void FieldDescriptorProto::clear_type_name() { - type_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + type_name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); clear_has_type_name(); } inline const ::std::string& FieldDescriptorProto::type_name() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.type_name) - return type_name_.GetNoArena(); + return type_name_.Get(); } inline void FieldDescriptorProto::set_type_name(const ::std::string& value) { set_has_type_name(); - type_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + type_name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.type_name) } #if LANG_CXX11 inline void FieldDescriptorProto::set_type_name(::std::string&& value) { set_has_type_name(); - type_name_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + type_name_.Set( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FieldDescriptorProto.type_name) } #endif inline void FieldDescriptorProto::set_type_name(const char* value) { GOOGLE_DCHECK(value != NULL); set_has_type_name(); - type_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + type_name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.protobuf.FieldDescriptorProto.type_name) } -inline void FieldDescriptorProto::set_type_name(const char* value, size_t size) { +inline void FieldDescriptorProto::set_type_name(const char* value, + size_t size) { set_has_type_name(); - type_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); + type_name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FieldDescriptorProto.type_name) } inline ::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()); + return type_name_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::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()); + return type_name_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline void FieldDescriptorProto::set_allocated_type_name(::std::string* type_name) { if (type_name != NULL) { @@ -5360,9 +7324,29 @@ inline void FieldDescriptorProto::set_allocated_type_name(::std::string* type_na } else { clear_has_type_name(); } - type_name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), type_name); + type_name_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), type_name, + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.FieldDescriptorProto.type_name) } +inline ::std::string* FieldDescriptorProto::unsafe_arena_release_type_name() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.FieldDescriptorProto.type_name) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + clear_has_type_name(); + return type_name_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); +} +inline void FieldDescriptorProto::unsafe_arena_set_allocated_type_name( + ::std::string* type_name) { + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + if (type_name != NULL) { + set_has_type_name(); + } else { + clear_has_type_name(); + } + type_name_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + type_name, GetArenaNoVirtual()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.FieldDescriptorProto.type_name) +} // optional string extendee = 2; inline bool FieldDescriptorProto::has_extendee() const { @@ -5375,47 +7359,49 @@ inline void FieldDescriptorProto::clear_has_extendee() { _has_bits_[0] &= ~0x00000002u; } inline void FieldDescriptorProto::clear_extendee() { - extendee_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + extendee_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); clear_has_extendee(); } inline const ::std::string& FieldDescriptorProto::extendee() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.extendee) - return extendee_.GetNoArena(); + return extendee_.Get(); } inline void FieldDescriptorProto::set_extendee(const ::std::string& value) { set_has_extendee(); - extendee_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + extendee_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.extendee) } #if LANG_CXX11 inline void FieldDescriptorProto::set_extendee(::std::string&& value) { set_has_extendee(); - extendee_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + extendee_.Set( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FieldDescriptorProto.extendee) } #endif inline void FieldDescriptorProto::set_extendee(const char* value) { GOOGLE_DCHECK(value != NULL); set_has_extendee(); - extendee_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + extendee_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.protobuf.FieldDescriptorProto.extendee) } -inline void FieldDescriptorProto::set_extendee(const char* value, size_t size) { +inline void FieldDescriptorProto::set_extendee(const char* value, + size_t size) { set_has_extendee(); - extendee_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); + extendee_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FieldDescriptorProto.extendee) } inline ::std::string* FieldDescriptorProto::mutable_extendee() { set_has_extendee(); // @@protoc_insertion_point(field_mutable:google.protobuf.FieldDescriptorProto.extendee) - return extendee_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return extendee_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* FieldDescriptorProto::release_extendee() { // @@protoc_insertion_point(field_release:google.protobuf.FieldDescriptorProto.extendee) clear_has_extendee(); - return extendee_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return extendee_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline void FieldDescriptorProto::set_allocated_extendee(::std::string* extendee) { if (extendee != NULL) { @@ -5423,9 +7409,29 @@ inline void FieldDescriptorProto::set_allocated_extendee(::std::string* extendee } else { clear_has_extendee(); } - extendee_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), extendee); + extendee_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), extendee, + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.FieldDescriptorProto.extendee) } +inline ::std::string* FieldDescriptorProto::unsafe_arena_release_extendee() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.FieldDescriptorProto.extendee) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + clear_has_extendee(); + return extendee_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); +} +inline void FieldDescriptorProto::unsafe_arena_set_allocated_extendee( + ::std::string* extendee) { + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + if (extendee != NULL) { + set_has_extendee(); + } else { + clear_has_extendee(); + } + extendee_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + extendee, GetArenaNoVirtual()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.FieldDescriptorProto.extendee) +} // optional string default_value = 7; inline bool FieldDescriptorProto::has_default_value() const { @@ -5438,47 +7444,49 @@ inline void FieldDescriptorProto::clear_has_default_value() { _has_bits_[0] &= ~0x00000008u; } inline void FieldDescriptorProto::clear_default_value() { - default_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + default_value_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); clear_has_default_value(); } inline const ::std::string& FieldDescriptorProto::default_value() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.default_value) - return default_value_.GetNoArena(); + return default_value_.Get(); } inline void FieldDescriptorProto::set_default_value(const ::std::string& value) { set_has_default_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.FieldDescriptorProto.default_value) } #if LANG_CXX11 inline void FieldDescriptorProto::set_default_value(::std::string&& value) { set_has_default_value(); - default_value_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + default_value_.Set( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FieldDescriptorProto.default_value) } #endif inline void FieldDescriptorProto::set_default_value(const char* value) { GOOGLE_DCHECK(value != NULL); set_has_default_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.FieldDescriptorProto.default_value) } -inline void FieldDescriptorProto::set_default_value(const char* value, size_t size) { +inline void FieldDescriptorProto::set_default_value(const char* value, + size_t size) { set_has_default_value(); - default_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); + default_value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FieldDescriptorProto.default_value) } inline ::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()); + return default_value_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::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()); + return default_value_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline void FieldDescriptorProto::set_allocated_default_value(::std::string* default_value) { if (default_value != NULL) { @@ -5486,9 +7494,29 @@ inline void FieldDescriptorProto::set_allocated_default_value(::std::string* def } else { clear_has_default_value(); } - 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.FieldDescriptorProto.default_value) } +inline ::std::string* FieldDescriptorProto::unsafe_arena_release_default_value() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.FieldDescriptorProto.default_value) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + clear_has_default_value(); + return default_value_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); +} +inline void FieldDescriptorProto::unsafe_arena_set_allocated_default_value( + ::std::string* default_value) { + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + if (default_value != NULL) { + set_has_default_value(); + } else { + clear_has_default_value(); + } + default_value_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + default_value, GetArenaNoVirtual()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.FieldDescriptorProto.default_value) +} // optional int32 oneof_index = 9; inline bool FieldDescriptorProto::has_oneof_index() const { @@ -5525,47 +7553,49 @@ inline void FieldDescriptorProto::clear_has_json_name() { _has_bits_[0] &= ~0x00000010u; } inline void FieldDescriptorProto::clear_json_name() { - json_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + json_name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); clear_has_json_name(); } inline const ::std::string& FieldDescriptorProto::json_name() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.json_name) - return json_name_.GetNoArena(); + return json_name_.Get(); } inline void FieldDescriptorProto::set_json_name(const ::std::string& value) { set_has_json_name(); - json_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + json_name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.json_name) } #if LANG_CXX11 inline void FieldDescriptorProto::set_json_name(::std::string&& value) { set_has_json_name(); - json_name_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + json_name_.Set( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FieldDescriptorProto.json_name) } #endif inline void FieldDescriptorProto::set_json_name(const char* value) { GOOGLE_DCHECK(value != NULL); set_has_json_name(); - 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.FieldDescriptorProto.json_name) } -inline void FieldDescriptorProto::set_json_name(const char* value, size_t size) { +inline void FieldDescriptorProto::set_json_name(const char* value, + size_t size) { set_has_json_name(); - json_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); + json_name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FieldDescriptorProto.json_name) } inline ::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()); + return json_name_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::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()); + return json_name_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline void FieldDescriptorProto::set_allocated_json_name(::std::string* json_name) { if (json_name != NULL) { @@ -5573,9 +7603,29 @@ inline void FieldDescriptorProto::set_allocated_json_name(::std::string* json_na } else { clear_has_json_name(); } - 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.FieldDescriptorProto.json_name) } +inline ::std::string* FieldDescriptorProto::unsafe_arena_release_json_name() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.FieldDescriptorProto.json_name) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + clear_has_json_name(); + return json_name_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); +} +inline void FieldDescriptorProto::unsafe_arena_set_allocated_json_name( + ::std::string* json_name) { + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + if (json_name != NULL) { + set_has_json_name(); + } else { + clear_has_json_name(); + } + json_name_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + json_name, GetArenaNoVirtual()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.FieldDescriptorProto.json_name) +} // optional .google.protobuf.FieldOptions options = 8; inline bool FieldDescriptorProto::has_options() const { @@ -5588,37 +7638,58 @@ inline void FieldDescriptorProto::clear_has_options() { _has_bits_[0] &= ~0x00000020u; } inline void FieldDescriptorProto::clear_options() { - if (options_ != NULL) options_->::google::protobuf::FieldOptions::Clear(); + if (options_ != NULL) options_->Clear(); clear_has_options(); } inline const ::google::protobuf::FieldOptions& FieldDescriptorProto::options() const { + const ::google::protobuf::FieldOptions* p = options_; // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.options) - return options_ != NULL ? *options_ - : *::google::protobuf::FieldOptions::internal_default_instance(); -} -inline ::google::protobuf::FieldOptions* FieldDescriptorProto::mutable_options() { - set_has_options(); - if (options_ == NULL) { - options_ = new ::google::protobuf::FieldOptions; - } - // @@protoc_insertion_point(field_mutable:google.protobuf.FieldDescriptorProto.options) - return options_; + return p != NULL ? *p : *reinterpret_cast<const ::google::protobuf::FieldOptions*>( + &::google::protobuf::_FieldOptions_default_instance_); } inline ::google::protobuf::FieldOptions* FieldDescriptorProto::release_options() { // @@protoc_insertion_point(field_release:google.protobuf.FieldDescriptorProto.options) clear_has_options(); ::google::protobuf::FieldOptions* temp = options_; + if (GetArenaNoVirtual() != NULL) { + temp = ::google::protobuf::internal::DuplicateIfNonNull(temp, NULL); + } options_ = NULL; return temp; } +inline ::google::protobuf::FieldOptions* FieldDescriptorProto::unsafe_arena_release_options() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.FieldDescriptorProto.options) + clear_has_options(); + ::google::protobuf::FieldOptions* temp = options_; + options_ = NULL; + return temp; +} +inline ::google::protobuf::FieldOptions* FieldDescriptorProto::mutable_options() { + set_has_options(); + if (options_ == NULL) { + options_ = ::google::protobuf::Arena::CreateMessage< ::google::protobuf::FieldOptions >( + GetArenaNoVirtual()); + } + // @@protoc_insertion_point(field_mutable:google.protobuf.FieldDescriptorProto.options) + return options_; +} inline void FieldDescriptorProto::set_allocated_options(::google::protobuf::FieldOptions* options) { - delete options_; - options_ = options; + ::google::protobuf::Arena* message_arena = GetArenaNoVirtual(); + if (message_arena == NULL) { + delete options_; + } if (options) { + ::google::protobuf::Arena* submessage_arena = + ::google::protobuf::Arena::GetArena(options); + if (message_arena != submessage_arena) { + options = ::google::protobuf::internal::GetOwnedMessage( + message_arena, options, submessage_arena); + } set_has_options(); } else { clear_has_options(); } + options_ = options; // @@protoc_insertion_point(field_set_allocated:google.protobuf.FieldDescriptorProto.options) } @@ -5637,47 +7708,49 @@ inline void OneofDescriptorProto::clear_has_name() { _has_bits_[0] &= ~0x00000001u; } inline void OneofDescriptorProto::clear_name() { - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); clear_has_name(); } inline const ::std::string& OneofDescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.OneofDescriptorProto.name) - return name_.GetNoArena(); + return name_.Get(); } inline void OneofDescriptorProto::set_name(const ::std::string& value) { set_has_name(); - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.OneofDescriptorProto.name) } #if LANG_CXX11 inline void OneofDescriptorProto::set_name(::std::string&& value) { set_has_name(); - name_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + name_.Set( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.OneofDescriptorProto.name) } #endif inline void OneofDescriptorProto::set_name(const char* value) { GOOGLE_DCHECK(value != NULL); set_has_name(); - 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.OneofDescriptorProto.name) } -inline void OneofDescriptorProto::set_name(const char* value, size_t size) { +inline void OneofDescriptorProto::set_name(const char* value, + size_t size) { set_has_name(); - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.OneofDescriptorProto.name) } inline ::std::string* OneofDescriptorProto::mutable_name() { set_has_name(); // @@protoc_insertion_point(field_mutable:google.protobuf.OneofDescriptorProto.name) - return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* OneofDescriptorProto::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.OneofDescriptorProto.name) clear_has_name(); - return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline void OneofDescriptorProto::set_allocated_name(::std::string* name) { if (name != NULL) { @@ -5685,9 +7758,29 @@ inline void OneofDescriptorProto::set_allocated_name(::std::string* name) { } else { clear_has_name(); } - name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name); + name_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name, + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.OneofDescriptorProto.name) } +inline ::std::string* OneofDescriptorProto::unsafe_arena_release_name() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.OneofDescriptorProto.name) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + clear_has_name(); + return name_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); +} +inline void OneofDescriptorProto::unsafe_arena_set_allocated_name( + ::std::string* name) { + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + if (name != NULL) { + set_has_name(); + } else { + clear_has_name(); + } + name_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + name, GetArenaNoVirtual()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.OneofDescriptorProto.name) +} // optional .google.protobuf.OneofOptions options = 2; inline bool OneofDescriptorProto::has_options() const { @@ -5700,42 +7793,115 @@ inline void OneofDescriptorProto::clear_has_options() { _has_bits_[0] &= ~0x00000002u; } inline void OneofDescriptorProto::clear_options() { - if (options_ != NULL) options_->::google::protobuf::OneofOptions::Clear(); + if (options_ != NULL) options_->Clear(); clear_has_options(); } inline const ::google::protobuf::OneofOptions& OneofDescriptorProto::options() const { + const ::google::protobuf::OneofOptions* p = options_; // @@protoc_insertion_point(field_get:google.protobuf.OneofDescriptorProto.options) - return options_ != NULL ? *options_ - : *::google::protobuf::OneofOptions::internal_default_instance(); -} -inline ::google::protobuf::OneofOptions* OneofDescriptorProto::mutable_options() { - set_has_options(); - if (options_ == NULL) { - options_ = new ::google::protobuf::OneofOptions; - } - // @@protoc_insertion_point(field_mutable:google.protobuf.OneofDescriptorProto.options) - return options_; + return p != NULL ? *p : *reinterpret_cast<const ::google::protobuf::OneofOptions*>( + &::google::protobuf::_OneofOptions_default_instance_); } inline ::google::protobuf::OneofOptions* OneofDescriptorProto::release_options() { // @@protoc_insertion_point(field_release:google.protobuf.OneofDescriptorProto.options) clear_has_options(); ::google::protobuf::OneofOptions* temp = options_; + if (GetArenaNoVirtual() != NULL) { + temp = ::google::protobuf::internal::DuplicateIfNonNull(temp, NULL); + } + options_ = NULL; + return temp; +} +inline ::google::protobuf::OneofOptions* OneofDescriptorProto::unsafe_arena_release_options() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.OneofDescriptorProto.options) + clear_has_options(); + ::google::protobuf::OneofOptions* temp = options_; options_ = NULL; return temp; } +inline ::google::protobuf::OneofOptions* OneofDescriptorProto::mutable_options() { + set_has_options(); + if (options_ == NULL) { + options_ = ::google::protobuf::Arena::CreateMessage< ::google::protobuf::OneofOptions >( + GetArenaNoVirtual()); + } + // @@protoc_insertion_point(field_mutable:google.protobuf.OneofDescriptorProto.options) + return options_; +} inline void OneofDescriptorProto::set_allocated_options(::google::protobuf::OneofOptions* options) { - delete options_; - options_ = options; + ::google::protobuf::Arena* message_arena = GetArenaNoVirtual(); + if (message_arena == NULL) { + delete options_; + } if (options) { + ::google::protobuf::Arena* submessage_arena = + ::google::protobuf::Arena::GetArena(options); + if (message_arena != submessage_arena) { + options = ::google::protobuf::internal::GetOwnedMessage( + message_arena, options, submessage_arena); + } set_has_options(); } else { clear_has_options(); } + options_ = options; // @@protoc_insertion_point(field_set_allocated:google.protobuf.OneofDescriptorProto.options) } // ------------------------------------------------------------------- +// EnumDescriptorProto_EnumReservedRange + +// optional int32 start = 1; +inline bool EnumDescriptorProto_EnumReservedRange::has_start() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +inline void EnumDescriptorProto_EnumReservedRange::set_has_start() { + _has_bits_[0] |= 0x00000001u; +} +inline void EnumDescriptorProto_EnumReservedRange::clear_has_start() { + _has_bits_[0] &= ~0x00000001u; +} +inline void EnumDescriptorProto_EnumReservedRange::clear_start() { + start_ = 0; + clear_has_start(); +} +inline ::google::protobuf::int32 EnumDescriptorProto_EnumReservedRange::start() const { + // @@protoc_insertion_point(field_get:google.protobuf.EnumDescriptorProto.EnumReservedRange.start) + return start_; +} +inline void EnumDescriptorProto_EnumReservedRange::set_start(::google::protobuf::int32 value) { + set_has_start(); + start_ = value; + // @@protoc_insertion_point(field_set:google.protobuf.EnumDescriptorProto.EnumReservedRange.start) +} + +// optional int32 end = 2; +inline bool EnumDescriptorProto_EnumReservedRange::has_end() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +inline void EnumDescriptorProto_EnumReservedRange::set_has_end() { + _has_bits_[0] |= 0x00000002u; +} +inline void EnumDescriptorProto_EnumReservedRange::clear_has_end() { + _has_bits_[0] &= ~0x00000002u; +} +inline void EnumDescriptorProto_EnumReservedRange::clear_end() { + end_ = 0; + clear_has_end(); +} +inline ::google::protobuf::int32 EnumDescriptorProto_EnumReservedRange::end() const { + // @@protoc_insertion_point(field_get:google.protobuf.EnumDescriptorProto.EnumReservedRange.end) + return end_; +} +inline void EnumDescriptorProto_EnumReservedRange::set_end(::google::protobuf::int32 value) { + set_has_end(); + end_ = value; + // @@protoc_insertion_point(field_set:google.protobuf.EnumDescriptorProto.EnumReservedRange.end) +} + +// ------------------------------------------------------------------- + // EnumDescriptorProto // optional string name = 1; @@ -5749,47 +7915,49 @@ inline void EnumDescriptorProto::clear_has_name() { _has_bits_[0] &= ~0x00000001u; } inline void EnumDescriptorProto::clear_name() { - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); clear_has_name(); } inline const ::std::string& EnumDescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.EnumDescriptorProto.name) - return name_.GetNoArena(); + return name_.Get(); } inline void EnumDescriptorProto::set_name(const ::std::string& value) { set_has_name(); - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.EnumDescriptorProto.name) } #if LANG_CXX11 inline void EnumDescriptorProto::set_name(::std::string&& value) { set_has_name(); - name_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + name_.Set( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.EnumDescriptorProto.name) } #endif inline void EnumDescriptorProto::set_name(const char* value) { GOOGLE_DCHECK(value != NULL); set_has_name(); - 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.EnumDescriptorProto.name) } -inline void EnumDescriptorProto::set_name(const char* value, size_t size) { +inline void EnumDescriptorProto::set_name(const char* value, + size_t size) { set_has_name(); - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.EnumDescriptorProto.name) } inline ::std::string* EnumDescriptorProto::mutable_name() { set_has_name(); // @@protoc_insertion_point(field_mutable:google.protobuf.EnumDescriptorProto.name) - return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* EnumDescriptorProto::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.EnumDescriptorProto.name) clear_has_name(); - return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline void EnumDescriptorProto::set_allocated_name(::std::string* name) { if (name != NULL) { @@ -5797,9 +7965,29 @@ inline void EnumDescriptorProto::set_allocated_name(::std::string* name) { } else { clear_has_name(); } - name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name); + name_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name, + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.EnumDescriptorProto.name) } +inline ::std::string* EnumDescriptorProto::unsafe_arena_release_name() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.EnumDescriptorProto.name) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + clear_has_name(); + return name_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); +} +inline void EnumDescriptorProto::unsafe_arena_set_allocated_name( + ::std::string* name) { + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + if (name != NULL) { + set_has_name(); + } else { + clear_has_name(); + } + name_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + name, GetArenaNoVirtual()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.EnumDescriptorProto.name) +} // repeated .google.protobuf.EnumValueDescriptorProto value = 2; inline int EnumDescriptorProto::value_size() const { @@ -5808,23 +7996,23 @@ inline int EnumDescriptorProto::value_size() const { inline void EnumDescriptorProto::clear_value() { value_.Clear(); } -inline const ::google::protobuf::EnumValueDescriptorProto& EnumDescriptorProto::value(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.EnumDescriptorProto.value) - return value_.Get(index); -} inline ::google::protobuf::EnumValueDescriptorProto* EnumDescriptorProto::mutable_value(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.EnumDescriptorProto.value) return value_.Mutable(index); } -inline ::google::protobuf::EnumValueDescriptorProto* EnumDescriptorProto::add_value() { - // @@protoc_insertion_point(field_add:google.protobuf.EnumDescriptorProto.value) - return value_.Add(); -} inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumValueDescriptorProto >* EnumDescriptorProto::mutable_value() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.EnumDescriptorProto.value) return &value_; } +inline const ::google::protobuf::EnumValueDescriptorProto& EnumDescriptorProto::value(int index) const { + // @@protoc_insertion_point(field_get:google.protobuf.EnumDescriptorProto.value) + return value_.Get(index); +} +inline ::google::protobuf::EnumValueDescriptorProto* EnumDescriptorProto::add_value() { + // @@protoc_insertion_point(field_add:google.protobuf.EnumDescriptorProto.value) + return value_.Add(); +} inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumValueDescriptorProto >& EnumDescriptorProto::value() const { // @@protoc_insertion_point(field_list:google.protobuf.EnumDescriptorProto.value) @@ -5842,40 +8030,160 @@ inline void EnumDescriptorProto::clear_has_options() { _has_bits_[0] &= ~0x00000002u; } inline void EnumDescriptorProto::clear_options() { - if (options_ != NULL) options_->::google::protobuf::EnumOptions::Clear(); + if (options_ != NULL) options_->Clear(); clear_has_options(); } inline const ::google::protobuf::EnumOptions& EnumDescriptorProto::options() const { + const ::google::protobuf::EnumOptions* p = options_; // @@protoc_insertion_point(field_get:google.protobuf.EnumDescriptorProto.options) - return options_ != NULL ? *options_ - : *::google::protobuf::EnumOptions::internal_default_instance(); -} -inline ::google::protobuf::EnumOptions* EnumDescriptorProto::mutable_options() { - set_has_options(); - if (options_ == NULL) { - options_ = new ::google::protobuf::EnumOptions; - } - // @@protoc_insertion_point(field_mutable:google.protobuf.EnumDescriptorProto.options) - return options_; + return p != NULL ? *p : *reinterpret_cast<const ::google::protobuf::EnumOptions*>( + &::google::protobuf::_EnumOptions_default_instance_); } inline ::google::protobuf::EnumOptions* EnumDescriptorProto::release_options() { // @@protoc_insertion_point(field_release:google.protobuf.EnumDescriptorProto.options) clear_has_options(); ::google::protobuf::EnumOptions* temp = options_; + if (GetArenaNoVirtual() != NULL) { + temp = ::google::protobuf::internal::DuplicateIfNonNull(temp, NULL); + } options_ = NULL; return temp; } +inline ::google::protobuf::EnumOptions* EnumDescriptorProto::unsafe_arena_release_options() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.EnumDescriptorProto.options) + clear_has_options(); + ::google::protobuf::EnumOptions* temp = options_; + options_ = NULL; + return temp; +} +inline ::google::protobuf::EnumOptions* EnumDescriptorProto::mutable_options() { + set_has_options(); + if (options_ == NULL) { + options_ = ::google::protobuf::Arena::CreateMessage< ::google::protobuf::EnumOptions >( + GetArenaNoVirtual()); + } + // @@protoc_insertion_point(field_mutable:google.protobuf.EnumDescriptorProto.options) + return options_; +} inline void EnumDescriptorProto::set_allocated_options(::google::protobuf::EnumOptions* options) { - delete options_; - options_ = options; + ::google::protobuf::Arena* message_arena = GetArenaNoVirtual(); + if (message_arena == NULL) { + delete options_; + } if (options) { + ::google::protobuf::Arena* submessage_arena = + ::google::protobuf::Arena::GetArena(options); + if (message_arena != submessage_arena) { + options = ::google::protobuf::internal::GetOwnedMessage( + message_arena, options, submessage_arena); + } set_has_options(); } else { clear_has_options(); } + options_ = options; // @@protoc_insertion_point(field_set_allocated:google.protobuf.EnumDescriptorProto.options) } +// repeated .google.protobuf.EnumDescriptorProto.EnumReservedRange reserved_range = 4; +inline int EnumDescriptorProto::reserved_range_size() const { + return reserved_range_.size(); +} +inline void EnumDescriptorProto::clear_reserved_range() { + reserved_range_.Clear(); +} +inline ::google::protobuf::EnumDescriptorProto_EnumReservedRange* EnumDescriptorProto::mutable_reserved_range(int index) { + // @@protoc_insertion_point(field_mutable:google.protobuf.EnumDescriptorProto.reserved_range) + return reserved_range_.Mutable(index); +} +inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumDescriptorProto_EnumReservedRange >* +EnumDescriptorProto::mutable_reserved_range() { + // @@protoc_insertion_point(field_mutable_list:google.protobuf.EnumDescriptorProto.reserved_range) + return &reserved_range_; +} +inline const ::google::protobuf::EnumDescriptorProto_EnumReservedRange& EnumDescriptorProto::reserved_range(int index) const { + // @@protoc_insertion_point(field_get:google.protobuf.EnumDescriptorProto.reserved_range) + return reserved_range_.Get(index); +} +inline ::google::protobuf::EnumDescriptorProto_EnumReservedRange* EnumDescriptorProto::add_reserved_range() { + // @@protoc_insertion_point(field_add:google.protobuf.EnumDescriptorProto.reserved_range) + return reserved_range_.Add(); +} +inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumDescriptorProto_EnumReservedRange >& +EnumDescriptorProto::reserved_range() const { + // @@protoc_insertion_point(field_list:google.protobuf.EnumDescriptorProto.reserved_range) + return reserved_range_; +} + +// repeated string reserved_name = 5; +inline int EnumDescriptorProto::reserved_name_size() const { + return reserved_name_.size(); +} +inline void EnumDescriptorProto::clear_reserved_name() { + reserved_name_.Clear(); +} +inline const ::std::string& EnumDescriptorProto::reserved_name(int index) const { + // @@protoc_insertion_point(field_get:google.protobuf.EnumDescriptorProto.reserved_name) + return reserved_name_.Get(index); +} +inline ::std::string* EnumDescriptorProto::mutable_reserved_name(int index) { + // @@protoc_insertion_point(field_mutable:google.protobuf.EnumDescriptorProto.reserved_name) + return reserved_name_.Mutable(index); +} +inline void EnumDescriptorProto::set_reserved_name(int index, const ::std::string& value) { + // @@protoc_insertion_point(field_set:google.protobuf.EnumDescriptorProto.reserved_name) + reserved_name_.Mutable(index)->assign(value); +} +#if LANG_CXX11 +inline void EnumDescriptorProto::set_reserved_name(int index, ::std::string&& value) { + // @@protoc_insertion_point(field_set:google.protobuf.EnumDescriptorProto.reserved_name) + reserved_name_.Mutable(index)->assign(std::move(value)); +} +#endif +inline void EnumDescriptorProto::set_reserved_name(int index, const char* value) { + GOOGLE_DCHECK(value != NULL); + reserved_name_.Mutable(index)->assign(value); + // @@protoc_insertion_point(field_set_char:google.protobuf.EnumDescriptorProto.reserved_name) +} +inline void EnumDescriptorProto::set_reserved_name(int index, const char* value, size_t size) { + reserved_name_.Mutable(index)->assign( + reinterpret_cast<const char*>(value), size); + // @@protoc_insertion_point(field_set_pointer:google.protobuf.EnumDescriptorProto.reserved_name) +} +inline ::std::string* EnumDescriptorProto::add_reserved_name() { + // @@protoc_insertion_point(field_add_mutable:google.protobuf.EnumDescriptorProto.reserved_name) + return reserved_name_.Add(); +} +inline void EnumDescriptorProto::add_reserved_name(const ::std::string& value) { + reserved_name_.Add()->assign(value); + // @@protoc_insertion_point(field_add:google.protobuf.EnumDescriptorProto.reserved_name) +} +#if LANG_CXX11 +inline void EnumDescriptorProto::add_reserved_name(::std::string&& value) { + reserved_name_.Add(std::move(value)); + // @@protoc_insertion_point(field_add:google.protobuf.EnumDescriptorProto.reserved_name) +} +#endif +inline void EnumDescriptorProto::add_reserved_name(const char* value) { + GOOGLE_DCHECK(value != NULL); + reserved_name_.Add()->assign(value); + // @@protoc_insertion_point(field_add_char:google.protobuf.EnumDescriptorProto.reserved_name) +} +inline void EnumDescriptorProto::add_reserved_name(const char* value, size_t size) { + reserved_name_.Add()->assign(reinterpret_cast<const char*>(value), size); + // @@protoc_insertion_point(field_add_pointer:google.protobuf.EnumDescriptorProto.reserved_name) +} +inline const ::google::protobuf::RepeatedPtrField< ::std::string>& +EnumDescriptorProto::reserved_name() const { + // @@protoc_insertion_point(field_list:google.protobuf.EnumDescriptorProto.reserved_name) + return reserved_name_; +} +inline ::google::protobuf::RepeatedPtrField< ::std::string>* +EnumDescriptorProto::mutable_reserved_name() { + // @@protoc_insertion_point(field_mutable_list:google.protobuf.EnumDescriptorProto.reserved_name) + return &reserved_name_; +} + // ------------------------------------------------------------------- // EnumValueDescriptorProto @@ -5891,47 +8199,49 @@ inline void EnumValueDescriptorProto::clear_has_name() { _has_bits_[0] &= ~0x00000001u; } inline void EnumValueDescriptorProto::clear_name() { - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); clear_has_name(); } inline const ::std::string& EnumValueDescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.EnumValueDescriptorProto.name) - return name_.GetNoArena(); + return name_.Get(); } inline void EnumValueDescriptorProto::set_name(const ::std::string& value) { set_has_name(); - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.EnumValueDescriptorProto.name) } #if LANG_CXX11 inline void EnumValueDescriptorProto::set_name(::std::string&& value) { set_has_name(); - name_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + name_.Set( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.EnumValueDescriptorProto.name) } #endif inline void EnumValueDescriptorProto::set_name(const char* value) { GOOGLE_DCHECK(value != NULL); set_has_name(); - 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.EnumValueDescriptorProto.name) } -inline void EnumValueDescriptorProto::set_name(const char* value, size_t size) { +inline void EnumValueDescriptorProto::set_name(const char* value, + size_t size) { set_has_name(); - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.EnumValueDescriptorProto.name) } inline ::std::string* EnumValueDescriptorProto::mutable_name() { set_has_name(); // @@protoc_insertion_point(field_mutable:google.protobuf.EnumValueDescriptorProto.name) - return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* EnumValueDescriptorProto::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.EnumValueDescriptorProto.name) clear_has_name(); - return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline void EnumValueDescriptorProto::set_allocated_name(::std::string* name) { if (name != NULL) { @@ -5939,9 +8249,29 @@ inline void EnumValueDescriptorProto::set_allocated_name(::std::string* name) { } else { clear_has_name(); } - name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name); + name_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name, + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.EnumValueDescriptorProto.name) } +inline ::std::string* EnumValueDescriptorProto::unsafe_arena_release_name() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.EnumValueDescriptorProto.name) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + clear_has_name(); + return name_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); +} +inline void EnumValueDescriptorProto::unsafe_arena_set_allocated_name( + ::std::string* name) { + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + if (name != NULL) { + set_has_name(); + } else { + clear_has_name(); + } + name_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + name, GetArenaNoVirtual()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.EnumValueDescriptorProto.name) +} // optional int32 number = 2; inline bool EnumValueDescriptorProto::has_number() const { @@ -5978,37 +8308,58 @@ inline void EnumValueDescriptorProto::clear_has_options() { _has_bits_[0] &= ~0x00000002u; } inline void EnumValueDescriptorProto::clear_options() { - if (options_ != NULL) options_->::google::protobuf::EnumValueOptions::Clear(); + if (options_ != NULL) options_->Clear(); clear_has_options(); } inline const ::google::protobuf::EnumValueOptions& EnumValueDescriptorProto::options() const { + const ::google::protobuf::EnumValueOptions* p = options_; // @@protoc_insertion_point(field_get:google.protobuf.EnumValueDescriptorProto.options) - return options_ != NULL ? *options_ - : *::google::protobuf::EnumValueOptions::internal_default_instance(); -} -inline ::google::protobuf::EnumValueOptions* EnumValueDescriptorProto::mutable_options() { - set_has_options(); - if (options_ == NULL) { - options_ = new ::google::protobuf::EnumValueOptions; - } - // @@protoc_insertion_point(field_mutable:google.protobuf.EnumValueDescriptorProto.options) - return options_; + return p != NULL ? *p : *reinterpret_cast<const ::google::protobuf::EnumValueOptions*>( + &::google::protobuf::_EnumValueOptions_default_instance_); } inline ::google::protobuf::EnumValueOptions* EnumValueDescriptorProto::release_options() { // @@protoc_insertion_point(field_release:google.protobuf.EnumValueDescriptorProto.options) clear_has_options(); ::google::protobuf::EnumValueOptions* temp = options_; + if (GetArenaNoVirtual() != NULL) { + temp = ::google::protobuf::internal::DuplicateIfNonNull(temp, NULL); + } + options_ = NULL; + return temp; +} +inline ::google::protobuf::EnumValueOptions* EnumValueDescriptorProto::unsafe_arena_release_options() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.EnumValueDescriptorProto.options) + clear_has_options(); + ::google::protobuf::EnumValueOptions* temp = options_; options_ = NULL; return temp; } +inline ::google::protobuf::EnumValueOptions* EnumValueDescriptorProto::mutable_options() { + set_has_options(); + if (options_ == NULL) { + options_ = ::google::protobuf::Arena::CreateMessage< ::google::protobuf::EnumValueOptions >( + GetArenaNoVirtual()); + } + // @@protoc_insertion_point(field_mutable:google.protobuf.EnumValueDescriptorProto.options) + return options_; +} inline void EnumValueDescriptorProto::set_allocated_options(::google::protobuf::EnumValueOptions* options) { - delete options_; - options_ = options; + ::google::protobuf::Arena* message_arena = GetArenaNoVirtual(); + if (message_arena == NULL) { + delete options_; + } if (options) { + ::google::protobuf::Arena* submessage_arena = + ::google::protobuf::Arena::GetArena(options); + if (message_arena != submessage_arena) { + options = ::google::protobuf::internal::GetOwnedMessage( + message_arena, options, submessage_arena); + } set_has_options(); } else { clear_has_options(); } + options_ = options; // @@protoc_insertion_point(field_set_allocated:google.protobuf.EnumValueDescriptorProto.options) } @@ -6027,47 +8378,49 @@ inline void ServiceDescriptorProto::clear_has_name() { _has_bits_[0] &= ~0x00000001u; } inline void ServiceDescriptorProto::clear_name() { - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); clear_has_name(); } inline const ::std::string& ServiceDescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.ServiceDescriptorProto.name) - return name_.GetNoArena(); + return name_.Get(); } inline void ServiceDescriptorProto::set_name(const ::std::string& value) { set_has_name(); - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.ServiceDescriptorProto.name) } #if LANG_CXX11 inline void ServiceDescriptorProto::set_name(::std::string&& value) { set_has_name(); - name_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + name_.Set( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.ServiceDescriptorProto.name) } #endif inline void ServiceDescriptorProto::set_name(const char* value) { GOOGLE_DCHECK(value != NULL); set_has_name(); - 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.ServiceDescriptorProto.name) } -inline void ServiceDescriptorProto::set_name(const char* value, size_t size) { +inline void ServiceDescriptorProto::set_name(const char* value, + size_t size) { set_has_name(); - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.ServiceDescriptorProto.name) } inline ::std::string* ServiceDescriptorProto::mutable_name() { set_has_name(); // @@protoc_insertion_point(field_mutable:google.protobuf.ServiceDescriptorProto.name) - return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* ServiceDescriptorProto::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.ServiceDescriptorProto.name) clear_has_name(); - return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline void ServiceDescriptorProto::set_allocated_name(::std::string* name) { if (name != NULL) { @@ -6075,9 +8428,29 @@ inline void ServiceDescriptorProto::set_allocated_name(::std::string* name) { } else { clear_has_name(); } - name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name); + name_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name, + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.ServiceDescriptorProto.name) } +inline ::std::string* ServiceDescriptorProto::unsafe_arena_release_name() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.ServiceDescriptorProto.name) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + clear_has_name(); + return name_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); +} +inline void ServiceDescriptorProto::unsafe_arena_set_allocated_name( + ::std::string* name) { + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + if (name != NULL) { + set_has_name(); + } else { + clear_has_name(); + } + name_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + name, GetArenaNoVirtual()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.ServiceDescriptorProto.name) +} // repeated .google.protobuf.MethodDescriptorProto method = 2; inline int ServiceDescriptorProto::method_size() const { @@ -6086,23 +8459,23 @@ inline int ServiceDescriptorProto::method_size() const { inline void ServiceDescriptorProto::clear_method() { method_.Clear(); } -inline const ::google::protobuf::MethodDescriptorProto& ServiceDescriptorProto::method(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.ServiceDescriptorProto.method) - return method_.Get(index); -} inline ::google::protobuf::MethodDescriptorProto* ServiceDescriptorProto::mutable_method(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.ServiceDescriptorProto.method) return method_.Mutable(index); } -inline ::google::protobuf::MethodDescriptorProto* ServiceDescriptorProto::add_method() { - // @@protoc_insertion_point(field_add:google.protobuf.ServiceDescriptorProto.method) - return method_.Add(); -} inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::MethodDescriptorProto >* ServiceDescriptorProto::mutable_method() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.ServiceDescriptorProto.method) return &method_; } +inline const ::google::protobuf::MethodDescriptorProto& ServiceDescriptorProto::method(int index) const { + // @@protoc_insertion_point(field_get:google.protobuf.ServiceDescriptorProto.method) + return method_.Get(index); +} +inline ::google::protobuf::MethodDescriptorProto* ServiceDescriptorProto::add_method() { + // @@protoc_insertion_point(field_add:google.protobuf.ServiceDescriptorProto.method) + return method_.Add(); +} inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::MethodDescriptorProto >& ServiceDescriptorProto::method() const { // @@protoc_insertion_point(field_list:google.protobuf.ServiceDescriptorProto.method) @@ -6120,37 +8493,58 @@ inline void ServiceDescriptorProto::clear_has_options() { _has_bits_[0] &= ~0x00000002u; } inline void ServiceDescriptorProto::clear_options() { - if (options_ != NULL) options_->::google::protobuf::ServiceOptions::Clear(); + if (options_ != NULL) options_->Clear(); clear_has_options(); } inline const ::google::protobuf::ServiceOptions& ServiceDescriptorProto::options() const { + const ::google::protobuf::ServiceOptions* p = options_; // @@protoc_insertion_point(field_get:google.protobuf.ServiceDescriptorProto.options) - return options_ != NULL ? *options_ - : *::google::protobuf::ServiceOptions::internal_default_instance(); -} -inline ::google::protobuf::ServiceOptions* ServiceDescriptorProto::mutable_options() { - set_has_options(); - if (options_ == NULL) { - options_ = new ::google::protobuf::ServiceOptions; - } - // @@protoc_insertion_point(field_mutable:google.protobuf.ServiceDescriptorProto.options) - return options_; + return p != NULL ? *p : *reinterpret_cast<const ::google::protobuf::ServiceOptions*>( + &::google::protobuf::_ServiceOptions_default_instance_); } inline ::google::protobuf::ServiceOptions* ServiceDescriptorProto::release_options() { // @@protoc_insertion_point(field_release:google.protobuf.ServiceDescriptorProto.options) clear_has_options(); ::google::protobuf::ServiceOptions* temp = options_; + if (GetArenaNoVirtual() != NULL) { + temp = ::google::protobuf::internal::DuplicateIfNonNull(temp, NULL); + } options_ = NULL; return temp; } +inline ::google::protobuf::ServiceOptions* ServiceDescriptorProto::unsafe_arena_release_options() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.ServiceDescriptorProto.options) + clear_has_options(); + ::google::protobuf::ServiceOptions* temp = options_; + options_ = NULL; + return temp; +} +inline ::google::protobuf::ServiceOptions* ServiceDescriptorProto::mutable_options() { + set_has_options(); + if (options_ == NULL) { + options_ = ::google::protobuf::Arena::CreateMessage< ::google::protobuf::ServiceOptions >( + GetArenaNoVirtual()); + } + // @@protoc_insertion_point(field_mutable:google.protobuf.ServiceDescriptorProto.options) + return options_; +} inline void ServiceDescriptorProto::set_allocated_options(::google::protobuf::ServiceOptions* options) { - delete options_; - options_ = options; + ::google::protobuf::Arena* message_arena = GetArenaNoVirtual(); + if (message_arena == NULL) { + delete options_; + } if (options) { + ::google::protobuf::Arena* submessage_arena = + ::google::protobuf::Arena::GetArena(options); + if (message_arena != submessage_arena) { + options = ::google::protobuf::internal::GetOwnedMessage( + message_arena, options, submessage_arena); + } set_has_options(); } else { clear_has_options(); } + options_ = options; // @@protoc_insertion_point(field_set_allocated:google.protobuf.ServiceDescriptorProto.options) } @@ -6169,47 +8563,49 @@ inline void MethodDescriptorProto::clear_has_name() { _has_bits_[0] &= ~0x00000001u; } inline void MethodDescriptorProto::clear_name() { - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); clear_has_name(); } inline const ::std::string& MethodDescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.name) - return name_.GetNoArena(); + return name_.Get(); } inline void MethodDescriptorProto::set_name(const ::std::string& value) { set_has_name(); - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.name) } #if LANG_CXX11 inline void MethodDescriptorProto::set_name(::std::string&& value) { set_has_name(); - name_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + name_.Set( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.MethodDescriptorProto.name) } #endif inline void MethodDescriptorProto::set_name(const char* value) { GOOGLE_DCHECK(value != NULL); set_has_name(); - 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.MethodDescriptorProto.name) } -inline void MethodDescriptorProto::set_name(const char* value, size_t size) { +inline void MethodDescriptorProto::set_name(const char* value, + size_t size) { set_has_name(); - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.MethodDescriptorProto.name) } inline ::std::string* MethodDescriptorProto::mutable_name() { set_has_name(); // @@protoc_insertion_point(field_mutable:google.protobuf.MethodDescriptorProto.name) - return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* MethodDescriptorProto::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.MethodDescriptorProto.name) clear_has_name(); - return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline void MethodDescriptorProto::set_allocated_name(::std::string* name) { if (name != NULL) { @@ -6217,9 +8613,29 @@ inline void MethodDescriptorProto::set_allocated_name(::std::string* name) { } else { clear_has_name(); } - name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name); + name_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name, + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.MethodDescriptorProto.name) } +inline ::std::string* MethodDescriptorProto::unsafe_arena_release_name() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.MethodDescriptorProto.name) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + clear_has_name(); + return name_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); +} +inline void MethodDescriptorProto::unsafe_arena_set_allocated_name( + ::std::string* name) { + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + if (name != NULL) { + set_has_name(); + } else { + clear_has_name(); + } + name_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + name, GetArenaNoVirtual()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.MethodDescriptorProto.name) +} // optional string input_type = 2; inline bool MethodDescriptorProto::has_input_type() const { @@ -6232,47 +8648,49 @@ inline void MethodDescriptorProto::clear_has_input_type() { _has_bits_[0] &= ~0x00000002u; } inline void MethodDescriptorProto::clear_input_type() { - input_type_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + input_type_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); clear_has_input_type(); } inline const ::std::string& MethodDescriptorProto::input_type() const { // @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.input_type) - return input_type_.GetNoArena(); + return input_type_.Get(); } inline void MethodDescriptorProto::set_input_type(const ::std::string& value) { set_has_input_type(); - input_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + input_type_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.input_type) } #if LANG_CXX11 inline void MethodDescriptorProto::set_input_type(::std::string&& value) { set_has_input_type(); - input_type_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + input_type_.Set( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.MethodDescriptorProto.input_type) } #endif inline void MethodDescriptorProto::set_input_type(const char* value) { GOOGLE_DCHECK(value != NULL); set_has_input_type(); - input_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + input_type_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.protobuf.MethodDescriptorProto.input_type) } -inline void MethodDescriptorProto::set_input_type(const char* value, size_t size) { +inline void MethodDescriptorProto::set_input_type(const char* value, + size_t size) { set_has_input_type(); - input_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); + input_type_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.MethodDescriptorProto.input_type) } inline ::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()); + return input_type_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::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()); + return input_type_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline void MethodDescriptorProto::set_allocated_input_type(::std::string* input_type) { if (input_type != NULL) { @@ -6280,9 +8698,29 @@ inline void MethodDescriptorProto::set_allocated_input_type(::std::string* input } else { clear_has_input_type(); } - input_type_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), input_type); + input_type_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), input_type, + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.MethodDescriptorProto.input_type) } +inline ::std::string* MethodDescriptorProto::unsafe_arena_release_input_type() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.MethodDescriptorProto.input_type) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + clear_has_input_type(); + return input_type_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); +} +inline void MethodDescriptorProto::unsafe_arena_set_allocated_input_type( + ::std::string* input_type) { + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + if (input_type != NULL) { + set_has_input_type(); + } else { + clear_has_input_type(); + } + input_type_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + input_type, GetArenaNoVirtual()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.MethodDescriptorProto.input_type) +} // optional string output_type = 3; inline bool MethodDescriptorProto::has_output_type() const { @@ -6295,47 +8733,49 @@ inline void MethodDescriptorProto::clear_has_output_type() { _has_bits_[0] &= ~0x00000004u; } inline void MethodDescriptorProto::clear_output_type() { - output_type_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + output_type_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); clear_has_output_type(); } inline const ::std::string& MethodDescriptorProto::output_type() const { // @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.output_type) - return output_type_.GetNoArena(); + return output_type_.Get(); } inline void MethodDescriptorProto::set_output_type(const ::std::string& value) { set_has_output_type(); - output_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + output_type_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.output_type) } #if LANG_CXX11 inline void MethodDescriptorProto::set_output_type(::std::string&& value) { set_has_output_type(); - output_type_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + output_type_.Set( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.MethodDescriptorProto.output_type) } #endif inline void MethodDescriptorProto::set_output_type(const char* value) { GOOGLE_DCHECK(value != NULL); set_has_output_type(); - output_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + output_type_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.protobuf.MethodDescriptorProto.output_type) } -inline void MethodDescriptorProto::set_output_type(const char* value, size_t size) { +inline void MethodDescriptorProto::set_output_type(const char* value, + size_t size) { set_has_output_type(); - output_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); + output_type_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.MethodDescriptorProto.output_type) } inline ::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()); + return output_type_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::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()); + return output_type_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline void MethodDescriptorProto::set_allocated_output_type(::std::string* output_type) { if (output_type != NULL) { @@ -6343,9 +8783,29 @@ inline void MethodDescriptorProto::set_allocated_output_type(::std::string* outp } else { clear_has_output_type(); } - output_type_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), output_type); + output_type_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), output_type, + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.MethodDescriptorProto.output_type) } +inline ::std::string* MethodDescriptorProto::unsafe_arena_release_output_type() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.MethodDescriptorProto.output_type) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + clear_has_output_type(); + return output_type_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); +} +inline void MethodDescriptorProto::unsafe_arena_set_allocated_output_type( + ::std::string* output_type) { + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + if (output_type != NULL) { + set_has_output_type(); + } else { + clear_has_output_type(); + } + output_type_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + output_type, GetArenaNoVirtual()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.MethodDescriptorProto.output_type) +} // optional .google.protobuf.MethodOptions options = 4; inline bool MethodDescriptorProto::has_options() const { @@ -6358,37 +8818,58 @@ inline void MethodDescriptorProto::clear_has_options() { _has_bits_[0] &= ~0x00000008u; } inline void MethodDescriptorProto::clear_options() { - if (options_ != NULL) options_->::google::protobuf::MethodOptions::Clear(); + if (options_ != NULL) options_->Clear(); clear_has_options(); } inline const ::google::protobuf::MethodOptions& MethodDescriptorProto::options() const { + const ::google::protobuf::MethodOptions* p = options_; // @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.options) - return options_ != NULL ? *options_ - : *::google::protobuf::MethodOptions::internal_default_instance(); -} -inline ::google::protobuf::MethodOptions* MethodDescriptorProto::mutable_options() { - set_has_options(); - if (options_ == NULL) { - options_ = new ::google::protobuf::MethodOptions; - } - // @@protoc_insertion_point(field_mutable:google.protobuf.MethodDescriptorProto.options) - return options_; + return p != NULL ? *p : *reinterpret_cast<const ::google::protobuf::MethodOptions*>( + &::google::protobuf::_MethodOptions_default_instance_); } inline ::google::protobuf::MethodOptions* MethodDescriptorProto::release_options() { // @@protoc_insertion_point(field_release:google.protobuf.MethodDescriptorProto.options) clear_has_options(); ::google::protobuf::MethodOptions* temp = options_; + if (GetArenaNoVirtual() != NULL) { + temp = ::google::protobuf::internal::DuplicateIfNonNull(temp, NULL); + } + options_ = NULL; + return temp; +} +inline ::google::protobuf::MethodOptions* MethodDescriptorProto::unsafe_arena_release_options() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.MethodDescriptorProto.options) + clear_has_options(); + ::google::protobuf::MethodOptions* temp = options_; options_ = NULL; return temp; } +inline ::google::protobuf::MethodOptions* MethodDescriptorProto::mutable_options() { + set_has_options(); + if (options_ == NULL) { + options_ = ::google::protobuf::Arena::CreateMessage< ::google::protobuf::MethodOptions >( + GetArenaNoVirtual()); + } + // @@protoc_insertion_point(field_mutable:google.protobuf.MethodDescriptorProto.options) + return options_; +} inline void MethodDescriptorProto::set_allocated_options(::google::protobuf::MethodOptions* options) { - delete options_; - options_ = options; + ::google::protobuf::Arena* message_arena = GetArenaNoVirtual(); + if (message_arena == NULL) { + delete options_; + } if (options) { + ::google::protobuf::Arena* submessage_arena = + ::google::protobuf::Arena::GetArena(options); + if (message_arena != submessage_arena) { + options = ::google::protobuf::internal::GetOwnedMessage( + message_arena, options, submessage_arena); + } set_has_options(); } else { clear_has_options(); } + options_ = options; // @@protoc_insertion_point(field_set_allocated:google.protobuf.MethodDescriptorProto.options) } @@ -6455,47 +8936,49 @@ inline void FileOptions::clear_has_java_package() { _has_bits_[0] &= ~0x00000001u; } inline void FileOptions::clear_java_package() { - java_package_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + java_package_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); clear_has_java_package(); } inline const ::std::string& FileOptions::java_package() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.java_package) - return java_package_.GetNoArena(); + return java_package_.Get(); } inline void FileOptions::set_java_package(const ::std::string& value) { set_has_java_package(); - java_package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + java_package_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_package) } #if LANG_CXX11 inline void FileOptions::set_java_package(::std::string&& value) { set_has_java_package(); - java_package_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + java_package_.Set( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.java_package) } #endif inline void FileOptions::set_java_package(const char* value) { GOOGLE_DCHECK(value != NULL); set_has_java_package(); - java_package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + java_package_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.java_package) } -inline void FileOptions::set_java_package(const char* value, size_t size) { +inline void FileOptions::set_java_package(const char* value, + size_t size) { set_has_java_package(); - java_package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); + java_package_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.java_package) } inline ::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()); + return java_package_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::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()); + return java_package_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline void FileOptions::set_allocated_java_package(::std::string* java_package) { if (java_package != NULL) { @@ -6503,9 +8986,29 @@ inline void FileOptions::set_allocated_java_package(::std::string* java_package) } else { clear_has_java_package(); } - java_package_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), java_package); + java_package_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), java_package, + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.java_package) } +inline ::std::string* FileOptions::unsafe_arena_release_java_package() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.FileOptions.java_package) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + clear_has_java_package(); + return java_package_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); +} +inline void FileOptions::unsafe_arena_set_allocated_java_package( + ::std::string* java_package) { + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + if (java_package != NULL) { + set_has_java_package(); + } else { + clear_has_java_package(); + } + java_package_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + java_package, GetArenaNoVirtual()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.FileOptions.java_package) +} // optional string java_outer_classname = 8; inline bool FileOptions::has_java_outer_classname() const { @@ -6518,47 +9021,49 @@ inline void FileOptions::clear_has_java_outer_classname() { _has_bits_[0] &= ~0x00000002u; } inline void FileOptions::clear_java_outer_classname() { - java_outer_classname_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + java_outer_classname_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); clear_has_java_outer_classname(); } inline const ::std::string& FileOptions::java_outer_classname() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.java_outer_classname) - return java_outer_classname_.GetNoArena(); + return java_outer_classname_.Get(); } inline void FileOptions::set_java_outer_classname(const ::std::string& value) { set_has_java_outer_classname(); - java_outer_classname_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + java_outer_classname_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_outer_classname) } #if LANG_CXX11 inline void FileOptions::set_java_outer_classname(::std::string&& value) { set_has_java_outer_classname(); - java_outer_classname_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + java_outer_classname_.Set( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.java_outer_classname) } #endif inline void FileOptions::set_java_outer_classname(const char* value) { GOOGLE_DCHECK(value != NULL); set_has_java_outer_classname(); - java_outer_classname_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + java_outer_classname_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.java_outer_classname) } -inline void FileOptions::set_java_outer_classname(const char* value, size_t size) { +inline void FileOptions::set_java_outer_classname(const char* value, + size_t size) { set_has_java_outer_classname(); - java_outer_classname_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); + java_outer_classname_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.java_outer_classname) } inline ::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()); + return java_outer_classname_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::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()); + return java_outer_classname_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline void FileOptions::set_allocated_java_outer_classname(::std::string* java_outer_classname) { if (java_outer_classname != NULL) { @@ -6566,19 +9071,39 @@ inline void FileOptions::set_allocated_java_outer_classname(::std::string* java_ } else { clear_has_java_outer_classname(); } - java_outer_classname_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), java_outer_classname); + java_outer_classname_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), java_outer_classname, + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.java_outer_classname) } +inline ::std::string* FileOptions::unsafe_arena_release_java_outer_classname() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.FileOptions.java_outer_classname) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + clear_has_java_outer_classname(); + return java_outer_classname_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); +} +inline void FileOptions::unsafe_arena_set_allocated_java_outer_classname( + ::std::string* java_outer_classname) { + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + if (java_outer_classname != NULL) { + set_has_java_outer_classname(); + } else { + clear_has_java_outer_classname(); + } + java_outer_classname_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + java_outer_classname, GetArenaNoVirtual()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.FileOptions.java_outer_classname) +} // optional bool java_multiple_files = 10 [default = false]; inline bool FileOptions::has_java_multiple_files() const { - return (_has_bits_[0] & 0x00000100u) != 0; + return (_has_bits_[0] & 0x00000200u) != 0; } inline void FileOptions::set_has_java_multiple_files() { - _has_bits_[0] |= 0x00000100u; + _has_bits_[0] |= 0x00000200u; } inline void FileOptions::clear_has_java_multiple_files() { - _has_bits_[0] &= ~0x00000100u; + _has_bits_[0] &= ~0x00000200u; } inline void FileOptions::clear_java_multiple_files() { java_multiple_files_ = false; @@ -6596,13 +9121,13 @@ inline void FileOptions::set_java_multiple_files(bool value) { // optional bool java_generate_equals_and_hash = 20 [deprecated = true]; inline bool FileOptions::has_java_generate_equals_and_hash() const { - return (_has_bits_[0] & 0x00000200u) != 0; + return (_has_bits_[0] & 0x00000400u) != 0; } inline void FileOptions::set_has_java_generate_equals_and_hash() { - _has_bits_[0] |= 0x00000200u; + _has_bits_[0] |= 0x00000400u; } inline void FileOptions::clear_has_java_generate_equals_and_hash() { - _has_bits_[0] &= ~0x00000200u; + _has_bits_[0] &= ~0x00000400u; } inline void FileOptions::clear_java_generate_equals_and_hash() { java_generate_equals_and_hash_ = false; @@ -6620,13 +9145,13 @@ inline void FileOptions::set_java_generate_equals_and_hash(bool value) { // optional bool java_string_check_utf8 = 27 [default = false]; inline bool FileOptions::has_java_string_check_utf8() const { - return (_has_bits_[0] & 0x00000400u) != 0; + return (_has_bits_[0] & 0x00000800u) != 0; } inline void FileOptions::set_has_java_string_check_utf8() { - _has_bits_[0] |= 0x00000400u; + _has_bits_[0] |= 0x00000800u; } inline void FileOptions::clear_has_java_string_check_utf8() { - _has_bits_[0] &= ~0x00000400u; + _has_bits_[0] &= ~0x00000800u; } inline void FileOptions::clear_java_string_check_utf8() { java_string_check_utf8_ = false; @@ -6644,13 +9169,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] & 0x00010000u) != 0; + return (_has_bits_[0] & 0x00020000u) != 0; } inline void FileOptions::set_has_optimize_for() { - _has_bits_[0] |= 0x00010000u; + _has_bits_[0] |= 0x00020000u; } inline void FileOptions::clear_has_optimize_for() { - _has_bits_[0] &= ~0x00010000u; + _has_bits_[0] &= ~0x00020000u; } inline void FileOptions::clear_optimize_for() { optimize_for_ = 1; @@ -6678,47 +9203,49 @@ inline void FileOptions::clear_has_go_package() { _has_bits_[0] &= ~0x00000004u; } inline void FileOptions::clear_go_package() { - go_package_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + go_package_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); clear_has_go_package(); } inline const ::std::string& FileOptions::go_package() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.go_package) - return go_package_.GetNoArena(); + return go_package_.Get(); } inline void FileOptions::set_go_package(const ::std::string& value) { set_has_go_package(); - go_package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + go_package_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.go_package) } #if LANG_CXX11 inline void FileOptions::set_go_package(::std::string&& value) { set_has_go_package(); - go_package_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + go_package_.Set( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.go_package) } #endif inline void FileOptions::set_go_package(const char* value) { GOOGLE_DCHECK(value != NULL); set_has_go_package(); - go_package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + go_package_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.go_package) } -inline void FileOptions::set_go_package(const char* value, size_t size) { +inline void FileOptions::set_go_package(const char* value, + size_t size) { set_has_go_package(); - go_package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); + go_package_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.go_package) } inline ::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()); + return go_package_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::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()); + return go_package_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline void FileOptions::set_allocated_go_package(::std::string* go_package) { if (go_package != NULL) { @@ -6726,19 +9253,39 @@ inline void FileOptions::set_allocated_go_package(::std::string* go_package) { } else { clear_has_go_package(); } - go_package_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), go_package); + go_package_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), go_package, + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.go_package) } +inline ::std::string* FileOptions::unsafe_arena_release_go_package() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.FileOptions.go_package) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + clear_has_go_package(); + return go_package_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); +} +inline void FileOptions::unsafe_arena_set_allocated_go_package( + ::std::string* go_package) { + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + if (go_package != NULL) { + set_has_go_package(); + } else { + clear_has_go_package(); + } + go_package_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + go_package, GetArenaNoVirtual()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.FileOptions.go_package) +} // optional bool cc_generic_services = 16 [default = false]; inline bool FileOptions::has_cc_generic_services() const { - return (_has_bits_[0] & 0x00000800u) != 0; + return (_has_bits_[0] & 0x00001000u) != 0; } inline void FileOptions::set_has_cc_generic_services() { - _has_bits_[0] |= 0x00000800u; + _has_bits_[0] |= 0x00001000u; } inline void FileOptions::clear_has_cc_generic_services() { - _has_bits_[0] &= ~0x00000800u; + _has_bits_[0] &= ~0x00001000u; } inline void FileOptions::clear_cc_generic_services() { cc_generic_services_ = false; @@ -6756,13 +9303,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] & 0x00001000u) != 0; + return (_has_bits_[0] & 0x00002000u) != 0; } inline void FileOptions::set_has_java_generic_services() { - _has_bits_[0] |= 0x00001000u; + _has_bits_[0] |= 0x00002000u; } inline void FileOptions::clear_has_java_generic_services() { - _has_bits_[0] &= ~0x00001000u; + _has_bits_[0] &= ~0x00002000u; } inline void FileOptions::clear_java_generic_services() { java_generic_services_ = false; @@ -6780,13 +9327,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] & 0x00002000u) != 0; + return (_has_bits_[0] & 0x00004000u) != 0; } inline void FileOptions::set_has_py_generic_services() { - _has_bits_[0] |= 0x00002000u; + _has_bits_[0] |= 0x00004000u; } inline void FileOptions::clear_has_py_generic_services() { - _has_bits_[0] &= ~0x00002000u; + _has_bits_[0] &= ~0x00004000u; } inline void FileOptions::clear_py_generic_services() { py_generic_services_ = false; @@ -6802,15 +9349,39 @@ inline void FileOptions::set_py_generic_services(bool value) { // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.py_generic_services) } +// optional bool php_generic_services = 42 [default = false]; +inline bool FileOptions::has_php_generic_services() const { + return (_has_bits_[0] & 0x00008000u) != 0; +} +inline void FileOptions::set_has_php_generic_services() { + _has_bits_[0] |= 0x00008000u; +} +inline void FileOptions::clear_has_php_generic_services() { + _has_bits_[0] &= ~0x00008000u; +} +inline void FileOptions::clear_php_generic_services() { + php_generic_services_ = false; + clear_has_php_generic_services(); +} +inline bool FileOptions::php_generic_services() const { + // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.php_generic_services) + return php_generic_services_; +} +inline void FileOptions::set_php_generic_services(bool value) { + set_has_php_generic_services(); + php_generic_services_ = value; + // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.php_generic_services) +} + // optional bool deprecated = 23 [default = false]; inline bool FileOptions::has_deprecated() const { - return (_has_bits_[0] & 0x00004000u) != 0; + return (_has_bits_[0] & 0x00010000u) != 0; } inline void FileOptions::set_has_deprecated() { - _has_bits_[0] |= 0x00004000u; + _has_bits_[0] |= 0x00010000u; } inline void FileOptions::clear_has_deprecated() { - _has_bits_[0] &= ~0x00004000u; + _has_bits_[0] &= ~0x00010000u; } inline void FileOptions::clear_deprecated() { deprecated_ = false; @@ -6828,13 +9399,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] & 0x00008000u) != 0; + return (_has_bits_[0] & 0x00000100u) != 0; } inline void FileOptions::set_has_cc_enable_arenas() { - _has_bits_[0] |= 0x00008000u; + _has_bits_[0] |= 0x00000100u; } inline void FileOptions::clear_has_cc_enable_arenas() { - _has_bits_[0] &= ~0x00008000u; + _has_bits_[0] &= ~0x00000100u; } inline void FileOptions::clear_cc_enable_arenas() { cc_enable_arenas_ = false; @@ -6861,47 +9432,49 @@ inline void FileOptions::clear_has_objc_class_prefix() { _has_bits_[0] &= ~0x00000008u; } inline void FileOptions::clear_objc_class_prefix() { - objc_class_prefix_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + objc_class_prefix_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); clear_has_objc_class_prefix(); } inline const ::std::string& FileOptions::objc_class_prefix() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.objc_class_prefix) - return objc_class_prefix_.GetNoArena(); + return objc_class_prefix_.Get(); } inline void FileOptions::set_objc_class_prefix(const ::std::string& value) { set_has_objc_class_prefix(); - objc_class_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + objc_class_prefix_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.objc_class_prefix) } #if LANG_CXX11 inline void FileOptions::set_objc_class_prefix(::std::string&& value) { set_has_objc_class_prefix(); - objc_class_prefix_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + objc_class_prefix_.Set( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.objc_class_prefix) } #endif inline void FileOptions::set_objc_class_prefix(const char* value) { GOOGLE_DCHECK(value != NULL); set_has_objc_class_prefix(); - objc_class_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + objc_class_prefix_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.objc_class_prefix) } -inline void FileOptions::set_objc_class_prefix(const char* value, size_t size) { +inline void FileOptions::set_objc_class_prefix(const char* value, + size_t size) { set_has_objc_class_prefix(); - objc_class_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); + objc_class_prefix_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.objc_class_prefix) } inline ::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()); + return objc_class_prefix_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::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()); + return objc_class_prefix_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline void FileOptions::set_allocated_objc_class_prefix(::std::string* objc_class_prefix) { if (objc_class_prefix != NULL) { @@ -6909,9 +9482,29 @@ inline void FileOptions::set_allocated_objc_class_prefix(::std::string* objc_cla } else { clear_has_objc_class_prefix(); } - objc_class_prefix_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), objc_class_prefix); + objc_class_prefix_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), objc_class_prefix, + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.objc_class_prefix) } +inline ::std::string* FileOptions::unsafe_arena_release_objc_class_prefix() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.FileOptions.objc_class_prefix) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + clear_has_objc_class_prefix(); + return objc_class_prefix_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); +} +inline void FileOptions::unsafe_arena_set_allocated_objc_class_prefix( + ::std::string* objc_class_prefix) { + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + if (objc_class_prefix != NULL) { + set_has_objc_class_prefix(); + } else { + clear_has_objc_class_prefix(); + } + objc_class_prefix_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + objc_class_prefix, GetArenaNoVirtual()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.FileOptions.objc_class_prefix) +} // optional string csharp_namespace = 37; inline bool FileOptions::has_csharp_namespace() const { @@ -6924,47 +9517,49 @@ inline void FileOptions::clear_has_csharp_namespace() { _has_bits_[0] &= ~0x00000010u; } inline void FileOptions::clear_csharp_namespace() { - csharp_namespace_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + csharp_namespace_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); clear_has_csharp_namespace(); } inline const ::std::string& FileOptions::csharp_namespace() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.csharp_namespace) - return csharp_namespace_.GetNoArena(); + return csharp_namespace_.Get(); } inline void FileOptions::set_csharp_namespace(const ::std::string& value) { set_has_csharp_namespace(); - csharp_namespace_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + csharp_namespace_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_namespace) } #if LANG_CXX11 inline void FileOptions::set_csharp_namespace(::std::string&& value) { set_has_csharp_namespace(); - csharp_namespace_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + csharp_namespace_.Set( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.csharp_namespace) } #endif inline void FileOptions::set_csharp_namespace(const char* value) { GOOGLE_DCHECK(value != NULL); set_has_csharp_namespace(); - csharp_namespace_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + csharp_namespace_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.csharp_namespace) } -inline void FileOptions::set_csharp_namespace(const char* value, size_t size) { +inline void FileOptions::set_csharp_namespace(const char* value, + size_t size) { set_has_csharp_namespace(); - csharp_namespace_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); + csharp_namespace_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.csharp_namespace) } inline ::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()); + return csharp_namespace_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::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()); + return csharp_namespace_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline void FileOptions::set_allocated_csharp_namespace(::std::string* csharp_namespace) { if (csharp_namespace != NULL) { @@ -6972,9 +9567,29 @@ inline void FileOptions::set_allocated_csharp_namespace(::std::string* csharp_na } else { clear_has_csharp_namespace(); } - csharp_namespace_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), csharp_namespace); + csharp_namespace_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), csharp_namespace, + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.csharp_namespace) } +inline ::std::string* FileOptions::unsafe_arena_release_csharp_namespace() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.FileOptions.csharp_namespace) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + clear_has_csharp_namespace(); + return csharp_namespace_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); +} +inline void FileOptions::unsafe_arena_set_allocated_csharp_namespace( + ::std::string* csharp_namespace) { + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + if (csharp_namespace != NULL) { + set_has_csharp_namespace(); + } else { + clear_has_csharp_namespace(); + } + csharp_namespace_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + csharp_namespace, GetArenaNoVirtual()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.FileOptions.csharp_namespace) +} // optional string swift_prefix = 39; inline bool FileOptions::has_swift_prefix() const { @@ -6987,47 +9602,49 @@ inline void FileOptions::clear_has_swift_prefix() { _has_bits_[0] &= ~0x00000020u; } inline void FileOptions::clear_swift_prefix() { - swift_prefix_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + swift_prefix_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); clear_has_swift_prefix(); } inline const ::std::string& FileOptions::swift_prefix() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.swift_prefix) - return swift_prefix_.GetNoArena(); + return swift_prefix_.Get(); } inline void FileOptions::set_swift_prefix(const ::std::string& value) { set_has_swift_prefix(); - swift_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + swift_prefix_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.swift_prefix) } #if LANG_CXX11 inline void FileOptions::set_swift_prefix(::std::string&& value) { set_has_swift_prefix(); - swift_prefix_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + swift_prefix_.Set( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.swift_prefix) } #endif inline void FileOptions::set_swift_prefix(const char* value) { GOOGLE_DCHECK(value != NULL); set_has_swift_prefix(); - swift_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + swift_prefix_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.swift_prefix) } -inline void FileOptions::set_swift_prefix(const char* value, size_t size) { +inline void FileOptions::set_swift_prefix(const char* value, + size_t size) { set_has_swift_prefix(); - swift_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); + swift_prefix_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.swift_prefix) } inline ::std::string* FileOptions::mutable_swift_prefix() { set_has_swift_prefix(); // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.swift_prefix) - return swift_prefix_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return swift_prefix_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* FileOptions::release_swift_prefix() { // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.swift_prefix) clear_has_swift_prefix(); - return swift_prefix_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return swift_prefix_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline void FileOptions::set_allocated_swift_prefix(::std::string* swift_prefix) { if (swift_prefix != NULL) { @@ -7035,9 +9652,29 @@ inline void FileOptions::set_allocated_swift_prefix(::std::string* swift_prefix) } else { clear_has_swift_prefix(); } - swift_prefix_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), swift_prefix); + swift_prefix_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), swift_prefix, + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.swift_prefix) } +inline ::std::string* FileOptions::unsafe_arena_release_swift_prefix() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.FileOptions.swift_prefix) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + clear_has_swift_prefix(); + return swift_prefix_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); +} +inline void FileOptions::unsafe_arena_set_allocated_swift_prefix( + ::std::string* swift_prefix) { + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + if (swift_prefix != NULL) { + set_has_swift_prefix(); + } else { + clear_has_swift_prefix(); + } + swift_prefix_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + swift_prefix, GetArenaNoVirtual()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.FileOptions.swift_prefix) +} // optional string php_class_prefix = 40; inline bool FileOptions::has_php_class_prefix() const { @@ -7050,47 +9687,49 @@ inline void FileOptions::clear_has_php_class_prefix() { _has_bits_[0] &= ~0x00000040u; } inline void FileOptions::clear_php_class_prefix() { - php_class_prefix_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + php_class_prefix_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); clear_has_php_class_prefix(); } inline const ::std::string& FileOptions::php_class_prefix() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.php_class_prefix) - return php_class_prefix_.GetNoArena(); + return php_class_prefix_.Get(); } inline void FileOptions::set_php_class_prefix(const ::std::string& value) { set_has_php_class_prefix(); - php_class_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + php_class_prefix_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.php_class_prefix) } #if LANG_CXX11 inline void FileOptions::set_php_class_prefix(::std::string&& value) { set_has_php_class_prefix(); - php_class_prefix_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + php_class_prefix_.Set( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.php_class_prefix) } #endif inline void FileOptions::set_php_class_prefix(const char* value) { GOOGLE_DCHECK(value != NULL); set_has_php_class_prefix(); - php_class_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + php_class_prefix_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.php_class_prefix) } -inline void FileOptions::set_php_class_prefix(const char* value, size_t size) { +inline void FileOptions::set_php_class_prefix(const char* value, + size_t size) { set_has_php_class_prefix(); - php_class_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); + php_class_prefix_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.php_class_prefix) } inline ::std::string* FileOptions::mutable_php_class_prefix() { set_has_php_class_prefix(); // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.php_class_prefix) - return php_class_prefix_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return php_class_prefix_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* FileOptions::release_php_class_prefix() { // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.php_class_prefix) clear_has_php_class_prefix(); - return php_class_prefix_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return php_class_prefix_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline void FileOptions::set_allocated_php_class_prefix(::std::string* php_class_prefix) { if (php_class_prefix != NULL) { @@ -7098,9 +9737,29 @@ inline void FileOptions::set_allocated_php_class_prefix(::std::string* php_class } else { clear_has_php_class_prefix(); } - php_class_prefix_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), php_class_prefix); + php_class_prefix_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), php_class_prefix, + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.php_class_prefix) } +inline ::std::string* FileOptions::unsafe_arena_release_php_class_prefix() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.FileOptions.php_class_prefix) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + clear_has_php_class_prefix(); + return php_class_prefix_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); +} +inline void FileOptions::unsafe_arena_set_allocated_php_class_prefix( + ::std::string* php_class_prefix) { + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + if (php_class_prefix != NULL) { + set_has_php_class_prefix(); + } else { + clear_has_php_class_prefix(); + } + php_class_prefix_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + php_class_prefix, GetArenaNoVirtual()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.FileOptions.php_class_prefix) +} // optional string php_namespace = 41; inline bool FileOptions::has_php_namespace() const { @@ -7113,47 +9772,49 @@ inline void FileOptions::clear_has_php_namespace() { _has_bits_[0] &= ~0x00000080u; } inline void FileOptions::clear_php_namespace() { - php_namespace_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + php_namespace_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); clear_has_php_namespace(); } inline const ::std::string& FileOptions::php_namespace() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.php_namespace) - return php_namespace_.GetNoArena(); + return php_namespace_.Get(); } inline void FileOptions::set_php_namespace(const ::std::string& value) { set_has_php_namespace(); - php_namespace_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + php_namespace_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.php_namespace) } #if LANG_CXX11 inline void FileOptions::set_php_namespace(::std::string&& value) { set_has_php_namespace(); - php_namespace_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + php_namespace_.Set( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.php_namespace) } #endif inline void FileOptions::set_php_namespace(const char* value) { GOOGLE_DCHECK(value != NULL); set_has_php_namespace(); - php_namespace_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + php_namespace_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.php_namespace) } -inline void FileOptions::set_php_namespace(const char* value, size_t size) { +inline void FileOptions::set_php_namespace(const char* value, + size_t size) { set_has_php_namespace(); - php_namespace_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); + php_namespace_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.php_namespace) } inline ::std::string* FileOptions::mutable_php_namespace() { set_has_php_namespace(); // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.php_namespace) - return php_namespace_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return php_namespace_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* FileOptions::release_php_namespace() { // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.php_namespace) clear_has_php_namespace(); - return php_namespace_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return php_namespace_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline void FileOptions::set_allocated_php_namespace(::std::string* php_namespace) { if (php_namespace != NULL) { @@ -7161,9 +9822,29 @@ inline void FileOptions::set_allocated_php_namespace(::std::string* php_namespac } else { clear_has_php_namespace(); } - php_namespace_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), php_namespace); + php_namespace_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), php_namespace, + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.php_namespace) } +inline ::std::string* FileOptions::unsafe_arena_release_php_namespace() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.FileOptions.php_namespace) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + clear_has_php_namespace(); + return php_namespace_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); +} +inline void FileOptions::unsafe_arena_set_allocated_php_namespace( + ::std::string* php_namespace) { + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + if (php_namespace != NULL) { + set_has_php_namespace(); + } else { + clear_has_php_namespace(); + } + php_namespace_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + php_namespace, GetArenaNoVirtual()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.FileOptions.php_namespace) +} // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; inline int FileOptions::uninterpreted_option_size() const { @@ -7172,23 +9853,23 @@ inline int FileOptions::uninterpreted_option_size() const { inline void FileOptions::clear_uninterpreted_option() { uninterpreted_option_.Clear(); } -inline const ::google::protobuf::UninterpretedOption& FileOptions::uninterpreted_option(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.uninterpreted_option) - return uninterpreted_option_.Get(index); -} inline ::google::protobuf::UninterpretedOption* FileOptions::mutable_uninterpreted_option(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.uninterpreted_option) return uninterpreted_option_.Mutable(index); } -inline ::google::protobuf::UninterpretedOption* FileOptions::add_uninterpreted_option() { - // @@protoc_insertion_point(field_add:google.protobuf.FileOptions.uninterpreted_option) - return uninterpreted_option_.Add(); -} inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >* FileOptions::mutable_uninterpreted_option() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.FileOptions.uninterpreted_option) return &uninterpreted_option_; } +inline const ::google::protobuf::UninterpretedOption& FileOptions::uninterpreted_option(int index) const { + // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.uninterpreted_option) + return uninterpreted_option_.Get(index); +} +inline ::google::protobuf::UninterpretedOption* FileOptions::add_uninterpreted_option() { + // @@protoc_insertion_point(field_add:google.protobuf.FileOptions.uninterpreted_option) + return uninterpreted_option_.Add(); +} inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >& FileOptions::uninterpreted_option() const { // @@protoc_insertion_point(field_list:google.protobuf.FileOptions.uninterpreted_option) @@ -7302,23 +9983,23 @@ inline int MessageOptions::uninterpreted_option_size() const { inline void MessageOptions::clear_uninterpreted_option() { uninterpreted_option_.Clear(); } -inline const ::google::protobuf::UninterpretedOption& MessageOptions::uninterpreted_option(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.MessageOptions.uninterpreted_option) - return uninterpreted_option_.Get(index); -} inline ::google::protobuf::UninterpretedOption* MessageOptions::mutable_uninterpreted_option(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.MessageOptions.uninterpreted_option) return uninterpreted_option_.Mutable(index); } -inline ::google::protobuf::UninterpretedOption* MessageOptions::add_uninterpreted_option() { - // @@protoc_insertion_point(field_add:google.protobuf.MessageOptions.uninterpreted_option) - return uninterpreted_option_.Add(); -} inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >* MessageOptions::mutable_uninterpreted_option() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.MessageOptions.uninterpreted_option) return &uninterpreted_option_; } +inline const ::google::protobuf::UninterpretedOption& MessageOptions::uninterpreted_option(int index) const { + // @@protoc_insertion_point(field_get:google.protobuf.MessageOptions.uninterpreted_option) + return uninterpreted_option_.Get(index); +} +inline ::google::protobuf::UninterpretedOption* MessageOptions::add_uninterpreted_option() { + // @@protoc_insertion_point(field_add:google.protobuf.MessageOptions.uninterpreted_option) + return uninterpreted_option_.Add(); +} inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >& MessageOptions::uninterpreted_option() const { // @@protoc_insertion_point(field_list:google.protobuf.MessageOptions.uninterpreted_option) @@ -7482,23 +10163,23 @@ inline int FieldOptions::uninterpreted_option_size() const { inline void FieldOptions::clear_uninterpreted_option() { uninterpreted_option_.Clear(); } -inline const ::google::protobuf::UninterpretedOption& FieldOptions::uninterpreted_option(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.FieldOptions.uninterpreted_option) - return uninterpreted_option_.Get(index); -} inline ::google::protobuf::UninterpretedOption* FieldOptions::mutable_uninterpreted_option(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.FieldOptions.uninterpreted_option) return uninterpreted_option_.Mutable(index); } -inline ::google::protobuf::UninterpretedOption* FieldOptions::add_uninterpreted_option() { - // @@protoc_insertion_point(field_add:google.protobuf.FieldOptions.uninterpreted_option) - return uninterpreted_option_.Add(); -} inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >* FieldOptions::mutable_uninterpreted_option() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.FieldOptions.uninterpreted_option) return &uninterpreted_option_; } +inline const ::google::protobuf::UninterpretedOption& FieldOptions::uninterpreted_option(int index) const { + // @@protoc_insertion_point(field_get:google.protobuf.FieldOptions.uninterpreted_option) + return uninterpreted_option_.Get(index); +} +inline ::google::protobuf::UninterpretedOption* FieldOptions::add_uninterpreted_option() { + // @@protoc_insertion_point(field_add:google.protobuf.FieldOptions.uninterpreted_option) + return uninterpreted_option_.Add(); +} inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >& FieldOptions::uninterpreted_option() const { // @@protoc_insertion_point(field_list:google.protobuf.FieldOptions.uninterpreted_option) @@ -7516,23 +10197,23 @@ inline int OneofOptions::uninterpreted_option_size() const { inline void OneofOptions::clear_uninterpreted_option() { uninterpreted_option_.Clear(); } -inline const ::google::protobuf::UninterpretedOption& OneofOptions::uninterpreted_option(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.OneofOptions.uninterpreted_option) - return uninterpreted_option_.Get(index); -} inline ::google::protobuf::UninterpretedOption* OneofOptions::mutable_uninterpreted_option(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.OneofOptions.uninterpreted_option) return uninterpreted_option_.Mutable(index); } -inline ::google::protobuf::UninterpretedOption* OneofOptions::add_uninterpreted_option() { - // @@protoc_insertion_point(field_add:google.protobuf.OneofOptions.uninterpreted_option) - return uninterpreted_option_.Add(); -} inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >* OneofOptions::mutable_uninterpreted_option() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.OneofOptions.uninterpreted_option) return &uninterpreted_option_; } +inline const ::google::protobuf::UninterpretedOption& OneofOptions::uninterpreted_option(int index) const { + // @@protoc_insertion_point(field_get:google.protobuf.OneofOptions.uninterpreted_option) + return uninterpreted_option_.Get(index); +} +inline ::google::protobuf::UninterpretedOption* OneofOptions::add_uninterpreted_option() { + // @@protoc_insertion_point(field_add:google.protobuf.OneofOptions.uninterpreted_option) + return uninterpreted_option_.Add(); +} inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >& OneofOptions::uninterpreted_option() const { // @@protoc_insertion_point(field_list:google.protobuf.OneofOptions.uninterpreted_option) @@ -7598,23 +10279,23 @@ inline int EnumOptions::uninterpreted_option_size() const { inline void EnumOptions::clear_uninterpreted_option() { uninterpreted_option_.Clear(); } -inline const ::google::protobuf::UninterpretedOption& EnumOptions::uninterpreted_option(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.EnumOptions.uninterpreted_option) - return uninterpreted_option_.Get(index); -} inline ::google::protobuf::UninterpretedOption* EnumOptions::mutable_uninterpreted_option(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.EnumOptions.uninterpreted_option) return uninterpreted_option_.Mutable(index); } -inline ::google::protobuf::UninterpretedOption* EnumOptions::add_uninterpreted_option() { - // @@protoc_insertion_point(field_add:google.protobuf.EnumOptions.uninterpreted_option) - return uninterpreted_option_.Add(); -} inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >* EnumOptions::mutable_uninterpreted_option() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.EnumOptions.uninterpreted_option) return &uninterpreted_option_; } +inline const ::google::protobuf::UninterpretedOption& EnumOptions::uninterpreted_option(int index) const { + // @@protoc_insertion_point(field_get:google.protobuf.EnumOptions.uninterpreted_option) + return uninterpreted_option_.Get(index); +} +inline ::google::protobuf::UninterpretedOption* EnumOptions::add_uninterpreted_option() { + // @@protoc_insertion_point(field_add:google.protobuf.EnumOptions.uninterpreted_option) + return uninterpreted_option_.Add(); +} inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >& EnumOptions::uninterpreted_option() const { // @@protoc_insertion_point(field_list:google.protobuf.EnumOptions.uninterpreted_option) @@ -7656,23 +10337,23 @@ inline int EnumValueOptions::uninterpreted_option_size() const { inline void EnumValueOptions::clear_uninterpreted_option() { uninterpreted_option_.Clear(); } -inline const ::google::protobuf::UninterpretedOption& EnumValueOptions::uninterpreted_option(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.EnumValueOptions.uninterpreted_option) - return uninterpreted_option_.Get(index); -} inline ::google::protobuf::UninterpretedOption* EnumValueOptions::mutable_uninterpreted_option(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.EnumValueOptions.uninterpreted_option) return uninterpreted_option_.Mutable(index); } -inline ::google::protobuf::UninterpretedOption* EnumValueOptions::add_uninterpreted_option() { - // @@protoc_insertion_point(field_add:google.protobuf.EnumValueOptions.uninterpreted_option) - return uninterpreted_option_.Add(); -} inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >* EnumValueOptions::mutable_uninterpreted_option() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.EnumValueOptions.uninterpreted_option) return &uninterpreted_option_; } +inline const ::google::protobuf::UninterpretedOption& EnumValueOptions::uninterpreted_option(int index) const { + // @@protoc_insertion_point(field_get:google.protobuf.EnumValueOptions.uninterpreted_option) + return uninterpreted_option_.Get(index); +} +inline ::google::protobuf::UninterpretedOption* EnumValueOptions::add_uninterpreted_option() { + // @@protoc_insertion_point(field_add:google.protobuf.EnumValueOptions.uninterpreted_option) + return uninterpreted_option_.Add(); +} inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >& EnumValueOptions::uninterpreted_option() const { // @@protoc_insertion_point(field_list:google.protobuf.EnumValueOptions.uninterpreted_option) @@ -7714,23 +10395,23 @@ inline int ServiceOptions::uninterpreted_option_size() const { inline void ServiceOptions::clear_uninterpreted_option() { uninterpreted_option_.Clear(); } -inline const ::google::protobuf::UninterpretedOption& ServiceOptions::uninterpreted_option(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.ServiceOptions.uninterpreted_option) - return uninterpreted_option_.Get(index); -} inline ::google::protobuf::UninterpretedOption* ServiceOptions::mutable_uninterpreted_option(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.ServiceOptions.uninterpreted_option) return uninterpreted_option_.Mutable(index); } -inline ::google::protobuf::UninterpretedOption* ServiceOptions::add_uninterpreted_option() { - // @@protoc_insertion_point(field_add:google.protobuf.ServiceOptions.uninterpreted_option) - return uninterpreted_option_.Add(); -} inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >* ServiceOptions::mutable_uninterpreted_option() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.ServiceOptions.uninterpreted_option) return &uninterpreted_option_; } +inline const ::google::protobuf::UninterpretedOption& ServiceOptions::uninterpreted_option(int index) const { + // @@protoc_insertion_point(field_get:google.protobuf.ServiceOptions.uninterpreted_option) + return uninterpreted_option_.Get(index); +} +inline ::google::protobuf::UninterpretedOption* ServiceOptions::add_uninterpreted_option() { + // @@protoc_insertion_point(field_add:google.protobuf.ServiceOptions.uninterpreted_option) + return uninterpreted_option_.Add(); +} inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >& ServiceOptions::uninterpreted_option() const { // @@protoc_insertion_point(field_list:google.protobuf.ServiceOptions.uninterpreted_option) @@ -7797,23 +10478,23 @@ inline int MethodOptions::uninterpreted_option_size() const { inline void MethodOptions::clear_uninterpreted_option() { uninterpreted_option_.Clear(); } -inline const ::google::protobuf::UninterpretedOption& MethodOptions::uninterpreted_option(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.MethodOptions.uninterpreted_option) - return uninterpreted_option_.Get(index); -} inline ::google::protobuf::UninterpretedOption* MethodOptions::mutable_uninterpreted_option(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.MethodOptions.uninterpreted_option) return uninterpreted_option_.Mutable(index); } -inline ::google::protobuf::UninterpretedOption* MethodOptions::add_uninterpreted_option() { - // @@protoc_insertion_point(field_add:google.protobuf.MethodOptions.uninterpreted_option) - return uninterpreted_option_.Add(); -} inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >* MethodOptions::mutable_uninterpreted_option() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.MethodOptions.uninterpreted_option) return &uninterpreted_option_; } +inline const ::google::protobuf::UninterpretedOption& MethodOptions::uninterpreted_option(int index) const { + // @@protoc_insertion_point(field_get:google.protobuf.MethodOptions.uninterpreted_option) + return uninterpreted_option_.Get(index); +} +inline ::google::protobuf::UninterpretedOption* MethodOptions::add_uninterpreted_option() { + // @@protoc_insertion_point(field_add:google.protobuf.MethodOptions.uninterpreted_option) + return uninterpreted_option_.Add(); +} inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >& MethodOptions::uninterpreted_option() const { // @@protoc_insertion_point(field_list:google.protobuf.MethodOptions.uninterpreted_option) @@ -7835,47 +10516,49 @@ inline void UninterpretedOption_NamePart::clear_has_name_part() { _has_bits_[0] &= ~0x00000001u; } inline void UninterpretedOption_NamePart::clear_name_part() { - name_part_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + name_part_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); clear_has_name_part(); } inline const ::std::string& UninterpretedOption_NamePart::name_part() const { // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.NamePart.name_part) - return name_part_.GetNoArena(); + return name_part_.Get(); } inline void UninterpretedOption_NamePart::set_name_part(const ::std::string& value) { set_has_name_part(); - name_part_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + name_part_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.NamePart.name_part) } #if LANG_CXX11 inline void UninterpretedOption_NamePart::set_name_part(::std::string&& value) { set_has_name_part(); - name_part_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + name_part_.Set( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.UninterpretedOption.NamePart.name_part) } #endif inline void UninterpretedOption_NamePart::set_name_part(const char* value) { GOOGLE_DCHECK(value != NULL); set_has_name_part(); - name_part_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + name_part_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.protobuf.UninterpretedOption.NamePart.name_part) } -inline void UninterpretedOption_NamePart::set_name_part(const char* value, size_t size) { +inline void UninterpretedOption_NamePart::set_name_part(const char* value, + size_t size) { set_has_name_part(); - name_part_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); + name_part_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.UninterpretedOption.NamePart.name_part) } inline ::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()); + return name_part_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::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()); + return name_part_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline void UninterpretedOption_NamePart::set_allocated_name_part(::std::string* name_part) { if (name_part != NULL) { @@ -7883,9 +10566,29 @@ inline void UninterpretedOption_NamePart::set_allocated_name_part(::std::string* } else { clear_has_name_part(); } - name_part_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name_part); + name_part_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name_part, + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.UninterpretedOption.NamePart.name_part) } +inline ::std::string* UninterpretedOption_NamePart::unsafe_arena_release_name_part() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.UninterpretedOption.NamePart.name_part) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + clear_has_name_part(); + return name_part_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); +} +inline void UninterpretedOption_NamePart::unsafe_arena_set_allocated_name_part( + ::std::string* name_part) { + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + if (name_part != NULL) { + set_has_name_part(); + } else { + clear_has_name_part(); + } + name_part_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + name_part, GetArenaNoVirtual()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.UninterpretedOption.NamePart.name_part) +} // required bool is_extension = 2; inline bool UninterpretedOption_NamePart::has_is_extension() const { @@ -7922,23 +10625,23 @@ inline int UninterpretedOption::name_size() const { inline void UninterpretedOption::clear_name() { name_.Clear(); } -inline const ::google::protobuf::UninterpretedOption_NamePart& UninterpretedOption::name(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.name) - return name_.Get(index); -} inline ::google::protobuf::UninterpretedOption_NamePart* UninterpretedOption::mutable_name(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.UninterpretedOption.name) return name_.Mutable(index); } -inline ::google::protobuf::UninterpretedOption_NamePart* UninterpretedOption::add_name() { - // @@protoc_insertion_point(field_add:google.protobuf.UninterpretedOption.name) - return name_.Add(); -} inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption_NamePart >* UninterpretedOption::mutable_name() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.UninterpretedOption.name) return &name_; } +inline const ::google::protobuf::UninterpretedOption_NamePart& UninterpretedOption::name(int index) const { + // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.name) + return name_.Get(index); +} +inline ::google::protobuf::UninterpretedOption_NamePart* UninterpretedOption::add_name() { + // @@protoc_insertion_point(field_add:google.protobuf.UninterpretedOption.name) + return name_.Add(); +} inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption_NamePart >& UninterpretedOption::name() const { // @@protoc_insertion_point(field_list:google.protobuf.UninterpretedOption.name) @@ -7956,47 +10659,49 @@ inline void UninterpretedOption::clear_has_identifier_value() { _has_bits_[0] &= ~0x00000001u; } inline void UninterpretedOption::clear_identifier_value() { - identifier_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + identifier_value_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); clear_has_identifier_value(); } inline const ::std::string& UninterpretedOption::identifier_value() const { // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.identifier_value) - return identifier_value_.GetNoArena(); + return identifier_value_.Get(); } inline void UninterpretedOption::set_identifier_value(const ::std::string& value) { set_has_identifier_value(); - identifier_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + identifier_value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.identifier_value) } #if LANG_CXX11 inline void UninterpretedOption::set_identifier_value(::std::string&& value) { set_has_identifier_value(); - identifier_value_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + identifier_value_.Set( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.UninterpretedOption.identifier_value) } #endif inline void UninterpretedOption::set_identifier_value(const char* value) { GOOGLE_DCHECK(value != NULL); set_has_identifier_value(); - identifier_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + identifier_value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.protobuf.UninterpretedOption.identifier_value) } -inline void UninterpretedOption::set_identifier_value(const char* value, size_t size) { +inline void UninterpretedOption::set_identifier_value(const char* value, + size_t size) { set_has_identifier_value(); - identifier_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); + identifier_value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.UninterpretedOption.identifier_value) } inline ::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()); + return identifier_value_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::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()); + return identifier_value_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline void UninterpretedOption::set_allocated_identifier_value(::std::string* identifier_value) { if (identifier_value != NULL) { @@ -8004,9 +10709,29 @@ inline void UninterpretedOption::set_allocated_identifier_value(::std::string* i } else { clear_has_identifier_value(); } - identifier_value_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), identifier_value); + identifier_value_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), identifier_value, + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.UninterpretedOption.identifier_value) } +inline ::std::string* UninterpretedOption::unsafe_arena_release_identifier_value() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.UninterpretedOption.identifier_value) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + clear_has_identifier_value(); + return identifier_value_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); +} +inline void UninterpretedOption::unsafe_arena_set_allocated_identifier_value( + ::std::string* identifier_value) { + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + if (identifier_value != NULL) { + set_has_identifier_value(); + } else { + clear_has_identifier_value(); + } + identifier_value_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + identifier_value, GetArenaNoVirtual()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.UninterpretedOption.identifier_value) +} // optional uint64 positive_int_value = 4; inline bool UninterpretedOption::has_positive_int_value() const { @@ -8091,47 +10816,49 @@ inline void UninterpretedOption::clear_has_string_value() { _has_bits_[0] &= ~0x00000002u; } inline void UninterpretedOption::clear_string_value() { - string_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + string_value_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); clear_has_string_value(); } inline const ::std::string& UninterpretedOption::string_value() const { // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.string_value) - return string_value_.GetNoArena(); + return string_value_.Get(); } inline void UninterpretedOption::set_string_value(const ::std::string& value) { set_has_string_value(); - string_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + string_value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.string_value) } #if LANG_CXX11 inline void UninterpretedOption::set_string_value(::std::string&& value) { set_has_string_value(); - string_value_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + string_value_.Set( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.UninterpretedOption.string_value) } #endif inline void UninterpretedOption::set_string_value(const char* value) { GOOGLE_DCHECK(value != NULL); set_has_string_value(); - string_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + string_value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.protobuf.UninterpretedOption.string_value) } -inline void UninterpretedOption::set_string_value(const void* value, size_t size) { +inline void UninterpretedOption::set_string_value(const void* value, + size_t size) { set_has_string_value(); - string_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); + string_value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.UninterpretedOption.string_value) } inline ::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()); + return string_value_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::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()); + return string_value_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline void UninterpretedOption::set_allocated_string_value(::std::string* string_value) { if (string_value != NULL) { @@ -8139,9 +10866,29 @@ inline void UninterpretedOption::set_allocated_string_value(::std::string* strin } else { clear_has_string_value(); } - string_value_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), string_value); + string_value_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), string_value, + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.UninterpretedOption.string_value) } +inline ::std::string* UninterpretedOption::unsafe_arena_release_string_value() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.UninterpretedOption.string_value) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + clear_has_string_value(); + return string_value_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); +} +inline void UninterpretedOption::unsafe_arena_set_allocated_string_value( + ::std::string* string_value) { + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + if (string_value != NULL) { + set_has_string_value(); + } else { + clear_has_string_value(); + } + string_value_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + string_value, GetArenaNoVirtual()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.UninterpretedOption.string_value) +} // optional string aggregate_value = 8; inline bool UninterpretedOption::has_aggregate_value() const { @@ -8154,47 +10901,49 @@ inline void UninterpretedOption::clear_has_aggregate_value() { _has_bits_[0] &= ~0x00000004u; } inline void UninterpretedOption::clear_aggregate_value() { - aggregate_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + aggregate_value_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); clear_has_aggregate_value(); } inline const ::std::string& UninterpretedOption::aggregate_value() const { // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.aggregate_value) - return aggregate_value_.GetNoArena(); + return aggregate_value_.Get(); } inline void UninterpretedOption::set_aggregate_value(const ::std::string& value) { set_has_aggregate_value(); - aggregate_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + aggregate_value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.aggregate_value) } #if LANG_CXX11 inline void UninterpretedOption::set_aggregate_value(::std::string&& value) { set_has_aggregate_value(); - aggregate_value_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + aggregate_value_.Set( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.UninterpretedOption.aggregate_value) } #endif inline void UninterpretedOption::set_aggregate_value(const char* value) { GOOGLE_DCHECK(value != NULL); set_has_aggregate_value(); - aggregate_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + aggregate_value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.protobuf.UninterpretedOption.aggregate_value) } -inline void UninterpretedOption::set_aggregate_value(const char* value, size_t size) { +inline void UninterpretedOption::set_aggregate_value(const char* value, + size_t size) { set_has_aggregate_value(); - aggregate_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); + aggregate_value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.UninterpretedOption.aggregate_value) } inline ::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()); + return aggregate_value_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::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()); + return aggregate_value_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline void UninterpretedOption::set_allocated_aggregate_value(::std::string* aggregate_value) { if (aggregate_value != NULL) { @@ -8202,9 +10951,29 @@ inline void UninterpretedOption::set_allocated_aggregate_value(::std::string* ag } else { clear_has_aggregate_value(); } - aggregate_value_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), aggregate_value); + aggregate_value_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), aggregate_value, + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.UninterpretedOption.aggregate_value) } +inline ::std::string* UninterpretedOption::unsafe_arena_release_aggregate_value() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.UninterpretedOption.aggregate_value) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + clear_has_aggregate_value(); + return aggregate_value_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); +} +inline void UninterpretedOption::unsafe_arena_set_allocated_aggregate_value( + ::std::string* aggregate_value) { + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + if (aggregate_value != NULL) { + set_has_aggregate_value(); + } else { + clear_has_aggregate_value(); + } + aggregate_value_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + aggregate_value, GetArenaNoVirtual()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.UninterpretedOption.aggregate_value) +} // ------------------------------------------------------------------- @@ -8281,47 +11050,49 @@ inline void SourceCodeInfo_Location::clear_has_leading_comments() { _has_bits_[0] &= ~0x00000001u; } inline void SourceCodeInfo_Location::clear_leading_comments() { - leading_comments_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + leading_comments_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); clear_has_leading_comments(); } inline const ::std::string& SourceCodeInfo_Location::leading_comments() const { // @@protoc_insertion_point(field_get:google.protobuf.SourceCodeInfo.Location.leading_comments) - return leading_comments_.GetNoArena(); + return leading_comments_.Get(); } inline void SourceCodeInfo_Location::set_leading_comments(const ::std::string& value) { set_has_leading_comments(); - leading_comments_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + leading_comments_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.leading_comments) } #if LANG_CXX11 inline void SourceCodeInfo_Location::set_leading_comments(::std::string&& value) { set_has_leading_comments(); - leading_comments_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + leading_comments_.Set( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.SourceCodeInfo.Location.leading_comments) } #endif inline void SourceCodeInfo_Location::set_leading_comments(const char* value) { GOOGLE_DCHECK(value != NULL); set_has_leading_comments(); - leading_comments_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + leading_comments_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.protobuf.SourceCodeInfo.Location.leading_comments) } -inline void SourceCodeInfo_Location::set_leading_comments(const char* value, size_t size) { +inline void SourceCodeInfo_Location::set_leading_comments(const char* value, + size_t size) { set_has_leading_comments(); - leading_comments_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); + leading_comments_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.SourceCodeInfo.Location.leading_comments) } inline ::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()); + return leading_comments_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::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()); + return leading_comments_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline void SourceCodeInfo_Location::set_allocated_leading_comments(::std::string* leading_comments) { if (leading_comments != NULL) { @@ -8329,9 +11100,29 @@ inline void SourceCodeInfo_Location::set_allocated_leading_comments(::std::strin } else { clear_has_leading_comments(); } - leading_comments_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), leading_comments); + leading_comments_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), leading_comments, + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.SourceCodeInfo.Location.leading_comments) } +inline ::std::string* SourceCodeInfo_Location::unsafe_arena_release_leading_comments() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.SourceCodeInfo.Location.leading_comments) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + clear_has_leading_comments(); + return leading_comments_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); +} +inline void SourceCodeInfo_Location::unsafe_arena_set_allocated_leading_comments( + ::std::string* leading_comments) { + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + if (leading_comments != NULL) { + set_has_leading_comments(); + } else { + clear_has_leading_comments(); + } + leading_comments_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + leading_comments, GetArenaNoVirtual()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.SourceCodeInfo.Location.leading_comments) +} // optional string trailing_comments = 4; inline bool SourceCodeInfo_Location::has_trailing_comments() const { @@ -8344,47 +11135,49 @@ inline void SourceCodeInfo_Location::clear_has_trailing_comments() { _has_bits_[0] &= ~0x00000002u; } inline void SourceCodeInfo_Location::clear_trailing_comments() { - trailing_comments_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + trailing_comments_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); clear_has_trailing_comments(); } inline const ::std::string& SourceCodeInfo_Location::trailing_comments() const { // @@protoc_insertion_point(field_get:google.protobuf.SourceCodeInfo.Location.trailing_comments) - return trailing_comments_.GetNoArena(); + return trailing_comments_.Get(); } inline void SourceCodeInfo_Location::set_trailing_comments(const ::std::string& value) { set_has_trailing_comments(); - trailing_comments_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + trailing_comments_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.trailing_comments) } #if LANG_CXX11 inline void SourceCodeInfo_Location::set_trailing_comments(::std::string&& value) { set_has_trailing_comments(); - trailing_comments_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + trailing_comments_.Set( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.SourceCodeInfo.Location.trailing_comments) } #endif inline void SourceCodeInfo_Location::set_trailing_comments(const char* value) { GOOGLE_DCHECK(value != NULL); set_has_trailing_comments(); - trailing_comments_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + trailing_comments_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.protobuf.SourceCodeInfo.Location.trailing_comments) } -inline void SourceCodeInfo_Location::set_trailing_comments(const char* value, size_t size) { +inline void SourceCodeInfo_Location::set_trailing_comments(const char* value, + size_t size) { set_has_trailing_comments(); - trailing_comments_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); + trailing_comments_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.SourceCodeInfo.Location.trailing_comments) } inline ::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()); + return trailing_comments_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::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()); + return trailing_comments_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline void SourceCodeInfo_Location::set_allocated_trailing_comments(::std::string* trailing_comments) { if (trailing_comments != NULL) { @@ -8392,9 +11185,29 @@ inline void SourceCodeInfo_Location::set_allocated_trailing_comments(::std::stri } else { clear_has_trailing_comments(); } - trailing_comments_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), trailing_comments); + trailing_comments_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), trailing_comments, + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.SourceCodeInfo.Location.trailing_comments) } +inline ::std::string* SourceCodeInfo_Location::unsafe_arena_release_trailing_comments() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.SourceCodeInfo.Location.trailing_comments) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + clear_has_trailing_comments(); + return trailing_comments_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); +} +inline void SourceCodeInfo_Location::unsafe_arena_set_allocated_trailing_comments( + ::std::string* trailing_comments) { + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + if (trailing_comments != NULL) { + set_has_trailing_comments(); + } else { + clear_has_trailing_comments(); + } + trailing_comments_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + trailing_comments, GetArenaNoVirtual()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.SourceCodeInfo.Location.trailing_comments) +} // repeated string leading_detached_comments = 6; inline int SourceCodeInfo_Location::leading_detached_comments_size() const { @@ -8476,23 +11289,23 @@ inline int SourceCodeInfo::location_size() const { inline void SourceCodeInfo::clear_location() { location_.Clear(); } -inline const ::google::protobuf::SourceCodeInfo_Location& SourceCodeInfo::location(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.SourceCodeInfo.location) - return location_.Get(index); -} inline ::google::protobuf::SourceCodeInfo_Location* SourceCodeInfo::mutable_location(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.SourceCodeInfo.location) return location_.Mutable(index); } -inline ::google::protobuf::SourceCodeInfo_Location* SourceCodeInfo::add_location() { - // @@protoc_insertion_point(field_add:google.protobuf.SourceCodeInfo.location) - return location_.Add(); -} inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::SourceCodeInfo_Location >* SourceCodeInfo::mutable_location() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.SourceCodeInfo.location) return &location_; } +inline const ::google::protobuf::SourceCodeInfo_Location& SourceCodeInfo::location(int index) const { + // @@protoc_insertion_point(field_get:google.protobuf.SourceCodeInfo.location) + return location_.Get(index); +} +inline ::google::protobuf::SourceCodeInfo_Location* SourceCodeInfo::add_location() { + // @@protoc_insertion_point(field_add:google.protobuf.SourceCodeInfo.location) + return location_.Add(); +} inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::SourceCodeInfo_Location >& SourceCodeInfo::location() const { // @@protoc_insertion_point(field_list:google.protobuf.SourceCodeInfo.location) @@ -8544,47 +11357,49 @@ inline void GeneratedCodeInfo_Annotation::clear_has_source_file() { _has_bits_[0] &= ~0x00000001u; } inline void GeneratedCodeInfo_Annotation::clear_source_file() { - source_file_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + source_file_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); clear_has_source_file(); } inline const ::std::string& GeneratedCodeInfo_Annotation::source_file() const { // @@protoc_insertion_point(field_get:google.protobuf.GeneratedCodeInfo.Annotation.source_file) - return source_file_.GetNoArena(); + return source_file_.Get(); } inline void GeneratedCodeInfo_Annotation::set_source_file(const ::std::string& value) { set_has_source_file(); - source_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + source_file_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.GeneratedCodeInfo.Annotation.source_file) } #if LANG_CXX11 inline void GeneratedCodeInfo_Annotation::set_source_file(::std::string&& value) { set_has_source_file(); - source_file_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + source_file_.Set( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_rvalue:google.protobuf.GeneratedCodeInfo.Annotation.source_file) } #endif inline void GeneratedCodeInfo_Annotation::set_source_file(const char* value) { GOOGLE_DCHECK(value != NULL); set_has_source_file(); - source_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + source_file_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.protobuf.GeneratedCodeInfo.Annotation.source_file) } -inline void GeneratedCodeInfo_Annotation::set_source_file(const char* value, size_t size) { +inline void GeneratedCodeInfo_Annotation::set_source_file(const char* value, + size_t size) { set_has_source_file(); - source_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); + source_file_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.GeneratedCodeInfo.Annotation.source_file) } inline ::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()); + return source_file_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::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()); + return source_file_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline void GeneratedCodeInfo_Annotation::set_allocated_source_file(::std::string* source_file) { if (source_file != NULL) { @@ -8592,9 +11407,29 @@ inline void GeneratedCodeInfo_Annotation::set_allocated_source_file(::std::strin } else { clear_has_source_file(); } - source_file_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), source_file); + source_file_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), source_file, + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.GeneratedCodeInfo.Annotation.source_file) } +inline ::std::string* GeneratedCodeInfo_Annotation::unsafe_arena_release_source_file() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.GeneratedCodeInfo.Annotation.source_file) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + clear_has_source_file(); + return source_file_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); +} +inline void GeneratedCodeInfo_Annotation::unsafe_arena_set_allocated_source_file( + ::std::string* source_file) { + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + if (source_file != NULL) { + set_has_source_file(); + } else { + clear_has_source_file(); + } + source_file_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + source_file, GetArenaNoVirtual()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.GeneratedCodeInfo.Annotation.source_file) +} // optional int32 begin = 3; inline bool GeneratedCodeInfo_Annotation::has_begin() const { @@ -8655,30 +11490,32 @@ inline int GeneratedCodeInfo::annotation_size() const { inline void GeneratedCodeInfo::clear_annotation() { annotation_.Clear(); } -inline const ::google::protobuf::GeneratedCodeInfo_Annotation& GeneratedCodeInfo::annotation(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.GeneratedCodeInfo.annotation) - return annotation_.Get(index); -} inline ::google::protobuf::GeneratedCodeInfo_Annotation* GeneratedCodeInfo::mutable_annotation(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.GeneratedCodeInfo.annotation) return annotation_.Mutable(index); } -inline ::google::protobuf::GeneratedCodeInfo_Annotation* GeneratedCodeInfo::add_annotation() { - // @@protoc_insertion_point(field_add:google.protobuf.GeneratedCodeInfo.annotation) - return annotation_.Add(); -} inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::GeneratedCodeInfo_Annotation >* GeneratedCodeInfo::mutable_annotation() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.GeneratedCodeInfo.annotation) return &annotation_; } +inline const ::google::protobuf::GeneratedCodeInfo_Annotation& GeneratedCodeInfo::annotation(int index) const { + // @@protoc_insertion_point(field_get:google.protobuf.GeneratedCodeInfo.annotation) + return annotation_.Get(index); +} +inline ::google::protobuf::GeneratedCodeInfo_Annotation* GeneratedCodeInfo::add_annotation() { + // @@protoc_insertion_point(field_add:google.protobuf.GeneratedCodeInfo.annotation) + return annotation_.Add(); +} inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::GeneratedCodeInfo_Annotation >& GeneratedCodeInfo::annotation() const { // @@protoc_insertion_point(field_list:google.protobuf.GeneratedCodeInfo.annotation) return annotation_; } -#endif // !PROTOBUF_INLINE_NOT_IN_HEADERS +#ifdef __GNUC__ + #pragma GCC diagnostic pop +#endif // __GNUC__ // ------------------------------------------------------------------- // ------------------------------------------------------------------- @@ -8727,14 +11564,16 @@ GeneratedCodeInfo::annotation() const { // ------------------------------------------------------------------- +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- -// @@protoc_insertion_point(namespace_scope) +// @@protoc_insertion_point(namespace_scope) } // namespace protobuf } // namespace google -#ifndef SWIG namespace google { namespace protobuf { @@ -8771,8 +11610,7 @@ inline const EnumDescriptor* GetEnumDescriptor< ::google::protobuf::MethodOption } // namespace protobuf } // namespace google -#endif // SWIG // @@protoc_insertion_point(global_scope) -#endif // PROTOBUF_google_2fprotobuf_2fdescriptor_2eproto__INCLUDED +#endif // PROTOBUF_google_2fprotobuf_2fdescriptor_2eproto_INCLUDED diff --git a/src/google/protobuf/descriptor.proto b/src/google/protobuf/descriptor.proto index c7fbaaf6..8697a50d 100644 --- a/src/google/protobuf/descriptor.proto +++ b/src/google/protobuf/descriptor.proto @@ -45,6 +45,7 @@ option java_package = "com.google.protobuf"; option java_outer_classname = "DescriptorProtos"; option csharp_namespace = "Google.Protobuf.Reflection"; option objc_class_prefix = "GPB"; +option cc_enable_arenas = true; // descriptor.proto must be optimized for speed because reflection-based // algorithms don't work during bootstrapping. @@ -101,6 +102,8 @@ message DescriptorProto { message ExtensionRange { optional int32 start = 1; optional int32 end = 2; + + optional ExtensionRangeOptions options = 3; } repeated ExtensionRange extension_range = 5; @@ -121,6 +124,14 @@ message DescriptorProto { repeated string reserved_name = 10; } +message ExtensionRangeOptions { + // The parser stores options it doesn't recognize here. See above. + repeated UninterpretedOption uninterpreted_option = 999; + + // Clients can define custom options in extensions of this message. See above. + extensions 1000 to max; +} + // Describes a field within a message. message FieldDescriptorProto { enum Type { @@ -215,6 +226,26 @@ message EnumDescriptorProto { repeated EnumValueDescriptorProto value = 2; optional EnumOptions options = 3; + + // Range of reserved numeric values. Reserved values may not be used by + // entries in the same enum. Reserved ranges may not overlap. + // + // Note that this is distinct from DescriptorProto.ReservedRange in that it + // is inclusive such that it can appropriately represent the entire int32 + // domain. + message EnumReservedRange { + optional int32 start = 1; // Inclusive. + optional int32 end = 2; // Inclusive. + } + + // Range of reserved numeric values. Reserved numeric values may not be used + // by enum values in the same enum declaration. Reserved ranges may not + // overlap. + repeated EnumReservedRange reserved_range = 4; + + // Reserved enum value names, which may not be reused. A given name may only + // be reserved once. + repeated string reserved_name = 5; } // Describes a value within an enum. @@ -351,6 +382,7 @@ message FileOptions { optional bool cc_generic_services = 16 [default=false]; optional bool java_generic_services = 17 [default=false]; optional bool py_generic_services = 18 [default=false]; + optional bool php_generic_services = 42 [default=false]; // Is this file deprecated? // Depending on the target platform, this can emit Deprecated annotations @@ -385,10 +417,12 @@ message FileOptions { // determining the namespace. optional string php_namespace = 41; - // The parser stores options it doesn't recognize here. See above. + // The parser stores options it doesn't recognize here. + // See the documentation for the "Options" section above. repeated UninterpretedOption uninterpreted_option = 999; - // Clients can define custom options in extensions of this message. See above. + // Clients can define custom options in extensions of this message. + // See the documentation for the "Options" section above. extensions 1000 to max; reserved 38; @@ -482,13 +516,15 @@ message FieldOptions { // 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 - // represented as JavaScript strings. This avoids loss of precision that can - // happen when a large value is converted to a floating point JavaScript - // numbers. Specifying JS_NUMBER for the jstype causes the generated - // JavaScript code to use the JavaScript "number" type instead of strings. - // This option is an enum to permit additional types to be added, - // e.g. goog.math.Integer. + // (int64, uint64, sint64, fixed64, sfixed64). A field with jstype JS_STRING + // is represented as JavaScript string, which avoids loss of precision that + // can happen when a large value is converted to a floating point JavaScript. + // Specifying JS_NUMBER for the jstype causes the generated JavaScript code to + // use the JavaScript "number" type. The behavior of the default option + // JS_NORMAL is implementation dependent. + // + // This option is an enum to permit additional types to be added, e.g. + // goog.math.Integer. optional JSType jstype = 6 [default = JS_NORMAL]; enum JSType { // Use the default type. diff --git a/src/google/protobuf/descriptor_database.cc b/src/google/protobuf/descriptor_database.cc index 4e46b2a8..ba85ef13 100644 --- a/src/google/protobuf/descriptor_database.cc +++ b/src/google/protobuf/descriptor_database.cc @@ -39,8 +39,9 @@ #include <google/protobuf/descriptor.pb.h> #include <google/protobuf/wire_format_lite_inl.h> #include <google/protobuf/stubs/strutil.h> -#include <google/protobuf/stubs/stl_util.h> + #include <google/protobuf/stubs/map_util.h> +#include <google/protobuf/stubs/stl_util.h> namespace google { namespace protobuf { @@ -230,7 +231,7 @@ bool SimpleDescriptorDatabase::DescriptorIndex<Value>::IsSubSymbol( const string& sub_symbol, const string& super_symbol) { return sub_symbol == super_symbol || (HasPrefixString(super_symbol, sub_symbol) && - super_symbol[sub_symbol.size()] == '.'); + super_symbol[sub_symbol.size()] == '.'); } template <typename Value> diff --git a/src/google/protobuf/descriptor_database_unittest.cc b/src/google/protobuf/descriptor_database_unittest.cc index 7e81d70a..9d710886 100644 --- a/src/google/protobuf/descriptor_database_unittest.cc +++ b/src/google/protobuf/descriptor_database_unittest.cc @@ -247,6 +247,10 @@ TEST_P(DescriptorDatabaseTest, FindFileContainingSymbol) { FileDescriptorProto file; EXPECT_TRUE(database_->FindFileContainingSymbol("Foo.qux", &file)); EXPECT_EQ("foo.proto", file.name()); + // Non-existent field under a valid top level symbol can also be + // found. + EXPECT_TRUE(database_->FindFileContainingSymbol("Foo.none_field.none", + &file)); } { diff --git a/src/google/protobuf/descriptor_unittest.cc b/src/google/protobuf/descriptor_unittest.cc index 75238931..b0337035 100644 --- a/src/google/protobuf/descriptor_unittest.cc +++ b/src/google/protobuf/descriptor_unittest.cc @@ -34,6 +34,7 @@ // // This file makes extensive use of RFC 3092. :) +#include <limits> #include <memory> #ifndef _SHARED_PTR_H #include <google/protobuf/stubs/shared_ptr.h> @@ -62,6 +63,7 @@ #include <google/protobuf/testing/googletest.h> #include <gtest/gtest.h> + namespace google { namespace protobuf { @@ -157,6 +159,14 @@ DescriptorProto::ReservedRange* AddReservedRange(DescriptorProto* parent, return result; } +EnumDescriptorProto::EnumReservedRange* AddReservedRange( + EnumDescriptorProto* parent, int start, int end) { + EnumDescriptorProto::EnumReservedRange* result = parent->add_reserved_range(); + result->set_start(start); + result->set_end(end); + return result; +} + EnumValueDescriptorProto* AddEnumValue(EnumDescriptorProto* enum_proto, const string& name, int number) { EnumValueDescriptorProto* result = enum_proto->add_value(); @@ -421,6 +431,7 @@ TEST_F(FileDescriptorTest, FindExtensionByNumber) { EXPECT_TRUE(pool_.FindExtensionByNumber(foo_message_, 2) == NULL); } + TEST_F(FileDescriptorTest, BuildAgain) { // Test that if te call BuildFile again on the same input we get the same // FileDescriptor back. @@ -963,6 +974,7 @@ TEST_F(DescriptorTest, FieldEnumType) { EXPECT_EQ(enum_, bar_->enum_type()); } + // =================================================================== // Test simple flat messages and fields. @@ -1933,6 +1945,7 @@ TEST_F(ExtensionDescriptorTest, FindAllExtensions) { EXPECT_EQ(39, extensions[3]->number()); } + TEST_F(ExtensionDescriptorTest, DuplicateFieldNumber) { DescriptorPool pool; FileDescriptorProto file_proto; @@ -2047,6 +2060,137 @@ TEST_F(ReservedDescriptorTest, IsReservedName) { // =================================================================== +// Test reserved enum fields. +class ReservedEnumDescriptorTest : public testing::Test { + protected: + virtual void SetUp() { + // Build descriptors for the following definitions: + // + // enum Foo { + // BAR = 1; + // reserved 2, 9 to 11, 15; + // reserved "foo", "bar"; + // } + + FileDescriptorProto foo_file; + foo_file.set_name("foo.proto"); + + EnumDescriptorProto* foo = AddEnum(&foo_file, "Foo"); + EnumDescriptorProto* edge1 = AddEnum(&foo_file, "Edge1"); + EnumDescriptorProto* edge2 = AddEnum(&foo_file, "Edge2"); + + AddEnumValue(foo, "BAR", 4); + AddReservedRange(foo, -5, -3); + AddReservedRange(foo, -2, 1); + AddReservedRange(foo, 2, 3); + AddReservedRange(foo, 9, 12); + AddReservedRange(foo, 15, 16); + + foo->add_reserved_name("foo"); + foo->add_reserved_name("bar"); + + // Some additional edge cases that cover most or all of the range of enum + // values + + // Note: We use INT_MAX as the maximum reserved range upper bound, + // inclusive. + AddEnumValue(edge1, "EDGE1", 1); + AddReservedRange(edge1, 10, INT_MAX); + AddEnumValue(edge2, "EDGE2", 15); + AddReservedRange(edge2, INT_MIN, 10); + + // Build the descriptors and get the pointers. + foo_file_ = pool_.BuildFile(foo_file); + ASSERT_TRUE(foo_file_ != NULL); + + ASSERT_EQ(3, foo_file_->enum_type_count()); + foo_ = foo_file_->enum_type(0); + edge1_ = foo_file_->enum_type(1); + edge2_ = foo_file_->enum_type(2); + } + + DescriptorPool pool_; + const FileDescriptor* foo_file_; + const EnumDescriptor* foo_; + const EnumDescriptor* edge1_; + const EnumDescriptor* edge2_; +}; + +TEST_F(ReservedEnumDescriptorTest, ReservedRanges) { + ASSERT_EQ(5, foo_->reserved_range_count()); + + EXPECT_EQ(-5, foo_->reserved_range(0)->start); + EXPECT_EQ(-3, foo_->reserved_range(0)->end); + + EXPECT_EQ(-2, foo_->reserved_range(1)->start); + EXPECT_EQ(1, foo_->reserved_range(1)->end); + + EXPECT_EQ(2, foo_->reserved_range(2)->start); + EXPECT_EQ(3, foo_->reserved_range(2)->end); + + EXPECT_EQ(9, foo_->reserved_range(3)->start); + EXPECT_EQ(12, foo_->reserved_range(3)->end); + + EXPECT_EQ(15, foo_->reserved_range(4)->start); + EXPECT_EQ(16, foo_->reserved_range(4)->end); + + ASSERT_EQ(1, edge1_->reserved_range_count()); + EXPECT_EQ(10, edge1_->reserved_range(0)->start); + EXPECT_EQ(INT_MAX, edge1_->reserved_range(0)->end); + + ASSERT_EQ(1, edge2_->reserved_range_count()); + EXPECT_EQ(INT_MIN, edge2_->reserved_range(0)->start); + EXPECT_EQ(10, edge2_->reserved_range(0)->end); +} + +TEST_F(ReservedEnumDescriptorTest, IsReservedNumber) { + EXPECT_TRUE(foo_->IsReservedNumber(-5)); + EXPECT_TRUE(foo_->IsReservedNumber(-4)); + EXPECT_TRUE(foo_->IsReservedNumber(-3)); + EXPECT_TRUE(foo_->IsReservedNumber(-2)); + EXPECT_TRUE(foo_->IsReservedNumber(-1)); + EXPECT_TRUE(foo_->IsReservedNumber(0)); + EXPECT_TRUE(foo_->IsReservedNumber(1)); + EXPECT_TRUE (foo_->IsReservedNumber(2)); + EXPECT_TRUE(foo_->IsReservedNumber(3)); + EXPECT_FALSE(foo_->IsReservedNumber(8)); + EXPECT_TRUE (foo_->IsReservedNumber(9)); + EXPECT_TRUE (foo_->IsReservedNumber(10)); + EXPECT_TRUE (foo_->IsReservedNumber(11)); + EXPECT_TRUE(foo_->IsReservedNumber(12)); + EXPECT_FALSE(foo_->IsReservedNumber(13)); + EXPECT_FALSE(foo_->IsReservedNumber(13)); + EXPECT_FALSE(foo_->IsReservedNumber(14)); + EXPECT_TRUE (foo_->IsReservedNumber(15)); + EXPECT_TRUE(foo_->IsReservedNumber(16)); + EXPECT_FALSE(foo_->IsReservedNumber(17)); + + EXPECT_FALSE(edge1_->IsReservedNumber(9)); + EXPECT_TRUE(edge1_->IsReservedNumber(10)); + EXPECT_TRUE(edge1_->IsReservedNumber(INT_MAX - 1)); + EXPECT_TRUE(edge1_->IsReservedNumber(INT_MAX)); + + EXPECT_TRUE(edge2_->IsReservedNumber(INT_MIN)); + EXPECT_TRUE(edge2_->IsReservedNumber(9)); + EXPECT_TRUE(edge2_->IsReservedNumber(10)); + EXPECT_FALSE(edge2_->IsReservedNumber(11)); +} + +TEST_F(ReservedEnumDescriptorTest, ReservedNames) { + ASSERT_EQ(2, foo_->reserved_name_count()); + + EXPECT_EQ("foo", foo_->reserved_name(0)); + EXPECT_EQ("bar", foo_->reserved_name(1)); +} + +TEST_F(ReservedEnumDescriptorTest, IsReservedName) { + EXPECT_TRUE (foo_->IsReservedName("foo")); + EXPECT_TRUE (foo_->IsReservedName("bar")); + EXPECT_FALSE(foo_->IsReservedName("baz")); +} + +// =================================================================== + class MiscTest : public testing::Test { protected: // Function which makes a field descriptor of the given type. @@ -3774,6 +3918,138 @@ TEST_F(ValidationErrorTest, ReservedFieldsDebugString) { file->DebugString()); } +TEST_F(ValidationErrorTest, EnumReservedFieldError) { + BuildFileWithErrors( + "name: \"foo.proto\" " + "enum_type {" + " name: \"Foo\"" + " value { name:\"BAR\" number:15 }" + " reserved_range { start: 10 end: 20 }" + "}", + + "foo.proto: BAR: NUMBER: Enum value \"BAR\" uses reserved number 15.\n"); +} + +TEST_F(ValidationErrorTest, EnumNegativeReservedFieldError) { + BuildFileWithErrors( + "name: \"foo.proto\" " + "enum_type {" + " name: \"Foo\"" + " value { name:\"BAR\" number:-15 }" + " reserved_range { start: -20 end: -10 }" + "}", + + "foo.proto: BAR: NUMBER: Enum value \"BAR\" uses reserved number -15.\n"); +} + +TEST_F(ValidationErrorTest, EnumReservedRangeOverlap) { + BuildFileWithErrors( + "name: \"foo.proto\" " + "enum_type {" + " name: \"Foo\"" + " value { name:\"BAR\" number:0 }" + " reserved_range { start: 10 end: 20 }" + " reserved_range { start: 5 end: 15 }" + "}", + + "foo.proto: Foo: NUMBER: Reserved range 5 to 14" + " overlaps with already-defined range 10 to 19.\n"); +} + +TEST_F(ValidationErrorTest, EnumNegativeReservedRangeOverlap) { + BuildFileWithErrors( + "name: \"foo.proto\" " + "enum_type {" + " name: \"Foo\"" + " value { name:\"BAR\" number:0 }" + " reserved_range { start: -20 end: -10 }" + " reserved_range { start: -15 end: -5 }" + "}", + + "foo.proto: Foo: NUMBER: Reserved range -15 to -6" + " overlaps with already-defined range -20 to -11.\n"); +} + +TEST_F(ValidationErrorTest, EnumMixedReservedRangeOverlap) { + BuildFileWithErrors( + "name: \"foo.proto\" " + "enum_type {" + " name: \"Foo\"" + " value { name:\"BAR\" number:20 }" + " reserved_range { start: -20 end: 10 }" + " reserved_range { start: -15 end: 5 }" + "}", + + "foo.proto: Foo: NUMBER: Reserved range -15 to 4" + " overlaps with already-defined range -20 to 9.\n"); +} + +TEST_F(ValidationErrorTest, EnumReservedRangeStartGreaterThanEnd) { + BuildFileWithErrors( + "name: \"foo.proto\" " + "enum_type {" + " name: \"Foo\"" + " value { name:\"BAR\" number:20 }" + " reserved_range { start: 11 end: 10 }" + "}", + + "foo.proto: Foo: NUMBER: Reserved range end number must be greater" + " than start number.\n"); +} + +TEST_F(ValidationErrorTest, EnumReservedNameError) { + BuildFileWithErrors( + "name: \"foo.proto\" " + "enum_type {" + " name: \"Foo\"" + " value { name:\"FOO\" number:15 }" + " value { name:\"BAR\" number:15 }" + " reserved_name: \"FOO\"" + " reserved_name: \"BAR\"" + "}", + + "foo.proto: FOO: NAME: Enum value \"FOO\" is reserved.\n" + "foo.proto: BAR: NAME: Enum value \"BAR\" is reserved.\n"); +} + +TEST_F(ValidationErrorTest, EnumReservedNameRedundant) { + BuildFileWithErrors( + "name: \"foo.proto\" " + "enum_type {" + " name: \"Foo\"" + " value { name:\"FOO\" number:15 }" + " reserved_name: \"foo\"" + " reserved_name: \"foo\"" + "}", + + "foo.proto: foo: NAME: Enum value \"foo\" is reserved multiple times.\n"); +} + +TEST_F(ValidationErrorTest, EnumReservedFieldsDebugString) { + const FileDescriptor* file = BuildFile( + "name: \"foo.proto\" " + "enum_type {" + " name: \"Foo\"" + " value { name:\"FOO\" number:3 }" + " reserved_name: \"foo\"" + " reserved_name: \"bar\"" + " reserved_range { start: -6 end: -6 }" + " reserved_range { start: -5 end: -4 }" + " reserved_range { start: -1 end: 1 }" + " reserved_range { start: 5 end: 5 }" + " reserved_range { start: 10 end: 19 }" + "}"); + + ASSERT_EQ( + "syntax = \"proto2\";\n\n" + "enum Foo {\n" + " FOO = 3;\n" + " reserved -6, -5 to -4, -1 to 1, 5, 10 to 19;\n" + " reserved \"foo\", \"bar\";\n" + "}\n\n", + file->DebugString()); +} + TEST_F(ValidationErrorTest, InvalidDefaults) { BuildFileWithErrors( "name: \"foo.proto\" " diff --git a/src/google/protobuf/drop_unknown_fields_test.cc b/src/google/protobuf/drop_unknown_fields_test.cc index 6f16dc53..f2f2f749 100644 --- a/src/google/protobuf/drop_unknown_fields_test.cc +++ b/src/google/protobuf/drop_unknown_fields_test.cc @@ -35,6 +35,7 @@ #include <google/protobuf/unittest_drop_unknown_fields.pb.h> #include <google/protobuf/dynamic_message.h> +#include <google/protobuf/message_lite.h> #include <gtest/gtest.h> namespace google { @@ -43,7 +44,8 @@ using unittest_drop_unknown_fields::FooWithExtraFields; namespace protobuf { -TEST(DropUnknownFieldsTest, GeneratedMessage) { +TEST(DropUnknownFieldsTest, GeneratedMessageDefaultDrop) { + ::google::protobuf::internal::SetProto3PreserveUnknownsDefault(false); FooWithExtraFields foo_with_extra_fields; foo_with_extra_fields.set_int32_value(1); foo_with_extra_fields.set_enum_value(FooWithExtraFields::QUX); @@ -54,8 +56,6 @@ TEST(DropUnknownFieldsTest, GeneratedMessage) { EXPECT_EQ(1, foo.int32_value()); EXPECT_EQ(static_cast<int>(FooWithExtraFields::QUX), static_cast<int>(foo.enum_value())); - // We don't generate unknown field accessors but the UnknownFieldSet is - // still exposed through reflection API. EXPECT_TRUE(foo.GetReflection()->GetUnknownFields(foo).empty()); ASSERT_TRUE(foo_with_extra_fields.ParseFromString(foo.SerializeAsString())); @@ -65,7 +65,29 @@ TEST(DropUnknownFieldsTest, GeneratedMessage) { EXPECT_EQ(0, foo_with_extra_fields.extra_int32_value()); } -TEST(DropUnknownFieldsTest, DynamicMessage) { +TEST(DropUnknownFieldsTest, GeneratedMessageDefaultPreserve) { + ::google::protobuf::internal::SetProto3PreserveUnknownsDefault(true); + FooWithExtraFields foo_with_extra_fields; + foo_with_extra_fields.set_int32_value(1); + foo_with_extra_fields.set_enum_value(FooWithExtraFields::QUX); + foo_with_extra_fields.set_extra_int32_value(2); + + Foo foo; + ASSERT_TRUE(foo.ParseFromString(foo_with_extra_fields.SerializeAsString())); + EXPECT_EQ(1, foo.int32_value()); + EXPECT_EQ(static_cast<int>(FooWithExtraFields::QUX), + static_cast<int>(foo.enum_value())); + EXPECT_FALSE(foo.GetReflection()->GetUnknownFields(foo).empty()); + + ASSERT_TRUE(foo_with_extra_fields.ParseFromString(foo.SerializeAsString())); + EXPECT_EQ(1, foo_with_extra_fields.int32_value()); + EXPECT_EQ(FooWithExtraFields::QUX, foo_with_extra_fields.enum_value()); + // The "extra_int32_value" field should not be lost. + EXPECT_EQ(2, foo_with_extra_fields.extra_int32_value()); +} + +TEST(DropUnknownFieldsTest, DynamicMessageDefaultDrop) { + internal::SetProto3PreserveUnknownsDefault(false); FooWithExtraFields foo_with_extra_fields; foo_with_extra_fields.set_int32_value(1); foo_with_extra_fields.set_enum_value(FooWithExtraFields::QUX); @@ -84,5 +106,25 @@ TEST(DropUnknownFieldsTest, DynamicMessage) { EXPECT_EQ(0, foo_with_extra_fields.extra_int32_value()); } +TEST(DropUnknownFieldsTest, DynamicMessageDefaultPreserve) { + internal::SetProto3PreserveUnknownsDefault(true); + FooWithExtraFields foo_with_extra_fields; + foo_with_extra_fields.set_int32_value(1); + foo_with_extra_fields.set_enum_value(FooWithExtraFields::QUX); + foo_with_extra_fields.set_extra_int32_value(2); + + google::protobuf::DynamicMessageFactory factory; + google::protobuf::scoped_ptr<google::protobuf::Message> foo( + factory.GetPrototype(Foo::descriptor())->New()); + ASSERT_TRUE(foo->ParseFromString(foo_with_extra_fields.SerializeAsString())); + EXPECT_FALSE(foo->GetReflection()->GetUnknownFields(*foo).empty()); + + ASSERT_TRUE(foo_with_extra_fields.ParseFromString(foo->SerializeAsString())); + EXPECT_EQ(1, foo_with_extra_fields.int32_value()); + EXPECT_EQ(FooWithExtraFields::QUX, foo_with_extra_fields.enum_value()); + // The "extra_int32_value" field should not be lost. + EXPECT_EQ(2, foo_with_extra_fields.extra_int32_value()); +} + } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/duration.pb.cc b/src/google/protobuf/duration.pb.cc index ae1a5e08..b4d5eb5f 100644 --- a/src/google/protobuf/duration.pb.cc +++ b/src/google/protobuf/duration.pb.cc @@ -1,7 +1,6 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/protobuf/duration.proto -#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION #include <google/protobuf/duration.pb.h> #include <algorithm> @@ -15,56 +14,61 @@ #include <google/protobuf/generated_message_reflection.h> #include <google/protobuf/reflection_ops.h> #include <google/protobuf/wire_format.h> +// This is a temporary google only hack +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS +#include "third_party/protobuf/version.h" +#endif // @@protoc_insertion_point(includes) - namespace google { namespace protobuf { -class DurationDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Duration> { +class DurationDefaultTypeInternal { + public: + ::google::protobuf::internal::ExplicitlyConstructed<Duration> + _instance; } _Duration_default_instance_; - +} // namespace protobuf +} // namespace google namespace protobuf_google_2fprotobuf_2fduration_2eproto { +void InitDefaultsDurationImpl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); +#else + ::google::protobuf::internal::InitProtobufDefaults(); +#endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + { + void* ptr = &::google::protobuf::_Duration_default_instance_; + new (ptr) ::google::protobuf::Duration(); + ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); + } + ::google::protobuf::Duration::InitAsDefaultInstance(); +} -namespace { +void InitDefaultsDuration() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsDurationImpl); +} ::google::protobuf::Metadata file_level_metadata[1]; -} // namespace - -PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::ParseTableField - const TableStruct::entries[] = { - {0, 0, 0, ::google::protobuf::internal::kInvalidMask, 0, 0}, -}; - -PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::AuxillaryParseTableField - const TableStruct::aux[] = { - ::google::protobuf::internal::AuxillaryParseTableField(), -}; -PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::ParseTable const - TableStruct::schema[] = { - { NULL, NULL, 0, -1, -1, false }, -}; - -const ::google::protobuf::uint32 TableStruct::offsets[] = { +const ::google::protobuf::uint32 TableStruct::offsets[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { ~0u, // no _has_bits_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Duration, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Duration, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Duration, seconds_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Duration, nanos_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Duration, seconds_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Duration, nanos_), }; - -static const ::google::protobuf::internal::MigrationSchema schemas[] = { - { 0, -1, sizeof(Duration)}, +static const ::google::protobuf::internal::MigrationSchema schemas[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { + { 0, -1, sizeof(::google::protobuf::Duration)}, }; static ::google::protobuf::Message const * const file_default_instances[] = { - reinterpret_cast<const ::google::protobuf::Message*>(&_Duration_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_Duration_default_instance_), }; -namespace { - void protobuf_AssignDescriptors() { AddDescriptors(); ::google::protobuf::MessageFactory* factory = NULL; @@ -78,33 +82,15 @@ void protobuf_AssignDescriptorsOnce() { ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors); } -void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; +void protobuf_RegisterTypes(const ::std::string&) GOOGLE_PROTOBUF_ATTRIBUTE_COLD; void protobuf_RegisterTypes(const ::std::string&) { protobuf_AssignDescriptorsOnce(); ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 1); } -} // namespace - -void TableStruct::Shutdown() { - _Duration_default_instance_.Shutdown(); - delete file_level_metadata[0].reflection; -} - -void TableStruct::InitDefaultsImpl() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - ::google::protobuf::internal::InitProtobufDefaults(); - _Duration_default_instance_.DefaultConstruct(); -} - -void InitDefaults() { - static GOOGLE_PROTOBUF_DECLARE_ONCE(once); - ::google::protobuf::GoogleOnceInit(&once, &TableStruct::InitDefaultsImpl); -} void AddDescriptorsImpl() { InitDefaults(); - static const char descriptor[] = { + static const char descriptor[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { "\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" @@ -116,25 +102,26 @@ void AddDescriptorsImpl() { descriptor, 227); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/duration.proto", &protobuf_RegisterTypes); - ::google::protobuf::internal::OnShutdown(&TableStruct::Shutdown); } void AddDescriptors() { static GOOGLE_PROTOBUF_DECLARE_ONCE(once); ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl); } -// Force AddDescriptors() to be called at static initialization time. +// Force AddDescriptors() to be called at dynamic initialization time. struct StaticDescriptorInitializer { StaticDescriptorInitializer() { AddDescriptors(); } } static_descriptor_initializer; - } // namespace protobuf_google_2fprotobuf_2fduration_2eproto - +namespace google { +namespace protobuf { // =================================================================== +void Duration::InitAsDefaultInstance() { +} #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int Duration::kSecondsFieldNumber; const int Duration::kNanosFieldNumber; @@ -143,7 +130,7 @@ const int Duration::kNanosFieldNumber; Duration::Duration() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { - protobuf_google_2fprotobuf_2fduration_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fduration_2eproto::InitDefaultsDuration(); } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Duration) @@ -151,9 +138,7 @@ Duration::Duration() Duration::Duration(::google::protobuf::Arena* arena) : ::google::protobuf::Message(), _internal_metadata_(arena) { -#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER - protobuf_google_2fprotobuf_2fduration_2eproto::InitDefaults(); -#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + ::protobuf_google_2fprotobuf_2fduration_2eproto::InitDefaultsDuration(); SharedCtor(); RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.Duration) @@ -164,14 +149,15 @@ Duration::Duration(const Duration& from) _cached_size_(0) { _internal_metadata_.MergeFrom(from._internal_metadata_); ::memcpy(&seconds_, &from.seconds_, - reinterpret_cast<char*>(&nanos_) - - reinterpret_cast<char*>(&seconds_) + sizeof(nanos_)); + static_cast<size_t>(reinterpret_cast<char*>(&nanos_) - + reinterpret_cast<char*>(&seconds_)) + sizeof(nanos_)); // @@protoc_insertion_point(copy_constructor:google.protobuf.Duration) } void Duration::SharedCtor() { - ::memset(&seconds_, 0, reinterpret_cast<char*>(&nanos_) - - reinterpret_cast<char*>(&seconds_) + sizeof(nanos_)); + ::memset(&seconds_, 0, static_cast<size_t>( + reinterpret_cast<char*>(&nanos_) - + reinterpret_cast<char*>(&seconds_)) + sizeof(nanos_)); _cached_size_ = 0; } @@ -181,11 +167,7 @@ Duration::~Duration() { } void Duration::SharedDtor() { - ::google::protobuf::Arena* arena = GetArenaNoVirtual(); - if (arena != NULL) { - return; - } - + GOOGLE_DCHECK(GetArenaNoVirtual() == NULL); } void Duration::ArenaDtor(void* object) { @@ -200,23 +182,26 @@ void Duration::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* Duration::descriptor() { - protobuf_google_2fprotobuf_2fduration_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fduration_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; + ::protobuf_google_2fprotobuf_2fduration_2eproto::protobuf_AssignDescriptorsOnce(); + return ::protobuf_google_2fprotobuf_2fduration_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const Duration& Duration::default_instance() { - protobuf_google_2fprotobuf_2fduration_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fduration_2eproto::InitDefaultsDuration(); return *internal_default_instance(); } -Duration* Duration::New(::google::protobuf::Arena* arena) const { - return ::google::protobuf::Arena::CreateMessage<Duration>(arena); -} void Duration::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.Duration) - ::memset(&seconds_, 0, reinterpret_cast<char*>(&nanos_) - - reinterpret_cast<char*>(&seconds_) + sizeof(nanos_)); + ::google::protobuf::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + ::memset(&seconds_, 0, static_cast<size_t>( + reinterpret_cast<char*>(&nanos_) - + reinterpret_cast<char*>(&seconds_)) + sizeof(nanos_)); + _internal_metadata_.Clear(); } bool Duration::MergePartialFromCodedStream( @@ -232,7 +217,7 @@ bool Duration::MergePartialFromCodedStream( // int64 seconds = 1; case 1: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(8u)) { + static_cast< ::google::protobuf::uint8>(8u /* 8 & 0xFF */)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>( @@ -246,7 +231,7 @@ bool Duration::MergePartialFromCodedStream( // int32 nanos = 2; case 2: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(16u)) { + static_cast< ::google::protobuf::uint8>(16u /* 16 & 0xFF */)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -259,12 +244,11 @@ bool Duration::MergePartialFromCodedStream( default: { handle_unusual: - if (tag == 0 || - ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + if (tag == 0) { goto success; } - DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag)); + DO_(::google::protobuf::internal::WireFormat::SkipField( + input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } @@ -294,11 +278,16 @@ void Duration::SerializeWithCachedSizes( ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->nanos(), output); } + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + ::google::protobuf::internal::WireFormat::SerializeUnknownFields( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), output); + } // @@protoc_insertion_point(serialize_end:google.protobuf.Duration) } ::google::protobuf::uint8* Duration::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Duration) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -313,6 +302,10 @@ void Duration::SerializeWithCachedSizes( target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->nanos(), target); } + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), target); + } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Duration) return target; } @@ -321,6 +314,11 @@ size_t Duration::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Duration) size_t total_size = 0; + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance())); + } // int64 seconds = 1; if (this->seconds() != 0) { total_size += 1 + @@ -410,51 +408,27 @@ void Duration::UnsafeArenaSwap(Duration* other) { InternalSwap(other); } void Duration::InternalSwap(Duration* other) { - std::swap(seconds_, other->seconds_); - std::swap(nanos_, other->nanos_); - std::swap(_cached_size_, other->_cached_size_); + using std::swap; + swap(seconds_, other->seconds_); + swap(nanos_, other->nanos_); + _internal_metadata_.Swap(&other->_internal_metadata_); + swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata Duration::GetMetadata() const { protobuf_google_2fprotobuf_2fduration_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fduration_2eproto::file_level_metadata[kIndexInFileMessages]; + return ::protobuf_google_2fprotobuf_2fduration_2eproto::file_level_metadata[kIndexInFileMessages]; } -#if PROTOBUF_INLINE_NOT_IN_HEADERS -// Duration - -// int64 seconds = 1; -void Duration::clear_seconds() { - seconds_ = GOOGLE_LONGLONG(0); -} -::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) { - - seconds_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.Duration.seconds) -} - -// int32 nanos = 2; -void Duration::clear_nanos() { - nanos_ = 0; -} -::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) { - - nanos_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.Duration.nanos) -} - -#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // @@protoc_insertion_point(namespace_scope) - +} // namespace protobuf +} // namespace google +namespace google { +namespace protobuf { +template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::Duration* Arena::CreateMessage< ::google::protobuf::Duration >(Arena* arena) { + return Arena::CreateMessageInternal< ::google::protobuf::Duration >(arena); +} } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/duration.pb.h b/src/google/protobuf/duration.pb.h index 34873d97..7fe0748d 100644 --- a/src/google/protobuf/duration.pb.h +++ b/src/google/protobuf/duration.pb.h @@ -1,19 +1,19 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/protobuf/duration.proto -#ifndef PROTOBUF_google_2fprotobuf_2fduration_2eproto__INCLUDED -#define PROTOBUF_google_2fprotobuf_2fduration_2eproto__INCLUDED +#ifndef PROTOBUF_google_2fprotobuf_2fduration_2eproto_INCLUDED +#define PROTOBUF_google_2fprotobuf_2fduration_2eproto_INCLUDED #include <string> #include <google/protobuf/stubs/common.h> -#if GOOGLE_PROTOBUF_VERSION < 3003000 +#if GOOGLE_PROTOBUF_VERSION < 3005000 #error This file was generated by a newer version of protoc which is #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3003000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION +#if 3005001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. @@ -30,30 +30,38 @@ #include <google/protobuf/extension_set.h> // IWYU pragma: export #include <google/protobuf/unknown_field_set.h> // @@protoc_insertion_point(includes) -namespace google { -namespace protobuf { -class Duration; -class DurationDefaultTypeInternal; -LIBPROTOBUF_EXPORT extern DurationDefaultTypeInternal _Duration_default_instance_; -} // namespace protobuf -} // namespace google - -namespace google { -namespace protobuf { namespace protobuf_google_2fprotobuf_2fduration_2eproto { -// Internal implementation detail -- do not call these. +// Internal implementation detail -- do not use these members. struct LIBPROTOBUF_EXPORT TableStruct { static const ::google::protobuf::internal::ParseTableField entries[]; static const ::google::protobuf::internal::AuxillaryParseTableField aux[]; - static const ::google::protobuf::internal::ParseTable schema[]; + static const ::google::protobuf::internal::ParseTable schema[1]; + static const ::google::protobuf::internal::FieldMetadata field_metadata[]; + static const ::google::protobuf::internal::SerializationTable serialization_table[]; static const ::google::protobuf::uint32 offsets[]; - static void InitDefaultsImpl(); - static void Shutdown(); }; void LIBPROTOBUF_EXPORT AddDescriptors(); -void LIBPROTOBUF_EXPORT InitDefaults(); +void LIBPROTOBUF_EXPORT InitDefaultsDurationImpl(); +void LIBPROTOBUF_EXPORT InitDefaultsDuration(); +inline void LIBPROTOBUF_EXPORT InitDefaults() { + InitDefaultsDuration(); +} } // namespace protobuf_google_2fprotobuf_2fduration_2eproto +namespace google { +namespace protobuf { +class Duration; +class DurationDefaultTypeInternal; +LIBPROTOBUF_EXPORT extern DurationDefaultTypeInternal _Duration_default_instance_; +} // namespace protobuf +} // namespace google +namespace google { +namespace protobuf { +template<> LIBPROTOBUF_EXPORT ::google::protobuf::Duration* Arena::CreateMessage< ::google::protobuf::Duration>(Arena*); +} // namespace protobuf +} // namespace google +namespace google { +namespace protobuf { // =================================================================== @@ -68,7 +76,21 @@ class LIBPROTOBUF_EXPORT Duration : public ::google::protobuf::Message /* @@prot CopyFrom(from); return *this; } + #if LANG_CXX11 + Duration(Duration&& from) noexcept + : Duration() { + *this = ::std::move(from); + } + inline Duration& operator=(Duration&& from) noexcept { + if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + #endif inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { return GetArenaNoVirtual(); } @@ -78,6 +100,7 @@ class LIBPROTOBUF_EXPORT Duration : public ::google::protobuf::Message /* @@prot static const ::google::protobuf::Descriptor* descriptor(); static const Duration& default_instance(); + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY static inline const Duration* internal_default_instance() { return reinterpret_cast<const Duration*>( &_Duration_default_instance_); @@ -87,12 +110,19 @@ class LIBPROTOBUF_EXPORT Duration : public ::google::protobuf::Message /* @@prot void UnsafeArenaSwap(Duration* other); void Swap(Duration* other); + friend void swap(Duration& a, Duration& b) { + a.Swap(&b); + } // implements Message ---------------------------------------------- - inline Duration* New() const PROTOBUF_FINAL { return New(NULL); } + inline Duration* New() const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<Duration>(NULL); + } - Duration* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + Duration* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<Duration>(arena); + } void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const Duration& from); @@ -149,20 +179,24 @@ class LIBPROTOBUF_EXPORT Duration : public ::google::protobuf::Message /* @@prot private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - friend class ::google::protobuf::Arena; + template <typename T> friend class ::google::protobuf::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; ::google::protobuf::int64 seconds_; ::google::protobuf::int32 nanos_; mutable int _cached_size_; - friend struct protobuf_google_2fprotobuf_2fduration_2eproto::TableStruct; + friend struct ::protobuf_google_2fprotobuf_2fduration_2eproto::TableStruct; + friend void ::protobuf_google_2fprotobuf_2fduration_2eproto::InitDefaultsDurationImpl(); }; // =================================================================== // =================================================================== -#if !PROTOBUF_INLINE_NOT_IN_HEADERS +#ifdef __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif // __GNUC__ // Duration // int64 seconds = 1; @@ -193,14 +227,15 @@ inline void Duration::set_nanos(::google::protobuf::int32 value) { // @@protoc_insertion_point(field_set:google.protobuf.Duration.nanos) } -#endif // !PROTOBUF_INLINE_NOT_IN_HEADERS +#ifdef __GNUC__ + #pragma GCC diagnostic pop +#endif // __GNUC__ // @@protoc_insertion_point(namespace_scope) - } // namespace protobuf } // namespace google // @@protoc_insertion_point(global_scope) -#endif // PROTOBUF_google_2fprotobuf_2fduration_2eproto__INCLUDED +#endif // PROTOBUF_google_2fprotobuf_2fduration_2eproto_INCLUDED diff --git a/src/google/protobuf/dynamic_message.cc b/src/google/protobuf/dynamic_message.cc index ee8113e3..48d6aad8 100644 --- a/src/google/protobuf/dynamic_message.cc +++ b/src/google/protobuf/dynamic_message.cc @@ -250,6 +250,10 @@ class DynamicMessage : public Message { }; DynamicMessage(const TypeInfo* type_info); + + // This should only be used by GetPrototypeNoLock() to avoid dead lock. + DynamicMessage(const TypeInfo* type_info, bool lock_factory); + ~DynamicMessage(); // Called on the prototype after construction to initialize message fields. @@ -259,7 +263,7 @@ class DynamicMessage : public Message { Message* New() const; Message* New(::google::protobuf::Arena* arena) const; - ::google::protobuf::Arena* GetArena() const { return NULL; }; + ::google::protobuf::Arena* GetArena() const { return arena_; } int GetCachedSize() const; void SetCachedSize(int size) const; @@ -278,9 +282,9 @@ class DynamicMessage : public Message { #endif // !_MSC_VER private: - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(DynamicMessage); DynamicMessage(const TypeInfo* type_info, ::google::protobuf::Arena* arena); - void SharedCtor(); + + void SharedCtor(bool lock_factory); inline bool is_prototype() const { return type_info_->prototype == this || @@ -297,24 +301,29 @@ class DynamicMessage : public Message { } const TypeInfo* type_info_; + Arena* const arena_; // TODO(kenton): Make this an atomic<int> when C++ supports it. mutable int cached_byte_size_; + GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(DynamicMessage); }; DynamicMessage::DynamicMessage(const TypeInfo* type_info) - : type_info_(type_info), - cached_byte_size_(0) { - SharedCtor(); + : type_info_(type_info), arena_(NULL), cached_byte_size_(0) { + SharedCtor(true); } DynamicMessage::DynamicMessage(const TypeInfo* type_info, ::google::protobuf::Arena* arena) - : type_info_(type_info), - cached_byte_size_(0) { - SharedCtor(); + : type_info_(type_info), arena_(arena), cached_byte_size_(0) { + SharedCtor(true); +} + +DynamicMessage::DynamicMessage(const TypeInfo* type_info, bool lock_factory) + : type_info_(type_info), arena_(NULL), cached_byte_size_(0) { + SharedCtor(lock_factory); } -void DynamicMessage::SharedCtor() { +void DynamicMessage::SharedCtor(bool lock_factory) { // We need to call constructors for various fields manually and set // default values where appropriate. We use placement new to call // constructors. If you haven't heard of placement new, I suggest Googling @@ -332,10 +341,10 @@ void DynamicMessage::SharedCtor() { } new (OffsetToPointer(type_info_->internal_metadata_offset)) - InternalMetadataWithArena; + InternalMetadataWithArena(arena_); if (type_info_->extensions_offset != -1) { - new (OffsetToPointer(type_info_->extensions_offset)) ExtensionSet; + new (OffsetToPointer(type_info_->extensions_offset)) ExtensionSet(arena_); } for (int i = 0; i < descriptor->field_count(); i++) { const FieldDescriptor* field = descriptor->field(i); @@ -344,14 +353,14 @@ void DynamicMessage::SharedCtor() { continue; } switch (field->cpp_type()) { -#define HANDLE_TYPE(CPPTYPE, TYPE) \ - case FieldDescriptor::CPPTYPE_##CPPTYPE: \ - if (!field->is_repeated()) { \ - new(field_ptr) TYPE(field->default_value_##TYPE()); \ - } else { \ - new(field_ptr) RepeatedField<TYPE>(); \ - } \ - break; +#define HANDLE_TYPE(CPPTYPE, TYPE) \ + case FieldDescriptor::CPPTYPE_##CPPTYPE: \ + if (!field->is_repeated()) { \ + new (field_ptr) TYPE(field->default_value_##TYPE()); \ + } else { \ + new (field_ptr) RepeatedField<TYPE>(arena_); \ + } \ + break; HANDLE_TYPE(INT32 , int32 ); HANDLE_TYPE(INT64 , int64 ); @@ -366,7 +375,7 @@ void DynamicMessage::SharedCtor() { if (!field->is_repeated()) { new(field_ptr) int(field->default_value_enum()->number()); } else { - new(field_ptr) RepeatedField<int>(); + new (field_ptr) RepeatedField<int>(arena_); } break; @@ -387,7 +396,7 @@ void DynamicMessage::SharedCtor() { ArenaStringPtr* asp = new(field_ptr) ArenaStringPtr(); asp->UnsafeSetDefault(default_value); } else { - new(field_ptr) RepeatedPtrField<string>(); + new (field_ptr) RepeatedPtrField<string>(arena_); } break; } @@ -398,10 +407,32 @@ void DynamicMessage::SharedCtor() { new(field_ptr) Message*(NULL); } else { if (IsMapFieldInApi(field)) { - new (field_ptr) DynamicMapField( - type_info_->factory->GetPrototypeNoLock(field->message_type())); + // We need to lock in most cases to avoid data racing. Only not lock + // when the constructor is called inside GetPrototype(), in which + // case we have already locked the factory. + if (lock_factory) { + if (arena_ != NULL) { + new (field_ptr) DynamicMapField( + type_info_->factory->GetPrototype(field->message_type()), + arena_); + } else { + new (field_ptr) DynamicMapField( + type_info_->factory->GetPrototype(field->message_type())); + } + } else { + if (arena_ != NULL) { + new (field_ptr) + DynamicMapField(type_info_->factory->GetPrototypeNoLock( + field->message_type()), + arena_); + } else { + new (field_ptr) + DynamicMapField(type_info_->factory->GetPrototypeNoLock( + field->message_type())); + } + } } else { - new (field_ptr) RepeatedPtrField<Message>(); + new (field_ptr) RepeatedPtrField<Message>(arena_); } } break; @@ -549,19 +580,17 @@ void DynamicMessage::CrossLinkPrototypes() { } } -Message* DynamicMessage::New() const { - void* new_base = operator new(type_info_->size); - memset(new_base, 0, type_info_->size); - return new(new_base) DynamicMessage(type_info_); -} +Message* DynamicMessage::New() const { return New(NULL); } Message* DynamicMessage::New(::google::protobuf::Arena* arena) const { if (arena != NULL) { - Message* message = New(); - arena->Own(message); - return message; + void* new_base = Arena::CreateArray<char>(arena, type_info_->size); + memset(new_base, 0, type_info_->size); + return new (new_base) DynamicMessage(type_info_, arena); } else { - return New(); + void* new_base = operator new(type_info_->size); + memset(new_base, 0, type_info_->size); + return new (new_base) DynamicMessage(type_info_); } } @@ -751,7 +780,10 @@ const Message* DynamicMessageFactory::GetPrototypeNoLock( // map). To break the cyclic dependency, we have to assgin the address of // prototype into type_info first. type_info->prototype = static_cast<DynamicMessage*>(base); - DynamicMessage* prototype = new(base) DynamicMessage(type_info); + + // We have already locked the factory so we should not lock in the constructor + // of dynamic message to avoid dead lock. + DynamicMessage* prototype = new (base) DynamicMessage(type_info, false); if (type->oneof_decl_count() > 0 || num_weak_fields > 0) { // Construct default oneof instance. diff --git a/src/google/protobuf/dynamic_message.h b/src/google/protobuf/dynamic_message.h index 816170ea..e29b148d 100644 --- a/src/google/protobuf/dynamic_message.h +++ b/src/google/protobuf/dynamic_message.h @@ -156,24 +156,24 @@ class LIBPROTOBUF_EXPORT DynamicMapSorter { int map_size, const Reflection* reflection, const FieldDescriptor* field) { - std::vector<const Message*> result(map_size); + std::vector<const Message*> result(static_cast<size_t>(map_size)); const RepeatedPtrField<Message>& map_field = reflection->GetRepeatedPtrField<Message>(message, field); - int i = 0; + size_t i = 0; for (RepeatedPtrField<Message>::const_pointer_iterator it = map_field.pointer_begin(); it != map_field.pointer_end(); ) { result[i++] = *it++; } - GOOGLE_DCHECK_EQ(result.size(), static_cast<size_t>(i)); + GOOGLE_DCHECK_EQ(result.size(), i); MapEntryMessageComparator comparator(field->message_type()); - std::sort(result.begin(), result.end(), comparator); + std::stable_sort(result.begin(), result.end(), comparator); // Complain if the keys aren't in ascending order. #ifndef NDEBUG - for (int j = 1; j < map_size; j++) { + for (size_t j = 1; j < static_cast<size_t>(map_size); j++) { if (!comparator(result[j - 1], result[j])) { GOOGLE_LOG(ERROR) << (comparator(result[j], result[j - 1]) ? - "internal error in map key sorting" : - "map keys are not unique"); + "internal error in map key sorting" : + "map keys are not unique"); } } #endif diff --git a/src/google/protobuf/dynamic_message_unittest.cc b/src/google/protobuf/dynamic_message_unittest.cc index fe51d8cf..34f3641b 100644 --- a/src/google/protobuf/dynamic_message_unittest.cc +++ b/src/google/protobuf/dynamic_message_unittest.cc @@ -60,7 +60,7 @@ namespace google { namespace protobuf { -class DynamicMessageTest : public testing::Test { +class DynamicMessageTest : public ::testing::TestWithParam<bool> { protected: DescriptorPool pool_; DynamicMessageFactory factory_; @@ -144,38 +144,54 @@ TEST_F(DynamicMessageTest, Defaults) { reflection_tester.ExpectClearViaReflection(*prototype_); } -TEST_F(DynamicMessageTest, IndependentOffsets) { +TEST_P(DynamicMessageTest, IndependentOffsets) { // Check that all fields have independent offsets by setting each // one to a unique value then checking that they all still have those // unique values (i.e. they don't stomp each other). - google::protobuf::scoped_ptr<Message> message(prototype_->New()); + Arena arena; + Message* message = prototype_->New(GetParam()? &arena : NULL); TestUtil::ReflectionTester reflection_tester(descriptor_); - reflection_tester.SetAllFieldsViaReflection(message.get()); + reflection_tester.SetAllFieldsViaReflection(message); reflection_tester.ExpectAllFieldsSetViaReflection(*message); + + if (!GetParam()) { + delete message; + } } -TEST_F(DynamicMessageTest, Extensions) { +TEST_P(DynamicMessageTest, Extensions) { // Check that extensions work. - google::protobuf::scoped_ptr<Message> message(extensions_prototype_->New()); + Arena arena; + Message* message = extensions_prototype_->New(GetParam()? &arena : NULL); TestUtil::ReflectionTester reflection_tester(extensions_descriptor_); - reflection_tester.SetAllFieldsViaReflection(message.get()); + reflection_tester.SetAllFieldsViaReflection(message); reflection_tester.ExpectAllFieldsSetViaReflection(*message); + + if (!GetParam()) { + delete message; + } } -TEST_F(DynamicMessageTest, PackedFields) { +TEST_P(DynamicMessageTest, PackedFields) { // Check that packed fields work properly. - google::protobuf::scoped_ptr<Message> message(packed_prototype_->New()); + Arena arena; + Message* message = packed_prototype_->New(GetParam()? &arena : NULL); TestUtil::ReflectionTester reflection_tester(packed_descriptor_); - reflection_tester.SetPackedFieldsViaReflection(message.get()); + reflection_tester.SetPackedFieldsViaReflection(message); reflection_tester.ExpectPackedFieldsSetViaReflection(*message); + + if (!GetParam()) { + delete message; + } } -TEST_F(DynamicMessageTest, Oneof) { +TEST_P(DynamicMessageTest, Oneof) { // Check that oneof fields work properly. - google::protobuf::scoped_ptr<Message> message(oneof_prototype_->New()); + Arena arena; + Message* message = oneof_prototype_->New(GetParam()? &arena : NULL); // Check default values. const Descriptor* descriptor = message->GetDescriptor(); @@ -226,29 +242,46 @@ TEST_F(DynamicMessageTest, Oneof) { // Check set functions. TestUtil::ReflectionTester reflection_tester(oneof_descriptor_); - reflection_tester.SetOneofViaReflection(message.get()); + reflection_tester.SetOneofViaReflection(message); reflection_tester.ExpectOneofSetViaReflection(*message); + + if (!GetParam()) { + delete message; + } } -TEST_F(DynamicMessageTest, SpaceUsed) { +TEST_P(DynamicMessageTest, SpaceUsed) { // Test that SpaceUsed() works properly // Since we share the implementation with generated messages, we don't need // to test very much here. Just make sure it appears to be working. - google::protobuf::scoped_ptr<Message> message(prototype_->New()); + Arena arena; + Message* message = prototype_->New(GetParam()? &arena : NULL); TestUtil::ReflectionTester reflection_tester(descriptor_); int initial_space_used = message->SpaceUsed(); - reflection_tester.SetAllFieldsViaReflection(message.get()); + reflection_tester.SetAllFieldsViaReflection(message); EXPECT_LT(initial_space_used, message->SpaceUsed()); + + if (!GetParam()) { + delete message; + } } TEST_F(DynamicMessageTest, Arena) { Arena arena; Message* message = prototype_->New(&arena); - (void)message; // avoid unused-variable error. + Message* extension_message = extensions_prototype_->New(&arena); + Message* packed_message = packed_prototype_->New(&arena); + Message* oneof_message = oneof_prototype_->New(&arena); + + // avoid unused-variable error. + (void)message; + (void)extension_message; + (void)packed_message; + (void)oneof_message; // Return without freeing: should not leak. } @@ -286,6 +319,7 @@ TEST_F(DynamicMessageTest, Proto3) { delete message; } +INSTANTIATE_TEST_CASE_P(UseArena, DynamicMessageTest, ::testing::Bool()); } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/empty.pb.cc b/src/google/protobuf/empty.pb.cc index 71195056..ffff80b9 100644 --- a/src/google/protobuf/empty.pb.cc +++ b/src/google/protobuf/empty.pb.cc @@ -1,7 +1,6 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/protobuf/empty.proto -#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION #include <google/protobuf/empty.pb.h> #include <algorithm> @@ -15,54 +14,59 @@ #include <google/protobuf/generated_message_reflection.h> #include <google/protobuf/reflection_ops.h> #include <google/protobuf/wire_format.h> +// This is a temporary google only hack +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS +#include "third_party/protobuf/version.h" +#endif // @@protoc_insertion_point(includes) - namespace google { namespace protobuf { -class EmptyDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Empty> { +class EmptyDefaultTypeInternal { + public: + ::google::protobuf::internal::ExplicitlyConstructed<Empty> + _instance; } _Empty_default_instance_; - +} // namespace protobuf +} // namespace google namespace protobuf_google_2fprotobuf_2fempty_2eproto { +void InitDefaultsEmptyImpl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); +#else + ::google::protobuf::internal::InitProtobufDefaults(); +#endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + { + void* ptr = &::google::protobuf::_Empty_default_instance_; + new (ptr) ::google::protobuf::Empty(); + ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); + } + ::google::protobuf::Empty::InitAsDefaultInstance(); +} -namespace { +void InitDefaultsEmpty() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsEmptyImpl); +} ::google::protobuf::Metadata file_level_metadata[1]; -} // namespace - -PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::ParseTableField - const TableStruct::entries[] = { - {0, 0, 0, ::google::protobuf::internal::kInvalidMask, 0, 0}, -}; - -PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::AuxillaryParseTableField - const TableStruct::aux[] = { - ::google::protobuf::internal::AuxillaryParseTableField(), -}; -PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::ParseTable const - TableStruct::schema[] = { - { NULL, NULL, 0, -1, -1, false }, -}; - -const ::google::protobuf::uint32 TableStruct::offsets[] = { +const ::google::protobuf::uint32 TableStruct::offsets[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { ~0u, // no _has_bits_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Empty, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Empty, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ }; - -static const ::google::protobuf::internal::MigrationSchema schemas[] = { - { 0, -1, sizeof(Empty)}, +static const ::google::protobuf::internal::MigrationSchema schemas[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { + { 0, -1, sizeof(::google::protobuf::Empty)}, }; static ::google::protobuf::Message const * const file_default_instances[] = { - reinterpret_cast<const ::google::protobuf::Message*>(&_Empty_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_Empty_default_instance_), }; -namespace { - void protobuf_AssignDescriptors() { AddDescriptors(); ::google::protobuf::MessageFactory* factory = NULL; @@ -76,33 +80,15 @@ void protobuf_AssignDescriptorsOnce() { ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors); } -void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; +void protobuf_RegisterTypes(const ::std::string&) GOOGLE_PROTOBUF_ATTRIBUTE_COLD; void protobuf_RegisterTypes(const ::std::string&) { protobuf_AssignDescriptorsOnce(); ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 1); } -} // namespace - -void TableStruct::Shutdown() { - _Empty_default_instance_.Shutdown(); - delete file_level_metadata[0].reflection; -} - -void TableStruct::InitDefaultsImpl() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - ::google::protobuf::internal::InitProtobufDefaults(); - _Empty_default_instance_.DefaultConstruct(); -} - -void InitDefaults() { - static GOOGLE_PROTOBUF_DECLARE_ONCE(once); - ::google::protobuf::GoogleOnceInit(&once, &TableStruct::InitDefaultsImpl); -} void AddDescriptorsImpl() { InitDefaults(); - static const char descriptor[] = { + static const char descriptor[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { "\n\033google/protobuf/empty.proto\022\017google.pr" "otobuf\"\007\n\005EmptyBv\n\023com.google.protobufB\n" "EmptyProtoP\001Z\'github.com/golang/protobuf" @@ -113,32 +99,33 @@ void AddDescriptorsImpl() { descriptor, 183); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/empty.proto", &protobuf_RegisterTypes); - ::google::protobuf::internal::OnShutdown(&TableStruct::Shutdown); } void AddDescriptors() { static GOOGLE_PROTOBUF_DECLARE_ONCE(once); ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl); } -// Force AddDescriptors() to be called at static initialization time. +// Force AddDescriptors() to be called at dynamic initialization time. struct StaticDescriptorInitializer { StaticDescriptorInitializer() { AddDescriptors(); } } static_descriptor_initializer; - } // namespace protobuf_google_2fprotobuf_2fempty_2eproto - +namespace google { +namespace protobuf { // =================================================================== +void Empty::InitAsDefaultInstance() { +} #if !defined(_MSC_VER) || _MSC_VER >= 1900 #endif // !defined(_MSC_VER) || _MSC_VER >= 1900 Empty::Empty() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { - protobuf_google_2fprotobuf_2fempty_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fempty_2eproto::InitDefaultsEmpty(); } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Empty) @@ -146,9 +133,7 @@ Empty::Empty() Empty::Empty(::google::protobuf::Arena* arena) : ::google::protobuf::Message(), _internal_metadata_(arena) { -#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER - protobuf_google_2fprotobuf_2fempty_2eproto::InitDefaults(); -#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + ::protobuf_google_2fprotobuf_2fempty_2eproto::InitDefaultsEmpty(); SharedCtor(); RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.Empty) @@ -171,11 +156,7 @@ Empty::~Empty() { } void Empty::SharedDtor() { - ::google::protobuf::Arena* arena = GetArenaNoVirtual(); - if (arena != NULL) { - return; - } - + GOOGLE_DCHECK(GetArenaNoVirtual() == NULL); } void Empty::ArenaDtor(void* object) { @@ -190,21 +171,23 @@ void Empty::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* Empty::descriptor() { - protobuf_google_2fprotobuf_2fempty_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fempty_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; + ::protobuf_google_2fprotobuf_2fempty_2eproto::protobuf_AssignDescriptorsOnce(); + return ::protobuf_google_2fprotobuf_2fempty_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const Empty& Empty::default_instance() { - protobuf_google_2fprotobuf_2fempty_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fempty_2eproto::InitDefaultsEmpty(); return *internal_default_instance(); } -Empty* Empty::New(::google::protobuf::Arena* arena) const { - return ::google::protobuf::Arena::CreateMessage<Empty>(arena); -} void Empty::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.Empty) + ::google::protobuf::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + _internal_metadata_.Clear(); } bool Empty::MergePartialFromCodedStream( @@ -217,12 +200,11 @@ bool Empty::MergePartialFromCodedStream( tag = p.first; if (!p.second) goto handle_unusual; handle_unusual: - if (tag == 0 || - ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + if (tag == 0) { goto success; } - DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag)); + DO_(::google::protobuf::internal::WireFormat::SkipField( + input, tag, _internal_metadata_.mutable_unknown_fields())); } success: // @@protoc_insertion_point(parse_success:google.protobuf.Empty) @@ -239,15 +221,24 @@ void Empty::SerializeWithCachedSizes( ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + ::google::protobuf::internal::WireFormat::SerializeUnknownFields( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), output); + } // @@protoc_insertion_point(serialize_end:google.protobuf.Empty) } ::google::protobuf::uint8* Empty::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Empty) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), target); + } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Empty) return target; } @@ -256,6 +247,11 @@ size_t Empty::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Empty) size_t total_size = 0; + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance())); + } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = cached_size; @@ -325,21 +321,25 @@ void Empty::UnsafeArenaSwap(Empty* other) { InternalSwap(other); } void Empty::InternalSwap(Empty* other) { - std::swap(_cached_size_, other->_cached_size_); + using std::swap; + _internal_metadata_.Swap(&other->_internal_metadata_); + swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata Empty::GetMetadata() const { protobuf_google_2fprotobuf_2fempty_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fempty_2eproto::file_level_metadata[kIndexInFileMessages]; + return ::protobuf_google_2fprotobuf_2fempty_2eproto::file_level_metadata[kIndexInFileMessages]; } -#if PROTOBUF_INLINE_NOT_IN_HEADERS -// Empty - -#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // @@protoc_insertion_point(namespace_scope) - +} // namespace protobuf +} // namespace google +namespace google { +namespace protobuf { +template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::Empty* Arena::CreateMessage< ::google::protobuf::Empty >(Arena* arena) { + return Arena::CreateMessageInternal< ::google::protobuf::Empty >(arena); +} } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/empty.pb.h b/src/google/protobuf/empty.pb.h index f28dc19b..2fef9a43 100644 --- a/src/google/protobuf/empty.pb.h +++ b/src/google/protobuf/empty.pb.h @@ -1,19 +1,19 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/protobuf/empty.proto -#ifndef PROTOBUF_google_2fprotobuf_2fempty_2eproto__INCLUDED -#define PROTOBUF_google_2fprotobuf_2fempty_2eproto__INCLUDED +#ifndef PROTOBUF_google_2fprotobuf_2fempty_2eproto_INCLUDED +#define PROTOBUF_google_2fprotobuf_2fempty_2eproto_INCLUDED #include <string> #include <google/protobuf/stubs/common.h> -#if GOOGLE_PROTOBUF_VERSION < 3003000 +#if GOOGLE_PROTOBUF_VERSION < 3005000 #error This file was generated by a newer version of protoc which is #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3003000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION +#if 3005001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. @@ -30,30 +30,38 @@ #include <google/protobuf/extension_set.h> // IWYU pragma: export #include <google/protobuf/unknown_field_set.h> // @@protoc_insertion_point(includes) -namespace google { -namespace protobuf { -class Empty; -class EmptyDefaultTypeInternal; -LIBPROTOBUF_EXPORT extern EmptyDefaultTypeInternal _Empty_default_instance_; -} // namespace protobuf -} // namespace google - -namespace google { -namespace protobuf { namespace protobuf_google_2fprotobuf_2fempty_2eproto { -// Internal implementation detail -- do not call these. +// Internal implementation detail -- do not use these members. struct LIBPROTOBUF_EXPORT TableStruct { static const ::google::protobuf::internal::ParseTableField entries[]; static const ::google::protobuf::internal::AuxillaryParseTableField aux[]; - static const ::google::protobuf::internal::ParseTable schema[]; + static const ::google::protobuf::internal::ParseTable schema[1]; + static const ::google::protobuf::internal::FieldMetadata field_metadata[]; + static const ::google::protobuf::internal::SerializationTable serialization_table[]; static const ::google::protobuf::uint32 offsets[]; - static void InitDefaultsImpl(); - static void Shutdown(); }; void LIBPROTOBUF_EXPORT AddDescriptors(); -void LIBPROTOBUF_EXPORT InitDefaults(); +void LIBPROTOBUF_EXPORT InitDefaultsEmptyImpl(); +void LIBPROTOBUF_EXPORT InitDefaultsEmpty(); +inline void LIBPROTOBUF_EXPORT InitDefaults() { + InitDefaultsEmpty(); +} } // namespace protobuf_google_2fprotobuf_2fempty_2eproto +namespace google { +namespace protobuf { +class Empty; +class EmptyDefaultTypeInternal; +LIBPROTOBUF_EXPORT extern EmptyDefaultTypeInternal _Empty_default_instance_; +} // namespace protobuf +} // namespace google +namespace google { +namespace protobuf { +template<> LIBPROTOBUF_EXPORT ::google::protobuf::Empty* Arena::CreateMessage< ::google::protobuf::Empty>(Arena*); +} // namespace protobuf +} // namespace google +namespace google { +namespace protobuf { // =================================================================== @@ -68,7 +76,21 @@ class LIBPROTOBUF_EXPORT Empty : public ::google::protobuf::Message /* @@protoc_ CopyFrom(from); return *this; } + #if LANG_CXX11 + Empty(Empty&& from) noexcept + : Empty() { + *this = ::std::move(from); + } + inline Empty& operator=(Empty&& from) noexcept { + if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + #endif inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { return GetArenaNoVirtual(); } @@ -78,6 +100,7 @@ class LIBPROTOBUF_EXPORT Empty : public ::google::protobuf::Message /* @@protoc_ static const ::google::protobuf::Descriptor* descriptor(); static const Empty& default_instance(); + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY static inline const Empty* internal_default_instance() { return reinterpret_cast<const Empty*>( &_Empty_default_instance_); @@ -87,12 +110,19 @@ class LIBPROTOBUF_EXPORT Empty : public ::google::protobuf::Message /* @@protoc_ void UnsafeArenaSwap(Empty* other); void Swap(Empty* other); + friend void swap(Empty& a, Empty& b) { + a.Swap(&b); + } // implements Message ---------------------------------------------- - inline Empty* New() const PROTOBUF_FINAL { return New(NULL); } + inline Empty* New() const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<Empty>(NULL); + } - Empty* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + Empty* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<Empty>(arena); + } void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const Empty& from); @@ -137,28 +167,33 @@ class LIBPROTOBUF_EXPORT Empty : public ::google::protobuf::Message /* @@protoc_ private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - friend class ::google::protobuf::Arena; + template <typename T> friend class ::google::protobuf::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; mutable int _cached_size_; - friend struct protobuf_google_2fprotobuf_2fempty_2eproto::TableStruct; + friend struct ::protobuf_google_2fprotobuf_2fempty_2eproto::TableStruct; + friend void ::protobuf_google_2fprotobuf_2fempty_2eproto::InitDefaultsEmptyImpl(); }; // =================================================================== // =================================================================== -#if !PROTOBUF_INLINE_NOT_IN_HEADERS +#ifdef __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif // __GNUC__ // Empty -#endif // !PROTOBUF_INLINE_NOT_IN_HEADERS +#ifdef __GNUC__ + #pragma GCC diagnostic pop +#endif // __GNUC__ // @@protoc_insertion_point(namespace_scope) - } // namespace protobuf } // namespace google // @@protoc_insertion_point(global_scope) -#endif // PROTOBUF_google_2fprotobuf_2fempty_2eproto__INCLUDED +#endif // PROTOBUF_google_2fprotobuf_2fempty_2eproto_INCLUDED diff --git a/src/google/protobuf/extension_set.cc b/src/google/protobuf/extension_set.cc index 955c079b..8f104800 100644 --- a/src/google/protobuf/extension_set.cc +++ b/src/google/protobuf/extension_set.cc @@ -33,6 +33,7 @@ // Sanjay Ghemawat, Jeff Dean, and others. #include <google/protobuf/stubs/hash.h> +#include <utility> #include <google/protobuf/stubs/common.h> #include <google/protobuf/stubs/once.h> #include <google/protobuf/extension_set.h> @@ -221,7 +222,7 @@ int ExtensionSet::NumExtensions() const { int ExtensionSet::ExtensionSize(int number) const { ExtensionMap::const_iterator iter = extensions_.find(number); - if (iter == extensions_.end()) return false; + if (iter == extensions_.end()) return 0; return iter->second.GetSize(); } @@ -750,8 +751,10 @@ MessageLite* ExtensionSet::AddMessage(int number, FieldType type, // RepeatedPtrField<MessageLite> does not know how to Add() since it cannot // allocate an abstract object, so we have to be tricky. - MessageLite* result = extension->repeated_message_value - ->AddFromCleared<GenericTypeHandler<MessageLite> >(); + MessageLite* result = + reinterpret_cast< ::google::protobuf::internal::RepeatedPtrFieldBase*>( + extension->repeated_message_value) + ->AddFromCleared<GenericTypeHandler<MessageLite> >(); if (result == NULL) { result = prototype.New(arena_); extension->repeated_message_value->AddAllocated(result); @@ -925,8 +928,10 @@ void ExtensionSet::InternalExtensionMergeFrom( other_extension.repeated_message_value; for (int i = 0; i < other_repeated_message->size(); i++) { const MessageLite& other_message = other_repeated_message->Get(i); - MessageLite* target = extension->repeated_message_value - ->AddFromCleared<GenericTypeHandler<MessageLite> >(); + MessageLite* target = + reinterpret_cast< ::google::protobuf::internal::RepeatedPtrFieldBase*>( + extension->repeated_message_value) + ->AddFromCleared<GenericTypeHandler<MessageLite> >(); if (target == NULL) { target = other_message.New(arena_); extension->repeated_message_value->AddAllocated(target); @@ -1747,6 +1752,9 @@ void ExtensionSet::Extension::Free() { // Defined in extension_set_heavy.cc. // int ExtensionSet::Extension::SpaceUsedExcludingSelf() const +// Dummy key method to avoid weak vtable. +void ExtensionSet::LazyMessageExtension::UnusedKeyMethod() {} + // ================================================================== // Default repeated field instances for iterator-compatible accessors diff --git a/src/google/protobuf/extension_set.h b/src/google/protobuf/extension_set.h index cf5f652d..b0f3b8dd 100644 --- a/src/google/protobuf/extension_set.h +++ b/src/google/protobuf/extension_set.h @@ -438,6 +438,11 @@ class LIBPROTOBUF_EXPORT ExtensionSet { // SpaceUsed()). size_t SpaceUsedExcludingSelfLong() const; + // This method just calls SpaceUsedExcludingSelfLong() but it can not be + // inlined because the definition of SpaceUsedExcludingSelfLong() is not + // included in lite runtime and when an inline method refers to it MSVC + // will complain about unresolved symbols when building the lite runtime + // as .dll. int SpaceUsedExcludingSelf() const; private: @@ -478,6 +483,8 @@ class LIBPROTOBUF_EXPORT ExtensionSet { } private: + virtual void UnusedKeyMethod(); // Dummy key method to avoid weak vtable. + GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(LazyMessageExtension); }; struct Extension { @@ -692,6 +699,10 @@ inline void ExtensionSet::AddString(int number, FieldType type, // ExtensionSet* set); // static inline void Add(int number, ConstType value, ExtensionSet* set); // static inline MutableType Add(int number, ExtensionSet* set); +// This is used by the ExtensionIdentifier constructor to register +// the extension at dynamic initialization. +// template <typename ExtendeeT> +// static void Register(int number, FieldType type, bool is_packed); // }; // // Not all of these methods make sense for all field types. For example, the @@ -723,6 +734,11 @@ class PrimitiveTypeTraits { ConstType default_value); static inline void Set(int number, FieldType field_type, ConstType value, ExtensionSet* set); + template <typename ExtendeeT> + static void Register(int number, FieldType type, bool is_packed) { + ExtensionSet::RegisterExtension(&ExtendeeT::default_instance(), number, + type, false, is_packed); + } }; template <typename Type> @@ -746,6 +762,11 @@ class RepeatedPrimitiveTypeTraits { bool is_packed, ExtensionSet* set); static const RepeatedFieldType* GetDefaultRepeatedField(); + template <typename ExtendeeT> + static void Register(int number, FieldType type, bool is_packed) { + ExtensionSet::RegisterExtension(&ExtendeeT::default_instance(), number, + type, true, is_packed); + } }; LIBPROTOBUF_EXPORT extern ProtobufOnceType repeated_primitive_generic_type_traits_once_init_; @@ -843,6 +864,11 @@ class LIBPROTOBUF_EXPORT StringTypeTraits { ExtensionSet* set) { return set->MutableString(number, field_type, NULL); } + template <typename ExtendeeT> + static void Register(int number, FieldType type, bool is_packed) { + ExtensionSet::RegisterExtension(&ExtendeeT::default_instance(), number, + type, false, is_packed); + } }; LIBPROTOBUF_EXPORT extern ProtobufOnceType repeated_string_type_traits_once_init_; @@ -895,6 +921,12 @@ class LIBPROTOBUF_EXPORT RepeatedStringTypeTraits { return default_repeated_field_; } + template <typename ExtendeeT> + static void Register(int number, FieldType type, bool is_packed) { + ExtensionSet::RegisterExtension(&ExtendeeT::default_instance(), number, + type, true, is_packed); + } + private: static void InitializeDefaultRepeatedFields(); static void DestroyDefaultRepeatedFields(); @@ -922,6 +954,11 @@ class EnumTypeTraits { GOOGLE_DCHECK(IsValid(value)); set->SetEnum(number, field_type, value, NULL); } + template <typename ExtendeeT> + static void Register(int number, FieldType type, bool is_packed) { + ExtensionSet::RegisterEnumExtension(&ExtendeeT::default_instance(), number, + type, false, is_packed, IsValid); + } }; template <typename Type, bool IsValid(int)> @@ -975,6 +1012,11 @@ class RepeatedEnumTypeTraits { return reinterpret_cast<const RepeatedField<Type>*>( RepeatedPrimitiveTypeTraits<int32>::GetDefaultRepeatedField()); } + template <typename ExtendeeT> + static void Register(int number, FieldType type, bool is_packed) { + ExtensionSet::RegisterEnumExtension(&ExtendeeT::default_instance(), number, + type, true, is_packed, IsValid); + } }; // ------------------------------------------------------------------- @@ -1020,6 +1062,12 @@ class MessageTypeTraits { return static_cast<Type*>(set->UnsafeArenaReleaseMessage( number, Type::default_instance())); } + template <typename ExtendeeT> + static void Register(int number, FieldType type, bool is_packed) { + ExtensionSet::RegisterMessageExtension(&ExtendeeT::default_instance(), + number, type, false, is_packed, + &Type::default_instance()); + } }; // forward declaration @@ -1065,6 +1113,12 @@ class RepeatedMessageTypeTraits { } static const RepeatedFieldType* GetDefaultRepeatedField(); + template <typename ExtendeeT> + static void Register(int number, FieldType type, bool is_packed) { + ExtensionSet::RegisterMessageExtension(&ExtendeeT::default_instance(), + number, type, true, is_packed, + &Type::default_instance()); + } }; LIBPROTOBUF_EXPORT extern ProtobufOnceType repeated_message_generic_type_traits_once_init_; @@ -1116,12 +1170,18 @@ class ExtensionIdentifier { typedef ExtendeeType Extendee; ExtensionIdentifier(int number, typename TypeTraits::ConstType default_value) - : number_(number), default_value_(default_value) {} + : number_(number), default_value_(default_value) { + Register(number); + } inline int number() const { return number_; } typename TypeTraits::ConstType default_value() const { return default_value_; } + static void Register(int number) { + TypeTraits::template Register<ExtendeeType>(number, field_type, is_packed); + } + private: const int number_; typename TypeTraits::ConstType default_value_; diff --git a/src/google/protobuf/extension_set_heavy.cc b/src/google/protobuf/extension_set_heavy.cc index f545fe30..432c0fd7 100644 --- a/src/google/protobuf/extension_set_heavy.cc +++ b/src/google/protobuf/extension_set_heavy.cc @@ -37,10 +37,12 @@ #include <google/protobuf/io/coded_stream.h> #include <google/protobuf/io/zero_copy_stream_impl_lite.h> +#include <google/protobuf/descriptor.pb.h> #include <google/protobuf/descriptor.h> #include <google/protobuf/extension_set.h> #include <google/protobuf/message.h> #include <google/protobuf/repeated_field.h> +#include <google/protobuf/unknown_field_set.h> #include <google/protobuf/wire_format.h> #include <google/protobuf/wire_format_lite_inl.h> @@ -257,8 +259,10 @@ MessageLite* ExtensionSet::AddMessage(const FieldDescriptor* descriptor, // RepeatedPtrField<Message> does not know how to Add() since it cannot // allocate an abstract object, so we have to be tricky. - MessageLite* result = extension->repeated_message_value - ->AddFromCleared<GenericTypeHandler<MessageLite> >(); + MessageLite* result = + reinterpret_cast< ::google::protobuf::internal::RepeatedPtrFieldBase*>( + extension->repeated_message_value) + ->AddFromCleared<GenericTypeHandler<MessageLite> >(); if (result == NULL) { const MessageLite* prototype; if (extension->repeated_message_value->size() == 0) { @@ -389,7 +393,9 @@ size_t ExtensionSet::Extension::SpaceUsedExcludingSelfLong() const { // type handler. total_size += sizeof(*repeated_message_value) + - RepeatedMessage_SpaceUsedExcludingSelfLong(repeated_message_value); + RepeatedMessage_SpaceUsedExcludingSelfLong( + reinterpret_cast< ::google::protobuf::internal::RepeatedPtrFieldBase*>( + repeated_message_value)); break; } } else { @@ -489,10 +495,10 @@ uint8* ExtensionSet::Extension::InternalSerializeFieldWithCachedSizesToArray( HANDLE_TYPE( ENUM, Enum, enum); #undef HANDLE_TYPE - case WireFormatLite::TYPE_STRING: - case WireFormatLite::TYPE_BYTES: - case WireFormatLite::TYPE_GROUP: - case WireFormatLite::TYPE_MESSAGE: + case FieldDescriptor::TYPE_STRING: + case FieldDescriptor::TYPE_BYTES: + case FieldDescriptor::TYPE_GROUP: + case FieldDescriptor::TYPE_MESSAGE: GOOGLE_LOG(FATAL) << "Non-primitive types can't be packed."; break; } diff --git a/src/google/protobuf/extension_set_unittest.cc b/src/google/protobuf/extension_set_unittest.cc index 772d2734..b8b6e428 100644 --- a/src/google/protobuf/extension_set_unittest.cc +++ b/src/google/protobuf/extension_set_unittest.cc @@ -32,6 +32,7 @@ // Based on original Protocol Buffers design by // Sanjay Ghemawat, Jeff Dean, and others. + #include <google/protobuf/stubs/strutil.h> #include <google/protobuf/extension_set.h> #include <google/protobuf/unittest.pb.h> @@ -791,11 +792,16 @@ TEST(ExtensionSetTest, SpaceUsedExcludingSelf) { message.AddExtension(unittest::repeated_##type##_extension, value); \ EXPECT_EQ(empty_repeated_field_size, message.SpaceUsed()) << #type; \ message.ClearExtension(unittest::repeated_##type##_extension); \ + const int old_capacity = \ + message.GetRepeatedExtension(unittest::repeated_##type##_extension) \ + .Capacity(); \ + EXPECT_GE(old_capacity, kMinRepeatedFieldAllocationSize); \ for (int i = 0; i < 16; ++i) { \ message.AddExtension(unittest::repeated_##type##_extension, value); \ } \ - int expected_size = sizeof(cpptype) * (16 - \ - kMinRepeatedFieldAllocationSize) + empty_repeated_field_size; \ + int expected_size = sizeof(cpptype) * \ + (message.GetRepeatedExtension(unittest::repeated_##type##_extension) \ + .Capacity() - old_capacity) + empty_repeated_field_size; \ EXPECT_LE(expected_size, message.SpaceUsed()) << #type; \ } while (0) diff --git a/src/google/protobuf/field_mask.pb.cc b/src/google/protobuf/field_mask.pb.cc index 094c4cc9..abee4fe7 100644 --- a/src/google/protobuf/field_mask.pb.cc +++ b/src/google/protobuf/field_mask.pb.cc @@ -1,7 +1,6 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/protobuf/field_mask.proto -#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION #include <google/protobuf/field_mask.pb.h> #include <algorithm> @@ -15,55 +14,60 @@ #include <google/protobuf/generated_message_reflection.h> #include <google/protobuf/reflection_ops.h> #include <google/protobuf/wire_format.h> +// This is a temporary google only hack +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS +#include "third_party/protobuf/version.h" +#endif // @@protoc_insertion_point(includes) - namespace google { namespace protobuf { -class FieldMaskDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<FieldMask> { +class FieldMaskDefaultTypeInternal { + public: + ::google::protobuf::internal::ExplicitlyConstructed<FieldMask> + _instance; } _FieldMask_default_instance_; - +} // namespace protobuf +} // namespace google namespace protobuf_google_2fprotobuf_2ffield_5fmask_2eproto { +void InitDefaultsFieldMaskImpl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); +#else + ::google::protobuf::internal::InitProtobufDefaults(); +#endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + { + void* ptr = &::google::protobuf::_FieldMask_default_instance_; + new (ptr) ::google::protobuf::FieldMask(); + ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); + } + ::google::protobuf::FieldMask::InitAsDefaultInstance(); +} -namespace { +void InitDefaultsFieldMask() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsFieldMaskImpl); +} ::google::protobuf::Metadata file_level_metadata[1]; -} // namespace - -PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::ParseTableField - const TableStruct::entries[] = { - {0, 0, 0, ::google::protobuf::internal::kInvalidMask, 0, 0}, -}; - -PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::AuxillaryParseTableField - const TableStruct::aux[] = { - ::google::protobuf::internal::AuxillaryParseTableField(), -}; -PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::ParseTable const - TableStruct::schema[] = { - { NULL, NULL, 0, -1, -1, false }, -}; - -const ::google::protobuf::uint32 TableStruct::offsets[] = { +const ::google::protobuf::uint32 TableStruct::offsets[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { ~0u, // no _has_bits_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldMask, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FieldMask, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldMask, paths_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FieldMask, paths_), }; - -static const ::google::protobuf::internal::MigrationSchema schemas[] = { - { 0, -1, sizeof(FieldMask)}, +static const ::google::protobuf::internal::MigrationSchema schemas[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { + { 0, -1, sizeof(::google::protobuf::FieldMask)}, }; static ::google::protobuf::Message const * const file_default_instances[] = { - reinterpret_cast<const ::google::protobuf::Message*>(&_FieldMask_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_FieldMask_default_instance_), }; -namespace { - void protobuf_AssignDescriptors() { AddDescriptors(); ::google::protobuf::MessageFactory* factory = NULL; @@ -77,33 +81,15 @@ void protobuf_AssignDescriptorsOnce() { ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors); } -void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; +void protobuf_RegisterTypes(const ::std::string&) GOOGLE_PROTOBUF_ATTRIBUTE_COLD; void protobuf_RegisterTypes(const ::std::string&) { protobuf_AssignDescriptorsOnce(); ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 1); } -} // namespace - -void TableStruct::Shutdown() { - _FieldMask_default_instance_.Shutdown(); - delete file_level_metadata[0].reflection; -} - -void TableStruct::InitDefaultsImpl() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - ::google::protobuf::internal::InitProtobufDefaults(); - _FieldMask_default_instance_.DefaultConstruct(); -} - -void InitDefaults() { - static GOOGLE_PROTOBUF_DECLARE_ONCE(once); - ::google::protobuf::GoogleOnceInit(&once, &TableStruct::InitDefaultsImpl); -} void AddDescriptorsImpl() { InitDefaults(); - static const char descriptor[] = { + static const char descriptor[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { "\n google/protobuf/field_mask.proto\022\017goog" "le.protobuf\"\032\n\tFieldMask\022\r\n\005paths\030\001 \003(\tB" "\211\001\n\023com.google.protobufB\016FieldMaskProtoP" @@ -115,25 +101,26 @@ void AddDescriptorsImpl() { descriptor, 227); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/field_mask.proto", &protobuf_RegisterTypes); - ::google::protobuf::internal::OnShutdown(&TableStruct::Shutdown); } void AddDescriptors() { static GOOGLE_PROTOBUF_DECLARE_ONCE(once); ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl); } -// Force AddDescriptors() to be called at static initialization time. +// Force AddDescriptors() to be called at dynamic initialization time. struct StaticDescriptorInitializer { StaticDescriptorInitializer() { AddDescriptors(); } } static_descriptor_initializer; - } // namespace protobuf_google_2fprotobuf_2ffield_5fmask_2eproto - +namespace google { +namespace protobuf { // =================================================================== +void FieldMask::InitAsDefaultInstance() { +} #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int FieldMask::kPathsFieldNumber; #endif // !defined(_MSC_VER) || _MSC_VER >= 1900 @@ -141,7 +128,7 @@ const int FieldMask::kPathsFieldNumber; FieldMask::FieldMask() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { - protobuf_google_2fprotobuf_2ffield_5fmask_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2ffield_5fmask_2eproto::InitDefaultsFieldMask(); } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.FieldMask) @@ -173,26 +160,24 @@ void FieldMask::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* FieldMask::descriptor() { - protobuf_google_2fprotobuf_2ffield_5fmask_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2ffield_5fmask_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; + ::protobuf_google_2fprotobuf_2ffield_5fmask_2eproto::protobuf_AssignDescriptorsOnce(); + return ::protobuf_google_2fprotobuf_2ffield_5fmask_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const FieldMask& FieldMask::default_instance() { - protobuf_google_2fprotobuf_2ffield_5fmask_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2ffield_5fmask_2eproto::InitDefaultsFieldMask(); return *internal_default_instance(); } -FieldMask* FieldMask::New(::google::protobuf::Arena* arena) const { - FieldMask* n = new FieldMask; - if (arena != NULL) { - arena->Own(n); - } - return n; -} void FieldMask::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.FieldMask) + ::google::protobuf::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + paths_.Clear(); + _internal_metadata_.Clear(); } bool FieldMask::MergePartialFromCodedStream( @@ -208,12 +193,12 @@ bool FieldMask::MergePartialFromCodedStream( // repeated string paths = 1; case 1: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(10u)) { + static_cast< ::google::protobuf::uint8>(10u /* 10 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->add_paths())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->paths(this->paths_size() - 1).data(), - this->paths(this->paths_size() - 1).length(), + static_cast<int>(this->paths(this->paths_size() - 1).length()), ::google::protobuf::internal::WireFormatLite::PARSE, "google.protobuf.FieldMask.paths")); } else { @@ -224,12 +209,11 @@ bool FieldMask::MergePartialFromCodedStream( default: { handle_unusual: - if (tag == 0 || - ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + if (tag == 0) { goto success; } - DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag)); + DO_(::google::protobuf::internal::WireFormat::SkipField( + input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } @@ -252,18 +236,23 @@ void FieldMask::SerializeWithCachedSizes( // repeated string paths = 1; for (int i = 0, n = this->paths_size(); i < n; i++) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( - this->paths(i).data(), this->paths(i).length(), + this->paths(i).data(), static_cast<int>(this->paths(i).length()), ::google::protobuf::internal::WireFormatLite::SERIALIZE, "google.protobuf.FieldMask.paths"); ::google::protobuf::internal::WireFormatLite::WriteString( 1, this->paths(i), output); } + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + ::google::protobuf::internal::WireFormat::SerializeUnknownFields( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), output); + } // @@protoc_insertion_point(serialize_end:google.protobuf.FieldMask) } ::google::protobuf::uint8* FieldMask::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.FieldMask) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -271,13 +260,17 @@ void FieldMask::SerializeWithCachedSizes( // repeated string paths = 1; for (int i = 0, n = this->paths_size(); i < n; i++) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( - this->paths(i).data(), this->paths(i).length(), + this->paths(i).data(), static_cast<int>(this->paths(i).length()), ::google::protobuf::internal::WireFormatLite::SERIALIZE, "google.protobuf.FieldMask.paths"); target = ::google::protobuf::internal::WireFormatLite:: WriteStringToArray(1, this->paths(i), target); } + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), target); + } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.FieldMask) return target; } @@ -286,6 +279,11 @@ size_t FieldMask::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.FieldMask) size_t total_size = 0; + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance())); + } // repeated string paths = 1; total_size += 1 * ::google::protobuf::internal::FromIntSize(this->paths_size()); @@ -349,91 +347,26 @@ void FieldMask::Swap(FieldMask* other) { InternalSwap(other); } void FieldMask::InternalSwap(FieldMask* other) { - paths_.InternalSwap(&other->paths_); - std::swap(_cached_size_, other->_cached_size_); + using std::swap; + paths_.InternalSwap(CastToBase(&other->paths_)); + _internal_metadata_.Swap(&other->_internal_metadata_); + swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata FieldMask::GetMetadata() const { protobuf_google_2fprotobuf_2ffield_5fmask_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2ffield_5fmask_2eproto::file_level_metadata[kIndexInFileMessages]; -} - -#if PROTOBUF_INLINE_NOT_IN_HEADERS -// FieldMask - -// repeated string paths = 1; -int FieldMask::paths_size() const { - return paths_.size(); -} -void FieldMask::clear_paths() { - paths_.Clear(); -} -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) { - // @@protoc_insertion_point(field_mutable:google.protobuf.FieldMask.paths) - return paths_.Mutable(index); -} -void FieldMask::set_paths(int index, const ::std::string& value) { - // @@protoc_insertion_point(field_set:google.protobuf.FieldMask.paths) - paths_.Mutable(index)->assign(value); -} -#if LANG_CXX11 -void FieldMask::set_paths(int index, ::std::string&& value) { - // @@protoc_insertion_point(field_set:google.protobuf.FieldMask.paths) - paths_.Mutable(index)->assign(std::move(value)); -} -#endif -void FieldMask::set_paths(int index, const char* value) { - GOOGLE_DCHECK(value != NULL); - 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) { - paths_.Mutable(index)->assign( - reinterpret_cast<const char*>(value), size); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.FieldMask.paths) -} -::std::string* FieldMask::add_paths() { - // @@protoc_insertion_point(field_add_mutable:google.protobuf.FieldMask.paths) - return paths_.Add(); -} -void FieldMask::add_paths(const ::std::string& value) { - paths_.Add()->assign(value); - // @@protoc_insertion_point(field_add:google.protobuf.FieldMask.paths) -} -#if LANG_CXX11 -void FieldMask::add_paths(::std::string&& value) { - paths_.Add(std::move(value)); - // @@protoc_insertion_point(field_add:google.protobuf.FieldMask.paths) -} -#endif -void FieldMask::add_paths(const char* value) { - GOOGLE_DCHECK(value != NULL); - paths_.Add()->assign(value); - // @@protoc_insertion_point(field_add_char:google.protobuf.FieldMask.paths) -} -void FieldMask::add_paths(const char* value, size_t size) { - paths_.Add()->assign(reinterpret_cast<const char*>(value), size); - // @@protoc_insertion_point(field_add_pointer:google.protobuf.FieldMask.paths) -} -const ::google::protobuf::RepeatedPtrField< ::std::string>& -FieldMask::paths() const { - // @@protoc_insertion_point(field_list:google.protobuf.FieldMask.paths) - return paths_; -} -::google::protobuf::RepeatedPtrField< ::std::string>* -FieldMask::mutable_paths() { - // @@protoc_insertion_point(field_mutable_list:google.protobuf.FieldMask.paths) - return &paths_; + return ::protobuf_google_2fprotobuf_2ffield_5fmask_2eproto::file_level_metadata[kIndexInFileMessages]; } -#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // @@protoc_insertion_point(namespace_scope) - +} // namespace protobuf +} // namespace google +namespace google { +namespace protobuf { +template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::FieldMask* Arena::Create< ::google::protobuf::FieldMask >(Arena* arena) { + return Arena::CreateInternal< ::google::protobuf::FieldMask >(arena); +} } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/field_mask.pb.h b/src/google/protobuf/field_mask.pb.h index 742c1cf9..2d75967e 100644 --- a/src/google/protobuf/field_mask.pb.h +++ b/src/google/protobuf/field_mask.pb.h @@ -1,19 +1,19 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/protobuf/field_mask.proto -#ifndef PROTOBUF_google_2fprotobuf_2ffield_5fmask_2eproto__INCLUDED -#define PROTOBUF_google_2fprotobuf_2ffield_5fmask_2eproto__INCLUDED +#ifndef PROTOBUF_google_2fprotobuf_2ffield_5fmask_2eproto_INCLUDED +#define PROTOBUF_google_2fprotobuf_2ffield_5fmask_2eproto_INCLUDED #include <string> #include <google/protobuf/stubs/common.h> -#if GOOGLE_PROTOBUF_VERSION < 3003000 +#if GOOGLE_PROTOBUF_VERSION < 3005000 #error This file was generated by a newer version of protoc which is #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3003000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION +#if 3005001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. @@ -30,30 +30,38 @@ #include <google/protobuf/extension_set.h> // IWYU pragma: export #include <google/protobuf/unknown_field_set.h> // @@protoc_insertion_point(includes) -namespace google { -namespace protobuf { -class FieldMask; -class FieldMaskDefaultTypeInternal; -LIBPROTOBUF_EXPORT extern FieldMaskDefaultTypeInternal _FieldMask_default_instance_; -} // namespace protobuf -} // namespace google - -namespace google { -namespace protobuf { namespace protobuf_google_2fprotobuf_2ffield_5fmask_2eproto { -// Internal implementation detail -- do not call these. +// Internal implementation detail -- do not use these members. struct LIBPROTOBUF_EXPORT TableStruct { static const ::google::protobuf::internal::ParseTableField entries[]; static const ::google::protobuf::internal::AuxillaryParseTableField aux[]; - static const ::google::protobuf::internal::ParseTable schema[]; + static const ::google::protobuf::internal::ParseTable schema[1]; + static const ::google::protobuf::internal::FieldMetadata field_metadata[]; + static const ::google::protobuf::internal::SerializationTable serialization_table[]; static const ::google::protobuf::uint32 offsets[]; - static void InitDefaultsImpl(); - static void Shutdown(); }; void LIBPROTOBUF_EXPORT AddDescriptors(); -void LIBPROTOBUF_EXPORT InitDefaults(); +void LIBPROTOBUF_EXPORT InitDefaultsFieldMaskImpl(); +void LIBPROTOBUF_EXPORT InitDefaultsFieldMask(); +inline void LIBPROTOBUF_EXPORT InitDefaults() { + InitDefaultsFieldMask(); +} } // namespace protobuf_google_2fprotobuf_2ffield_5fmask_2eproto +namespace google { +namespace protobuf { +class FieldMask; +class FieldMaskDefaultTypeInternal; +LIBPROTOBUF_EXPORT extern FieldMaskDefaultTypeInternal _FieldMask_default_instance_; +} // namespace protobuf +} // namespace google +namespace google { +namespace protobuf { +template<> LIBPROTOBUF_EXPORT ::google::protobuf::FieldMask* Arena::Create< ::google::protobuf::FieldMask>(Arena*); +} // namespace protobuf +} // namespace google +namespace google { +namespace protobuf { // =================================================================== @@ -68,10 +76,25 @@ class LIBPROTOBUF_EXPORT FieldMask : public ::google::protobuf::Message /* @@pro CopyFrom(from); return *this; } + #if LANG_CXX11 + FieldMask(FieldMask&& from) noexcept + : FieldMask() { + *this = ::std::move(from); + } + inline FieldMask& operator=(FieldMask&& from) noexcept { + if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + #endif static const ::google::protobuf::Descriptor* descriptor(); static const FieldMask& default_instance(); + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY static inline const FieldMask* internal_default_instance() { return reinterpret_cast<const FieldMask*>( &_FieldMask_default_instance_); @@ -80,12 +103,19 @@ class LIBPROTOBUF_EXPORT FieldMask : public ::google::protobuf::Message /* @@pro 0; void Swap(FieldMask* other); + friend void swap(FieldMask& a, FieldMask& b) { + a.Swap(&b); + } // implements Message ---------------------------------------------- - inline FieldMask* New() const PROTOBUF_FINAL { return New(NULL); } + inline FieldMask* New() const PROTOBUF_FINAL { + return ::google::protobuf::Arena::Create<FieldMask>(NULL); + } - FieldMask* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + FieldMask* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL { + return ::google::protobuf::Arena::Create<FieldMask>(arena); + } void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const FieldMask& from); @@ -149,14 +179,18 @@ class LIBPROTOBUF_EXPORT FieldMask : public ::google::protobuf::Message /* @@pro ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; ::google::protobuf::RepeatedPtrField< ::std::string> paths_; mutable int _cached_size_; - friend struct protobuf_google_2fprotobuf_2ffield_5fmask_2eproto::TableStruct; + friend struct ::protobuf_google_2fprotobuf_2ffield_5fmask_2eproto::TableStruct; + friend void ::protobuf_google_2fprotobuf_2ffield_5fmask_2eproto::InitDefaultsFieldMaskImpl(); }; // =================================================================== // =================================================================== -#if !PROTOBUF_INLINE_NOT_IN_HEADERS +#ifdef __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif // __GNUC__ // FieldMask // repeated string paths = 1; @@ -228,14 +262,15 @@ FieldMask::mutable_paths() { return &paths_; } -#endif // !PROTOBUF_INLINE_NOT_IN_HEADERS +#ifdef __GNUC__ + #pragma GCC diagnostic pop +#endif // __GNUC__ // @@protoc_insertion_point(namespace_scope) - } // namespace protobuf } // namespace google // @@protoc_insertion_point(global_scope) -#endif // PROTOBUF_google_2fprotobuf_2ffield_5fmask_2eproto__INCLUDED +#endif // PROTOBUF_google_2fprotobuf_2ffield_5fmask_2eproto_INCLUDED diff --git a/src/google/protobuf/field_mask.proto b/src/google/protobuf/field_mask.proto index c68d247c..eb96ba00 100644 --- a/src/google/protobuf/field_mask.proto +++ b/src/google/protobuf/field_mask.proto @@ -240,6 +240,12 @@ option go_package = "google.golang.org/genproto/protobuf/field_mask;field_mask"; // // Note that oneof type names ("test_oneof" in this case) cannot be used in // paths. +// +// ## Field Mask Verification +// +// The implementation of the all the API methods, which have any FieldMask type +// field in the request, should verify the included field paths, and return +// `INVALID_ARGUMENT` error if any path is duplicated or unmappable. message FieldMask { // The set of field mask paths. repeated string paths = 1; diff --git a/src/google/protobuf/generated_enum_reflection.h b/src/google/protobuf/generated_enum_reflection.h index fdcdc277..983d3185 100644 --- a/src/google/protobuf/generated_enum_reflection.h +++ b/src/google/protobuf/generated_enum_reflection.h @@ -41,7 +41,6 @@ #include <string> -#include <google/protobuf/stubs/template_util.h> #include <google/protobuf/generated_enum_util.h> namespace google { diff --git a/src/google/protobuf/generated_enum_util.h b/src/google/protobuf/generated_enum_util.h index e4242055..4f5ded5b 100644 --- a/src/google/protobuf/generated_enum_util.h +++ b/src/google/protobuf/generated_enum_util.h @@ -31,7 +31,7 @@ #ifndef GOOGLE_PROTOBUF_GENERATED_ENUM_UTIL_H__ #define GOOGLE_PROTOBUF_GENERATED_ENUM_UTIL_H__ -#include <google/protobuf/stubs/template_util.h> +#include <google/protobuf/stubs/type_traits.h> namespace google { namespace protobuf { diff --git a/src/google/protobuf/generated_message_reflection.cc b/src/google/protobuf/generated_message_reflection.cc index 9aebd901..b0c975b4 100644 --- a/src/google/protobuf/generated_message_reflection.cc +++ b/src/google/protobuf/generated_message_reflection.cc @@ -44,7 +44,7 @@ #include <google/protobuf/generated_message_util.h> #include <google/protobuf/map_field.h> #include <google/protobuf/repeated_field.h> -// #include "google/protobuf/bridge/compatibility_mode_support.h" +#include <google/protobuf/wire_format.h> #define GOOGLE_PROTOBUF_HAS_ONEOF @@ -197,32 +197,14 @@ GeneratedMessageReflection::GeneratedMessageReflection( GeneratedMessageReflection::~GeneratedMessageReflection() {} -namespace { -UnknownFieldSet* empty_unknown_field_set_ = NULL; -GOOGLE_PROTOBUF_DECLARE_ONCE(empty_unknown_field_set_once_); - -void DeleteEmptyUnknownFieldSet() { - delete empty_unknown_field_set_; - empty_unknown_field_set_ = NULL; -} - -void InitEmptyUnknownFieldSet() { - empty_unknown_field_set_ = new UnknownFieldSet; - internal::OnShutdown(&DeleteEmptyUnknownFieldSet); -} - -const UnknownFieldSet& GetEmptyUnknownFieldSet() { - ::google::protobuf::GoogleOnceInit(&empty_unknown_field_set_once_, &InitEmptyUnknownFieldSet); - return *empty_unknown_field_set_; -} -} // namespace - const UnknownFieldSet& GeneratedMessageReflection::GetUnknownFields( const Message& message) const { - if (descriptor_->file()->syntax() == FileDescriptor::SYNTAX_PROTO3) { + if (descriptor_->file()->syntax() == FileDescriptor::SYNTAX_PROTO3 && + !GetProto3PreserveUnknownsDefault()) { // We have to ensure that any mutations made to the return value of - // MutableUnknownFields() are not reflected here. - return GetEmptyUnknownFieldSet(); + // MutableUnknownFields() are not reflected here when Proto3 defaults to + // discard unknowns. + return *UnknownFieldSet::default_instance(); } else { return GetInternalMetadataWithArena(message).unknown_fields(); } @@ -1020,7 +1002,7 @@ void GeneratedMessageReflection::ListFields( schema_.HasHasbits() ? GetHasBits(message) : NULL; const uint32* const has_bits_indices = schema_.has_bit_indices_; const uint32* const oneof_case_array = - &GetConstRefAtOffset<uint32>(message, schema_.oneof_case_offset_); + GetConstPointerAtOffset<uint32>(&message, schema_.oneof_case_offset_); output->reserve(descriptor_->field_count()); for (int i = 0; i <= last_non_weak_field_index_; i++) { const FieldDescriptor* field = descriptor_->field(i); @@ -1142,9 +1124,6 @@ string GeneratedMessageReflection::GetString( return GetField<ArenaStringPtr>(message, field).Get(); } } - - GOOGLE_LOG(FATAL) << "Can't get here."; - return GetEmptyString(); // Make compiler happy. } } @@ -1162,9 +1141,6 @@ const string& GeneratedMessageReflection::GetStringReference( return GetField<ArenaStringPtr>(message, field).Get(); } } - - GOOGLE_LOG(FATAL) << "Can't get here."; - return GetEmptyString(); // Make compiler happy. } } @@ -1206,9 +1182,6 @@ string GeneratedMessageReflection::GetRepeatedString( case FieldOptions::STRING: return GetRepeatedPtrField<string>(message, field, index); } - - GOOGLE_LOG(FATAL) << "Can't get here."; - return GetEmptyString(); // Make compiler happy. } } @@ -1224,9 +1197,6 @@ const string& GeneratedMessageReflection::GetRepeatedStringReference( case FieldOptions::STRING: return GetRepeatedPtrField<string>(message, field, index); } - - GOOGLE_LOG(FATAL) << "Can't get here."; - return GetEmptyString(); // Make compiler happy. } } @@ -2268,17 +2238,15 @@ class AssignDescriptorsHelper { file_level_metadata_->descriptor = descriptor; - if (!descriptor->options().map_entry()) { - // Only set reflection for non map types. - file_level_metadata_->reflection = new GeneratedMessageReflection( - descriptor, MigrationToReflectionSchema(default_instance_data_, - offsets_, *schemas_), - ::google::protobuf::DescriptorPool::generated_pool(), factory_); - for (int i = 0; i < descriptor->enum_type_count(); i++) { - AssignEnumDescriptor(descriptor->enum_type(i)); - } - schemas_++; + file_level_metadata_->reflection = new GeneratedMessageReflection( + descriptor, + MigrationToReflectionSchema(default_instance_data_, offsets_, + *schemas_), + ::google::protobuf::DescriptorPool::generated_pool(), factory_); + for (int i = 0; i < descriptor->enum_type_count(); i++) { + AssignEnumDescriptor(descriptor->enum_type(i)); } + schemas_++; default_instance_data_++; file_level_metadata_++; } @@ -2288,6 +2256,8 @@ class AssignDescriptorsHelper { file_level_enum_descriptors_++; } + const Metadata* GetCurrentMetadataPtr() const { return file_level_metadata_; } + private: MessageFactory* factory_; Metadata* file_level_metadata_; @@ -2297,6 +2267,41 @@ class AssignDescriptorsHelper { const uint32* offsets_; }; +// We have the routines that assign descriptors and build reflection +// automatically delete the allocated reflection. MetadataOwner owns +// all the allocated reflection instances. +struct MetadataOwner { + void AddArray(const Metadata* begin, const Metadata* end) { + MutexLock lock(&mu_); + metadata_arrays_.push_back(std::make_pair(begin, end)); + } + + static MetadataOwner* Instance() { + static MetadataOwner* res = new MetadataOwner; + return res; + } + + private: + // Use the constructor to register the shutdown code. Because c++ makes sure + // this called only once. + MetadataOwner() { OnShutdown(&DeleteMetadata); } + ~MetadataOwner() { + for (int i = 0; i < metadata_arrays_.size(); i++) { + for (const Metadata* m = metadata_arrays_[i].first; + m < metadata_arrays_[i].second; m++) { + delete m->reflection; + } + } + } + + static void DeleteMetadata() { + delete Instance(); + } + + Mutex mu_; + std::vector<std::pair<const Metadata*, const Metadata*> > metadata_arrays_; +}; + } // namespace void AssignDescriptors( @@ -2329,6 +2334,8 @@ void AssignDescriptors( file_level_service_descriptors[i] = file->service(i); } } + MetadataOwner::Instance()->AddArray( + file_level_metadata, helper.GetCurrentMetadataPtr()); } void RegisterAllTypesInternal(const Metadata* file_level_metadata, int size) { @@ -2349,6 +2356,18 @@ void RegisterAllTypes(const Metadata* file_level_metadata, int size) { RegisterAllTypesInternal(file_level_metadata, size); } +void UnknownFieldSetSerializer(const uint8* base, uint32 offset, uint32 tag, + uint32 has_offset, + ::google::protobuf::io::CodedOutputStream* output) { + const void* ptr = base + offset; + const InternalMetadataWithArena* metadata = + static_cast<const InternalMetadataWithArena*>(ptr); + if (metadata->have_unknown_fields()) { + ::google::protobuf::internal::WireFormat::SerializeUnknownFields( + metadata->unknown_fields(), output); + } +} + } // namespace internal } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/generated_message_reflection.h b/src/google/protobuf/generated_message_reflection.h index 12b73ca3..3c6701cf 100644 --- a/src/google/protobuf/generated_message_reflection.h +++ b/src/google/protobuf/generated_message_reflection.h @@ -45,7 +45,6 @@ // TODO(jasonh): Remove this once the compiler change to directly include this // is released to components. #include <google/protobuf/generated_enum_reflection.h> -#include <google/protobuf/generated_message_util.h> #include <google/protobuf/message.h> #include <google/protobuf/metadata.h> #include <google/protobuf/unknown_field_set.h> @@ -129,7 +128,7 @@ class WeakFieldMap; // weak_field_map.h struct ReflectionSchema { public: // Size of a google::protobuf::Message object of this type. - uint32 GetObjectSize() const { return object_size_; } + uint32 GetObjectSize() const { return static_cast<uint32>(object_size_); } // Offset of a non-oneof field. Getting a field offset is slightly more // efficient when we know statically that it is not a oneof field. @@ -141,8 +140,9 @@ struct ReflectionSchema { // Offset of any field. uint32 GetFieldOffset(const FieldDescriptor* field) const { if (field->containing_oneof()) { - size_t offset = field->containing_type()->field_count() + - field->containing_oneof()->index(); + size_t offset = + static_cast<size_t>(field->containing_type()->field_count() + + field->containing_oneof()->index()); return offsets_[offset]; } else { return GetFieldOffsetNonOneof(field); @@ -150,7 +150,9 @@ struct ReflectionSchema { } uint32 GetOneofCaseOffset(const OneofDescriptor* oneof_descriptor) const { - return oneof_case_offset_ + (oneof_descriptor->index() * sizeof(uint32)); + return static_cast<uint32>(oneof_case_offset_) + + static_cast<uint32>( + static_cast<size_t>(oneof_descriptor->index()) * sizeof(uint32)); } bool HasHasbits() const { return has_bits_offset_ != -1; } @@ -164,7 +166,7 @@ struct ReflectionSchema { // Byte offset of the hasbits array. uint32 HasBitsOffset() const { GOOGLE_DCHECK(HasHasbits()); - return has_bits_offset_; + return static_cast<uint32>(has_bits_offset_); } // The offset of the InternalMetadataWithArena member. @@ -172,7 +174,7 @@ struct ReflectionSchema { // The schema doesn't contain enough information to distinguish between // these two cases. uint32 GetMetadataOffset() const { - return metadata_offset_; + return static_cast<uint32>(metadata_offset_); } // Whether this message has an ExtensionSet. @@ -181,7 +183,7 @@ struct ReflectionSchema { // The offset of the ExtensionSet in this message. uint32 GetExtensionSetOffset() const { GOOGLE_DCHECK(HasExtensionSet()); - return extensions_offset_; + return static_cast<uint32>(extensions_offset_); } // The off set of WeakFieldMap when the message contains weak fields. @@ -653,12 +655,9 @@ class LIBPROTOBUF_EXPORT GeneratedMessageReflection PROTOBUF_FINAL : public Refl // dynamic_cast_if_available() implements this logic. If RTTI is // enabled, it does a dynamic_cast. If RTTI is disabled, it just returns // NULL. -// -// If you need to compile without RTTI, simply #define GOOGLE_PROTOBUF_NO_RTTI. -// On MSVC, this should be detected automatically. template<typename To, typename From> inline To dynamic_cast_if_available(From from) { -#if defined(GOOGLE_PROTOBUF_NO_RTTI) || (defined(_MSC_VER)&&!defined(_CPPRTTI)) +#ifdef GOOGLE_PROTOBUF_NO_RTTI // Avoid the compiler warning about unused variables. (void)from; return NULL; @@ -686,8 +685,7 @@ T* DynamicCastToGenerated(const Message* from) { const Message* unused = static_cast<T*>(NULL); (void)unused; -#if defined(GOOGLE_PROTOBUF_NO_RTTI) || \ - (defined(_MSC_VER) && !defined(_CPPRTTI)) +#ifdef GOOGLE_PROTOBUF_NO_RTTI bool ok = &T::default_instance() == from->GetReflection()->GetMessageFactory()->GetPrototype( from->GetDescriptor()); @@ -714,6 +712,11 @@ LIBPROTOBUF_EXPORT void AssignDescriptors( LIBPROTOBUF_EXPORT void RegisterAllTypes(const Metadata* file_level_metadata, int size); +// These cannot be in lite so we put them in the reflection. +LIBPROTOBUF_EXPORT void UnknownFieldSetSerializer(const uint8* base, uint32 offset, uint32 tag, + uint32 has_offset, + ::google::protobuf::io::CodedOutputStream* output); + } // namespace internal } // namespace protobuf diff --git a/src/google/protobuf/generated_message_table_driven.cc b/src/google/protobuf/generated_message_table_driven.cc index e281266d..29af1ef6 100644 --- a/src/google/protobuf/generated_message_table_driven.cc +++ b/src/google/protobuf/generated_message_table_driven.cc @@ -32,643 +32,70 @@ #include <google/protobuf/stubs/type_traits.h> +#include <google/protobuf/generated_message_table_driven_lite.h> #include <google/protobuf/io/zero_copy_stream_impl_lite.h> -#include <google/protobuf/metadata_lite.h> +#include <google/protobuf/metadata.h> #include <google/protobuf/repeated_field.h> +#include <google/protobuf/wire_format.h> #include <google/protobuf/wire_format_lite.h> #include <google/protobuf/wire_format_lite_inl.h> - namespace google { namespace protobuf { namespace internal { - namespace { -enum StringType { - StringType_STRING = 0, - StringType_CORD = 1, - StringType_STRING_PIECE = 2 -}; - -template <typename Type> -inline Type* Raw(MessageLite* msg, int64 offset) { - return reinterpret_cast<Type*>(reinterpret_cast<uint8*>(msg) + offset); +UnknownFieldSet* MutableUnknownFields(MessageLite* msg, int64 arena_offset) { + return Raw<InternalMetadataWithArena>(msg, arena_offset) + ->mutable_unknown_fields(); } -template <typename Type> -inline const Type* Raw(const MessageLite* msg, int64 offset) { - return reinterpret_cast<const Type*>(reinterpret_cast<const uint8*>(msg) + - offset); -} +struct UnknownFieldHandler { + static bool Skip(MessageLite* msg, const ParseTable& table, + io::CodedInputStream* input, + int tag) { + GOOGLE_DCHECK(table.unknown_field_set); -inline Arena* GetArena(MessageLite* msg, int64 arena_offset) { - if (GOOGLE_PREDICT_FALSE(arena_offset == -1)) { - return NULL; + return WireFormat::SkipField(input, tag, + MutableUnknownFields(msg, table.arena_offset)); } - return Raw<InternalMetadataWithArenaLite>(msg, arena_offset)->arena(); -} - -template <typename Type> -inline Type* AddField(MessageLite* msg, int64 offset) { -#if LANG_CXX11 - static_assert(std::is_trivially_copy_assignable<Type>::value, - "Do not assign"); -#endif - - google::protobuf::RepeatedField<Type>* repeated = - Raw<google::protobuf::RepeatedField<Type> >(msg, offset); - return repeated->Add(); -} + static void Varint(MessageLite* msg, const ParseTable& table, + int tag, int value) { + GOOGLE_DCHECK(table.unknown_field_set); -template <> -inline string* AddField<string>(MessageLite* msg, int64 offset) { - google::protobuf::RepeatedPtrField<string>* repeated = - Raw<google::protobuf::RepeatedPtrField<string> >(msg, offset); - return repeated->Add(); -} - - -template <typename Type> -inline void AddField(MessageLite* msg, int64 offset, Type value) { -#if LANG_CXX11 - static_assert(std::is_trivially_copy_assignable<Type>::value, - "Do not assign"); -#endif - *AddField<Type>(msg, offset) = value; -} - -inline void SetBit(uint32* has_bits, uint32 has_bit_index) { - GOOGLE_DCHECK(has_bits != NULL); - - uint32 mask = static_cast<uint32>(1u) << (has_bit_index % 32); - has_bits[has_bit_index / 32u] |= mask; -} - -template <typename Type> -inline Type* MutableField(MessageLite* msg, uint32* has_bits, - uint32 has_bit_index, int64 offset) { - SetBit(has_bits, has_bit_index); - return Raw<Type>(msg, offset); -} - -template <typename Type> -inline void SetField(MessageLite* msg, uint32* has_bits, uint32 has_bit_index, - int64 offset, Type value) { -#if LANG_CXX11 - static_assert(std::is_trivially_copy_assignable<Type>::value, - "Do not assign"); -#endif - *MutableField<Type>(msg, has_bits, has_bit_index, offset) = value; -} - -template <bool repeated, bool validate, StringType ctype> -static inline bool HandleString(io::CodedInputStream* input, MessageLite* msg, - Arena* arena, uint32* has_bits, - uint32 has_bit_index, int64 offset, - const void* default_ptr, bool strict_utf8, - const char* field_name) { -#ifdef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED - const char* sdata; - size_t size; -#endif - - string* value; - if (repeated) { - value = AddField<string>(msg, offset); - GOOGLE_DCHECK(value != NULL); - } else { - // TODO(ckennelly): Is this optimal? - value = MutableField<ArenaStringPtr>(msg, has_bits, has_bit_index, offset) - ->Mutable(static_cast<const string*>(default_ptr), arena); - GOOGLE_DCHECK(value != NULL); - } + MutableUnknownFields(msg, table.arena_offset)->AddVarint( + WireFormatLite::GetTagFieldNumber(tag), value); + } - if (GOOGLE_PREDICT_FALSE(!WireFormatLite::ReadString(input, value))) { + static bool ParseExtension( + MessageLite* msg, const ParseTable& table, + io::CodedInputStream* input, int tag) { + ExtensionSet* extensions = GetExtensionSet(msg, table.extension_offset); + if (extensions == NULL) { return false; } -#ifdef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED - sdata = value->data(); - size = value->size(); -#endif - -#ifdef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED - if (validate) { - if (strict_utf8) { - if (GOOGLE_PREDICT_FALSE(!WireFormatLite::VerifyUtf8String( - sdata, size, WireFormatLite::PARSE, field_name))) { - return false; - } - } else { - WireFormatLite::VerifyUTF8String( - sdata, size, WireFormat::PARSE, field_name); - } - } -#endif - - return true; -} + const Message* prototype = down_cast<const Message*>( + table.default_instance()); -string* MutableUnknownFields(MessageLite* msg, int64 arena_offset) { - return Raw<InternalMetadataWithArenaLite>(msg, arena_offset) - ->mutable_unknown_fields(); -} + GOOGLE_DCHECK(prototype != NULL); + GOOGLE_DCHECK(table.unknown_field_set); + UnknownFieldSet* unknown_fields = + MutableUnknownFields(msg, table.arena_offset); -// RepeatedMessageTypeHandler allows us to operate on RepeatedPtrField fields -// without instantiating the specific template. -class RepeatedMessageTypeHandler { - public: - typedef MessageLite Type; - static Arena* GetArena(Type* t) { return t->GetArena(); } - static void* GetMaybeArenaPointer(Type* t) { - return t->GetMaybeArenaPointer(); - } - static inline Type* NewFromPrototype(const Type* prototype, - Arena* arena = NULL) { - return prototype->New(arena); - } - static void Delete(Type* t, Arena* arena = NULL) { - if (arena == NULL) { - delete t; - } + return extensions->ParseField(tag, input, prototype, unknown_fields); } }; -inline bool ReadGroup(int field_number, io::CodedInputStream* input, - MessageLite* value, const ParseTable& table) { - if (GOOGLE_PREDICT_FALSE(!input->IncrementRecursionDepth())) { - return false; - } - - if (GOOGLE_PREDICT_FALSE(!MergePartialFromCodedStream(value, table, input))) { - return false; - } - - input->DecrementRecursionDepth(); - // Make sure the last thing read was an end tag for this group. - if (GOOGLE_PREDICT_FALSE(!input->LastTagWas(WireFormatLite::MakeTag( - field_number, WireFormatLite::WIRETYPE_END_GROUP)))) { - return false; - } - - return true; -} - -inline bool ReadMessage(io::CodedInputStream* input, MessageLite* value, - const ParseTable& table) { - int length; - if (GOOGLE_PREDICT_FALSE(!input->ReadVarintSizeAsInt(&length))) { - return false; - } - - std::pair<io::CodedInputStream::Limit, int> p = - input->IncrementRecursionDepthAndPushLimit(length); - if (GOOGLE_PREDICT_FALSE(p.second < 0 || - !MergePartialFromCodedStream(value, table, input))) { - return false; - } - - // Make sure that parsing stopped when the limit was hit, not at an endgroup - // tag. - return input->DecrementRecursionDepthAndPopLimit(p.first); -} - } // namespace -class MergePartialFromCodedStreamHelper { - public: - static MessageLite* Add(RepeatedPtrFieldBase* field, - const MessageLite* prototype) { - return field->Add<RepeatedMessageTypeHandler>( - const_cast<MessageLite*>(prototype)); - } -}; - -bool MergePartialFromCodedStream(MessageLite* msg, const ParseTable& table, - io::CodedInputStream* input) { - // We require that has_bits are present, as to avoid having to check for them - // for every field. - // - // TODO(ckennelly): Make this a compile-time parameter with templates. - GOOGLE_DCHECK_GE(table.has_bits_offset, 0); - uint32* has_bits = Raw<uint32>(msg, table.has_bits_offset); - GOOGLE_DCHECK(has_bits != NULL); - - while (true) { - uint32 tag = input->ReadTag(); - - const WireFormatLite::WireType wire_type = - WireFormatLite::GetTagWireType(tag); - const int field_number = WireFormatLite::GetTagFieldNumber(tag); - - if (GOOGLE_PREDICT_FALSE(field_number > table.max_field_number)) { - GOOGLE_DCHECK(!table.unknown_field_set); - ::google::protobuf::io::StringOutputStream unknown_fields_string( - MutableUnknownFields(msg, table.arena_offset)); - ::google::protobuf::io::CodedOutputStream unknown_fields_stream( - &unknown_fields_string, false); - - if (!::google::protobuf::internal::WireFormatLite::SkipField( - input, tag, &unknown_fields_stream)) { - return false; - } - - continue; - } - - // We implicitly verify that data points to a valid field as we check the - // wire types. Entries in table.fields[i] that do not correspond to valid - // field numbers have their normal_wiretype and packed_wiretype fields set - // with the kInvalidMask value. As wire_type cannot take on that value, we - // will never match. - const ParseTableField* data = table.fields + field_number; - - // TODO(ckennelly): Avoid sign extension - const int64 has_bit_index = data->has_bit_index; - const int64 offset = data->offset; - const unsigned char processing_type = data->processing_type; - - if (data->normal_wiretype == static_cast<unsigned char>(wire_type)) { - // TODO(ckennelly): Use a computed goto on GCC/LLVM or otherwise eliminate - // the bounds check on processing_type. - - switch (processing_type) { -#define STR(S) #S -#define HANDLE_TYPE(TYPE, CPPTYPE) \ - case (WireFormatLite::TYPE_##TYPE): { \ - CPPTYPE value; \ - if (GOOGLE_PREDICT_FALSE( \ - (!WireFormatLite::ReadPrimitive< \ - CPPTYPE, WireFormatLite::TYPE_##TYPE>(input, &value)))) { \ - return false; \ - } \ - SetField(msg, has_bits, has_bit_index, offset, value); \ - break; \ - } \ - case (WireFormatLite::TYPE_##TYPE) | kRepeatedMask: { \ - google::protobuf::RepeatedField<CPPTYPE>* values = \ - Raw<google::protobuf::RepeatedField<CPPTYPE> >(msg, offset); \ - if (GOOGLE_PREDICT_FALSE((!WireFormatLite::ReadRepeatedPrimitive< \ - CPPTYPE, WireFormatLite::TYPE_##TYPE>( \ - data->tag_size, tag, input, values)))) { \ - return false; \ - } \ - break; \ - } - - HANDLE_TYPE(INT32, int32) - HANDLE_TYPE(INT64, int64) - HANDLE_TYPE(SINT32, int32) - HANDLE_TYPE(SINT64, int64) - HANDLE_TYPE(UINT32, uint32) - HANDLE_TYPE(UINT64, uint64) - - HANDLE_TYPE(FIXED32, uint32) - HANDLE_TYPE(FIXED64, uint64) - HANDLE_TYPE(SFIXED32, int32) - HANDLE_TYPE(SFIXED64, int64) - - HANDLE_TYPE(FLOAT, float) - HANDLE_TYPE(DOUBLE, double) - - HANDLE_TYPE(BOOL, bool) -#undef HANDLE_TYPE -#undef STR - case WireFormatLite::TYPE_BYTES: -#ifndef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED - case WireFormatLite::TYPE_STRING: -#endif - { - GOOGLE_DCHECK(!table.unknown_field_set); - Arena* const arena = GetArena(msg, table.arena_offset); - const void* default_ptr = table.aux[field_number].strings.default_ptr; - - if (GOOGLE_PREDICT_FALSE((!HandleString<false, false, StringType_STRING>( - input, msg, arena, has_bits, has_bit_index, offset, - default_ptr, false, NULL)))) { - return false; - } - break; - } - case (WireFormatLite::TYPE_BYTES) | kRepeatedMask: -#ifndef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED - case (WireFormatLite::TYPE_STRING) | kRepeatedMask: -#endif - { - GOOGLE_DCHECK(!table.unknown_field_set); - Arena* const arena = GetArena(msg, table.arena_offset); - const void* default_ptr = - table.aux[field_number].strings.default_ptr; - - if (GOOGLE_PREDICT_FALSE((!HandleString<true, false, StringType_STRING>( - input, msg, arena, has_bits, has_bit_index, offset, - default_ptr, false, NULL)))) { - return false; - } - break; - } -#ifdef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED - case (WireFormatLite::TYPE_STRING): { - GOOGLE_DCHECK(!table.unknown_field_set); - Arena* const arena = GetArena(msg, table.arena_offset); - const void* default_ptr = table.aux[field_number].strings.default_ptr; - const char* field_name = table.aux[field_number].strings.field_name; - const bool strict_utf8 = table.aux[field_number].strings.strict_utf8; - - if (GOOGLE_PREDICT_FALSE((!HandleString<false, true, StringType_STRING>( - input, msg, arena, has_bits, has_bit_index, offset, - default_ptr, strict_utf8, field_name)))) { - return false; - } - break; - } - case (WireFormatLite::TYPE_STRING) | kRepeatedMask: { - GOOGLE_DCHECK(!table.unknown_field_set); - Arena* const arena = GetArena(msg, table.arena_offset); - const void* default_ptr = table.aux[field_number].strings.default_ptr; - const char* field_name = table.aux[field_number].strings.field_name; - const bool strict_utf8 = table.aux[field_number].strings.strict_utf8; - - if (GOOGLE_PREDICT_FALSE((!HandleString<true, true, StringType_STRING>( - input, msg, arena, has_bits, has_bit_index, offset, - default_ptr, strict_utf8, field_name)))) { - return false; - } - break; - } -#endif - case WireFormatLite::TYPE_ENUM: { - int value; - if (GOOGLE_PREDICT_FALSE((!WireFormatLite::ReadPrimitive< - int, WireFormatLite::TYPE_ENUM>(input, &value)))) { - return false; - } - - AuxillaryParseTableField::EnumValidator validator = - table.aux[field_number].enums.validator; - if (validator(value)) { - SetField(msg, has_bits, has_bit_index, offset, value); - } else { - GOOGLE_DCHECK(!table.unknown_field_set); - - ::google::protobuf::io::StringOutputStream unknown_fields_string( - MutableUnknownFields(msg, table.arena_offset)); - ::google::protobuf::io::CodedOutputStream unknown_fields_stream( - &unknown_fields_string, false); - unknown_fields_stream.WriteVarint32(tag); - unknown_fields_stream.WriteVarint32(value); - } - break; - } - case WireFormatLite::TYPE_ENUM | kRepeatedMask: { - int value; - if (GOOGLE_PREDICT_FALSE((!WireFormatLite::ReadPrimitive< - int, WireFormatLite::TYPE_ENUM>(input, &value)))) { - return false; - } - - AuxillaryParseTableField::EnumValidator validator = - table.aux[field_number].enums.validator; - if (validator(value)) { - AddField(msg, offset, value); - } else { - GOOGLE_DCHECK(!table.unknown_field_set); - - ::google::protobuf::io::StringOutputStream unknown_fields_string( - MutableUnknownFields(msg, table.arena_offset)); - ::google::protobuf::io::CodedOutputStream unknown_fields_stream( - &unknown_fields_string, false); - unknown_fields_stream.WriteVarint32(tag); - unknown_fields_stream.WriteVarint32(value); - } - - break; - } - case WireFormatLite::TYPE_GROUP: { - MessageLite** submsg_holder = - MutableField<MessageLite*>(msg, has_bits, has_bit_index, offset); - MessageLite* submsg = *submsg_holder; - - if (submsg == NULL) { - GOOGLE_DCHECK(!table.unknown_field_set); - Arena* const arena = GetArena(msg, table.arena_offset); - const MessageLite* prototype = - table.aux[field_number].messages.default_message(); - submsg = prototype->New(arena); - *submsg_holder = submsg; - } - - const ParseTable* ptable = - table.aux[field_number].messages.parse_table; - - if (ptable) { - if (GOOGLE_PREDICT_FALSE( - !ReadGroup(field_number, input, submsg, *ptable))) { - return false; - } - } else if (!WireFormatLite::ReadGroup(field_number, input, submsg)) { - return false; - } - - break; - } - case WireFormatLite::TYPE_GROUP | kRepeatedMask: { - RepeatedPtrFieldBase* field = Raw<RepeatedPtrFieldBase>(msg, offset); - const MessageLite* prototype = - table.aux[field_number].messages.default_message(); - GOOGLE_DCHECK(prototype != NULL); - - MessageLite* submsg = - MergePartialFromCodedStreamHelper::Add(field, prototype); - const ParseTable* ptable = - table.aux[field_number].messages.parse_table; - - if (ptable) { - if (GOOGLE_PREDICT_FALSE( - !ReadGroup(field_number, input, submsg, *ptable))) { - return false; - } - } else if (!WireFormatLite::ReadGroup(field_number, input, submsg)) { - return false; - } - - break; - } - case WireFormatLite::TYPE_MESSAGE: { - MessageLite** submsg_holder = - MutableField<MessageLite*>(msg, has_bits, has_bit_index, offset); - MessageLite* submsg = *submsg_holder; - - if (submsg == NULL) { - GOOGLE_DCHECK(!table.unknown_field_set); - Arena* const arena = GetArena(msg, table.arena_offset); - const MessageLite* prototype = - table.aux[field_number].messages.default_message(); - submsg = prototype->New(arena); - *submsg_holder = submsg; - } - - const ParseTable* ptable = - table.aux[field_number].messages.parse_table; - - if (ptable) { - if (GOOGLE_PREDICT_FALSE(!ReadMessage(input, submsg, *ptable))) { - return false; - } - } else if (!WireFormatLite::ReadMessage(input, submsg)) { - return false; - } - - break; - } - // TODO(ckennelly): Adapt ReadMessageNoVirtualNoRecursionDepth and - // manage input->IncrementRecursionDepth() here. - case WireFormatLite::TYPE_MESSAGE | kRepeatedMask: { - RepeatedPtrFieldBase* field = Raw<RepeatedPtrFieldBase>(msg, offset); - const MessageLite* prototype = - table.aux[field_number].messages.default_message(); - GOOGLE_DCHECK(prototype != NULL); - - MessageLite* submsg = - MergePartialFromCodedStreamHelper::Add(field, prototype); - const ParseTable* ptable = - table.aux[field_number].messages.parse_table; - - if (ptable) { - if (GOOGLE_PREDICT_FALSE(!ReadMessage(input, submsg, *ptable))) { - return false; - } - } else if (!WireFormatLite::ReadMessage(input, submsg)) { - return false; - } - - break; - } - case 0: { - // Done. - return true; - } - default: - break; - } - } else if (data->packed_wiretype == static_cast<unsigned char>(wire_type)) { - // Non-packable fields have their packed_wiretype masked with - // kNotPackedMask, which is impossible to match here. - GOOGLE_DCHECK(processing_type & kRepeatedMask); - GOOGLE_DCHECK_NE(processing_type, kRepeatedMask); - - - - // TODO(ckennelly): Use a computed goto on GCC/LLVM. - // - // Mask out kRepeatedMask bit, allowing the jump table to be smaller. - switch (static_cast<WireFormatLite::FieldType>( - processing_type ^ kRepeatedMask)) { -#define HANDLE_PACKED_TYPE(TYPE, CPPTYPE, CPPTYPE_METHOD) \ - case WireFormatLite::TYPE_##TYPE: { \ - google::protobuf::RepeatedField<CPPTYPE>* values = \ - Raw<google::protobuf::RepeatedField<CPPTYPE> >(msg, offset); \ - if (GOOGLE_PREDICT_FALSE( \ - (!WireFormatLite::ReadPackedPrimitive< \ - CPPTYPE, WireFormatLite::TYPE_##TYPE>(input, values)))) { \ - return false; \ - } \ - break; \ - } - - HANDLE_PACKED_TYPE(INT32, int32, Int32) - HANDLE_PACKED_TYPE(INT64, int64, Int64) - HANDLE_PACKED_TYPE(SINT32, int32, Int32) - HANDLE_PACKED_TYPE(SINT64, int64, Int64) - HANDLE_PACKED_TYPE(UINT32, uint32, UInt32) - HANDLE_PACKED_TYPE(UINT64, uint64, UInt64) - - HANDLE_PACKED_TYPE(FIXED32, uint32, UInt32) - HANDLE_PACKED_TYPE(FIXED64, uint64, UInt64) - HANDLE_PACKED_TYPE(SFIXED32, int32, Int32) - HANDLE_PACKED_TYPE(SFIXED64, int64, Int64) - - HANDLE_PACKED_TYPE(FLOAT, float, Float) - HANDLE_PACKED_TYPE(DOUBLE, double, Double) - - HANDLE_PACKED_TYPE(BOOL, bool, Bool) -#undef HANDLE_PACKED_TYPE - case WireFormatLite::TYPE_ENUM: { - // To avoid unnecessarily calling MutableUnknownFields (which mutates - // InternalMetadataWithArena) when all inputs in the repeated series - // are valid, we implement our own parser rather than call - // WireFormat::ReadPackedEnumPreserveUnknowns. - uint32 length; - if (GOOGLE_PREDICT_FALSE(!input->ReadVarint32(&length))) { - return false; - } - - AuxillaryParseTableField::EnumValidator validator = - table.aux[field_number].enums.validator; - google::protobuf::RepeatedField<int>* values = - Raw<google::protobuf::RepeatedField<int> >(msg, offset); - string* unknown_fields = NULL; - - io::CodedInputStream::Limit limit = input->PushLimit(length); - while (input->BytesUntilLimit() > 0) { - int value; - if (GOOGLE_PREDICT_FALSE( - (!google::protobuf::internal::WireFormatLite::ReadPrimitive< - int, WireFormatLite::TYPE_ENUM>(input, &value)))) { - return false; - } - - if (validator(value)) { - values->Add(value); - } else { - if (GOOGLE_PREDICT_FALSE(unknown_fields == NULL)) { - GOOGLE_DCHECK(!table.unknown_field_set); - unknown_fields = MutableUnknownFields(msg, table.arena_offset); - } - - ::google::protobuf::io::StringOutputStream unknown_fields_string( - unknown_fields); - ::google::protobuf::io::CodedOutputStream unknown_fields_stream( - &unknown_fields_string, false); - unknown_fields_stream.WriteVarint32(tag); - unknown_fields_stream.WriteVarint32(value); - } - } - input->PopLimit(limit); - - break; - } - case WireFormatLite::TYPE_STRING: - case WireFormatLite::TYPE_GROUP: - case WireFormatLite::TYPE_MESSAGE: - case WireFormatLite::TYPE_BYTES: - GOOGLE_DCHECK(false); - return false; - default: - break; - } - } else { - if (wire_type == WireFormatLite::WIRETYPE_END_GROUP) { - // Must be the end of the message. - return true; - } - - // process unknown field. - GOOGLE_DCHECK(!table.unknown_field_set); - ::google::protobuf::io::StringOutputStream unknown_fields_string( - MutableUnknownFields(msg, table.arena_offset)); - ::google::protobuf::io::CodedOutputStream unknown_fields_stream( - &unknown_fields_string, false); - - if (!::google::protobuf::internal::WireFormatLite::SkipField( - input, tag, &unknown_fields_stream)) { - return false; - } - } - } +bool MergePartialFromCodedStream( + MessageLite* msg, const ParseTable& table, io::CodedInputStream* input) { + return MergePartialFromCodedStreamImpl<UnknownFieldHandler, + InternalMetadataWithArena>(msg, table, + input); } } // namespace internal diff --git a/src/google/protobuf/generated_message_table_driven.h b/src/google/protobuf/generated_message_table_driven.h index 557c57d3..6f3fe666 100644 --- a/src/google/protobuf/generated_message_table_driven.h +++ b/src/google/protobuf/generated_message_table_driven.h @@ -31,7 +31,12 @@ #ifndef GOOGLE_PROTOBUF_GENERATED_MESSAGE_TABLE_DRIVEN_H__ #define GOOGLE_PROTOBUF_GENERATED_MESSAGE_TABLE_DRIVEN_H__ +#include <google/protobuf/map.h> +#include <google/protobuf/map_entry_lite.h> +#include <google/protobuf/map_field_lite.h> #include <google/protobuf/message_lite.h> +#include <google/protobuf/wire_format_lite.h> +#include <google/protobuf/wire_format_lite_inl.h> #if LANG_CXX11 #define PROTOBUF_CONSTEXPR constexpr @@ -39,7 +44,8 @@ // We require C++11 and Clang to use constexpr for variables, as GCC 4.8 // requires constexpr to be consistent between declarations of variables // unnecessarily (see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58541). -#ifdef __clang__ +// VS 2017 Update 3 also supports this usage of constexpr. +#if defined(__clang__) || (defined(_MSC_VER) && _MSC_VER >= 1911) #define PROTOBUF_CONSTEXPR_VAR constexpr #else // !__clang__ #define PROTOBUF_CONSTEXPR_VAR @@ -54,10 +60,14 @@ namespace google { namespace protobuf { namespace internal { +// Processing-type masks. static PROTOBUF_CONSTEXPR const unsigned char kOneofMask = 0x40; static PROTOBUF_CONSTEXPR const unsigned char kRepeatedMask = 0x20; -// Check this against types. +// Mask for the raw type: either a WireFormatLite::FieldType or one of the +// ProcessingTypes below, without the oneof or repeated flag. +static PROTOBUF_CONSTEXPR const unsigned char kTypeMask = 0x1f; +// Wire type masks. static PROTOBUF_CONSTEXPR const unsigned char kNotPackedMask = 0x10; static PROTOBUF_CONSTEXPR const unsigned char kInvalidMask = 0x20; @@ -66,10 +76,11 @@ enum ProcessingTypes { TYPE_STRING_STRING_PIECE = 20, TYPE_BYTES_CORD = 21, TYPE_BYTES_STRING_PIECE = 22, + TYPE_MAP = 23, }; #if LANG_CXX11 -static_assert(TYPE_BYTES_STRING_PIECE < kRepeatedMask, "Invalid enum"); +static_assert(TYPE_MAP < kRepeatedMask, "Invalid enum"); #endif // TODO(ckennelly): Add a static assertion to ensure that these masks do not @@ -81,7 +92,9 @@ static_assert(TYPE_BYTES_STRING_PIECE < kRepeatedMask, "Invalid enum"); // AuxillaryParseTableField. struct ParseTableField { uint32 offset; - uint32 has_bit_index; + // The presence_index ordinarily represents a has_bit index, but for fields + // inside a oneof it represents the index in _oneof_case_. + uint32 presence_index; unsigned char normal_wiretype; unsigned char packed_wiretype; @@ -100,7 +113,6 @@ union AuxillaryParseTableField { // Enums struct enum_aux { EnumValidator validator; - const char* name; }; enum_aux enums; // Group, messages @@ -119,11 +131,14 @@ union AuxillaryParseTableField { struct string_aux { const void* default_ptr; const char* field_name; - bool strict_utf8; - const char* name; }; string_aux strings; + struct map_aux { + bool (*parse_map)(io::CodedInputStream*, void*); + }; + map_aux maps; + #if LANG_CXX11 AuxillaryParseTableField() = default; #else @@ -135,6 +150,9 @@ union AuxillaryParseTableField { AuxillaryParseTableField::message_aux m) : messages(m) {} PROTOBUF_CONSTEXPR AuxillaryParseTableField( AuxillaryParseTableField::string_aux s) : strings(s) {} + PROTOBUF_CONSTEXPR AuxillaryParseTableField( + AuxillaryParseTableField::map_aux m) + : maps(m) {} }; struct ParseTable { @@ -145,8 +163,19 @@ struct ParseTable { // TODO(ckennelly): Vet these for sign extension. int64 has_bits_offset; + int64 oneof_case_offset; + int64 extension_offset; int64 arena_offset; - int unknown_field_set; + + // ExplicitlyInitialized<T> -> T requires a reinterpret_cast, which prevents + // the tables from being constructed as a constexpr. We use void to avoid + // the cast. + const void* default_instance_void; + const MessageLite* default_instance() const { + return static_cast<const MessageLite*>(default_instance_void); + } + + bool unknown_field_set; }; // TODO(jhen): Remove the __NVCC__ check when we get a version of nvcc that @@ -163,8 +192,25 @@ static_assert(std::is_pod<AuxillaryParseTableField::string_aux>::value, ""); static_assert(std::is_pod<ParseTable>::value, ""); #endif +// TODO(ckennelly): Consolidate these implementations into a single one, using +// dynamic dispatch to the appropriate unknown field handler. bool MergePartialFromCodedStream(MessageLite* msg, const ParseTable& table, io::CodedInputStream* input); +bool MergePartialFromCodedStreamLite(MessageLite* msg, const ParseTable& table, + io::CodedInputStream* input); + +template <typename Entry> +bool ParseMap(io::CodedInputStream* input, void* map_field) { + typedef typename MapEntryToMapField<Entry>::MapFieldType MapFieldType; + typedef google::protobuf::Map<typename Entry::EntryKeyType, + typename Entry::EntryValueType> + MapType; + typedef typename Entry::template Parser<MapFieldType, MapType> ParserType; + + ParserType parser(static_cast<MapFieldType*>(map_field)); + return ::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(input, + &parser); +} } // namespace internal } // namespace protobuf diff --git a/src/google/protobuf/generated_message_table_driven_lite.cc b/src/google/protobuf/generated_message_table_driven_lite.cc new file mode 100644 index 00000000..90a50505 --- /dev/null +++ b/src/google/protobuf/generated_message_table_driven_lite.cc @@ -0,0 +1,109 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include <google/protobuf/generated_message_table_driven_lite.h> + +#include <google/protobuf/stubs/type_traits.h> + +#include <google/protobuf/io/zero_copy_stream_impl_lite.h> +#include <google/protobuf/metadata_lite.h> +#include <google/protobuf/repeated_field.h> +#include <google/protobuf/wire_format_lite.h> +#include <google/protobuf/wire_format_lite_inl.h> + +namespace google { +namespace protobuf { +namespace internal { + +namespace { + +string* MutableUnknownFields(MessageLite* msg, int64 arena_offset) { + return Raw<InternalMetadataWithArenaLite>(msg, arena_offset) + ->mutable_unknown_fields(); +} + +struct UnknownFieldHandlerLite { + static bool Skip(MessageLite* msg, const ParseTable& table, + io::CodedInputStream* input, + int tag) { + GOOGLE_DCHECK(!table.unknown_field_set); + ::google::protobuf::io::StringOutputStream unknown_fields_string( + MutableUnknownFields(msg, table.arena_offset)); + ::google::protobuf::io::CodedOutputStream unknown_fields_stream( + &unknown_fields_string, false); + + return ::google::protobuf::internal::WireFormatLite::SkipField( + input, tag, &unknown_fields_stream); + } + + static void Varint(MessageLite* msg, const ParseTable& table, + int tag, int value) { + GOOGLE_DCHECK(!table.unknown_field_set); + + ::google::protobuf::io::StringOutputStream unknown_fields_string( + MutableUnknownFields(msg, table.arena_offset)); + ::google::protobuf::io::CodedOutputStream unknown_fields_stream( + &unknown_fields_string, false); + unknown_fields_stream.WriteVarint32(tag); + unknown_fields_stream.WriteVarint32(value); + } + + static bool ParseExtension( + MessageLite* msg, const ParseTable& table, + io::CodedInputStream* input, int tag) { + ExtensionSet* extensions = GetExtensionSet(msg, table.extension_offset); + if (extensions == NULL) { + return false; + } + + const MessageLite* prototype = table.default_instance(); + + GOOGLE_DCHECK(!table.unknown_field_set); + ::google::protobuf::io::StringOutputStream unknown_fields_string( + MutableUnknownFields(msg, table.arena_offset)); + ::google::protobuf::io::CodedOutputStream unknown_fields_stream( + &unknown_fields_string, false); + return extensions->ParseField( + tag, input, prototype, &unknown_fields_stream); + } +}; + +} // namespace + +bool MergePartialFromCodedStreamLite( + MessageLite* msg, const ParseTable& table, io::CodedInputStream* input) { + return MergePartialFromCodedStreamImpl<UnknownFieldHandlerLite, + InternalMetadataWithArenaLite>( + msg, table, input); +} + +} // namespace internal +} // namespace protobuf +} // namespace google diff --git a/src/google/protobuf/generated_message_table_driven_lite.h b/src/google/protobuf/generated_message_table_driven_lite.h new file mode 100644 index 00000000..4dfbf678 --- /dev/null +++ b/src/google/protobuf/generated_message_table_driven_lite.h @@ -0,0 +1,829 @@ +// 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_GENERATED_MESSAGE_TABLE_DRIVEN_LITE_H__ +#define GOOGLE_PROTOBUF_GENERATED_MESSAGE_TABLE_DRIVEN_LITE_H__ + +#include <google/protobuf/generated_message_table_driven.h> + +#include <google/protobuf/stubs/type_traits.h> + +#include <google/protobuf/io/zero_copy_stream_impl_lite.h> +#include <google/protobuf/extension_set.h> +#include <google/protobuf/metadata_lite.h> +#include <google/protobuf/repeated_field.h> +#include <google/protobuf/wire_format_lite.h> +#include <google/protobuf/wire_format_lite_inl.h> + + +namespace google { +namespace protobuf { +namespace internal { + + +enum StringType { + StringType_STRING = 0, + StringType_CORD = 1, + StringType_STRING_PIECE = 2 +}; + +// Logically a superset of StringType, consisting of all field types that +// require special initialization. +enum ProcessingType { + ProcessingType_STRING = 0, + ProcessingType_CORD = 1, + ProcessingType_STRING_PIECE = 2, + ProcessingType_MESSAGE = 3 +}; + +enum Cardinality { + Cardinality_SINGULAR = 0, + Cardinality_REPEATED = 1, + Cardinality_ONEOF = 3 +}; + +template <typename Type> +inline Type* Raw(MessageLite* msg, int64 offset) { + return reinterpret_cast<Type*>(reinterpret_cast<uint8*>(msg) + offset); +} + +template <typename Type> +inline const Type* Raw(const MessageLite* msg, int64 offset) { + return reinterpret_cast<const Type*>(reinterpret_cast<const uint8*>(msg) + + offset); +} + +template <typename InternalMetadata> +inline Arena* GetArena(MessageLite* msg, int64 arena_offset) { + if (GOOGLE_PREDICT_FALSE(arena_offset == -1)) { + return NULL; + } + + return Raw<InternalMetadata>(msg, arena_offset)->arena(); +} + +inline ExtensionSet* GetExtensionSet(MessageLite* msg, int64 extension_offset) { + if (extension_offset == -1) { + return NULL; + } + + return Raw<ExtensionSet>(msg, extension_offset); +} + +template <typename Type> +inline Type* AddField(MessageLite* msg, int64 offset) { +#if LANG_CXX11 + static_assert(has_trivial_copy<Type>::value, + "Do not assign"); +#endif + + google::protobuf::RepeatedField<Type>* repeated = + Raw<google::protobuf::RepeatedField<Type> >(msg, offset); + return repeated->Add(); +} + +template <> +inline string* AddField<string>(MessageLite* msg, int64 offset) { + google::protobuf::RepeatedPtrField<string>* repeated = + Raw<google::protobuf::RepeatedPtrField<string> >(msg, offset); + return repeated->Add(); +} + + +template <typename Type> +inline void AddField(MessageLite* msg, int64 offset, Type value) { +#if LANG_CXX11 + static_assert(has_trivial_copy<Type>::value, + "Do not assign"); +#endif + *AddField<Type>(msg, offset) = value; +} + +inline void SetBit(uint32* has_bits, uint32 has_bit_index) { + GOOGLE_DCHECK(has_bits != NULL); + + uint32 mask = static_cast<uint32>(1u) << (has_bit_index % 32); + has_bits[has_bit_index / 32u] |= mask; +} + +template <typename Type> +inline Type* MutableField(MessageLite* msg, uint32* has_bits, + uint32 has_bit_index, int64 offset) { + SetBit(has_bits, has_bit_index); + return Raw<Type>(msg, offset); +} + +template <typename Type> +inline void SetField(MessageLite* msg, uint32* has_bits, uint32 has_bit_index, + int64 offset, Type value) { +#if LANG_CXX11 + static_assert(has_trivial_copy<Type>::value, + "Do not assign"); +#endif + *MutableField<Type>(msg, has_bits, has_bit_index, offset) = value; +} + +template <typename Type> +inline void SetOneofField(MessageLite* msg, uint32* oneof_case, + uint32 oneof_case_index, int64 offset, + int field_number, Type value) { + oneof_case[oneof_case_index] = field_number; + *Raw<Type>(msg, offset) = value; +} + +// Clears a oneof field. The field argument should correspond to the particular +// field that is currently set in the oneof. +inline void ClearOneofField(const ParseTableField& field, Arena* arena, + MessageLite* msg) { + switch (field.processing_type & kTypeMask) { + case WireFormatLite::TYPE_MESSAGE: + if (arena == NULL) { + delete *Raw<MessageLite*>(msg, field.offset); + } + break; + + case WireFormatLite::TYPE_STRING: + case WireFormatLite::TYPE_BYTES: + Raw<ArenaStringPtr>(msg, field.offset) + ->Destroy(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), arena); + break; + + default: + // No cleanup needed. + break; + } +} + +// Clears and reinitializes a oneof field as necessary, in preparation for +// parsing a new value with type field_type and field number field_number. +// +// Note: the oneof_case argument should point directly to the _oneof_case_ +// element corresponding to this particular oneof, not to the beginning of the +// _oneof_case_ array. +template <ProcessingType field_type> +inline void ResetOneofField(const ParseTable& table, int field_number, + Arena* arena, MessageLite* msg, uint32* oneof_case, + int64 offset, const void* default_ptr) { + if (*oneof_case == field_number) { + // The oneof is already set to the right type, so there is no need to clear + // it. + return; + } + + if (*oneof_case != 0) { + ClearOneofField(table.fields[*oneof_case], arena, msg); + } + *oneof_case = field_number; + + switch (field_type) { + case ProcessingType_STRING: + Raw<ArenaStringPtr>(msg, offset) + ->UnsafeSetDefault(static_cast<const string*>(default_ptr)); + break; + case ProcessingType_MESSAGE: + MessageLite** submessage = Raw<MessageLite*>(msg, offset); + const MessageLite* prototype = + table.aux[field_number].messages.default_message(); + *submessage = prototype->New(arena); + break; + } +} + +template <Cardinality cardinality, bool validate, StringType ctype> +static inline bool HandleString(io::CodedInputStream* input, MessageLite* msg, + Arena* arena, uint32* has_bits, + uint32 has_bit_index, int64 offset, + const void* default_ptr, + const char* field_name) { +#ifdef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED + const char* sdata; + size_t size; +#endif + + string* value; + switch (cardinality) { + case Cardinality_SINGULAR: + // TODO(ckennelly): Is this optimal? + value = + MutableField<ArenaStringPtr>(msg, has_bits, has_bit_index, offset) + ->Mutable(static_cast<const string*>(default_ptr), arena); + break; + case Cardinality_REPEATED: + value = AddField<string>(msg, offset); + break; + case Cardinality_ONEOF: + value = Raw<ArenaStringPtr>(msg, offset) + ->Mutable(static_cast<const string*>(default_ptr), arena); + break; + } + GOOGLE_DCHECK(value != NULL); + + if (GOOGLE_PREDICT_FALSE(!WireFormatLite::ReadString(input, value))) { + return false; + } + +#ifdef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED + sdata = value->data(); + size = value->size(); +#endif + +#ifdef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED + if (validate) { + WireFormatLite::VerifyUtf8String(sdata, size, WireFormatLite::PARSE, + field_name); + } +#endif + + return true; +} + +template <typename UnknownFieldHandler, typename InternalMetadata, + Cardinality cardinality> +inline bool HandleEnum(const ParseTable& table, io::CodedInputStream* input, + MessageLite* msg, uint32* presence, + uint32 presence_index, int64 offset, uint32 tag, + int field_number) { + int value; + if (GOOGLE_PREDICT_FALSE( + (!WireFormatLite::ReadPrimitive<int, WireFormatLite::TYPE_ENUM>( + input, &value)))) { + return false; + } + + AuxillaryParseTableField::EnumValidator validator = + table.aux[field_number].enums.validator; + if (validator(value)) { + switch (cardinality) { + case Cardinality_SINGULAR: + SetField(msg, presence, presence_index, offset, value); + break; + case Cardinality_REPEATED: + AddField(msg, offset, value); + break; + case Cardinality_ONEOF: + ClearOneofField(table.fields[presence[presence_index]], + GetArena<InternalMetadata>(msg, table.arena_offset), + msg); + SetOneofField(msg, presence, presence_index, offset, field_number, + value); + break; + } + } else { + UnknownFieldHandler::Varint(msg, table, tag, value); + } + + return true; +} + +// RepeatedMessageTypeHandler allows us to operate on RepeatedPtrField fields +// without instantiating the specific template. +class RepeatedMessageTypeHandler { + public: + typedef MessageLite Type; + typedef MessageLite WeakType; + static Arena* GetArena(Type* t) { return t->GetArena(); } + static void* GetMaybeArenaPointer(Type* t) { + return t->GetMaybeArenaPointer(); + } + static inline Type* NewFromPrototype(const Type* prototype, + Arena* arena = NULL) { + return prototype->New(arena); + } + static void Delete(Type* t, Arena* arena = NULL) { + if (arena == NULL) { + delete t; + } + } +}; + +inline bool ReadGroup(int field_number, io::CodedInputStream* input, + MessageLite* value) { + if (GOOGLE_PREDICT_FALSE(!input->IncrementRecursionDepth())) { + return false; + } + + if (GOOGLE_PREDICT_FALSE(!value->MergePartialFromCodedStream(input))) { + return false; + } + + input->DecrementRecursionDepth(); + // Make sure the last thing read was an end tag for this group. + if (GOOGLE_PREDICT_FALSE(!input->LastTagWas(WireFormatLite::MakeTag( + field_number, WireFormatLite::WIRETYPE_END_GROUP)))) { + return false; + } + + return true; +} + +inline bool ReadMessage(io::CodedInputStream* input, MessageLite* value) { + int length; + if (GOOGLE_PREDICT_FALSE(!input->ReadVarintSizeAsInt(&length))) { + return false; + } + + std::pair<io::CodedInputStream::Limit, int> p = + input->IncrementRecursionDepthAndPushLimit(length); + if (GOOGLE_PREDICT_FALSE(p.second < 0 || + !value->MergePartialFromCodedStream(input))) { + return false; + } + + // Make sure that parsing stopped when the limit was hit, not at an endgroup + // tag. + return input->DecrementRecursionDepthAndPopLimit(p.first); +} + +class MergePartialFromCodedStreamHelper { + public: + static MessageLite* Add(RepeatedPtrFieldBase* field, + const MessageLite* prototype) { + return field->Add<RepeatedMessageTypeHandler>( + const_cast<MessageLite*>(prototype)); + } +}; + +template <typename UnknownFieldHandler, typename InternalMetadata> +bool MergePartialFromCodedStreamImpl(MessageLite* msg, const ParseTable& table, + io::CodedInputStream* input) { + // We require that has_bits are present, as to avoid having to check for them + // for every field. + // + // TODO(ckennelly): Make this a compile-time parameter with templates. + GOOGLE_DCHECK_GE(table.has_bits_offset, 0); + uint32* has_bits = Raw<uint32>(msg, table.has_bits_offset); + GOOGLE_DCHECK(has_bits != NULL); + + while (true) { + uint32 tag = input->ReadTag(); + + const WireFormatLite::WireType wire_type = + WireFormatLite::GetTagWireType(tag); + const int field_number = WireFormatLite::GetTagFieldNumber(tag); + + if (field_number > table.max_field_number) { + // check for possible extensions + if (UnknownFieldHandler::ParseExtension(msg, table, input, tag)) { + // successfully parsed + continue; + } + + if (GOOGLE_PREDICT_FALSE( + !UnknownFieldHandler::Skip(msg, table, input, tag))) { + return false; + } + + continue; + } + + // We implicitly verify that data points to a valid field as we check the + // wire types. Entries in table.fields[i] that do not correspond to valid + // field numbers have their normal_wiretype and packed_wiretype fields set + // with the kInvalidMask value. As wire_type cannot take on that value, we + // will never match. + const ParseTableField* data = table.fields + field_number; + + // TODO(ckennelly): Avoid sign extension + const int64 presence_index = data->presence_index; + const int64 offset = data->offset; + const unsigned char processing_type = data->processing_type; + + if (data->normal_wiretype == static_cast<unsigned char>(wire_type)) { + // TODO(ckennelly): Use a computed goto on GCC/LLVM or otherwise eliminate + // the bounds check on processing_type. + + switch (processing_type) { +#define HANDLE_TYPE(TYPE, CPPTYPE) \ + case (WireFormatLite::TYPE_##TYPE): { \ + CPPTYPE value; \ + if (GOOGLE_PREDICT_FALSE( \ + (!WireFormatLite::ReadPrimitive< \ + CPPTYPE, WireFormatLite::TYPE_##TYPE>(input, &value)))) { \ + return false; \ + } \ + SetField(msg, has_bits, presence_index, offset, value); \ + break; \ + } \ + case (WireFormatLite::TYPE_##TYPE) | kRepeatedMask: { \ + google::protobuf::RepeatedField<CPPTYPE>* values = \ + Raw<google::protobuf::RepeatedField<CPPTYPE> >(msg, offset); \ + if (GOOGLE_PREDICT_FALSE((!WireFormatLite::ReadRepeatedPrimitive< \ + CPPTYPE, WireFormatLite::TYPE_##TYPE>( \ + data->tag_size, tag, input, values)))) { \ + return false; \ + } \ + break; \ + } \ + case (WireFormatLite::TYPE_##TYPE) | kOneofMask: { \ + uint32* oneof_case = Raw<uint32>(msg, table.oneof_case_offset); \ + CPPTYPE value; \ + if (GOOGLE_PREDICT_FALSE( \ + (!WireFormatLite::ReadPrimitive< \ + CPPTYPE, WireFormatLite::TYPE_##TYPE>(input, &value)))) { \ + return false; \ + } \ + ClearOneofField(table.fields[oneof_case[presence_index]], \ + GetArena<InternalMetadata>(msg, table.arena_offset), msg); \ + SetOneofField(msg, oneof_case, presence_index, offset, field_number, \ + value); \ + break; \ + } + + HANDLE_TYPE(INT32, int32) + HANDLE_TYPE(INT64, int64) + HANDLE_TYPE(SINT32, int32) + HANDLE_TYPE(SINT64, int64) + HANDLE_TYPE(UINT32, uint32) + HANDLE_TYPE(UINT64, uint64) + + HANDLE_TYPE(FIXED32, uint32) + HANDLE_TYPE(FIXED64, uint64) + HANDLE_TYPE(SFIXED32, int32) + HANDLE_TYPE(SFIXED64, int64) + + HANDLE_TYPE(FLOAT, float) + HANDLE_TYPE(DOUBLE, double) + + HANDLE_TYPE(BOOL, bool) +#undef HANDLE_TYPE + case WireFormatLite::TYPE_BYTES: +#ifndef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED + case WireFormatLite::TYPE_STRING: +#endif + { + Arena* const arena = + GetArena<InternalMetadata>(msg, table.arena_offset); + const void* default_ptr = table.aux[field_number].strings.default_ptr; + + if (GOOGLE_PREDICT_FALSE(( + !HandleString<Cardinality_SINGULAR, false, StringType_STRING>( + input, msg, arena, has_bits, presence_index, offset, + default_ptr, NULL)))) { + return false; + } + break; + } + case WireFormatLite::TYPE_BYTES | kOneofMask: +#ifndef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED + case WireFormatLite::TYPE_STRING | kOneofMask: +#endif + { + Arena* const arena = + GetArena<InternalMetadata>(msg, table.arena_offset); + uint32* oneof_case = Raw<uint32>(msg, table.oneof_case_offset); + const void* default_ptr = table.aux[field_number].strings.default_ptr; + + ResetOneofField<ProcessingType_STRING>( + table, field_number, arena, msg, oneof_case + presence_index, + offset, default_ptr); + + if (GOOGLE_PREDICT_FALSE( + (!HandleString<Cardinality_ONEOF, false, StringType_STRING>( + input, msg, arena, has_bits, presence_index, offset, + default_ptr, NULL)))) { + return false; + } + break; + } + case (WireFormatLite::TYPE_BYTES) | kRepeatedMask: +#ifndef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED + case (WireFormatLite::TYPE_STRING) | kRepeatedMask: +#endif + { + Arena* const arena = + GetArena<InternalMetadata>(msg, table.arena_offset); + const void* default_ptr = + table.aux[field_number].strings.default_ptr; + + if (GOOGLE_PREDICT_FALSE(( + !HandleString<Cardinality_REPEATED, false, StringType_STRING>( + input, msg, arena, has_bits, presence_index, offset, + default_ptr, NULL)))) { + return false; + } + break; + } +#ifdef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED + case (WireFormatLite::TYPE_STRING): { + Arena* const arena = + GetArena<InternalMetadata>(msg, table.arena_offset); + const void* default_ptr = table.aux[field_number].strings.default_ptr; + const char* field_name = table.aux[field_number].strings.field_name; + + if (GOOGLE_PREDICT_FALSE( + (!HandleString<Cardinality_SINGULAR, true, StringType_STRING>( + input, msg, arena, has_bits, presence_index, offset, + default_ptr, field_name)))) { + return false; + } + break; + } + case (WireFormatLite::TYPE_STRING) | kRepeatedMask: { + Arena* const arena = + GetArena<InternalMetadata>(msg, table.arena_offset); + const void* default_ptr = table.aux[field_number].strings.default_ptr; + const char* field_name = table.aux[field_number].strings.field_name; + + if (GOOGLE_PREDICT_FALSE( + (!HandleString<Cardinality_REPEATED, true, StringType_STRING>( + input, msg, arena, has_bits, presence_index, offset, + default_ptr, field_name)))) { + return false; + } + break; + } + case (WireFormatLite::TYPE_STRING) | kOneofMask: { + Arena* const arena = + GetArena<InternalMetadata>(msg, table.arena_offset); + uint32* oneof_case = Raw<uint32>(msg, table.oneof_case_offset); + const void* default_ptr = table.aux[field_number].strings.default_ptr; + const char* field_name = table.aux[field_number].strings.field_name; + + ResetOneofField<ProcessingType_STRING>( + table, field_number, arena, msg, oneof_case + presence_index, + offset, default_ptr); + + if (GOOGLE_PREDICT_FALSE( + (!HandleString<Cardinality_ONEOF, true, StringType_STRING>( + input, msg, arena, has_bits, presence_index, offset, + default_ptr, field_name)))) { + return false; + } + break; + } +#endif + case WireFormatLite::TYPE_ENUM: { + if (GOOGLE_PREDICT_FALSE( + (!HandleEnum<UnknownFieldHandler, InternalMetadata, + Cardinality_SINGULAR>( + table, input, msg, has_bits, presence_index, offset, tag, + field_number)))) { + return false; + } + break; + } + case WireFormatLite::TYPE_ENUM | kRepeatedMask: { + if (GOOGLE_PREDICT_FALSE( + (!HandleEnum<UnknownFieldHandler, InternalMetadata, + Cardinality_REPEATED>( + table, input, msg, has_bits, presence_index, offset, tag, + field_number)))) { + return false; + } + break; + } + case WireFormatLite::TYPE_ENUM | kOneofMask: { + uint32* oneof_case = Raw<uint32>(msg, table.oneof_case_offset); + if (GOOGLE_PREDICT_FALSE( + (!HandleEnum<UnknownFieldHandler, InternalMetadata, + Cardinality_ONEOF>(table, input, msg, oneof_case, + presence_index, offset, tag, + field_number)))) { + return false; + } + break; + } + case WireFormatLite::TYPE_GROUP: { + MessageLite** submsg_holder = + MutableField<MessageLite*>(msg, has_bits, presence_index, offset); + MessageLite* submsg = *submsg_holder; + + if (submsg == NULL) { + Arena* const arena = + GetArena<InternalMetadata>(msg, table.arena_offset); + const MessageLite* prototype = + table.aux[field_number].messages.default_message(); + submsg = prototype->New(arena); + *submsg_holder = submsg; + } + + if (GOOGLE_PREDICT_FALSE( + !WireFormatLite::ReadGroup(field_number, input, submsg))) { + return false; + } + + break; + } + case WireFormatLite::TYPE_GROUP | kRepeatedMask: { + RepeatedPtrFieldBase* field = Raw<RepeatedPtrFieldBase>(msg, offset); + const MessageLite* prototype = + table.aux[field_number].messages.default_message(); + GOOGLE_DCHECK(prototype != NULL); + + MessageLite* submsg = + MergePartialFromCodedStreamHelper::Add(field, prototype); + + if (GOOGLE_PREDICT_FALSE( + !WireFormatLite::ReadGroup(field_number, input, submsg))) { + return false; + } + + break; + } + case WireFormatLite::TYPE_MESSAGE: { + MessageLite** submsg_holder = + MutableField<MessageLite*>(msg, has_bits, presence_index, offset); + MessageLite* submsg = *submsg_holder; + + if (submsg == NULL) { + Arena* const arena = + GetArena<InternalMetadata>(msg, table.arena_offset); + const MessageLite* prototype = + table.aux[field_number].messages.default_message(); + submsg = prototype->New(arena); + *submsg_holder = submsg; + } + + if (GOOGLE_PREDICT_FALSE(!WireFormatLite::ReadMessage(input, submsg))) { + return false; + } + + break; + } + // TODO(ckennelly): Adapt ReadMessageNoVirtualNoRecursionDepth and + // manage input->IncrementRecursionDepth() here. + case WireFormatLite::TYPE_MESSAGE | kRepeatedMask: { + RepeatedPtrFieldBase* field = Raw<RepeatedPtrFieldBase>(msg, offset); + const MessageLite* prototype = + table.aux[field_number].messages.default_message(); + GOOGLE_DCHECK(prototype != NULL); + + MessageLite* submsg = + MergePartialFromCodedStreamHelper::Add(field, prototype); + + if (GOOGLE_PREDICT_FALSE(!WireFormatLite::ReadMessage(input, submsg))) { + return false; + } + + break; + } + case WireFormatLite::TYPE_MESSAGE | kOneofMask: { + Arena* const arena = + GetArena<InternalMetadata>(msg, table.arena_offset); + uint32* oneof_case = Raw<uint32>(msg, table.oneof_case_offset); + MessageLite** submsg_holder = Raw<MessageLite*>(msg, offset); + ResetOneofField<ProcessingType_MESSAGE>( + table, field_number, arena, msg, oneof_case + presence_index, + offset, NULL); + MessageLite* submsg = *submsg_holder; + + if (GOOGLE_PREDICT_FALSE(!WireFormatLite::ReadMessage(input, submsg))) { + return false; + } + + break; + } + case TYPE_MAP: { + if (GOOGLE_PREDICT_FALSE(!(*table.aux[field_number].maps.parse_map)( + input, Raw<void>(msg, offset)))) { + return false; + } + break; + } + case 0: { + // Done. + return true; + } + default: + break; + } + } else if (data->packed_wiretype == static_cast<unsigned char>(wire_type)) { + // Non-packable fields have their packed_wiretype masked with + // kNotPackedMask, which is impossible to match here. + GOOGLE_DCHECK(processing_type & kRepeatedMask); + GOOGLE_DCHECK_NE(processing_type, kRepeatedMask); + GOOGLE_DCHECK_EQ(0, processing_type & kOneofMask); + + + + // TODO(ckennelly): Use a computed goto on GCC/LLVM. + // + // Mask out kRepeatedMask bit, allowing the jump table to be smaller. + switch (static_cast<WireFormatLite::FieldType>( + processing_type ^ kRepeatedMask)) { +#define HANDLE_PACKED_TYPE(TYPE, CPPTYPE, CPPTYPE_METHOD) \ + case WireFormatLite::TYPE_##TYPE: { \ + google::protobuf::RepeatedField<CPPTYPE>* values = \ + Raw<google::protobuf::RepeatedField<CPPTYPE> >(msg, offset); \ + if (GOOGLE_PREDICT_FALSE( \ + (!WireFormatLite::ReadPackedPrimitive< \ + CPPTYPE, WireFormatLite::TYPE_##TYPE>(input, values)))) { \ + return false; \ + } \ + break; \ + } + + HANDLE_PACKED_TYPE(INT32, int32, Int32) + HANDLE_PACKED_TYPE(INT64, int64, Int64) + HANDLE_PACKED_TYPE(SINT32, int32, Int32) + HANDLE_PACKED_TYPE(SINT64, int64, Int64) + HANDLE_PACKED_TYPE(UINT32, uint32, UInt32) + HANDLE_PACKED_TYPE(UINT64, uint64, UInt64) + + HANDLE_PACKED_TYPE(FIXED32, uint32, UInt32) + HANDLE_PACKED_TYPE(FIXED64, uint64, UInt64) + HANDLE_PACKED_TYPE(SFIXED32, int32, Int32) + HANDLE_PACKED_TYPE(SFIXED64, int64, Int64) + + HANDLE_PACKED_TYPE(FLOAT, float, Float) + HANDLE_PACKED_TYPE(DOUBLE, double, Double) + + HANDLE_PACKED_TYPE(BOOL, bool, Bool) +#undef HANDLE_PACKED_TYPE + case WireFormatLite::TYPE_ENUM: { + // To avoid unnecessarily calling MutableUnknownFields (which mutates + // InternalMetadataWithArena) when all inputs in the repeated series + // are valid, we implement our own parser rather than call + // WireFormat::ReadPackedEnumPreserveUnknowns. + uint32 length; + if (GOOGLE_PREDICT_FALSE(!input->ReadVarint32(&length))) { + return false; + } + + AuxillaryParseTableField::EnumValidator validator = + table.aux[field_number].enums.validator; + google::protobuf::RepeatedField<int>* values = + Raw<google::protobuf::RepeatedField<int> >(msg, offset); + + io::CodedInputStream::Limit limit = input->PushLimit(length); + while (input->BytesUntilLimit() > 0) { + int value; + if (GOOGLE_PREDICT_FALSE( + (!google::protobuf::internal::WireFormatLite::ReadPrimitive< + int, WireFormatLite::TYPE_ENUM>(input, &value)))) { + return false; + } + + if (validator(value)) { + values->Add(value); + } else { + // TODO(ckennelly): Consider caching here. + UnknownFieldHandler::Varint(msg, table, tag, value); + } + } + input->PopLimit(limit); + + break; + } + case WireFormatLite::TYPE_STRING: + case WireFormatLite::TYPE_GROUP: + case WireFormatLite::TYPE_MESSAGE: + case WireFormatLite::TYPE_BYTES: + GOOGLE_DCHECK(false); + return false; + default: + break; + } + } else { + if (wire_type == WireFormatLite::WIRETYPE_END_GROUP) { + // Must be the end of the message. + return true; + } + + // check for possible extensions + if (UnknownFieldHandler::ParseExtension(msg, table, input, tag)) { + // successfully parsed + continue; + } + + // process unknown field. + if (GOOGLE_PREDICT_FALSE( + !UnknownFieldHandler::Skip(msg, table, input, tag))) { + return false; + } + } + } +} + +} // namespace internal +} // namespace protobuf + +} // namespace google +#endif // GOOGLE_PROTOBUF_GENERATED_MESSAGE_TABLE_DRIVEN_LITE_H__ diff --git a/src/google/protobuf/generated_message_util.cc b/src/google/protobuf/generated_message_util.cc index 35d8156e..15d84222 100644 --- a/src/google/protobuf/generated_message_util.cc +++ b/src/google/protobuf/generated_message_util.cc @@ -35,12 +35,25 @@ #include <google/protobuf/generated_message_util.h> #include <limits> +#include <vector> +#include <google/protobuf/io/coded_stream_inl.h> +#include <google/protobuf/io/coded_stream.h> +#include <google/protobuf/arenastring.h> +#include <google/protobuf/extension_set.h> +#include <google/protobuf/message_lite.h> +#include <google/protobuf/metadata_lite.h> +#include <google/protobuf/stubs/port.h> +#include <google/protobuf/repeated_field.h> +#include <google/protobuf/wire_format_lite.h> +#include <google/protobuf/wire_format_lite_inl.h> namespace google { + namespace protobuf { namespace internal { + double Infinity() { return std::numeric_limits<double>::infinity(); } @@ -51,7 +64,7 @@ double NaN() { ExplicitlyConstructed< ::std::string> fixed_address_empty_string; GOOGLE_PROTOBUF_DECLARE_ONCE(empty_string_once_init_); -void DeleteEmptyString() { fixed_address_empty_string.Shutdown(); } +void DeleteEmptyString() { fixed_address_empty_string.Destruct(); } void InitEmptyString() { fixed_address_empty_string.DefaultConstruct(); @@ -75,6 +88,643 @@ void InitProtobufDefaults() { GetEmptyString(); } +template <typename T> +const T& Get(const void* ptr) { + return *static_cast<const T*>(ptr); +} + +// PrimitiveTypeHelper is a wrapper around the interface of WireFormatLite. +// WireFormatLite has a very inconvenient interface with respect to template +// meta-programming. This class wraps the different named functions into +// a single Serialize / SerializeToArray interface. +template <int type> +struct PrimitiveTypeHelper; + +template <> +struct PrimitiveTypeHelper<WireFormatLite::TYPE_BOOL> { + typedef bool Type; + static void Serialize(const void* ptr, + ::google::protobuf::io::CodedOutputStream* output) { + WireFormatLite::WriteBoolNoTag(Get<bool>(ptr), output); + } + static uint8* SerializeToArray(const void* ptr, uint8* buffer) { + return WireFormatLite::WriteBoolNoTagToArray(Get<Type>(ptr), buffer); + } +}; + +template <> +struct PrimitiveTypeHelper<WireFormatLite::TYPE_INT32> { + typedef int32 Type; + static void Serialize(const void* ptr, + ::google::protobuf::io::CodedOutputStream* output) { + WireFormatLite::WriteInt32NoTag(Get<int32>(ptr), output); + } + static uint8* SerializeToArray(const void* ptr, uint8* buffer) { + return WireFormatLite::WriteInt32NoTagToArray(Get<Type>(ptr), buffer); + } +}; + +template <> +struct PrimitiveTypeHelper<WireFormatLite::TYPE_SINT32> { + typedef int32 Type; + static void Serialize(const void* ptr, + ::google::protobuf::io::CodedOutputStream* output) { + WireFormatLite::WriteSInt32NoTag(Get<int32>(ptr), output); + } + static uint8* SerializeToArray(const void* ptr, uint8* buffer) { + return WireFormatLite::WriteSInt32NoTagToArray(Get<Type>(ptr), buffer); + } +}; + +template <> +struct PrimitiveTypeHelper<WireFormatLite::TYPE_UINT32> { + typedef uint32 Type; + static void Serialize(const void* ptr, + ::google::protobuf::io::CodedOutputStream* output) { + WireFormatLite::WriteUInt32NoTag(Get<uint32>(ptr), output); + } + static uint8* SerializeToArray(const void* ptr, uint8* buffer) { + return WireFormatLite::WriteUInt32NoTagToArray(Get<Type>(ptr), buffer); + } +}; +template <> +struct PrimitiveTypeHelper<WireFormatLite::TYPE_INT64> { + typedef int64 Type; + static void Serialize(const void* ptr, + ::google::protobuf::io::CodedOutputStream* output) { + WireFormatLite::WriteInt64NoTag(Get<int64>(ptr), output); + } + static uint8* SerializeToArray(const void* ptr, uint8* buffer) { + return WireFormatLite::WriteInt64NoTagToArray(Get<Type>(ptr), buffer); + } +}; + +template <> +struct PrimitiveTypeHelper<WireFormatLite::TYPE_SINT64> { + typedef int64 Type; + static void Serialize(const void* ptr, + ::google::protobuf::io::CodedOutputStream* output) { + WireFormatLite::WriteSInt64NoTag(Get<int64>(ptr), output); + } + static uint8* SerializeToArray(const void* ptr, uint8* buffer) { + return WireFormatLite::WriteSInt64NoTagToArray(Get<Type>(ptr), buffer); + } +}; +template <> +struct PrimitiveTypeHelper<WireFormatLite::TYPE_UINT64> { + typedef uint64 Type; + static void Serialize(const void* ptr, + ::google::protobuf::io::CodedOutputStream* output) { + WireFormatLite::WriteUInt64NoTag(Get<uint64>(ptr), output); + } + static uint8* SerializeToArray(const void* ptr, uint8* buffer) { + return WireFormatLite::WriteUInt64NoTagToArray(Get<Type>(ptr), buffer); + } +}; + +template <> +struct PrimitiveTypeHelper<WireFormatLite::TYPE_FIXED32> { + typedef uint32 Type; + static void Serialize(const void* ptr, + ::google::protobuf::io::CodedOutputStream* output) { + WireFormatLite::WriteFixed32NoTag(Get<uint32>(ptr), output); + } + static uint8* SerializeToArray(const void* ptr, uint8* buffer) { + return WireFormatLite::WriteFixed32NoTagToArray(Get<Type>(ptr), buffer); + } +}; + +template <> +struct PrimitiveTypeHelper<WireFormatLite::TYPE_FIXED64> { + typedef uint64 Type; + static void Serialize(const void* ptr, + ::google::protobuf::io::CodedOutputStream* output) { + WireFormatLite::WriteFixed64NoTag(Get<uint64>(ptr), output); + } + static uint8* SerializeToArray(const void* ptr, uint8* buffer) { + return WireFormatLite::WriteFixed64NoTagToArray(Get<Type>(ptr), buffer); + } +}; + +template <> +struct PrimitiveTypeHelper<WireFormatLite::TYPE_ENUM> + : PrimitiveTypeHelper<WireFormatLite::TYPE_INT32> {}; + +template <> +struct PrimitiveTypeHelper<WireFormatLite::TYPE_SFIXED32> + : PrimitiveTypeHelper<WireFormatLite::TYPE_FIXED32> { + typedef int32 Type; +}; +template <> +struct PrimitiveTypeHelper<WireFormatLite::TYPE_SFIXED64> + : PrimitiveTypeHelper<WireFormatLite::TYPE_FIXED64> { + typedef int64 Type; +}; +template <> +struct PrimitiveTypeHelper<WireFormatLite::TYPE_FLOAT> + : PrimitiveTypeHelper<WireFormatLite::TYPE_FIXED32> { + typedef float Type; +}; +template <> +struct PrimitiveTypeHelper<WireFormatLite::TYPE_DOUBLE> + : PrimitiveTypeHelper<WireFormatLite::TYPE_FIXED64> { + typedef double Type; +}; + +template <> +struct PrimitiveTypeHelper<WireFormatLite::TYPE_STRING> { + typedef string Type; + static void Serialize(const void* ptr, + ::google::protobuf::io::CodedOutputStream* output) { + const Type& value = *static_cast<const Type*>(ptr); + output->WriteVarint32(value.size()); + output->WriteRawMaybeAliased(value.data(), value.size()); + } + static uint8* SerializeToArray(const void* ptr, uint8* buffer) { + const Type& value = *static_cast<const Type*>(ptr); + return io::CodedOutputStream::WriteStringWithSizeToArray(value, buffer); + } +}; + +template <> +struct PrimitiveTypeHelper<WireFormatLite::TYPE_BYTES> + : PrimitiveTypeHelper<WireFormatLite::TYPE_STRING> {}; + + +// We want to serialize to both CodedOutputStream and directly into byte arrays +// without duplicating the code. In fact we might want extra output channels in +// the future. +template <typename O, int type> +struct OutputHelper; + +template <int type, typename O> +void SerializeTo(const void* ptr, O* output) { + OutputHelper<O, type>::Serialize(ptr, output); +} + +template <typename O> +void WriteTagTo(uint32 tag, O* output) { + SerializeTo<WireFormatLite::TYPE_UINT32>(&tag, output); +} + +template <typename O> +void WriteLengthTo(uint32 length, O* output) { + SerializeTo<WireFormatLite::TYPE_UINT32>(&length, output); +} + +// Specialization for coded output stream +template <int type> +struct OutputHelper< ::google::protobuf::io::CodedOutputStream, type> { + static void Serialize(const void* ptr, + ::google::protobuf::io::CodedOutputStream* output) { + PrimitiveTypeHelper<type>::Serialize(ptr, output); + } +}; + +// Specialization for writing into a plain array +struct ArrayOutput { + uint8* ptr; + bool is_deterministic; +}; + +template <int type> +struct OutputHelper<ArrayOutput, type> { + static void Serialize(const void* ptr, ArrayOutput* output) { + output->ptr = PrimitiveTypeHelper<type>::SerializeToArray(ptr, output->ptr); + } +}; + +void SerializeMessageNoTable(const MessageLite* msg, + ::google::protobuf::io::CodedOutputStream* output) { + msg->SerializeWithCachedSizes(output); +} + +void SerializeMessageNoTable(const MessageLite* msg, ArrayOutput* output) { + output->ptr = msg->InternalSerializeWithCachedSizesToArray( + output->is_deterministic, output->ptr); +} + +// Helper to branch to fast path if possible +void SerializeMessageDispatch(const ::google::protobuf::MessageLite& msg, + const FieldMetadata* field_table, int num_fields, + int32 cached_size, + ::google::protobuf::io::CodedOutputStream* output) { + const uint8* base = reinterpret_cast<const uint8*>(&msg); + // Try the fast path + uint8* ptr = output->GetDirectBufferForNBytesAndAdvance(cached_size); + if (ptr) { + // We use virtual dispatch to enable dedicated generated code for the + // fast path. + msg.InternalSerializeWithCachedSizesToArray( + output->IsSerializationDeterministic(), ptr); + return; + } + SerializeInternal(base, field_table, num_fields, output); +} + +// Helper to branch to fast path if possible +void SerializeMessageDispatch(const ::google::protobuf::MessageLite& msg, + const FieldMetadata* field_table, int num_fields, + int32 cached_size, ArrayOutput* output) { + const uint8* base = reinterpret_cast<const uint8*>(&msg); + output->ptr = SerializeInternalToArray(base, field_table, num_fields, + output->is_deterministic, output->ptr); +} + +// Serializing messages is special as it's not a primitive type and needs an +// explicit overload for each output type. +template <typename O> +void SerializeMessageTo(const MessageLite* msg, const void* table_ptr, + O* output) { + const SerializationTable* table = + static_cast<const SerializationTable*>(table_ptr); + if (!table) { + // Proto1 + WriteLengthTo(msg->GetCachedSize(), output); + SerializeMessageNoTable(msg, output); + return; + } + const FieldMetadata* field_table = table->field_table; + const uint8* base = reinterpret_cast<const uint8*>(msg); + int cached_size = *reinterpret_cast<const int32*>(base + field_table->offset); + WriteLengthTo(cached_size, output); + int num_fields = table->num_fields - 1; + SerializeMessageDispatch(*msg, field_table + 1, num_fields, cached_size, + output); +} + +// Almost the same as above only it doesn't output the length field. +template <typename O> +void SerializeGroupTo(const MessageLite* msg, const void* table_ptr, + O* output) { + const SerializationTable* table = + static_cast<const SerializationTable*>(table_ptr); + if (!table) { + // Proto1 + SerializeMessageNoTable(msg, output); + return; + } + const FieldMetadata* field_table = table->field_table; + const uint8* base = reinterpret_cast<const uint8*>(msg); + int cached_size = *reinterpret_cast<const int32*>(base + field_table->offset); + int num_fields = table->num_fields - 1; + SerializeMessageDispatch(*msg, field_table + 1, num_fields, cached_size, + output); +} + +template <int type> +struct SingularFieldHelper { + template <typename O> + static void Serialize(const void* field, const FieldMetadata& md, O* output) { + WriteTagTo(md.tag, output); + SerializeTo<type>(field, output); + } +}; + +template <> +struct SingularFieldHelper<WireFormatLite::TYPE_STRING> { + template <typename O> + static void Serialize(const void* field, const FieldMetadata& md, O* output) { + WriteTagTo(md.tag, output); + SerializeTo<WireFormatLite::TYPE_STRING>(&Get<ArenaStringPtr>(field).Get(), + output); + } +}; + +template <> +struct SingularFieldHelper<WireFormatLite::TYPE_BYTES> + : SingularFieldHelper<WireFormatLite::TYPE_STRING> {}; + +template <> +struct SingularFieldHelper<WireFormatLite::TYPE_GROUP> { + template <typename O> + static void Serialize(const void* field, const FieldMetadata& md, O* output) { + WriteTagTo(md.tag, output); + SerializeGroupTo(Get<const MessageLite*>(field), + static_cast<const SerializationTable*>(md.ptr), output); + WriteTagTo(md.tag + 1, output); + } +}; + +template <> +struct SingularFieldHelper<WireFormatLite::TYPE_MESSAGE> { + template <typename O> + static void Serialize(const void* field, const FieldMetadata& md, O* output) { + WriteTagTo(md.tag, output); + SerializeMessageTo(Get<const MessageLite*>(field), + static_cast<const SerializationTable*>(md.ptr), output); + } +}; + +template <int type> +struct RepeatedFieldHelper { + template <typename O> + static void Serialize(const void* field, const FieldMetadata& md, O* output) { + typedef typename PrimitiveTypeHelper<type>::Type T; + const RepeatedField<T>& array = Get<RepeatedField<T> >(field); + for (int i = 0; i < array.size(); i++) { + WriteTagTo(md.tag, output); + SerializeTo<type>(&array[i], output); + } + } +}; + +// We need to use a helper class to get access to the private members +class AccessorHelper { + public: + static int Size(const RepeatedPtrFieldBase& x) { return x.size(); } + static void const* Get(const RepeatedPtrFieldBase& x, int idx) { + return x.raw_data()[idx]; + } +}; + +template <> +struct RepeatedFieldHelper<WireFormatLite::TYPE_STRING> { + template <typename O> + static void Serialize(const void* field, const FieldMetadata& md, O* output) { + const internal::RepeatedPtrFieldBase& array = + Get<internal::RepeatedPtrFieldBase>(field); + for (int i = 0; i < AccessorHelper::Size(array); i++) { + WriteTagTo(md.tag, output); + SerializeTo<WireFormatLite::TYPE_STRING>(AccessorHelper::Get(array, i), + output); + } + } +}; + +template <> +struct RepeatedFieldHelper<WireFormatLite::TYPE_BYTES> + : RepeatedFieldHelper<WireFormatLite::TYPE_STRING> {}; + +template <> +struct RepeatedFieldHelper<WireFormatLite::TYPE_GROUP> { + template <typename O> + static void Serialize(const void* field, const FieldMetadata& md, O* output) { + const internal::RepeatedPtrFieldBase& array = + Get<internal::RepeatedPtrFieldBase>(field); + for (int i = 0; i < AccessorHelper::Size(array); i++) { + WriteTagTo(md.tag, output); + SerializeGroupTo( + static_cast<const MessageLite*>(AccessorHelper::Get(array, i)), + static_cast<const SerializationTable*>(md.ptr), output); + WriteTagTo(md.tag + 1, output); + } + } +}; + +template <> +struct RepeatedFieldHelper<WireFormatLite::TYPE_MESSAGE> { + template <typename O> + static void Serialize(const void* field, const FieldMetadata& md, O* output) { + const internal::RepeatedPtrFieldBase& array = + Get<internal::RepeatedPtrFieldBase>(field); + for (int i = 0; i < AccessorHelper::Size(array); i++) { + WriteTagTo(md.tag, output); + SerializeMessageTo( + static_cast<const MessageLite*>(AccessorHelper::Get(array, i)), md.ptr, + output); + } + } +}; + + +template <int type> +struct PackedFieldHelper { + template <typename O> + static void Serialize(const void* field, const FieldMetadata& md, O* output) { + typedef typename PrimitiveTypeHelper<type>::Type T; + const RepeatedField<T>& array = Get<RepeatedField<T> >(field); + if (array.empty()) return; + WriteTagTo(md.tag, output); + int cached_size = + Get<int>(static_cast<const uint8*>(field) + sizeof(RepeatedField<T>)); + WriteLengthTo(cached_size, output); + for (int i = 0; i < array.size(); i++) { + SerializeTo<type>(&array[i], output); + } + } +}; + +template <> +struct PackedFieldHelper<WireFormatLite::TYPE_STRING> { + template <typename O> + static void Serialize(const void* field, const FieldMetadata& md, O* output) { + GOOGLE_LOG(FATAL) << "Not implemented field number " << md.tag << " with type " + << md.type; + } +}; + +template <> +struct PackedFieldHelper<WireFormatLite::TYPE_BYTES> + : PackedFieldHelper<WireFormatLite::TYPE_STRING> {}; +template <> +struct PackedFieldHelper<WireFormatLite::TYPE_GROUP> + : PackedFieldHelper<WireFormatLite::TYPE_STRING> {}; +template <> +struct PackedFieldHelper<WireFormatLite::TYPE_MESSAGE> + : PackedFieldHelper<WireFormatLite::TYPE_STRING> {}; + +template <int type> +struct OneOfFieldHelper { + template <typename O> + static void Serialize(const void* field, const FieldMetadata& md, O* output) { + SingularFieldHelper<type>::Serialize(field, md, output); + } +}; + + +void SerializeNotImplemented(int field) { + GOOGLE_LOG(FATAL) << "Not implemented field number " << field; +} + +// When switching to c++11 we should make these constexpr functions +#define SERIALIZE_TABLE_OP(type, type_class) \ + ((type - 1) + static_cast<int>(type_class) * FieldMetadata::kNumTypes) + +int FieldMetadata::CalculateType(int type, + FieldMetadata::FieldTypeClass type_class) { + return SERIALIZE_TABLE_OP(type, type_class); +} + +template <int type> +bool IsNull(const void* ptr) { + return *static_cast<const typename PrimitiveTypeHelper<type>::Type*>(ptr) == + 0; +} + +template <> +bool IsNull<WireFormatLite::TYPE_STRING>(const void* ptr) { + return static_cast<const ArenaStringPtr*>(ptr)->Get().size() == 0; +} + +template <> +bool IsNull<WireFormatLite::TYPE_BYTES>(const void* ptr) { + return static_cast<const ArenaStringPtr*>(ptr)->Get().size() == 0; +} + +template <> +bool IsNull<WireFormatLite::TYPE_GROUP>(const void* ptr) { + return Get<const MessageLite*>(ptr) == NULL; +} + +template <> +bool IsNull<WireFormatLite::TYPE_MESSAGE>(const void* ptr) { + return Get<const MessageLite*>(ptr) == NULL; +} + + +#define SERIALIZERS_FOR_TYPE(type) \ + case SERIALIZE_TABLE_OP(type, FieldMetadata::kPresence): \ + if (!IsPresent(base, field_metadata.has_offset)) continue; \ + SingularFieldHelper<type>::Serialize(ptr, field_metadata, output); \ + break; \ + case SERIALIZE_TABLE_OP(type, FieldMetadata::kNoPresence): \ + if (IsNull<type>(ptr)) continue; \ + SingularFieldHelper<type>::Serialize(ptr, field_metadata, output); \ + break; \ + case SERIALIZE_TABLE_OP(type, FieldMetadata::kRepeated): \ + RepeatedFieldHelper<type>::Serialize(ptr, field_metadata, output); \ + break; \ + case SERIALIZE_TABLE_OP(type, FieldMetadata::kPacked): \ + PackedFieldHelper<type>::Serialize(ptr, field_metadata, output); \ + break; \ + case SERIALIZE_TABLE_OP(type, FieldMetadata::kOneOf): \ + if (!IsOneofPresent(base, field_metadata.has_offset, field_metadata.tag)) \ + continue; \ + OneOfFieldHelper<type>::Serialize(ptr, field_metadata, output); \ + break + +void SerializeInternal(const uint8* base, + const FieldMetadata* field_metadata_table, + int32 num_fields, + ::google::protobuf::io::CodedOutputStream* output) { + for (int i = 0; i < num_fields; i++) { + const FieldMetadata& field_metadata = field_metadata_table[i]; + const uint8* ptr = base + field_metadata.offset; + switch (field_metadata.type) { + SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_DOUBLE); + SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_FLOAT); + SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_INT64); + SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_UINT64); + SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_INT32); + SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_FIXED64); + SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_FIXED32); + SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_BOOL); + SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_STRING); + SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_GROUP); + SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_MESSAGE); + SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_BYTES); + SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_UINT32); + SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_ENUM); + SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_SFIXED32); + SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_SFIXED64); + SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_SINT32); + SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_SINT64); + + // Special cases + case FieldMetadata::kSpecial: + reinterpret_cast<SpecialSerializer>( + const_cast<void*>(field_metadata.ptr))( + base, field_metadata.offset, field_metadata.tag, + field_metadata.has_offset, output); + break; + default: + // __builtin_unreachable() + SerializeNotImplemented(field_metadata.type); + } + } +} + +uint8* SerializeInternalToArray(const uint8* base, + const FieldMetadata* field_metadata_table, + int32 num_fields, bool is_deterministic, + uint8* buffer) { + ArrayOutput array_output = {buffer, is_deterministic}; + ArrayOutput* output = &array_output; + for (int i = 0; i < num_fields; i++) { + const FieldMetadata& field_metadata = field_metadata_table[i]; + const uint8* ptr = base + field_metadata.offset; + switch (field_metadata.type) { + SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_DOUBLE); + SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_FLOAT); + SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_INT64); + SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_UINT64); + SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_INT32); + SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_FIXED64); + SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_FIXED32); + SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_BOOL); + SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_STRING); + SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_GROUP); + SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_MESSAGE); + SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_BYTES); + SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_UINT32); + SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_ENUM); + SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_SFIXED32); + SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_SFIXED64); + SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_SINT32); + SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_SINT64); + // Special cases + case FieldMetadata::kSpecial: { + io::ArrayOutputStream array_stream(array_output.ptr, INT_MAX); + io::CodedOutputStream output(&array_stream); + output.SetSerializationDeterministic(is_deterministic); + reinterpret_cast<SpecialSerializer>( + const_cast<void*>(field_metadata.ptr))( + base, field_metadata.offset, field_metadata.tag, + field_metadata.has_offset, &output); + array_output.ptr += output.ByteCount(); + } break; + default: + // __builtin_unreachable() + SerializeNotImplemented(field_metadata.type); + } + } + return array_output.ptr; +} +#undef SERIALIZERS_FOR_TYPE + +void ExtensionSerializer(const uint8* ptr, uint32 offset, uint32 tag, + uint32 has_offset, + ::google::protobuf::io::CodedOutputStream* output) { + reinterpret_cast<const ExtensionSet*>(ptr + offset) + ->SerializeWithCachedSizes(tag, has_offset, output); +} + +void UnknownFieldSerializerLite(const uint8* ptr, uint32 offset, uint32 tag, + uint32 has_offset, + ::google::protobuf::io::CodedOutputStream* output) { + output->WriteString( + reinterpret_cast<const InternalMetadataWithArenaLite*>(ptr + offset) + ->unknown_fields()); +} + +MessageLite* DuplicateIfNonNullInternal(MessageLite* message, Arena* arena) { + if (message) { + MessageLite* ret = message->New(arena); + ret->CheckTypeAndMergeFrom(*message); + return ret; + } else { + return NULL; + } +} + +// Returns a message owned by this Arena. This may require Own()ing or +// duplicating the message. +MessageLite* GetOwnedMessageInternal(Arena* message_arena, + MessageLite* submessage, + Arena* submessage_arena) { + GOOGLE_DCHECK(submessage->GetArena() == submessage_arena); + GOOGLE_DCHECK(message_arena != submessage_arena); + if (message_arena != NULL && submessage_arena == NULL) { + message_arena->Own(submessage); + return submessage; + } else { + MessageLite* ret = submessage->New(message_arena); + ret->CheckTypeAndMergeFrom(*submessage); + return ret; + } +} + } // namespace internal } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/generated_message_util.h b/src/google/protobuf/generated_message_util.h index 44174466..cd74b45e 100644 --- a/src/google/protobuf/generated_message_util.h +++ b/src/google/protobuf/generated_message_util.h @@ -41,25 +41,23 @@ #include <assert.h> #include <climits> #include <string> +#include <vector> #include <google/protobuf/stubs/logging.h> #include <google/protobuf/stubs/common.h> #include <google/protobuf/stubs/once.h> #include <google/protobuf/has_bits.h> - -#ifndef PROTOBUF_FINAL -#if LANG_CXX11 && !defined(__NVCC__) -#define PROTOBUF_FINAL final -#else -#define PROTOBUF_FINAL -#endif -#endif // !PROTOBUF_FINAL +#include <google/protobuf/implicit_weak_message.h> +#include <google/protobuf/map_entry_lite.h> +#include <google/protobuf/message_lite.h> +#include <google/protobuf/wire_format_lite.h> namespace google { namespace protobuf { class Arena; + namespace io { class CodedInputStream; } namespace internal { @@ -100,127 +98,235 @@ namespace internal { // choose 16 rather than some other number just in case the compiler would // be confused by an unaligned pointer. #define GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TYPE, FIELD) \ - static_cast<int>( \ + static_cast< ::google::protobuf::uint32>( \ reinterpret_cast<const char*>( \ &reinterpret_cast<const TYPE*>(16)->FIELD) - \ reinterpret_cast<const char*>(16)) #endif -#define GOOGLE_PROTOBUF_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET(ONEOF, FIELD) \ - static_cast< ::google::protobuf::uint32>( \ - reinterpret_cast<const char*>(&(ONEOF->FIELD)) \ - - reinterpret_cast<const char*>(ONEOF)) -// TODO(acozzette): remove this transitional macro after updating generated code -#define PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET(ONEOF, FIELD) \ - GOOGLE_PROTOBUF_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET(ONEOF, FIELD) - // Constants for special floating point values. LIBPROTOBUF_EXPORT double Infinity(); LIBPROTOBUF_EXPORT double NaN(); -// This type is used to define a global variable, without it's constructor -// and destructor run on start and end of the program lifetime. This circumvents -// the initial construction order fiasco, while keeping the address of the -// empty string a compile time constant. -template <typename T> -class ExplicitlyConstructed { - public: - void DefaultConstruct() { - new (&union_) T(); - init_ = true; + +// True if IsInitialized() is true for all elements of t. Type is expected +// to be a RepeatedPtrField<some message type>. It's useful to have this +// helper here to keep the protobuf compiler from ever having to emit loops in +// IsInitialized() methods. We want the C++ compiler to inline this or not +// as it sees fit. +template <class Type> bool AllAreInitialized(const Type& t) { + for (int i = t.size(); --i >= 0; ) { + if (!t.Get(i).IsInitialized()) return false; } + return true; +} - bool IsInitialized() { return init_; } - void Shutdown() { - if (init_) { - init_ = false; - get_mutable()->~T(); +// "Weak" variant of AllAreInitialized, used to implement implicit weak fields. +// This version operates on MessageLite to avoid introducing a dependency on the +// concrete message type. +template <class T> +bool AllAreInitializedWeak(const ::google::protobuf::RepeatedPtrField<T>& t) { + for (int i = t.size(); --i >= 0;) { + if (!reinterpret_cast<const ::google::protobuf::internal::RepeatedPtrFieldBase&>(t) + .Get< ::google::protobuf::internal::ImplicitWeakTypeHandler<T> >(i) + .IsInitialized()) { + return false; } } + return true; +} -#if LANG_CXX11 - constexpr -#endif - const T& - get() const { - return reinterpret_cast<const T&>(union_); - } - T* get_mutable() { return reinterpret_cast<T*>(&union_); } - - private: - // Prefer c++14 aligned_storage, but for compatibility this will do. - union AlignedUnion { - char space[sizeof(T)]; - int64 align_to_int64; - void* align_to_ptr; - } union_; - bool init_; // false by linker +LIBPROTOBUF_EXPORT void InitProtobufDefaults(); + +struct LIBPROTOBUF_EXPORT FieldMetadata { + uint32 offset; // offset of this field in the struct + uint32 tag; // field * 8 + wire_type + // byte offset * 8 + bit_offset; + // if the high bit is set then this is the byte offset of the oneof_case + // for this field. + uint32 has_offset; + uint32 type; // the type of this field. + const void* ptr; // auxiliary data + + // From the serializer point of view each fundamental type can occur in + // 4 different ways. For simplicity we treat all combinations as a cartesion + // product although not all combinations are allowed. + enum FieldTypeClass { + kPresence, + kNoPresence, + kRepeated, + kPacked, + kOneOf, + kNumTypeClasses // must be last enum + }; + // C++ protobuf has 20 fundamental types, were we added Cord and StringPiece + // and also distinquish the same types if they have different wire format. + enum { + kCordType = 19, + kStringPieceType = 20, + kNumTypes = 20, + kSpecial = kNumTypes * kNumTypeClasses, + }; + + static int CalculateType(int fundamental_type, FieldTypeClass type_class); }; -// 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. +inline bool IsPresent(const void* base, uint32 hasbit) { + const uint32* has_bits_array = static_cast<const uint32*>(base); + return has_bits_array[hasbit / 32] & (1u << (hasbit & 31)); +} + +inline bool IsOneofPresent(const void* base, uint32 offset, uint32 tag) { + const uint32* oneof = + reinterpret_cast<const uint32*>(static_cast<const uint8*>(base) + offset); + return *oneof == tag >> 3; +} -// Default empty string object. Don't use this directly. Instead, call -// GetEmptyString() to get the reference. -extern ExplicitlyConstructed< ::std::string> fixed_address_empty_string; -LIBPROTOBUF_EXPORT extern ProtobufOnceType empty_string_once_init_; -LIBPROTOBUF_EXPORT void InitEmptyString(); +typedef void (*SpecialSerializer)(const uint8* base, uint32 offset, uint32 tag, + uint32 has_offset, + ::google::protobuf::io::CodedOutputStream* output); +LIBPROTOBUF_EXPORT void ExtensionSerializer(const uint8* base, uint32 offset, uint32 tag, + uint32 has_offset, + ::google::protobuf::io::CodedOutputStream* output); +LIBPROTOBUF_EXPORT void UnknownFieldSerializerLite(const uint8* base, uint32 offset, uint32 tag, + uint32 has_offset, + ::google::protobuf::io::CodedOutputStream* output); -LIBPROTOBUF_EXPORT inline const ::std::string& GetEmptyStringAlreadyInited() { - return fixed_address_empty_string.get(); +struct SerializationTable { + int num_fields; + const FieldMetadata* field_table; +}; + +LIBPROTOBUF_EXPORT void SerializeInternal(const uint8* base, const FieldMetadata* table, + int num_fields, ::google::protobuf::io::CodedOutputStream* output); + +inline void TableSerialize(const ::google::protobuf::MessageLite& msg, + const SerializationTable* table, + ::google::protobuf::io::CodedOutputStream* output) { + const FieldMetadata* field_table = table->field_table; + int num_fields = table->num_fields - 1; + const uint8* base = reinterpret_cast<const uint8*>(&msg); + // TODO(gerbens) This skips the first test if we could use the fast + // array serialization path, we should make this + // int cached_size = + // *reinterpret_cast<const int32*>(base + field_table->offset); + // SerializeWithCachedSize(msg, field_table + 1, num_fields, cached_size, ...) + // But we keep conformance with the old way for now. + SerializeInternal(base, field_table + 1, num_fields, output); } -LIBPROTOBUF_EXPORT inline const ::std::string& GetEmptyString() { - ::google::protobuf::GoogleOnceInit(&empty_string_once_init_, &InitEmptyString); - return GetEmptyStringAlreadyInited(); +uint8* SerializeInternalToArray(const uint8* base, const FieldMetadata* table, + int num_fields, bool is_deterministic, + uint8* buffer); + +inline uint8* TableSerializeToArray(const ::google::protobuf::MessageLite& msg, + const SerializationTable* table, + bool is_deterministic, uint8* buffer) { + const uint8* base = reinterpret_cast<const uint8*>(&msg); + const FieldMetadata* field_table = table->field_table + 1; + int num_fields = table->num_fields - 1; + return SerializeInternalToArray(base, field_table, num_fields, + is_deterministic, buffer); } -LIBPROTOBUF_EXPORT size_t StringSpaceUsedExcludingSelfLong(const string& str); +template <typename T> +struct CompareHelper { + bool operator()(const T& a, const T& b) { return a < b; } +}; +template <> +struct CompareHelper<ArenaStringPtr> { + bool operator()(const ArenaStringPtr& a, const ArenaStringPtr& b) { + return a.Get() < b.Get(); + } +}; -// True if IsInitialized() is true for all elements of t. Type is expected -// to be a RepeatedPtrField<some message type>. It's useful to have this -// helper here to keep the protobuf compiler from ever having to emit loops in -// IsInitialized() methods. We want the C++ compiler to inline this or not -// as it sees fit. -template <class Type> bool AllAreInitialized(const Type& t) { - for (int i = t.size(); --i >= 0; ) { - if (!t.Get(i).IsInitialized()) return false; +struct CompareMapKey { + template <typename T> + bool operator()(const MapEntryHelper<T>& a, const MapEntryHelper<T>& b) { + return Compare(a.key_, b.key_); + } + template <typename T> + bool Compare(const T& a, const T& b) { + return CompareHelper<T>()(a, b); + } +}; + +template <typename MapFieldType, const SerializationTable* table> +void MapFieldSerializer(const uint8* base, uint32 offset, uint32 tag, + uint32 has_offset, + ::google::protobuf::io::CodedOutputStream* output) { + typedef MapEntryHelper<typename MapFieldType::EntryTypeTrait> Entry; + typedef typename MapFieldType::MapType::const_iterator Iter; + + const MapFieldType& map_field = + *reinterpret_cast<const MapFieldType*>(base + offset); + const SerializationTable* t = + table + + has_offset; // has_offset is overloaded for maps to mean table offset + if (!output->IsSerializationDeterministic()) { + for (Iter it = map_field.GetMap().begin(); it != map_field.GetMap().end(); + ++it) { + Entry map_entry(*it); + output->WriteVarint32(tag); + output->WriteVarint32(map_entry._cached_size_); + SerializeInternal(reinterpret_cast<const uint8*>(&map_entry), + t->field_table, t->num_fields, output); + } + } else { + std::vector<Entry> v; + for (Iter it = map_field.GetMap().begin(); it != map_field.GetMap().end(); + ++it) { + v.push_back(Entry(*it)); + } + std::sort(v.begin(), v.end(), CompareMapKey()); + for (int i = 0; i < v.size(); i++) { + output->WriteVarint32(tag); + output->WriteVarint32(v[i]._cached_size_); + SerializeInternal(reinterpret_cast<const uint8*>(&v[i]), t->field_table, + t->num_fields, output); + } } - return true; } -LIBPROTOBUF_EXPORT void InitProtobufDefaults(); +LIBPROTOBUF_EXPORT MessageLite* DuplicateIfNonNullInternal(MessageLite* message, Arena* arena); +LIBPROTOBUF_EXPORT MessageLite* GetOwnedMessageInternal(Arena* message_arena, + MessageLite* submessage, + Arena* submessage_arena); -// 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. However this case should not error or GOOGLE_CHECK-fail, -// because the full size_t resolution is still returned from ByteSizeLong() and -// checked against INT_MAX; we can catch the overflow there. -inline int ToCachedSize(size_t size) { - return static_cast<int>(size); +template <typename T> +T* DuplicateIfNonNull(T* message, Arena* arena) { + // The casts must be reinterpret_cast<> because T might be a forward-declared + // type that the compiler doesn't know is related to MessageLite. + return reinterpret_cast<T*>(DuplicateIfNonNullInternal( + reinterpret_cast<MessageLite*>(message), arena)); } -// For cases where a legacy function returns an integer size. We GOOGLE_DCHECK() that -// the conversion will fit within an integer; if this is false then we are -// losing information. -inline int ToIntSize(size_t size) { - GOOGLE_DCHECK_LE(size, static_cast<size_t>(INT_MAX)); - return static_cast<int>(size); +template <typename T> +T* GetOwnedMessage(Arena* message_arena, T* submessage, + Arena* submessage_arena) { + // The casts must be reinterpret_cast<> because T might be a forward-declared + // type that the compiler doesn't know is related to MessageLite. + return reinterpret_cast<T*>(GetOwnedMessageInternal( + message_arena, reinterpret_cast<MessageLite*>(submessage), + submessage_arena)); } -// We mainly calculate sizes in terms of size_t, but some functions that compute -// sizes return "int". These int sizes are expected to always be positive. -// This function is more efficient than casting an int to size_t directly on -// 64-bit platforms because it avoids making the compiler emit a sign extending -// instruction, which we don't want and don't want to pay for. -inline size_t FromIntSize(int size) { - // Convert to unsigned before widening so sign extension is not necessary. - return static_cast<unsigned int>(size); +// Returns a message owned by this Arena. This may require Own()ing or +// duplicating the message. +template <typename T> +T* GetOwnedMessage(T* message, Arena* arena) { + GOOGLE_DCHECK(message); + Arena* message_arena = google::protobuf::Arena::GetArena(message); + if (message_arena == arena) { + return message; + } else if (arena != NULL && message_arena == NULL) { + arena->Own(message); + return message; + } else { + return DuplicateIfNonNull(message, arena); + } } } // namespace internal diff --git a/src/google/protobuf/has_bits.h b/src/google/protobuf/has_bits.h index cb1d7ccc..e3a0149a 100644 --- a/src/google/protobuf/has_bits.h +++ b/src/google/protobuf/has_bits.h @@ -32,6 +32,7 @@ #define GOOGLE_PROTOBUF_HAS_BITS_H__ #include <google/protobuf/stubs/common.h> +#include <google/protobuf/stubs/port.h> namespace google { namespace protobuf { @@ -40,17 +41,18 @@ namespace internal { template<size_t doublewords> class HasBits { public: - HasBits() GOOGLE_ATTRIBUTE_ALWAYS_INLINE { Clear(); } + HasBits() GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE { Clear(); } - void Clear() GOOGLE_ATTRIBUTE_ALWAYS_INLINE { + void Clear() GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE { memset(has_bits_, 0, sizeof(has_bits_)); } - ::google::protobuf::uint32& operator[](int index) GOOGLE_ATTRIBUTE_ALWAYS_INLINE { + ::google::protobuf::uint32& operator[](int index) GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE { return has_bits_[index]; } - const ::google::protobuf::uint32& operator[](int index) const GOOGLE_ATTRIBUTE_ALWAYS_INLINE { + const ::google::protobuf::uint32& operator[](int index) const + GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE { return has_bits_[index]; } diff --git a/src/google/protobuf/unittest_import_public_proto3.proto b/src/google/protobuf/implicit_weak_message.cc index d6f11e28..0dd126be 100644 --- a/src/google/protobuf/unittest_import_public_proto3.proto +++ b/src/google/protobuf/implicit_weak_message.cc @@ -28,15 +28,24 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Author: liujisi@google.com (Pherl Liu) +#include <google/protobuf/implicit_weak_message.h> -syntax = "proto3"; +#include <google/protobuf/io/zero_copy_stream_impl_lite.h> +#include <google/protobuf/wire_format_lite.h> -package protobuf_unittest_import; +namespace google { +namespace protobuf { +namespace internal { -option java_package = "com.google.protobuf.test"; -option csharp_namespace = "Google.Protobuf.TestProtos"; +::google::protobuf::internal::ExplicitlyConstructed<ImplicitWeakMessage> + implicit_weak_message_default_instance; -message PublicImportMessage { - int32 e = 1; +bool ImplicitWeakMessage::MergePartialFromCodedStream(io::CodedInputStream* input) { + io::StringOutputStream string_stream(&data_); + io::CodedOutputStream coded_stream(&string_stream, false); + return WireFormatLite::SkipMessage(input, &coded_stream); } + +} // namespace internal +} // namespace protobuf +} // namespace google diff --git a/src/google/protobuf/implicit_weak_message.h b/src/google/protobuf/implicit_weak_message.h new file mode 100644 index 00000000..a822172e --- /dev/null +++ b/src/google/protobuf/implicit_weak_message.h @@ -0,0 +1,138 @@ +// 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_IMPLICIT_WEAK_MESSAGE_H__ +#define GOOGLE_PROTOBUF_IMPLICIT_WEAK_MESSAGE_H__ + +#include <google/protobuf/io/coded_stream.h> +#include <google/protobuf/arena.h> +#include <google/protobuf/message_lite.h> + +// This file is logically internal-only and should only be used by protobuf +// generated code. + +namespace google { +namespace protobuf { +namespace internal { + +// An implementation of MessageLite that treats all data as unknown. This type +// acts as a placeholder for an implicit weak field in the case where the true +// message type does not get linked into the binary. +class LIBPROTOBUF_EXPORT ImplicitWeakMessage : public MessageLite { + public: + ImplicitWeakMessage() : arena_(NULL) {} + explicit ImplicitWeakMessage(Arena* arena) : arena_(arena) {} + + string GetTypeName() const { return ""; } + + MessageLite* New() const { return new ImplicitWeakMessage; } + MessageLite* New(Arena* arena) const { + return Arena::CreateMessage<ImplicitWeakMessage>(arena); + } + + Arena* GetArena() const { return arena_; } + + void Clear() { data_.clear(); } + + bool IsInitialized() const { return true; } + + void CheckTypeAndMergeFrom(const MessageLite& other) { + data_.append(static_cast<const ImplicitWeakMessage&>(other).data_); + } + + bool MergePartialFromCodedStream(io::CodedInputStream* input); + + size_t ByteSizeLong() const { return data_.size(); } + + void SerializeWithCachedSizes(io::CodedOutputStream* output) const { + output->WriteString(data_); + } + + int GetCachedSize() const { return static_cast<int>(data_.size()); } + + typedef void InternalArenaConstructable_; + + private: + Arena* const arena_; + string data_; + GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImplicitWeakMessage); +}; + +// A type handler for use with implicit weak repeated message fields. +template <typename ImplicitWeakType> +class ImplicitWeakTypeHandler { + public: + typedef ImplicitWeakType Type; + typedef ::google::protobuf::MessageLite WeakType; +#if LANG_CXX11 + static const bool Moveable = false; +#endif + + // With implicit weak fields, we need separate NewFromPrototype and + // NewFromPrototypeWeak functions. The former is used when we want to create a + // strong dependency on the message type, and it just delegates to the + // GenericTypeHandler. The latter avoids creating a strong dependency, by + // simply calling MessageLite::New. + static inline ::google::protobuf::MessageLite* NewFromPrototype( + const ::google::protobuf::MessageLite* prototype, ::google::protobuf::Arena* arena = NULL) { + return prototype->New(arena); + } + + static inline void Delete(::google::protobuf::MessageLite* value, Arena* arena) { + if (arena == NULL) { + delete value; + } + } + static inline ::google::protobuf::Arena* GetArena(::google::protobuf::MessageLite* value) { + return value->GetArena(); + } + static inline void* GetMaybeArenaPointer(::google::protobuf::MessageLite* value) { + return value->GetArena(); + } + static inline void Clear(::google::protobuf::MessageLite* value) { + value->Clear(); + } + static void Merge(const ::google::protobuf::MessageLite& from, + ::google::protobuf::MessageLite* to) { + to->CheckTypeAndMergeFrom(from); + } + static inline size_t SpaceUsedLong(const Type& value) { + return value.SpaceUsedLong(); + } +}; + +extern ::google::protobuf::internal::ExplicitlyConstructed<ImplicitWeakMessage> + implicit_weak_message_default_instance; + +} // namespace internal +} // namespace protobuf + +} // namespace google +#endif // GOOGLE_PROTOBUF_IMPLICIT_WEAK_MESSAGE_H__ diff --git a/src/google/protobuf/io/coded_stream.cc b/src/google/protobuf/io/coded_stream.cc index df4250e5..d3bc7c6d 100644 --- a/src/google/protobuf/io/coded_stream.cc +++ b/src/google/protobuf/io/coded_stream.cc @@ -121,9 +121,9 @@ CodedInputStream::Limit CodedInputStream::PushLimit(int byte_limit) { // security: byte_limit is possibly evil, so check for negative values // and overflow. Also check that the new requested limit is before the // previous limit; otherwise we continue to enforce the previous limit. - if GOOGLE_PREDICT_TRUE(byte_limit >= 0 && - byte_limit <= INT_MAX - current_position && - byte_limit < current_limit_ - current_position) { + if (GOOGLE_PREDICT_TRUE(byte_limit >= 0 && + byte_limit <= INT_MAX - current_position && + byte_limit < current_limit_ - current_position)) { current_limit_ = current_position + byte_limit; RecomputeBufferLimits(); } @@ -173,10 +173,7 @@ int CodedInputStream::BytesUntilLimit() const { return current_limit_ - current_position; } -void CodedInputStream::SetTotalBytesLimit( - int total_bytes_limit, int warning_threshold) { - (void) warning_threshold; - +void CodedInputStream::SetTotalBytesLimit(int total_bytes_limit) { // Make sure the limit isn't already past, since this could confuse other // code. int current_position = CurrentPosition(); @@ -197,17 +194,7 @@ void CodedInputStream::PrintTotalBytesLimitError() { "in google/protobuf/io/coded_stream.h."; } -bool CodedInputStream::Skip(int count) { - if (count < 0) return false; // security: count is often user-supplied - - const int original_buffer_size = BufferSize(); - - if (count <= original_buffer_size) { - // Just skipping within the current buffer. Easy. - Advance(count); - return true; - } - +bool CodedInputStream::SkipFallback(int count, int original_buffer_size) { if (buffer_size_after_limit_ > 0) { // We hit a limit inside this buffer. Advance to the limit and fail. Advance(original_buffer_size); @@ -325,7 +312,8 @@ namespace { // The first part of the pair is true iff the read was successful. The second // part is buffer + (number of bytes read). This function is always inlined, // so returning a pair is costless. -GOOGLE_ATTRIBUTE_ALWAYS_INLINE ::std::pair<bool, const uint8*> ReadVarint32FromArray( +GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE +::std::pair<bool, const uint8*> ReadVarint32FromArray( uint32 first_byte, const uint8* buffer, uint32* value); inline ::std::pair<bool, const uint8*> ReadVarint32FromArray( @@ -362,8 +350,8 @@ inline ::std::pair<bool, const uint8*> ReadVarint32FromArray( return std::make_pair(true, ptr); } -GOOGLE_ATTRIBUTE_ALWAYS_INLINE::std::pair<bool, const uint8*> ReadVarint64FromArray( - const uint8* buffer, uint64* value); +GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE::std::pair<bool, const uint8*> +ReadVarint64FromArray(const uint8* buffer, uint64* value); inline ::std::pair<bool, const uint8*> ReadVarint64FromArray( const uint8* buffer, uint64* value) { const uint8* ptr = buffer; diff --git a/src/google/protobuf/io/coded_stream.h b/src/google/protobuf/io/coded_stream.h index 20d86143..ec85147b 100644 --- a/src/google/protobuf/io/coded_stream.h +++ b/src/google/protobuf/io/coded_stream.h @@ -134,6 +134,7 @@ #include <google/protobuf/stubs/atomicops.h> #include <google/protobuf/stubs/common.h> #include <google/protobuf/stubs/port.h> +#include <google/protobuf/stubs/port.h> namespace google { @@ -184,7 +185,7 @@ class LIBPROTOBUF_EXPORT CodedInputStream { // Skips a number of bytes. Returns false if an underlying read error // occurs. - bool Skip(int count); + inline bool Skip(int count); // Sets *data to point directly at the unread part of the CodedInputStream's // underlying buffer, and *size to the size of that buffer, but does not @@ -197,28 +198,23 @@ class LIBPROTOBUF_EXPORT CodedInputStream { // Like GetDirectBufferPointer, but this method is inlined, and does not // attempt to Refresh() if the buffer is currently empty. - GOOGLE_ATTRIBUTE_ALWAYS_INLINE void GetDirectBufferPointerInline(const void** data, - int* size); + GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE + void GetDirectBufferPointerInline(const void** data, int* size); // Read raw bytes, copying them into the given buffer. bool ReadRaw(void* buffer, int size); // Like the above, with inlined optimizations. This should only be used // by the protobuf implementation. - GOOGLE_ATTRIBUTE_ALWAYS_INLINE bool InternalReadRawInline(void* buffer, int size); + GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE + bool InternalReadRawInline(void* buffer, int size); // Like ReadRaw, but reads into a string. - // - // Implementation Note: ReadString() grows the string gradually as it - // reads in the data, rather than allocating the entire requested size - // upfront. This prevents denial-of-service attacks in which a client - // could claim that a string is going to be MAX_INT bytes long in order to - // crash the server because it can't allocate this much space at once. bool ReadString(string* buffer, int size); // Like the above, with inlined optimizations. This should only be used // by the protobuf implementation. - GOOGLE_ATTRIBUTE_ALWAYS_INLINE bool InternalReadStringInline(string* buffer, - int size); + GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE + bool InternalReadStringInline(string* buffer, int size); // Read a 32-bit little-endian integer. @@ -261,8 +257,11 @@ class LIBPROTOBUF_EXPORT CodedInputStream { // Always inline because this is only called in one place per parse loop // but it is called for every iteration of said loop, so it should be fast. // GCC doesn't want to inline this by default. - GOOGLE_ATTRIBUTE_ALWAYS_INLINE uint32 ReadTag(); - GOOGLE_ATTRIBUTE_ALWAYS_INLINE uint32 ReadTagNoLastTag(); + GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE uint32 ReadTag() { + return last_tag_ = ReadTagNoLastTag(); + } + + GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE uint32 ReadTagNoLastTag(); // This usually a faster alternative to ReadTag() when cutoff is a manifest @@ -273,10 +272,15 @@ class LIBPROTOBUF_EXPORT CodedInputStream { // above cutoff or is 0. (There's intentional wiggle room when tag is 0, // because that can arise in several ways, and for best performance we want // to avoid an extra "is tag == 0?" check here.) - GOOGLE_ATTRIBUTE_ALWAYS_INLINE std::pair<uint32, bool> ReadTagWithCutoff( - uint32 cutoff); - GOOGLE_ATTRIBUTE_ALWAYS_INLINE std::pair<uint32, bool> ReadTagWithCutoffNoLastTag( - uint32 cutoff); + GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE + std::pair<uint32, bool> ReadTagWithCutoff(uint32 cutoff) { + std::pair<uint32, bool> result = ReadTagWithCutoffNoLastTag(cutoff); + last_tag_ = result.first; + return result; + } + + GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE + std::pair<uint32, bool> ReadTagWithCutoffNoLastTag(uint32 cutoff); // Usually returns true if calling ReadVarint32() now would produce the given // value. Will always return false if ReadVarint32() would not return the @@ -285,7 +289,7 @@ class LIBPROTOBUF_EXPORT CodedInputStream { // parameter. // Always inline because this collapses to a small number of instructions // when given a constant parameter, but GCC doesn't want to inline by default. - GOOGLE_ATTRIBUTE_ALWAYS_INLINE bool ExpectTag(uint32 expected); + GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE bool ExpectTag(uint32 expected); // Like above, except this reads from the specified buffer. The caller is // responsible for ensuring that the buffer is large enough to read a varint @@ -294,9 +298,8 @@ class LIBPROTOBUF_EXPORT CodedInputStream { // // Returns a pointer beyond the expected tag if it was found, or NULL if it // was not. - GOOGLE_ATTRIBUTE_ALWAYS_INLINE static const uint8* ExpectTagFromArray( - const uint8* buffer, - uint32 expected); + GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE + static const uint8* ExpectTagFromArray(const uint8* buffer, uint32 expected); // Usually returns true if no more bytes can be read. Always returns false // if more bytes can be read. If ExpectAtEnd() returns true, a subsequent @@ -316,6 +319,7 @@ class LIBPROTOBUF_EXPORT CodedInputStream { // tag to make sure it had the right number, so it calls LastTagWas() on // return from the embedded parser to check. bool LastTagWas(uint32 expected); + void SetLastTag(uint32 tag) { last_tag_ = tag; } // When parsing message (but NOT a group), this method must be called // immediately after MergeFromCodedStream() returns (if it returns true) @@ -363,42 +367,32 @@ class LIBPROTOBUF_EXPORT CodedInputStream { // Total Bytes Limit ----------------------------------------------- // To prevent malicious users from sending excessively large messages - // and causing integer overflows or memory exhaustion, CodedInputStream - // imposes a hard limit on the total number of bytes it will read. + // and causing memory exhaustion, CodedInputStream imposes a hard limit on + // the total number of bytes it will read. // Sets the maximum number of bytes that this CodedInputStream will read - // before refusing to continue. To prevent integer overflows in the - // protocol buffers implementation, as well as to prevent servers from - // allocating enormous amounts of memory to hold parsed messages, the - // maximum message length should be limited to the shortest length that - // will not harm usability. The theoretical shortest message that could - // cause integer overflows is 512MB. The default limit is 64MB. Apps - // should set shorter limits if possible. For backwards compatibility all - // negative values get squashed to -1, as other negative values might have - // special internal meanings. An error will always be printed to stderr if - // the limit is reached. + // before refusing to continue. To prevent servers from allocating enormous + // amounts of memory to hold parsed messages, the maximum message length + // should be limited to the shortest length that will not harm usability. + // The default limit is INT_MAX (~2GB) and apps should set shorter limits + // if possible. An error will always be printed to stderr if the limit is + // reached. // - // This is unrelated to PushLimit()/PopLimit(). + // Note: setting a limit less than the current read position is interpreted + // as a limit on the current position. // - // Hint: If you are reading this because your program is printing a - // warning about dangerously large protocol messages, you may be - // confused about what to do next. The best option is to change your - // design such that excessively large messages are not necessary. - // For example, try to design file formats to consist of many small - // messages rather than a single large one. If this is infeasible, - // you will need to increase the limit. Chances are, though, that - // your code never constructs a CodedInputStream on which the limit - // can be set. You probably parse messages by calling things like - // Message::ParseFromString(). In this case, you will need to change - // your code to instead construct some sort of ZeroCopyInputStream - // (e.g. an ArrayInputStream), construct a CodedInputStream around - // that, then call Message::ParseFromCodedStream() instead. Then - // you can adjust the limit. Yes, it's more work, but you're doing - // something unusual. - void SetTotalBytesLimit(int total_bytes_limit, int warning_threshold); - - // The Total Bytes Limit minus the Current Position, or -1 if there - // is no Total Bytes Limit. + // This is unrelated to PushLimit()/PopLimit(). + void SetTotalBytesLimit(int total_bytes_limit); + + PROTOBUF_RUNTIME_DEPRECATED( + "Please use the single parameter version of SetTotalBytesLimit(). The " + "second parameter is ignored.") + void SetTotalBytesLimit(int total_bytes_limit, int) { + SetTotalBytesLimit(total_bytes_limit); + } + + // The Total Bytes Limit minus the Current Position, or -1 if the total bytes + // limit is INT_MAX. int BytesUntilTotalBytesLimit() const; // Recursion Limit ------------------------------------------------- @@ -576,14 +570,15 @@ class LIBPROTOBUF_EXPORT CodedInputStream { // Recursion depth limit, set by SetRecursionLimit(). int recursion_limit_; - bool disable_strict_correctness_enforcement_; - // See SetExtensionRegistry(). const DescriptorPool* extension_pool_; MessageFactory* extension_factory_; // Private member functions. + // Fallback when Skip() goes past the end of the current buffer. + bool SkipFallback(int count, int original_buffer_size); + // Advance the buffer by a given number of bytes. void Advance(int amount); @@ -621,12 +616,6 @@ class LIBPROTOBUF_EXPORT CodedInputStream { bool ReadLittleEndian32Fallback(uint32* value); bool ReadLittleEndian64Fallback(uint64* value); - template<bool update_last_tag> - GOOGLE_ATTRIBUTE_ALWAYS_INLINE uint32 ReadTagImplementation(); - template<bool update_last_tag> - GOOGLE_ATTRIBUTE_ALWAYS_INLINE - std::pair<uint32, bool> ReadTagWithCutoffImplementation(uint32 cutoff); - // Fallback/slow methods for reading tags. These do not update last_tag_, // but will set legitimate_message_end_ if we are at the end of the input // stream. @@ -793,8 +782,8 @@ class LIBPROTOBUF_EXPORT CodedOutputStream { // but GCC by default doesn't want to inline this. void WriteTag(uint32 value); // Like WriteTag() but writing directly to the target array. - GOOGLE_ATTRIBUTE_ALWAYS_INLINE static uint8* WriteTagToArray(uint32 value, - uint8* target); + GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE + static uint8* WriteTagToArray(uint32 value, uint8* target); // Returns the number of bytes needed to encode the given value as a varint. static size_t VarintSize32(uint32 value); @@ -861,11 +850,11 @@ class LIBPROTOBUF_EXPORT CodedOutputStream { bool IsSerializationDeterministic() const { return serialization_deterministic_is_overridden_ ? serialization_deterministic_override_ : - default_serialization_deterministic_; + IsDefaultSerializationDeterministic(); } static bool IsDefaultSerializationDeterministic() { - return google::protobuf::internal::Acquire_Load(&default_serialization_deterministic_); + return google::protobuf::internal::NoBarrier_Load(&default_serialization_deterministic_); } private: @@ -881,6 +870,7 @@ class LIBPROTOBUF_EXPORT CodedOutputStream { bool serialization_deterministic_is_overridden_; bool serialization_deterministic_override_; // Conceptually, default_serialization_deterministic_ is an atomic bool. + // TODO(haberman): replace with std::atomic<bool> when we move to C++11. static google::protobuf::internal::AtomicWord default_serialization_deterministic_; // Advance the buffer by a given number of bytes. @@ -908,7 +898,7 @@ class LIBPROTOBUF_EXPORT CodedOutputStream { // thread has done so. friend void ::google::protobuf::internal::MapTestForceDeterministic(); static void SetDefaultSerializationDeterministic() { - google::protobuf::internal::Release_Store(&default_serialization_deterministic_, 1); + google::protobuf::internal::NoBarrier_Store(&default_serialization_deterministic_, 1); } }; @@ -1018,48 +1008,21 @@ inline bool CodedInputStream::ReadLittleEndian64(uint64* value) { #endif } -inline uint32 CodedInputStream::ReadTag() { - return ReadTagImplementation<true>(); -} - inline uint32 CodedInputStream::ReadTagNoLastTag() { - return ReadTagImplementation<false>(); -} - -template<bool update_last_tag> -inline uint32 CodedInputStream::ReadTagImplementation() { uint32 v = 0; if (GOOGLE_PREDICT_TRUE(buffer_ < buffer_end_)) { v = *buffer_; if (v < 0x80) { - if (update_last_tag) { - last_tag_ = v; - } Advance(1); return v; } } v = ReadTagFallback(v); - if (update_last_tag) { - last_tag_ = v; - } return v; } -inline std::pair<uint32, bool> CodedInputStream::ReadTagWithCutoff( - uint32 cutoff) { - return ReadTagWithCutoffImplementation<true>(cutoff); -} - inline std::pair<uint32, bool> CodedInputStream::ReadTagWithCutoffNoLastTag( uint32 cutoff) { - return ReadTagWithCutoffImplementation<false>(cutoff); -} - -template<bool update_last_tag> -inline std::pair<uint32, bool> -CodedInputStream::ReadTagWithCutoffImplementation( - uint32 cutoff) { // In performance-sensitive code we can expect cutoff to be a compile-time // constant, and things like "cutoff >= kMax1ByteVarint" to be evaluated at // compile time. @@ -1072,23 +1035,16 @@ CodedInputStream::ReadTagWithCutoffImplementation( if (static_cast<int8>(buffer_[0]) > 0) { const uint32 kMax1ByteVarint = 0x7f; uint32 tag = buffer_[0]; - if (update_last_tag) { - last_tag_ = tag; - } Advance(1); return std::make_pair(tag, cutoff >= kMax1ByteVarint || tag <= cutoff); } // Other hot case: cutoff >= 0x80, buffer_ has at least two bytes available, // and tag is two bytes. The latter is tested by bitwise-and-not of the // first byte and the second byte. - if (cutoff >= 0x80 && - GOOGLE_PREDICT_TRUE(buffer_ + 1 < buffer_end_) && + if (cutoff >= 0x80 && GOOGLE_PREDICT_TRUE(buffer_ + 1 < buffer_end_) && GOOGLE_PREDICT_TRUE((buffer_[0] & ~buffer_[1]) >= 0x80)) { const uint32 kMax2ByteVarint = (0x7f << 7) + 0x7f; uint32 tag = (1u << 7) * buffer_[1] + (buffer_[0] - 0x80); - if (update_last_tag) { - last_tag_ = tag; - } Advance(2); // It might make sense to test for tag == 0 now, but it is so rare that // that we don't bother. A varint-encoded 0 should be one byte unless @@ -1102,9 +1058,6 @@ CodedInputStream::ReadTagWithCutoffImplementation( } // Slow path const uint32 tag = ReadTagFallback(first_byte_or_zero); - if (update_last_tag) { - last_tag_ = tag; - } return std::make_pair(tag, static_cast<uint32>(tag - 1) < cutoff); } @@ -1398,7 +1351,6 @@ inline CodedInputStream::CodedInputStream(ZeroCopyInputStream* input) total_bytes_limit_(kDefaultTotalBytesLimit), recursion_budget_(default_recursion_limit_), recursion_limit_(default_recursion_limit_), - disable_strict_correctness_enforcement_(true), extension_pool_(NULL), extension_factory_(NULL) { // Eagerly Refresh() so buffer space is immediately available. @@ -1419,7 +1371,6 @@ inline CodedInputStream::CodedInputStream(const uint8* buffer, int size) total_bytes_limit_(kDefaultTotalBytesLimit), recursion_budget_(default_recursion_limit_), recursion_limit_(default_recursion_limit_), - disable_strict_correctness_enforcement_(true), extension_pool_(NULL), extension_factory_(NULL) { // Note that setting current_limit_ == size is important to prevent some @@ -1430,11 +1381,25 @@ inline bool CodedInputStream::IsFlat() const { return input_ == NULL; } +inline bool CodedInputStream::Skip(int count) { + if (count < 0) return false; // security: count is often user-supplied + + const int original_buffer_size = BufferSize(); + + if (count <= original_buffer_size) { + // Just skipping within the current buffer. Easy. + Advance(count); + return true; + } + + return SkipFallback(count, original_buffer_size); +} + } // namespace io } // namespace protobuf -#if _MSC_VER >= 1300 && !defined(__INTEL_COMPILER) +#if defined(_MSC_VER) && _MSC_VER >= 1300 && !defined(__INTEL_COMPILER) #pragma runtime_checks("c", restore) #endif // _MSC_VER && !defined(__INTEL_COMPILER) diff --git a/src/google/protobuf/io/printer.cc b/src/google/protobuf/io/printer.cc index 99e895f5..8493268d 100644 --- a/src/google/protobuf/io/printer.cc +++ b/src/google/protobuf/io/printer.cc @@ -111,6 +111,7 @@ void Printer::Print(const std::map<string, string>& variables, int size = strlen(text); int pos = 0; // The number of bytes we've written so far. substitutions_.clear(); + line_start_variables_.clear(); for (int i = 0; i < size; i++) { if (text[i] == '\n') { @@ -122,6 +123,7 @@ void Printer::Print(const std::map<string, string>& variables, // Setting this true will cause the next WriteRaw() to insert an indent // first. at_start_of_line_ = true; + line_start_variables_.clear(); } else if (text[i] == variable_delimiter_) { // Saw the start of a variable name. @@ -148,12 +150,15 @@ void Printer::Print(const std::map<string, string>& variables, if (iter == variables.end()) { GOOGLE_LOG(DFATAL) << " Undefined variable: " << varname; } else { - size_t begin = offset_; + if (at_start_of_line_ && iter->second.empty()) { + line_start_variables_.push_back(varname); + } WriteRaw(iter->second.data(), iter->second.size()); std::pair<std::map<string, std::pair<size_t, size_t> >::iterator, bool> - inserted = substitutions_.insert( - std::make_pair(varname, std::make_pair(begin, offset_))); + inserted = substitutions_.insert(std::make_pair( + varname, + std::make_pair(offset_ - iter->second.size(), offset_))); if (!inserted.second) { // This variable was used multiple times. Make its span have // negative length so we can detect it if it gets used in an @@ -319,10 +324,29 @@ void Printer::WriteRaw(const char* data, int size) { if (at_start_of_line_ && (size > 0) && (data[0] != '\n')) { // Insert an indent. at_start_of_line_ = false; - WriteRaw(indent_.data(), indent_.size()); + CopyToBuffer(indent_.data(), indent_.size()); if (failed_) return; + // Fix up empty variables (e.g., "{") that should be annotated as + // coming after the indent. + for (std::vector<string>::iterator i = line_start_variables_.begin(); + i != line_start_variables_.end(); ++i) { + substitutions_[*i].first += indent_.size(); + substitutions_[*i].second += indent_.size(); + } } + // If we're going to write any data, clear line_start_variables_, since + // we've either updated them in the block above or they no longer refer to + // the current line. + line_start_variables_.clear(); + + CopyToBuffer(data, size); +} + +void Printer::CopyToBuffer(const char* data, int size) { + if (failed_) return; + if (size == 0) return; + while (size > buffer_size_) { // Data exceeds space in the buffer. Copy what we can and request a // new buffer. diff --git a/src/google/protobuf/io/printer.h b/src/google/protobuf/io/printer.h index e666445b..d11745ce 100644 --- a/src/google/protobuf/io/printer.h +++ b/src/google/protobuf/io/printer.h @@ -157,7 +157,7 @@ class AnnotationProtoCollector : public AnnotationCollector { // vars["function"] = "call"; // vars["mark"] = ""; // printer.Print(vars, "$function$($foo$,$foo$)$mark$"); -// printer.Annotate("function", "rmark", call_); +// printer.Annotate("function", "mark", call_); // // This code associates the span covering "call(bar,bar)" in the output with the // call_ descriptor. @@ -311,6 +311,9 @@ class LIBPROTOBUF_EXPORT Printer { void Annotate(const char* begin_varname, const char* end_varname, const string& file_path, const std::vector<int>& path); + // Copy size worth of bytes from data to buffer_. + void CopyToBuffer(const char* data, int size); + const char variable_delimiter_; ZeroCopyOutputStream* const output_; @@ -334,6 +337,11 @@ class LIBPROTOBUF_EXPORT Printer { // length of the substituted string). std::map<string, std::pair<size_t, size_t> > substitutions_; + // Keeps track of the keys in substitutions_ that need to be updated when + // indents are inserted. These are keys that refer to the beginning of the + // current line. + std::vector<string> line_start_variables_; + // Returns true and sets range to the substitution range in the output for // varname if varname was used once in the last call to Print. If varname // was not used, or if it was used multiple times, returns false (and diff --git a/src/google/protobuf/io/printer_unittest.cc b/src/google/protobuf/io/printer_unittest.cc index 0435228a..d0a0ebee 100644 --- a/src/google/protobuf/io/printer_unittest.cc +++ b/src/google/protobuf/io/printer_unittest.cc @@ -360,6 +360,83 @@ TEST(Printer, AnnotateDespiteUnrelatedMultipleUses) { EXPECT_EQ(7, bar->end()); } +TEST(Printer, AnnotateIndent) { + char buffer[8192]; + ArrayOutputStream output(buffer, sizeof(buffer)); + GeneratedCodeInfo info; + AnnotationProtoCollector<GeneratedCodeInfo> info_collector(&info); + { + Printer printer(&output, '$', &info_collector); + printer.Print("0\n"); + printer.Indent(); + printer.Print("$foo$", "foo", "4"); + std::vector<int> path; + path.push_back(44); + MockDescriptor descriptor("path", path); + printer.Annotate("foo", &descriptor); + printer.Print(",\n"); + printer.Print("$bar$", "bar", "9"); + path[0] = 99; + MockDescriptor descriptor_two("path", path); + printer.Annotate("bar", &descriptor_two); + printer.Print("\n${$$D$$}$\n", "{", "", "}", "", "D", "d"); + path[0] = 1313; + MockDescriptor descriptor_three("path", path); + printer.Annotate("{", "}", &descriptor_three); + printer.Outdent(); + printer.Print("\n"); + } + buffer[output.ByteCount()] = '\0'; + EXPECT_STREQ("0\n 4,\n 9\n d\n\n", buffer); + ASSERT_EQ(3, info.annotation_size()); + const GeneratedCodeInfo::Annotation* foo = &info.annotation(0); + ASSERT_EQ(1, foo->path_size()); + EXPECT_EQ(44, foo->path(0)); + EXPECT_EQ("path", foo->source_file()); + EXPECT_EQ(4, foo->begin()); + EXPECT_EQ(5, foo->end()); + const GeneratedCodeInfo::Annotation* bar = &info.annotation(1); + ASSERT_EQ(1, bar->path_size()); + EXPECT_EQ(99, bar->path(0)); + EXPECT_EQ("path", bar->source_file()); + EXPECT_EQ(9, bar->begin()); + EXPECT_EQ(10, bar->end()); + const GeneratedCodeInfo::Annotation* braces = &info.annotation(2); + ASSERT_EQ(1, braces->path_size()); + EXPECT_EQ(1313, braces->path(0)); + EXPECT_EQ("path", braces->source_file()); + EXPECT_EQ(13, braces->begin()); + EXPECT_EQ(14, braces->end()); +} + +TEST(Printer, AnnotateIndentNewline) { + char buffer[8192]; + ArrayOutputStream output(buffer, sizeof(buffer)); + GeneratedCodeInfo info; + AnnotationProtoCollector<GeneratedCodeInfo> info_collector(&info); + { + Printer printer(&output, '$', &info_collector); + printer.Indent(); + printer.Print("$A$$N$$B$C\n", "A", "", "N", "\nz", "B", ""); + std::vector<int> path; + path.push_back(0); + MockDescriptor descriptor("path", path); + printer.Annotate("A", "B", &descriptor); + printer.Outdent(); + printer.Print("\n"); + } + buffer[output.ByteCount()] = '\0'; + EXPECT_STREQ("\nz C\n\n", buffer); + ASSERT_EQ(1, info.annotation_size()); + const GeneratedCodeInfo::Annotation* ab = &info.annotation(0); + ASSERT_EQ(1, ab->path_size()); + EXPECT_EQ(0, ab->path(0)); + EXPECT_EQ("path", ab->source_file()); + EXPECT_EQ(0, ab->begin()); + EXPECT_EQ(4, ab->end()); +} + + TEST(Printer, Indenting) { char buffer[8192]; diff --git a/src/google/protobuf/io/zero_copy_stream.cc b/src/google/protobuf/io/zero_copy_stream.cc index 186de001..f81555e5 100644 --- a/src/google/protobuf/io/zero_copy_stream.cc +++ b/src/google/protobuf/io/zero_copy_stream.cc @@ -41,9 +41,6 @@ namespace google { namespace protobuf { namespace io { -ZeroCopyInputStream::~ZeroCopyInputStream() {} -ZeroCopyOutputStream::~ZeroCopyOutputStream() {} - bool ZeroCopyOutputStream::WriteAliasedRaw(const void* /* data */, int /* size */) { diff --git a/src/google/protobuf/io/zero_copy_stream.h b/src/google/protobuf/io/zero_copy_stream.h index 52650fc6..62ace7ae 100644 --- a/src/google/protobuf/io/zero_copy_stream.h +++ b/src/google/protobuf/io/zero_copy_stream.h @@ -123,8 +123,8 @@ class ZeroCopyOutputStream; // copying. class LIBPROTOBUF_EXPORT ZeroCopyInputStream { public: - inline ZeroCopyInputStream() {} - virtual ~ZeroCopyInputStream(); + ZeroCopyInputStream() {} + virtual ~ZeroCopyInputStream() {} // Obtains a chunk of data from the stream. // @@ -180,8 +180,8 @@ class LIBPROTOBUF_EXPORT ZeroCopyInputStream { // copying. class LIBPROTOBUF_EXPORT ZeroCopyOutputStream { public: - inline ZeroCopyOutputStream() {} - virtual ~ZeroCopyOutputStream(); + ZeroCopyOutputStream() {} + virtual ~ZeroCopyOutputStream() {} // Obtains a buffer into which data can be written. Any data written // into this buffer will eventually (maybe instantly, maybe later on) diff --git a/src/google/protobuf/io/zero_copy_stream_impl.cc b/src/google/protobuf/io/zero_copy_stream_impl.cc index 109c55c1..dd921135 100644 --- a/src/google/protobuf/io/zero_copy_stream_impl.cc +++ b/src/google/protobuf/io/zero_copy_stream_impl.cc @@ -32,9 +32,7 @@ // Based on original Protocol Buffers design by // Sanjay Ghemawat, Jeff Dean, and others. -#ifdef _MSC_VER -#include <io.h> -#else +#ifndef _MSC_VER #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> @@ -43,11 +41,11 @@ #include <errno.h> #include <iostream> #include <algorithm> - #include <google/protobuf/io/zero_copy_stream_impl.h> #include <google/protobuf/stubs/common.h> #include <google/protobuf/stubs/logging.h> #include <google/protobuf/stubs/stl_util.h> +#include <google/protobuf/stubs/io_win32.h> namespace google { @@ -58,6 +56,13 @@ namespace io { // Win32 lseek is broken: If invoked on a non-seekable file descriptor, its // return value is undefined. We re-define it to always produce an error. #define lseek(fd, offset, origin) ((off_t)-1) +// DO NOT include <io.h>, instead create functions in io_win32.{h,cc} and import +// them like we do below. +using google::protobuf::internal::win32::access; +using google::protobuf::internal::win32::close; +using google::protobuf::internal::win32::open; +using google::protobuf::internal::win32::read; +using google::protobuf::internal::win32::write; #endif namespace { @@ -81,8 +86,6 @@ FileInputStream::FileInputStream(int file_descriptor, int block_size) impl_(©ing_input_, block_size) { } -FileInputStream::~FileInputStream() {} - bool FileInputStream::Close() { return copying_input_.Close(); } @@ -273,8 +276,6 @@ bool FileOutputStream::CopyingFileOutputStream::Write( IstreamInputStream::IstreamInputStream(std::istream* input, int block_size) : copying_input_(input), impl_(©ing_input_, block_size) {} -IstreamInputStream::~IstreamInputStream() {} - bool IstreamInputStream::Next(const void** data, int* size) { return impl_.Next(data, size); } @@ -348,9 +349,6 @@ ConcatenatingInputStream::ConcatenatingInputStream( : streams_(streams), stream_count_(count), bytes_retired_(0) { } -ConcatenatingInputStream::~ConcatenatingInputStream() { -} - bool ConcatenatingInputStream::Next(const void** data, int* size) { while (stream_count_ > 0) { if (streams_[0]->Next(data, size)) return true; diff --git a/src/google/protobuf/io/zero_copy_stream_impl.h b/src/google/protobuf/io/zero_copy_stream_impl.h index 3365790e..ea978bfb 100644 --- a/src/google/protobuf/io/zero_copy_stream_impl.h +++ b/src/google/protobuf/io/zero_copy_stream_impl.h @@ -67,7 +67,6 @@ class LIBPROTOBUF_EXPORT FileInputStream : public ZeroCopyInputStream { // should be read and returned with each call to Next(). Otherwise, // a reasonable default is used. explicit FileInputStream(int file_descriptor, int block_size = -1); - ~FileInputStream(); // Flushes any buffers and closes the underlying file. Returns false if // an error occurs during the process; use GetErrno() to examine the error. @@ -219,7 +218,6 @@ class LIBPROTOBUF_EXPORT IstreamInputStream : public ZeroCopyInputStream { // should be read and returned with each call to Next(). Otherwise, // a reasonable default is used. explicit IstreamInputStream(std::istream* stream, int block_size = -1); - ~IstreamInputStream(); // implements ZeroCopyInputStream ---------------------------------- bool Next(const void** data, int* size); @@ -306,7 +304,6 @@ class LIBPROTOBUF_EXPORT ConcatenatingInputStream : public ZeroCopyInputStream { // All streams passed in as well as the array itself must remain valid // until the ConcatenatingInputStream is destroyed. ConcatenatingInputStream(ZeroCopyInputStream* const streams[], int count); - ~ConcatenatingInputStream(); // implements ZeroCopyInputStream ---------------------------------- bool Next(const void** data, int* size); diff --git a/src/google/protobuf/io/zero_copy_stream_impl_lite.cc b/src/google/protobuf/io/zero_copy_stream_impl_lite.cc index e6ca88c2..66ad49bc 100644 --- a/src/google/protobuf/io/zero_copy_stream_impl_lite.cc +++ b/src/google/protobuf/io/zero_copy_stream_impl_lite.cc @@ -64,9 +64,6 @@ ArrayInputStream::ArrayInputStream(const void* data, int size, last_returned_size_(0) { } -ArrayInputStream::~ArrayInputStream() { -} - bool ArrayInputStream::Next(const void** data, int* size) { if (position_ < size_) { last_returned_size_ = std::min(block_size_, size_ - position_); @@ -117,9 +114,6 @@ ArrayOutputStream::ArrayOutputStream(void* data, int size, int block_size) last_returned_size_(0) { } -ArrayOutputStream::~ArrayOutputStream() { -} - bool ArrayOutputStream::Next(void** data, int* size) { if (position_ < size_) { last_returned_size_ = std::min(block_size_, size_ - position_); @@ -153,9 +147,6 @@ StringOutputStream::StringOutputStream(string* target) : target_(target) { } -StringOutputStream::~StringOutputStream() { -} - bool StringOutputStream::Next(void** data, int* size) { GOOGLE_CHECK(target_ != NULL); int old_size = target_->size(); @@ -205,32 +196,6 @@ void StringOutputStream::SetString(string* target) { // =================================================================== -LazyStringOutputStream::LazyStringOutputStream( - ResultCallback<string*>* callback) - : StringOutputStream(NULL), - callback_(GOOGLE_CHECK_NOTNULL(callback)), - string_is_set_(false) { -} - -LazyStringOutputStream::~LazyStringOutputStream() { -} - -bool LazyStringOutputStream::Next(void** data, int* size) { - if (!string_is_set_) { - SetString(callback_->Run()); - string_is_set_ = true; - } - return StringOutputStream::Next(data, size); -} - -int64 LazyStringOutputStream::ByteCount() const { - return string_is_set_ ? StringOutputStream::ByteCount() : 0; -} - -// =================================================================== - -CopyingInputStream::~CopyingInputStream() {} - int CopyingInputStream::Skip(int count) { char junk[4096]; int skipped = 0; @@ -350,8 +315,6 @@ void CopyingInputStreamAdaptor::FreeBuffer() { // =================================================================== -CopyingOutputStream::~CopyingOutputStream() {} - CopyingOutputStreamAdaptor::CopyingOutputStreamAdaptor( CopyingOutputStream* copying_stream, int block_size) : copying_stream_(copying_stream), diff --git a/src/google/protobuf/io/zero_copy_stream_impl_lite.h b/src/google/protobuf/io/zero_copy_stream_impl_lite.h index 6db1d695..ab0fd5ac 100644 --- a/src/google/protobuf/io/zero_copy_stream_impl_lite.h +++ b/src/google/protobuf/io/zero_copy_stream_impl_lite.h @@ -73,7 +73,6 @@ class LIBPROTOBUF_EXPORT ArrayInputStream : public ZeroCopyInputStream { // useful for testing; in production you would probably never want to set // it. ArrayInputStream(const void* data, int size, int block_size = -1); - ~ArrayInputStream(); // implements ZeroCopyInputStream ---------------------------------- bool Next(const void** data, int* size); @@ -107,7 +106,6 @@ class LIBPROTOBUF_EXPORT ArrayOutputStream : public ZeroCopyOutputStream { // useful for testing; in production you would probably never want to set // it. ArrayOutputStream(void* data, int size, int block_size = -1); - ~ArrayOutputStream(); // implements ZeroCopyOutputStream --------------------------------- bool Next(void** data, int* size); @@ -141,7 +139,6 @@ class LIBPROTOBUF_EXPORT StringOutputStream : public ZeroCopyOutputStream { // the first call to Next() will return at least n bytes of buffer // space. explicit StringOutputStream(string* target); - ~StringOutputStream(); // implements ZeroCopyOutputStream --------------------------------- bool Next(void** data, int* size); @@ -159,27 +156,6 @@ class LIBPROTOBUF_EXPORT StringOutputStream : public ZeroCopyOutputStream { GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(StringOutputStream); }; -// LazyStringOutputStream is a StringOutputStream with lazy acquisition of -// the output string from a callback. The string is owned externally, and not -// deleted in the stream destructor. -class LIBPROTOBUF_EXPORT LazyStringOutputStream : public StringOutputStream { - public: - // Callback should be permanent (non-self-deleting). Ownership is transferred - // to the LazyStringOutputStream. - explicit LazyStringOutputStream(ResultCallback<string*>* callback); - ~LazyStringOutputStream(); - - // implements ZeroCopyOutputStream, overriding StringOutputStream ----------- - bool Next(void** data, int* size); - int64 ByteCount() const; - - private: - const google::protobuf::scoped_ptr<ResultCallback<string*> > callback_; - bool string_is_set_; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(LazyStringOutputStream); -}; - // Note: There is no StringInputStream. Instead, just create an // ArrayInputStream as follows: // ArrayInputStream input(str.data(), str.size()); @@ -199,7 +175,7 @@ class LIBPROTOBUF_EXPORT LazyStringOutputStream : public StringOutputStream { // in large blocks. class LIBPROTOBUF_EXPORT CopyingInputStream { public: - virtual ~CopyingInputStream(); + virtual ~CopyingInputStream() {} // Reads up to "size" bytes into the given buffer. Returns the number of // bytes read. Read() waits until at least one byte is available, or @@ -293,7 +269,7 @@ class LIBPROTOBUF_EXPORT CopyingInputStreamAdaptor : public ZeroCopyInputStream // in large blocks. class LIBPROTOBUF_EXPORT CopyingOutputStream { public: - virtual ~CopyingOutputStream(); + virtual ~CopyingOutputStream() {} // Writes "size" bytes from the given buffer to the output. Returns true // if successful, false on a write error. diff --git a/src/google/protobuf/io/zero_copy_stream_unittest.cc b/src/google/protobuf/io/zero_copy_stream_unittest.cc index 235cbca4..91792f18 100644 --- a/src/google/protobuf/io/zero_copy_stream_unittest.cc +++ b/src/google/protobuf/io/zero_copy_stream_unittest.cc @@ -47,9 +47,7 @@ // implementations. -#ifdef _MSC_VER -#include <io.h> -#else +#ifndef _MSC_VER #include <unistd.h> #endif #include <stdlib.h> @@ -76,6 +74,7 @@ #include <google/protobuf/testing/googletest.h> #include <google/protobuf/testing/file.h> #include <gtest/gtest.h> +#include <google/protobuf/stubs/io_win32.h> namespace google { namespace protobuf { @@ -84,6 +83,12 @@ namespace { #ifdef _WIN32 #define pipe(fds) _pipe(fds, 4096, O_BINARY) +// DO NOT include <io.h>, instead create functions in io_win32.{h,cc} and import +// them like we do below. +using google::protobuf::internal::win32::access; +using google::protobuf::internal::win32::mkdir; +using google::protobuf::internal::win32::open; +using google::protobuf::internal::win32::close; #endif #ifndef O_BINARY diff --git a/src/google/protobuf/lite_arena_unittest.cc b/src/google/protobuf/lite_arena_unittest.cc index f0bee880..dadaffb6 100644 --- a/src/google/protobuf/lite_arena_unittest.cc +++ b/src/google/protobuf/lite_arena_unittest.cc @@ -37,13 +37,22 @@ namespace google { namespace protobuf { namespace { -TEST(LiteArenaTest, MapNoHeapAllocation) { - // Allocate a large initial block to avoid mallocs during hooked test. - std::vector<char> arena_block(128 * 1024); - google::protobuf::ArenaOptions options; - options.initial_block = &arena_block[0]; - options.initial_block_size = arena_block.size(); - google::protobuf::Arena arena(options); +class LiteArenaTest : public testing::Test { + protected: + LiteArenaTest() { + ArenaOptions options; + options.start_block_size = 128 * 1024; + options.max_block_size = 128 * 1024; + arena_.reset(new Arena(options)); + // Trigger the allocation of the first arena block, so that further use of + // the arena will not require any heap allocations. + google::protobuf::Arena::CreateArray<char>(arena_.get(), 1); + } + + google::protobuf::scoped_ptr<Arena> arena_; +}; + +TEST_F(LiteArenaTest, MapNoHeapAllocation) { string data; data.reserve(128 * 1024); @@ -53,22 +62,21 @@ TEST(LiteArenaTest, MapNoHeapAllocation) { // google::protobuf::internal::NoHeapChecker no_heap; protobuf_unittest::TestArenaMapLite* from = - google::protobuf::Arena::CreateMessage<protobuf_unittest::TestArenaMapLite>(&arena); + Arena::CreateMessage<protobuf_unittest::TestArenaMapLite>(arena_.get()); google::protobuf::MapLiteTestUtil::SetArenaMapFields(from); from->SerializeToString(&data); protobuf_unittest::TestArenaMapLite* to = - google::protobuf::Arena::CreateMessage<protobuf_unittest::TestArenaMapLite>(&arena); + Arena::CreateMessage<protobuf_unittest::TestArenaMapLite>(arena_.get()); to->ParseFromString(data); google::protobuf::MapLiteTestUtil::ExpectArenaMapFieldsSet(*to); } } -TEST(LiteArenaTest, UnknownFieldMemLeak) { - google::protobuf::Arena arena; +TEST_F(LiteArenaTest, UnknownFieldMemLeak) { protobuf_unittest::ForeignMessageArenaLite* message = google::protobuf::Arena::CreateMessage<protobuf_unittest::ForeignMessageArenaLite>( - &arena); + arena_.get()); string data = "\012\000"; int original_capacity = data.capacity(); while (data.capacity() <= original_capacity) { diff --git a/src/google/protobuf/lite_unittest.cc b/src/google/protobuf/lite_unittest.cc index 2f5268af..d6693963 100644 --- a/src/google/protobuf/lite_unittest.cc +++ b/src/google/protobuf/lite_unittest.cc @@ -48,6 +48,8 @@ #include <google/protobuf/stubs/strutil.h> +using std::string; + namespace { // Helper methods to test parsing merge behavior. void ExpectMessageMerged(const google::protobuf::unittest::TestAllTypesLite& message) { @@ -71,7 +73,7 @@ void SetAllTypesInEmptyMessageUnknownFields( protobuf_unittest::TestAllTypesLite message; google::protobuf::TestUtilLite::ExpectClear(message); google::protobuf::TestUtilLite::SetAllFields(&message); - std::string data = message.SerializeAsString(); + string data = message.SerializeAsString(); empty_message->ParseFromString(data); } @@ -83,14 +85,14 @@ void SetSomeTypesInEmptyMessageUnknownFields( message.set_optional_int64(102); message.set_optional_uint32(103); message.set_optional_uint64(104); - std::string data = message.SerializeAsString(); + string data = message.SerializeAsString(); empty_message->ParseFromString(data); } } // namespace TEST(Lite, AllLite1) { - std::string data; + string data; { protobuf_unittest::TestAllTypesLite message, message2, message3; @@ -110,13 +112,13 @@ TEST(Lite, AllLite1) { } TEST(Lite, AllLite2) { - std::string data; + string data; { protobuf_unittest::TestAllExtensionsLite message, message2, message3; google::protobuf::TestUtilLite::ExpectExtensionsClear(message); google::protobuf::TestUtilLite::SetAllExtensions(&message); message2.CopyFrom(message); - std::string extensions_data = message.SerializeAsString(); + string extensions_data = message.SerializeAsString(); message3.ParseFromString(extensions_data); google::protobuf::TestUtilLite::ExpectAllExtensionsSet(message); google::protobuf::TestUtilLite::ExpectAllExtensionsSet(message2); @@ -129,7 +131,7 @@ TEST(Lite, AllLite2) { } TEST(Lite, AllLite3) { - std::string data, packed_data; + string data, packed_data; { protobuf_unittest::TestPackedTypesLite message, message2, message3; @@ -152,7 +154,7 @@ TEST(Lite, AllLite3) { google::protobuf::TestUtilLite::ExpectPackedExtensionsClear(message); google::protobuf::TestUtilLite::SetPackedExtensions(&message); message2.CopyFrom(message); - std::string packed_extensions_data = message.SerializeAsString(); + string packed_extensions_data = message.SerializeAsString(); EXPECT_EQ(packed_extensions_data, packed_data); message3.ParseFromString(packed_extensions_data); google::protobuf::TestUtilLite::ExpectPackedExtensionsSet(message); @@ -166,7 +168,7 @@ TEST(Lite, AllLite3) { } TEST(Lite, AllLite5) { - std::string data; + string data; { // Test that if an optional or required message/group field appears multiple @@ -200,7 +202,7 @@ TEST(Lite, AllLite5) { #undef ASSIGN_REPEATED_GROUP - std::string buffer; + string buffer; generator.SerializeToString(&buffer); google::protobuf::unittest::TestParsingMergeLite parsing_merge; parsing_merge.ParseFromString(buffer); @@ -223,7 +225,7 @@ TEST(Lite, AllLite5) { } TEST(Lite, AllLite6) { - std::string data; + string data; // Test unknown fields support for lite messages. { @@ -244,7 +246,7 @@ TEST(Lite, AllLite6) { } TEST(Lite, AllLite7) { - std::string data; + string data; { protobuf_unittest::TestAllExtensionsLite message, message2; @@ -264,7 +266,7 @@ TEST(Lite, AllLite7) { } TEST(Lite, AllLite8) { - std::string data; + string data; { protobuf_unittest::TestPackedTypesLite message, message2; @@ -284,7 +286,7 @@ TEST(Lite, AllLite8) { } TEST(Lite, AllLite9) { - std::string data; + string data; { protobuf_unittest::TestPackedExtensionsLite message, message2; @@ -304,7 +306,7 @@ TEST(Lite, AllLite9) { } TEST(Lite, AllLite10) { - std::string data; + string data; { // Test Unknown fields swap @@ -312,7 +314,7 @@ TEST(Lite, AllLite10) { SetAllTypesInEmptyMessageUnknownFields(&empty_message); SetSomeTypesInEmptyMessageUnknownFields(&empty_message2); data = empty_message.SerializeAsString(); - std::string data2 = empty_message2.SerializeAsString(); + string data2 = empty_message2.SerializeAsString(); empty_message.Swap(&empty_message2); EXPECT_EQ(data, empty_message2.SerializeAsString()); EXPECT_EQ(data2, empty_message.SerializeAsString()); @@ -320,7 +322,7 @@ TEST(Lite, AllLite10) { } TEST(Lite, AllLite11) { - std::string data; + string data; { // Test unknown fields swap with self @@ -333,7 +335,7 @@ TEST(Lite, AllLite11) { } TEST(Lite, AllLite12) { - std::string data; + string data; { // Test MergeFrom with unknown fields @@ -363,12 +365,12 @@ TEST(Lite, AllLite12) { } TEST(Lite, AllLite13) { - std::string data; + string data; { // Test unknown enum value protobuf_unittest::TestAllTypesLite message; - std::string buffer; + string buffer; { google::protobuf::io::StringOutputStream output_stream(&buffer); google::protobuf::io::CodedOutputStream coded_output(&output_stream); @@ -388,7 +390,7 @@ TEST(Lite, AllLite13) { } TEST(Lite, AllLite14) { - std::string data; + string data; { // Test Clear with unknown fields @@ -402,7 +404,7 @@ TEST(Lite, AllLite14) { // Tests for map lite ============================================= TEST(Lite, AllLite15) { - std::string data; + string data; { // Accessors @@ -417,7 +419,7 @@ TEST(Lite, AllLite15) { } TEST(Lite, AllLite16) { - std::string data; + string data; { // SetMapFieldsInitialized @@ -429,7 +431,7 @@ TEST(Lite, AllLite16) { } TEST(Lite, AllLite17) { - std::string data; + string data; { // Clear @@ -442,7 +444,7 @@ TEST(Lite, AllLite17) { } TEST(Lite, AllLite18) { - std::string data; + string data; { // ClearMessageMap @@ -455,7 +457,7 @@ TEST(Lite, AllLite18) { } TEST(Lite, AllLite19) { - std::string data; + string data; { // CopyFrom @@ -472,7 +474,7 @@ TEST(Lite, AllLite19) { } TEST(Lite, AllLite20) { - std::string data; + string data; { // CopyFromMessageMap @@ -490,7 +492,7 @@ TEST(Lite, AllLite20) { } TEST(Lite, AllLite21) { - std::string data; + string data; { // SwapWithEmpty @@ -507,7 +509,7 @@ TEST(Lite, AllLite21) { } TEST(Lite, AllLite22) { - std::string data; + string data; { // SwapWithSelf @@ -522,7 +524,7 @@ TEST(Lite, AllLite22) { } TEST(Lite, AllLite23) { - std::string data; + string data; { // SwapWithOther @@ -539,7 +541,7 @@ TEST(Lite, AllLite23) { } TEST(Lite, AllLite24) { - std::string data; + string data; { // CopyConstructor @@ -552,7 +554,7 @@ TEST(Lite, AllLite24) { } TEST(Lite, AllLite25) { - std::string data; + string data; { // CopyAssignmentOperator @@ -570,7 +572,7 @@ TEST(Lite, AllLite25) { } TEST(Lite, AllLite26) { - std::string data; + string data; { // NonEmptyMergeFrom @@ -592,7 +594,7 @@ TEST(Lite, AllLite26) { } TEST(Lite, AllLite27) { - std::string data; + string data; { // MergeFromMessageMap @@ -610,12 +612,12 @@ TEST(Lite, AllLite27) { } TEST(Lite, AllLite28) { - std::string data; + string data; { // Test the generated SerializeWithCachedSizesToArray() protobuf_unittest::TestMapLite message1, message2; - std::string data; + string data; google::protobuf::MapLiteTestUtil::SetMapFields(&message1); int size = message1.ByteSize(); data.resize(size); @@ -628,14 +630,14 @@ TEST(Lite, AllLite28) { } TEST(Lite, AllLite29) { - std::string data; + string data; { // Test the generated SerializeWithCachedSizes() protobuf_unittest::TestMapLite message1, message2; google::protobuf::MapLiteTestUtil::SetMapFields(&message1); int size = message1.ByteSize(); - std::string data; + string data; data.resize(size); { // Allow the output stream to buffer only one byte at a time. @@ -653,7 +655,7 @@ TEST(Lite, AllLite29) { TEST(Lite, AllLite32) { - std::string data; + string data; { // Proto2UnknownEnum @@ -662,7 +664,7 @@ TEST(Lite, AllLite32) { protobuf_unittest::E_PROTO2_MAP_ENUM_FOO_LITE; (*from.mutable_unknown_map_field())[0] = protobuf_unittest::E_PROTO2_MAP_ENUM_EXTRA_LITE; - std::string data; + string data; from.SerializeToString(&data); protobuf_unittest::TestEnumMapLite to; @@ -687,12 +689,12 @@ TEST(Lite, AllLite32) { } TEST(Lite, AllLite33) { - std::string data; + string data; { // StandardWireFormat protobuf_unittest::TestMapLite message; - std::string data = "\x0A\x04\x08\x01\x10\x01"; + string data = "\x0A\x04\x08\x01\x10\x01"; EXPECT_TRUE(message.ParseFromString(data)); EXPECT_EQ(1, message.map_int32_int32().size()); @@ -701,14 +703,14 @@ TEST(Lite, AllLite33) { } TEST(Lite, AllLite34) { - std::string data; + string data; { // UnorderedWireFormat protobuf_unittest::TestMapLite message; // put value before key in wire format - std::string data = "\x0A\x04\x10\x01\x08\x02"; + string data = "\x0A\x04\x10\x01\x08\x02"; EXPECT_TRUE(message.ParseFromString(data)); EXPECT_EQ(1, message.map_int32_int32().size()); @@ -717,14 +719,14 @@ TEST(Lite, AllLite34) { } TEST(Lite, AllLite35) { - std::string data; + string data; { // DuplicatedKeyWireFormat protobuf_unittest::TestMapLite message; // Two key fields in wire format - std::string data = "\x0A\x06\x08\x01\x08\x02\x10\x01"; + string data = "\x0A\x06\x08\x01\x08\x02\x10\x01"; EXPECT_TRUE(message.ParseFromString(data)); EXPECT_EQ(1, message.map_int32_int32().size()); @@ -733,14 +735,14 @@ TEST(Lite, AllLite35) { } TEST(Lite, AllLite36) { - std::string data; + string data; { // DuplicatedValueWireFormat protobuf_unittest::TestMapLite message; // Two value fields in wire format - std::string data = "\x0A\x06\x08\x01\x10\x01\x10\x02"; + string data = "\x0A\x06\x08\x01\x10\x01\x10\x02"; EXPECT_TRUE(message.ParseFromString(data)); EXPECT_EQ(1, message.map_int32_int32().size()); @@ -749,14 +751,14 @@ TEST(Lite, AllLite36) { } TEST(Lite, AllLite37) { - std::string data; + string data; { // MissedKeyWireFormat protobuf_unittest::TestMapLite message; // No key field in wire format - std::string data = "\x0A\x02\x10\x01"; + string data = "\x0A\x02\x10\x01"; EXPECT_TRUE(message.ParseFromString(data)); EXPECT_EQ(1, message.map_int32_int32().size()); @@ -765,14 +767,14 @@ TEST(Lite, AllLite37) { } TEST(Lite, AllLite38) { - std::string data; + string data; { // MissedValueWireFormat protobuf_unittest::TestMapLite message; // No value field in wire format - std::string data = "\x0A\x02\x08\x01"; + string data = "\x0A\x02\x08\x01"; EXPECT_TRUE(message.ParseFromString(data)); EXPECT_EQ(1, message.map_int32_int32().size()); @@ -781,14 +783,14 @@ TEST(Lite, AllLite38) { } TEST(Lite, AllLite39) { - std::string data; + string data; { // UnknownFieldWireFormat protobuf_unittest::TestMapLite message; // Unknown field in wire format - std::string data = "\x0A\x06\x08\x02\x10\x03\x18\x01"; + string data = "\x0A\x06\x08\x02\x10\x03\x18\x01"; EXPECT_TRUE(message.ParseFromString(data)); EXPECT_EQ(1, message.map_int32_int32().size()); @@ -797,21 +799,21 @@ TEST(Lite, AllLite39) { } TEST(Lite, AllLite40) { - std::string data; + string data; { // CorruptedWireFormat protobuf_unittest::TestMapLite message; // corrupted data in wire format - std::string data = "\x0A\x06\x08\x02\x11\x03"; + string data = "\x0A\x06\x08\x02\x11\x03"; EXPECT_FALSE(message.ParseFromString(data)); } } TEST(Lite, AllLite41) { - std::string data; + string data; { // IsInitialized @@ -830,7 +832,7 @@ TEST(Lite, AllLite41) { } TEST(Lite, AllLite42) { - std::string data; + string data; { // Check that adding more values to enum does not corrupt message @@ -839,7 +841,7 @@ TEST(Lite, AllLite42) { v2_message.set_int_field(800); // Set enum field to the value not understood by the old client. v2_message.set_enum_field(protobuf_unittest::V2_SECOND); - std::string v2_bytes = v2_message.SerializeAsString(); + string v2_bytes = v2_message.SerializeAsString(); protobuf_unittest::V1MessageLite v1_message; v1_message.ParseFromString(v2_bytes); @@ -850,7 +852,7 @@ TEST(Lite, AllLite42) { EXPECT_EQ(v1_message.enum_field(), protobuf_unittest::V1_FIRST); // However, when re-serialized, it should preserve enum value. - std::string v1_bytes = v1_message.SerializeAsString(); + string v1_bytes = v1_message.SerializeAsString(); protobuf_unittest::V2MessageLite same_v2_message; same_v2_message.ParseFromString(v1_bytes); @@ -858,6 +860,146 @@ TEST(Lite, AllLite42) { EXPECT_EQ(v2_message.int_field(), same_v2_message.int_field()); EXPECT_EQ(v2_message.enum_field(), same_v2_message.enum_field()); } +} + +// Test that when parsing a oneof, we can successfully clear whatever already +// happened to be stored in the oneof. +TEST(Lite, AllLite43) { + protobuf_unittest::TestOneofParsingLite message1; + + message1.set_oneof_int32(17); + string serialized; + EXPECT_TRUE(message1.SerializeToString(&serialized)); + + // Submessage + { + protobuf_unittest::TestOneofParsingLite message2; + message2.mutable_oneof_submessage(); + google::protobuf::io::CodedInputStream input_stream( + reinterpret_cast<const ::google::protobuf::uint8*>(serialized.data()), serialized.size()); + EXPECT_TRUE(message2.MergeFromCodedStream(&input_stream)); + EXPECT_EQ(17, message2.oneof_int32()); + } + + // String + { + protobuf_unittest::TestOneofParsingLite message2; + message2.set_oneof_string("string"); + google::protobuf::io::CodedInputStream input_stream( + reinterpret_cast<const ::google::protobuf::uint8*>(serialized.data()), serialized.size()); + EXPECT_TRUE(message2.MergeFromCodedStream(&input_stream)); + EXPECT_EQ(17, message2.oneof_int32()); + } + + // Bytes + { + protobuf_unittest::TestOneofParsingLite message2; + message2.set_oneof_bytes("bytes"); + google::protobuf::io::CodedInputStream input_stream( + reinterpret_cast<const ::google::protobuf::uint8*>(serialized.data()), serialized.size()); + EXPECT_TRUE(message2.MergeFromCodedStream(&input_stream)); + EXPECT_EQ(17, message2.oneof_int32()); + } +} + +// Verify that we can successfully parse fields of various types within oneof +// fields. We also verify that we can parse the same data twice into the same +// message. +TEST(Lite, AllLite44) { + // Int32 + { + protobuf_unittest::TestOneofParsingLite original; + original.set_oneof_int32(17); + string serialized; + EXPECT_TRUE(original.SerializeToString(&serialized)); + protobuf_unittest::TestOneofParsingLite parsed; + for (int i = 0; i < 2; ++i) { + google::protobuf::io::CodedInputStream input_stream( + reinterpret_cast<const ::google::protobuf::uint8*>(serialized.data()), + serialized.size()); + EXPECT_TRUE(parsed.MergeFromCodedStream(&input_stream)); + EXPECT_EQ(17, parsed.oneof_int32()); + } + } + + // Submessage + { + protobuf_unittest::TestOneofParsingLite original; + original.mutable_oneof_submessage()->set_optional_int32(5); + string serialized; + EXPECT_TRUE(original.SerializeToString(&serialized)); + protobuf_unittest::TestOneofParsingLite parsed; + for (int i = 0; i < 2; ++i) { + google::protobuf::io::CodedInputStream input_stream( + reinterpret_cast<const ::google::protobuf::uint8*>(serialized.data()), + serialized.size()); + EXPECT_TRUE(parsed.MergeFromCodedStream(&input_stream)); + EXPECT_EQ(5, parsed.oneof_submessage().optional_int32()); + } + } + + // String + { + protobuf_unittest::TestOneofParsingLite original; + original.set_oneof_string("string"); + string serialized; + EXPECT_TRUE(original.SerializeToString(&serialized)); + protobuf_unittest::TestOneofParsingLite parsed; + for (int i = 0; i < 2; ++i) { + google::protobuf::io::CodedInputStream input_stream( + reinterpret_cast<const ::google::protobuf::uint8*>(serialized.data()), + serialized.size()); + EXPECT_TRUE(parsed.MergeFromCodedStream(&input_stream)); + EXPECT_EQ("string", parsed.oneof_string()); + } + } + + // Bytes + { + protobuf_unittest::TestOneofParsingLite original; + original.set_oneof_bytes("bytes"); + string serialized; + EXPECT_TRUE(original.SerializeToString(&serialized)); + protobuf_unittest::TestOneofParsingLite parsed; + for (int i = 0; i < 2; ++i) { + google::protobuf::io::CodedInputStream input_stream( + reinterpret_cast<const ::google::protobuf::uint8*>(serialized.data()), + serialized.size()); + EXPECT_TRUE(parsed.MergeFromCodedStream(&input_stream)); + EXPECT_EQ("bytes", parsed.oneof_bytes()); + } + } + + // Enum + { + protobuf_unittest::TestOneofParsingLite original; + original.set_oneof_enum(protobuf_unittest::V2_SECOND); + string serialized; + EXPECT_TRUE(original.SerializeToString(&serialized)); + protobuf_unittest::TestOneofParsingLite parsed; + for (int i = 0; i < 2; ++i) { + google::protobuf::io::CodedInputStream input_stream( + reinterpret_cast<const ::google::protobuf::uint8*>(serialized.data()), + serialized.size()); + EXPECT_TRUE(parsed.MergeFromCodedStream(&input_stream)); + EXPECT_EQ(protobuf_unittest::V2_SECOND, parsed.oneof_enum()); + } + } std::cout << "PASS" << std::endl; } + +TEST(Lite, AllLite45) { + // Test unknown fields are not discarded upon parsing. + string data = "\20\1"; // varint 1 with field number 2 + + protobuf_unittest::ForeignMessageLite a; + EXPECT_TRUE(a.ParseFromString(data)); + google::protobuf::io::CodedInputStream input_stream( + reinterpret_cast<const ::google::protobuf::uint8*>(data.data()), data.size()); + EXPECT_TRUE(a.MergePartialFromCodedStream(&input_stream)); + + string serialized = a.SerializeAsString(); + EXPECT_EQ(serialized.substr(0, 2), data); + EXPECT_EQ(serialized.substr(2), data); +} diff --git a/src/google/protobuf/map.h b/src/google/protobuf/map.h index e5a32c5c..a75fb786 100644 --- a/src/google/protobuf/map.h +++ b/src/google/protobuf/map.h @@ -48,6 +48,10 @@ #include <google/protobuf/map_type_handler.h> #include <google/protobuf/stubs/hash.h> +#if LANG_CXX11 +#include <initializer_list> +#endif + namespace google { namespace protobuf { @@ -142,6 +146,26 @@ class Map { insert(other.begin(), other.end()); } +#if LANG_CXX11 + Map(Map&& other) noexcept : Map() { + if (other.arena_) { + *this = other; + } else { + swap(other); + } + } + Map& operator=(Map&& other) noexcept { + if (this != &other) { + if (arena_ != other.arena_) { + *this = other; + } else { + swap(other); + } + } + return *this; + } +#endif + template <class InputIt> Map(const InputIt& first, const InputIt& last) : arena_(NULL), default_enum_value_(0) { @@ -158,7 +182,7 @@ class Map { private: void Init() { - elements_ = Arena::Create<InnerMap>(arena_, 0, hasher(), Allocator(arena_)); + elements_ = Arena::Create<InnerMap>(arena_, 0u, hasher(), Allocator(arena_)); } // re-implement std::allocator to use arena allocator for memory allocation. @@ -181,7 +205,7 @@ class Map { MapAllocator(const MapAllocator<X>& allocator) : arena_(allocator.arena()) {} - pointer allocate(size_type n, const void* hint = 0) { + pointer allocate(size_type n, const void* /* hint */ = 0) { // If arena is not given, malloc needs to be called which doesn't // construct element object. if (arena_ == NULL) { @@ -197,6 +221,7 @@ class Map { #if defined(__GXX_DELETE_WITH_SIZE__) || defined(__cpp_sized_deallocation) ::operator delete(p, n * sizeof(value_type)); #else + (void)n; ::operator delete(p); #endif } @@ -720,7 +745,7 @@ class Map { return true; } } else if (GOOGLE_PREDICT_FALSE(new_size <= lo_cutoff && - num_buckets_ > kMinTableSize)) { + num_buckets_ > kMinTableSize)) { size_type lg2_of_size_reduction_factor = 1; // It's possible we want to shrink a lot here... size() could even be 0. // So, estimate how much to shrink by making sure we don't shrink so @@ -862,14 +887,7 @@ class Map { size_type BucketNumber(const Key& k) const { // We inherit from hasher, so one-arg operator() provides a hash function. size_type h = (*const_cast<InnerMap*>(this))(k); - // To help prevent people from making assumptions about the hash function, - // we use the seed differently depending on NDEBUG. The default hash - // function, the seeding, etc., are all likely to change in the future. -#ifndef NDEBUG - return (h * (seed_ | 1)) & (num_buckets_ - 1); -#else return (h + seed_) & (num_buckets_ - 1); -#endif } bool IsMatch(const Key& k0, const Key& k1) const { @@ -939,12 +957,16 @@ class Map { public: // Iterators - class const_iterator - : public std::iterator<std::forward_iterator_tag, value_type, ptrdiff_t, - const value_type*, const value_type&> { + class const_iterator { typedef typename InnerMap::const_iterator InnerIt; public: + typedef std::forward_iterator_tag iterator_category; + typedef typename Map::value_type value_type; + typedef ptrdiff_t difference_type; + typedef const value_type* pointer; + typedef const value_type& reference; + const_iterator() {} explicit const_iterator(const InnerIt& it) : it_(it) {} @@ -970,10 +992,16 @@ class Map { InnerIt it_; }; - class iterator : public std::iterator<std::forward_iterator_tag, value_type> { + class iterator { typedef typename InnerMap::iterator InnerIt; public: + typedef std::forward_iterator_tag iterator_category; + typedef typename Map::value_type value_type; + typedef ptrdiff_t difference_type; + typedef value_type* pointer; + typedef value_type& reference; + iterator() {} explicit iterator(const InnerIt& it) : it_(it) {} @@ -1032,12 +1060,12 @@ class Map { } const T& at(const key_type& key) const { const_iterator it = find(key); - GOOGLE_CHECK(it != end()); + GOOGLE_CHECK(it != end()) << "key not found: " << key; return it->second; } T& at(const key_type& key) { iterator it = find(key); - GOOGLE_CHECK(it != end()); + GOOGLE_CHECK(it != end()) << "key not found: " << key; return it->second; } @@ -1089,6 +1117,11 @@ class Map { } } } +#if LANG_CXX11 + void insert(std::initializer_list<value_type> values) { + insert(values.begin(), values.end()); + } +#endif // Erase and clear size_type erase(const key_type& key) { @@ -1138,9 +1171,7 @@ class Map { // Access to hasher. Currently this returns a copy, but it may // be modified to return a const reference in the future. - hasher hash_function() const { - return elements_->hash_function(); - } + hasher hash_function() const { return elements_->hash_function(); } private: // Set default enum value only for proto2 map field whose value is enum type. diff --git a/src/google/protobuf/map_entry.h b/src/google/protobuf/map_entry.h index 7c675568..801def97 100644 --- a/src/google/protobuf/map_entry.h +++ b/src/google/protobuf/map_entry.h @@ -87,28 +87,6 @@ class MapEntry : public MapEntryImpl<Derived, Message, Key, Value, kKeyFieldType, kValueFieldType, default_enum_value> { public: - // Create default MapEntry instance for given descriptor. Descriptor has to be - // given when creating default MapEntry instance because different map field - // may have the same type and MapEntry class. The given descriptor is needed - // to distinguish instances of the same MapEntry class. - static const Reflection* CreateReflection(const Descriptor* descriptor, - const Derived* entry) { - ReflectionSchema schema = { - entry, - offsets_, - has_bits_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MapEntry, _has_bits_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MapEntry, - _internal_metadata_), - -1, - -1, - sizeof(MapEntry)}; - const Reflection* reflection = new GeneratedMessageReflection( - descriptor, schema, DescriptorPool::generated_pool(), - MessageFactory::generated_factory()); - return reflection; - } - MapEntry() : _internal_metadata_(NULL) {} explicit MapEntry(Arena* arena) : MapEntryImpl<Derived, Message, Key, Value, kKeyFieldType, @@ -117,11 +95,9 @@ class MapEntry typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - private: - static uint32 offsets_[2]; - static uint32 has_bits_[2]; InternalMetadataWithArena _internal_metadata_; + private: friend class ::google::protobuf::Arena; template <typename C, typename K, typename V, WireFormatLite::FieldType k_wire_type, WireFormatLite::FieldType, @@ -132,20 +108,30 @@ class MapEntry GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MapEntry); }; +// Specialization for the full runtime template <typename Derived, typename Key, typename Value, WireFormatLite::FieldType kKeyFieldType, WireFormatLite::FieldType kValueFieldType, int default_enum_value> -uint32 MapEntry<Derived, Key, Value, kKeyFieldType, kValueFieldType, - default_enum_value>::offsets_[2] = { - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MapEntry, key_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MapEntry, value_), +struct MapEntryHelper<MapEntry<Derived, Key, Value, kKeyFieldType, + kValueFieldType, default_enum_value> > + : MapEntryHelper<MapEntryLite<Derived, Key, Value, kKeyFieldType, + kValueFieldType, default_enum_value> > { + explicit MapEntryHelper(const MapPair<Key, Value>& map_pair) + : MapEntryHelper<MapEntryLite<Derived, Key, Value, kKeyFieldType, + kValueFieldType, default_enum_value> >( + map_pair) {} }; -template <typename Derived, typename Key, typename Value, - WireFormatLite::FieldType kKeyFieldType, - WireFormatLite::FieldType kValueFieldType, int default_enum_value> -uint32 MapEntry<Derived, Key, Value, kKeyFieldType, kValueFieldType, - default_enum_value>::has_bits_[2] = {0, 1}; +template <typename Derived, typename K, typename V, + WireFormatLite::FieldType key, WireFormatLite::FieldType value, + int default_enum> +struct DeconstructMapEntry<MapEntry<Derived, K, V, key, value, default_enum> > { + typedef K Key; + typedef V Value; + static const WireFormatLite::FieldType kKeyFieldType = key; + static const WireFormatLite::FieldType kValueFieldType = value; + static const int default_enum_value = default_enum; +}; } // namespace internal } // namespace protobuf diff --git a/src/google/protobuf/map_entry_lite.h b/src/google/protobuf/map_entry_lite.h index c466cc7b..dc6ec917 100644 --- a/src/google/protobuf/map_entry_lite.h +++ b/src/google/protobuf/map_entry_lite.h @@ -34,7 +34,10 @@ #include <assert.h> #include <google/protobuf/arena.h> +#include <google/protobuf/arenastring.h> +#include <google/protobuf/map.h> #include <google/protobuf/map_type_handler.h> +#include <google/protobuf/stubs/port.h> #include <google/protobuf/wire_format_lite_inl.h> namespace google { @@ -131,14 +134,14 @@ class MapEntryImpl : public Base { static const WireFormatLite::FieldType kEntryValueFieldType = kValueFieldType; static const int kEntryDefaultEnumValue = default_enum_value; - MapEntryImpl() : default_instance_(NULL), arena_(NULL) { + MapEntryImpl() : arena_(NULL) { KeyTypeHandler::Initialize(&key_, NULL); ValueTypeHandler::InitializeMaybeByDefaultEnum(&value_, default_enum_value, NULL); _has_bits_[0] = 0; } - explicit MapEntryImpl(Arena* arena) : default_instance_(NULL), arena_(arena) { + explicit MapEntryImpl(Arena* arena) : arena_(arena) { KeyTypeHandler::Initialize(&key_, arena); ValueTypeHandler::InitializeMaybeByDefaultEnum(&value_, default_enum_value, arena); @@ -146,11 +149,9 @@ class MapEntryImpl : public Base { } ~MapEntryImpl() { - if (this != default_instance_) { - if (GetArenaNoVirtual() != NULL) return; - KeyTypeHandler::DeleteNoArena(key_); - ValueTypeHandler::DeleteNoArena(value_); - } + if (GetArenaNoVirtual() != NULL) return; + KeyTypeHandler::DeleteNoArena(key_); + ValueTypeHandler::DeleteNoArena(value_); } // accessors ====================================================== @@ -159,9 +160,8 @@ class MapEntryImpl : public Base { return KeyTypeHandler::GetExternalReference(key_); } virtual inline const ValueMapEntryAccessorType& value() const { - GOOGLE_CHECK(default_instance_ != NULL); - return ValueTypeHandler::DefaultIfNotInitialized(value_, - default_instance_->value_); + return ValueTypeHandler::DefaultIfNotInitialized( + value_, Derived::internal_default_instance()->value_); } inline KeyMapEntryAccessorType* mutable_key() { set_has_key(); @@ -201,8 +201,7 @@ class MapEntryImpl : public Base { return false; } set_has_key(); - if (!input->ExpectTag(kValueTag)) break; - GOOGLE_FALLTHROUGH_INTENDED; + break; case kValueTag: if (!ValueTypeHandler::Read(input, mutable_value())) { @@ -226,8 +225,10 @@ class MapEntryImpl : public Base { size_t ByteSizeLong() const { size_t size = 0; - size += has_key() ? kTagSize + KeyTypeHandler::ByteSize(key()) : 0; - size += has_value() ? kTagSize + ValueTypeHandler::ByteSize(value()) : 0; + size += has_key() ? + kTagSize + static_cast<size_t>(KeyTypeHandler::ByteSize(key())) : 0; + size += has_value() ? + kTagSize + static_cast<size_t>(ValueTypeHandler::ByteSize(value())) : 0; return size; } @@ -250,11 +251,10 @@ class MapEntryImpl : public Base { int GetCachedSize() const { int size = 0; size += has_key() - ? kTagSize + KeyTypeHandler::GetCachedSize(key()) + ? static_cast<int>(kTagSize) + KeyTypeHandler::GetCachedSize(key()) : 0; size += has_value() - ? kTagSize + ValueTypeHandler::GetCachedSize( - value()) + ? static_cast<int>(kTagSize) + ValueTypeHandler::GetCachedSize(value()) : 0; return size; } @@ -263,13 +263,11 @@ class MapEntryImpl : public Base { Base* New() const { Derived* entry = new Derived; - entry->default_instance_ = default_instance_; return entry; } Base* New(Arena* arena) const { Derived* entry = Arena::CreateMessage<Derived>(arena); - entry->default_instance_ = default_instance_; return entry; } @@ -307,13 +305,10 @@ class MapEntryImpl : public Base { clear_has_value(); } - void set_default_instance(MapEntryImpl* default_instance) { - default_instance_ = default_instance; - } - - void InitAsDefaultInstance() { - KeyTypeHandler::AssignDefaultValue(&key_); - ValueTypeHandler::AssignDefaultValue(&value_); + static void InitAsDefaultInstance() { + Derived* d = const_cast<Derived*>(Derived::internal_default_instance()); + KeyTypeHandler::AssignDefaultValue(&d->key_); + ValueTypeHandler::AssignDefaultValue(&d->value_); } Arena* GetArena() const { @@ -391,7 +386,7 @@ class MapEntryImpl : public Base { const Value& value() const { return *value_ptr_; } private: - void UseKeyAndValueFromEntry() GOOGLE_ATTRIBUTE_COLD { + void UseKeyAndValueFromEntry() GOOGLE_PROTOBUF_ATTRIBUTE_COLD { // Update key_ in case we need it later (because key() is called). // This is potentially inefficient, especially if the key is // expensive to copy (e.g., a long string), but this is a cold @@ -409,7 +404,7 @@ class MapEntryImpl : public Base { // into map_, we are not at the end of the input. This is unusual, but // allowed by the spec. bool ReadBeyondKeyValuePair(::google::protobuf::io::CodedInputStream* input) - GOOGLE_ATTRIBUTE_COLD { + GOOGLE_PROTOBUF_ATTRIBUTE_COLD { typedef MoveHelper<KeyTypeHandler::kIsEnum, KeyTypeHandler::kIsMessage, KeyTypeHandler::kWireType == @@ -515,13 +510,13 @@ class MapEntryImpl : public Base { return arena_; } - MapEntryImpl* default_instance_; - + public: // Needed for constructing tables KeyOnMemory key_; ValueOnMemory value_; Arena* arena_; uint32 _has_bits_[1]; + private: friend class ::google::protobuf::Arena; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; @@ -535,23 +530,37 @@ class MapEntryImpl : public Base { GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MapEntryImpl); }; -template <typename Key, typename Value, WireFormatLite::FieldType kKeyFieldType, +template <typename T, typename Key, typename Value, + WireFormatLite::FieldType kKeyFieldType, WireFormatLite::FieldType kValueFieldType, int default_enum_value> class MapEntryLite - : public MapEntryImpl<MapEntryLite<Key, Value, kKeyFieldType, - kValueFieldType, default_enum_value>, - MessageLite, Key, Value, kKeyFieldType, + : public MapEntryImpl<T, MessageLite, Key, Value, kKeyFieldType, kValueFieldType, default_enum_value> { public: - typedef MapEntryImpl<MapEntryLite, MessageLite, Key, Value, kKeyFieldType, + typedef MapEntryImpl<T, MessageLite, Key, Value, kKeyFieldType, kValueFieldType, default_enum_value> SuperType; MapEntryLite() {} explicit MapEntryLite(Arena* arena) : SuperType(arena) {} - void MergeFrom(const MapEntryLite<Key, Value, kKeyFieldType, kValueFieldType, - default_enum_value>& other) { - MergeFromInternal(other); - } + void MergeFrom(const MapEntryLite& other) { MergeFromInternal(other); } + + private: + GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MapEntryLite); +}; +// The completely unprincipled and unwieldy use of template parameters in +// the map code necessitates wrappers to make the code a little bit more +// manageable. +template <typename Derived> +struct DeconstructMapEntry; + +template <typename T, typename K, typename V, WireFormatLite::FieldType key, + WireFormatLite::FieldType value, int default_enum> +struct DeconstructMapEntry<MapEntryLite<T, K, V, key, value, default_enum> > { + typedef K Key; + typedef V Value; + static const WireFormatLite::FieldType kKeyFieldType = key; + static const WireFormatLite::FieldType kValueFieldType = value; + static const int default_enum_value = default_enum; }; // Helpers for deterministic serialization ============================= @@ -580,6 +589,80 @@ template <typename T> struct CompareByDerefFirst { } }; +// Helper for table driven serialization + +template <WireFormatLite::FieldType FieldType> +struct FromHelper { + template <typename T> + static const T& From(const T& x) { + return x; + } +}; + +template <> +struct FromHelper<WireFormatLite::TYPE_STRING> { + static ArenaStringPtr From(const string& x) { + ArenaStringPtr res; + TaggedPtr< ::std::string> ptr; + ptr.Set(const_cast<string*>(&x)); + res.UnsafeSetTaggedPointer(ptr); + return res; + } +}; +template <> +struct FromHelper<WireFormatLite::TYPE_BYTES> { + static ArenaStringPtr From(const string& x) { + ArenaStringPtr res; + TaggedPtr< ::std::string> ptr; + ptr.Set(const_cast<string*>(&x)); + res.UnsafeSetTaggedPointer(ptr); + return res; + } +}; +template <> +struct FromHelper<WireFormatLite::TYPE_MESSAGE> { + template <typename T> + static T* From(const T& x) { + return const_cast<T*>(&x); + } +}; + +template <typename MapEntryType> +struct MapEntryHelper; + +template <typename T, typename Key, typename Value, + WireFormatLite::FieldType kKeyFieldType, + WireFormatLite::FieldType kValueFieldType, int default_enum_value> +struct MapEntryHelper<MapEntryLite<T, Key, Value, kKeyFieldType, + kValueFieldType, default_enum_value> > { + // Provide utilities to parse/serialize key/value. Provide utilities to + // manipulate internal stored type. + typedef MapTypeHandler<kKeyFieldType, Key> KeyTypeHandler; + typedef MapTypeHandler<kValueFieldType, Value> ValueTypeHandler; + + // Define internal memory layout. Strings and messages are stored as + // pointers, while other types are stored as values. + typedef typename KeyTypeHandler::TypeOnMemory KeyOnMemory; + typedef typename ValueTypeHandler::TypeOnMemory ValueOnMemory; + + explicit MapEntryHelper(const MapPair<Key, Value>& map_pair) + : _has_bits_(3), + _cached_size_(2 + KeyTypeHandler::GetCachedSize(map_pair.first) + + ValueTypeHandler::GetCachedSize(map_pair.second)), + key_(FromHelper<kKeyFieldType>::From(map_pair.first)), + value_(FromHelper<kValueFieldType>::From(map_pair.second)) {} + + // Purposely not folowing the style guide naming. These are the names + // the proto compiler would generate given the map entry descriptor. + // The proto compiler generates the offsets in this struct as if this was + // a regular message. This way the table driven code barely notices it's + // dealing with a map field. + uint32 _has_bits_; // NOLINT + uint32 _cached_size_; // NOLINT + KeyOnMemory key_; // NOLINT + ValueOnMemory value_; // NOLINT +}; + } // namespace internal } // namespace protobuf diff --git a/src/google/protobuf/map_field.cc b/src/google/protobuf/map_field.cc index 64dcc990..ec4f83e1 100644 --- a/src/google/protobuf/map_field.cc +++ b/src/google/protobuf/map_field.cc @@ -43,13 +43,15 @@ MapFieldBase::~MapFieldBase() { const RepeatedPtrFieldBase& MapFieldBase::GetRepeatedField() const { SyncRepeatedFieldWithMap(); - return *repeated_field_; + return *reinterpret_cast< ::google::protobuf::internal::RepeatedPtrFieldBase*>( + repeated_field_); } RepeatedPtrFieldBase* MapFieldBase::MutableRepeatedField() { SyncRepeatedFieldWithMap(); SetRepeatedDirty(); - return repeated_field_; + return reinterpret_cast< ::google::protobuf::internal::RepeatedPtrFieldBase*>( + repeated_field_); } size_t MapFieldBase::SpaceUsedExcludingSelfLong() const { @@ -130,6 +132,7 @@ DynamicMapField::DynamicMapField(const Message* default_entry) DynamicMapField::DynamicMapField(const Message* default_entry, Arena* arena) : TypeDefinedMapFieldBase<MapKey, MapValueRef>(arena), + map_(arena), default_entry_(default_entry) { } diff --git a/src/google/protobuf/map_field.h b/src/google/protobuf/map_field.h index 9d5a328e..6c75a6da 100644 --- a/src/google/protobuf/map_field.h +++ b/src/google/protobuf/map_field.h @@ -170,6 +170,7 @@ class LIBPROTOBUF_EXPORT MapFieldBase { // IncreaseIterator() is called by operator++() of MapIterator only. // It implements the ++ operator of MapIterator. virtual void IncreaseIterator(MapIterator* map_iter) const = 0; + GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MapFieldBase); }; // This class provides common Map Reflection implementations for generated @@ -199,6 +200,7 @@ class TypeDefinedMapFieldBase : public MapFieldBase { void IncreaseIterator(MapIterator* map_iter) const; virtual void SetMapIteratorValue(MapIterator* map_iter) const = 0; + GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(TypeDefinedMapFieldBase); }; // This class provides access to map field using generated api. It is used for @@ -215,8 +217,9 @@ class MapField : public TypeDefinedMapFieldBase<Key, T> { // Define message type for internal repeated field. typedef Derived EntryType; - typedef MapEntryLite<Key, T, kKeyFieldType, kValueFieldType, - default_enum_value> EntryLiteType; + typedef MapEntryLite<Derived, Key, T, kKeyFieldType, kValueFieldType, + default_enum_value> + EntryLiteType; // Define abbreviation for parent MapFieldLite typedef MapFieldLite<Derived, Key, T, kKeyFieldType, kValueFieldType, @@ -231,6 +234,9 @@ class MapField : public TypeDefinedMapFieldBase<Key, T> { typedef typename MapIf<kIsValueEnum, T, const T&>::type CastValueType; public: + typedef typename Derived::SuperType EntryTypeTrait; + typedef Map<Key, T> MapType; + MapField() {} explicit MapField(Arena* arena) : TypeDefinedMapFieldBase<Key, T>(arena), impl_(arena) {} @@ -287,6 +293,17 @@ class MapField : public TypeDefinedMapFieldBase<Key, T> { friend class ::google::protobuf::Arena; friend class MapFieldStateTest; // For testing, it needs raw access to impl_ + GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MapField); +}; + +template <typename T, typename Key, typename Value, + WireFormatLite::FieldType kKeyFieldType, + WireFormatLite::FieldType kValueFieldType, int default_enum_value> +struct MapEntryToMapField<MapEntry<T, Key, Value, kKeyFieldType, + kValueFieldType, default_enum_value> > { + typedef MapField<T, Key, Value, kKeyFieldType, kValueFieldType, + default_enum_value> + MapFieldType; }; class LIBPROTOBUF_EXPORT DynamicMapField: public TypeDefinedMapFieldBase<MapKey, MapValueRef> { @@ -314,6 +331,7 @@ class LIBPROTOBUF_EXPORT DynamicMapField: public TypeDefinedMapFieldBase<MapKey, void SyncMapWithRepeatedFieldNoLock() const; size_t SpaceUsedExcludingSelfNoLock() const; void SetMapIteratorValue(MapIterator* map_iter) const; + GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(DynamicMapField); }; } // namespace internal @@ -338,6 +356,10 @@ class LIBPROTOBUF_EXPORT MapKey { MapKey(const MapKey& other) : type_(0) { CopyFrom(other); } + MapKey& operator=(const MapKey& other) { + CopyFrom(other); + return *this; + } ~MapKey() { if (type_ == FieldDescriptor::CPPTYPE_STRING) { @@ -697,6 +719,7 @@ class LIBPROTOBUF_EXPORT MapValueRef { void* data_; // type_ is 0 or a valid FieldDescriptor::CppType. int type_; + GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MapValueRef); }; #undef TYPE_CHECK @@ -718,6 +741,11 @@ class LIBPROTOBUF_EXPORT MapIterator { ~MapIterator() { map_->DeleteIterator(this); } + MapIterator& operator=(const MapIterator& other) { + map_ = other.map_; + map_->CopyIterator(this, other); + return *this; + } friend bool operator==(const MapIterator& a, const MapIterator& b) { return a.map_->EqualIterator(a, b); } diff --git a/src/google/protobuf/map_field_inl.h b/src/google/protobuf/map_field_inl.h index 8c5da3c6..e317b5ed 100644 --- a/src/google/protobuf/map_field_inl.h +++ b/src/google/protobuf/map_field_inl.h @@ -168,7 +168,7 @@ template <typename Derived, typename Key, typename T, int MapField<Derived, Key, T, kKeyFieldType, kValueFieldType, default_enum_value>::size() const { MapFieldBase::SyncMapWithRepeatedField(); - return impl_.GetMap().size(); + return static_cast<int>(impl_.GetMap().size()); } template <typename Derived, typename Key, typename T, @@ -252,9 +252,9 @@ template <typename Derived, typename Key, typename T, WireFormatLite::FieldType kValueFieldType, int default_enum_value> void MapField<Derived, Key, T, kKeyFieldType, kValueFieldType, default_enum_value>::Swap(MapField* other) { - std::swap(MapFieldBase::repeated_field_, other->repeated_field_); + std::swap(this->MapFieldBase::repeated_field_, other->repeated_field_); impl_.Swap(&other->impl_); - std::swap(MapFieldBase::state_, other->state_); + std::swap(this->MapFieldBase::state_, other->state_); } template <typename Derived, typename Key, typename T, diff --git a/src/google/protobuf/map_field_lite.h b/src/google/protobuf/map_field_lite.h index 2d102392..f648b430 100644 --- a/src/google/protobuf/map_field_lite.h +++ b/src/google/protobuf/map_field_lite.h @@ -33,6 +33,7 @@ #include <google/protobuf/map.h> #include <google/protobuf/map_entry_lite.h> +#include <google/protobuf/wire_format_lite.h> namespace google { namespace protobuf { @@ -49,6 +50,9 @@ class MapFieldLite { typedef Derived EntryType; public: + typedef Map<Key, T> MapType; + typedef EntryType EntryTypeTrait; + MapFieldLite() : arena_(NULL) { SetDefaultEnumValue(); } explicit MapFieldLite(Arena* arena) : arena_(arena), map_(arena) { @@ -60,7 +64,7 @@ class MapFieldLite { Map<Key, T>* MutableMap() { return &map_; } // Convenient methods for generated message implementation. - int size() const { return map_.size(); } + int size() const { return static_cast<int>(map_.size()); } void Clear() { return map_.clear(); } void MergeFrom(const MapFieldLite& other) { for (typename Map<Key, T>::const_iterator it = other.map_.begin(); @@ -104,7 +108,6 @@ class MapFieldLite { friend class ::google::protobuf::Arena; }; - // True if IsInitialized() is true for value field in all elements of t. T is // expected to be message. It's useful to have this helper here to keep the // protobuf compiler from ever having to emit loops in IsInitialized() methods. @@ -118,6 +121,21 @@ bool AllAreInitialized(const Map<Key, T>& t) { return true; } +template <typename MEntry> +struct MapEntryToMapField : MapEntryToMapField<typename MEntry::SuperType> {}; + +template <typename T, typename Key, typename Value, + WireFormatLite::FieldType kKeyFieldType, + WireFormatLite::FieldType kValueFieldType, int default_enum_value> +struct MapEntryToMapField<MapEntryLite<T, Key, Value, kKeyFieldType, + kValueFieldType, default_enum_value> > { + typedef MapFieldLite<MapEntryLite<T, Key, Value, kKeyFieldType, + kValueFieldType, default_enum_value>, + Key, Value, kKeyFieldType, kValueFieldType, + default_enum_value> + MapFieldType; +}; + } // namespace internal } // namespace protobuf diff --git a/src/google/protobuf/map_field_test.cc b/src/google/protobuf/map_field_test.cc index 8617a366..4e0e751c 100644 --- a/src/google/protobuf/map_field_test.cc +++ b/src/google/protobuf/map_field_test.cc @@ -101,7 +101,7 @@ class MapFieldBaseStub : public MapFieldBase { class MapFieldBasePrimitiveTest : public ::testing::Test { protected: - typedef unittest::TestMap::TestMap_MapInt32Int32Entry EntryType; + typedef unittest::TestMap_MapInt32Int32Entry_DoNotUse EntryType; typedef MapField<EntryType, int32, int32, WireFormatLite::TYPE_INT32, WireFormatLite::TYPE_INT32, false> MapFieldType; @@ -206,7 +206,7 @@ class MapFieldStateTest : public testing::TestWithParam<State> { public: protected: - typedef unittest::TestMap::TestMap_MapInt32Int32Entry EntryType; + typedef unittest::TestMap_MapInt32Int32Entry_DoNotUse EntryType; typedef MapField<EntryType, int32, int32, WireFormatLite::TYPE_INT32, WireFormatLite::TYPE_INT32, false> MapFieldType; diff --git a/src/google/protobuf/map_test.cc b/src/google/protobuf/map_test.cc index a06b432a..d59f92d2 100644 --- a/src/google/protobuf/map_test.cc +++ b/src/google/protobuf/map_test.cc @@ -130,7 +130,7 @@ class MapImplTest : public ::testing::Test { EXPECT_EQ(value, map_.at(key)); Map<int32, int32>::iterator it = map_.find(key); - // interator dereferenceable + // iterator dereferenceable EXPECT_EQ(key, (*it).first); EXPECT_EQ(value, (*it).second); EXPECT_EQ(key, it->first); @@ -158,7 +158,7 @@ class MapImplTest : public ::testing::Test { EXPECT_EQ(value, const_map_.at(key)); Map<int32, int32>::const_iterator const_it = const_map_.find(key); - // interator dereferenceable + // iterator dereferenceable EXPECT_EQ(key, (*const_it).first); EXPECT_EQ(value, (*const_it).second); EXPECT_EQ(key, const_it->first); @@ -236,6 +236,13 @@ TEST_F(MapImplTest, UsageErrors) { #endif // PROTOBUF_HAS_DEATH_TEST +TEST_F(MapImplTest, MapKeyAssignment) { + MapKey from, to; + from.SetStringValue("abc"); + to = from; + EXPECT_EQ("abc", to.GetStringValue()); +} + TEST_F(MapImplTest, CountNonExist) { EXPECT_EQ(0, map_.count(0)); } @@ -551,7 +558,7 @@ TEST_F(MapImplTest, IteratorInvalidation) { #endif std::set<int> s; int n = kMaxSizeToTest; - int frog = k1 + n; + unsigned int frog = k1 + n; while (n > 1 && s.size() < 25) { s.insert(n); n = static_cast<int>(n * 100 / (101.0 + (frog & 63))); @@ -669,6 +676,16 @@ TEST_F(MapImplTest, InsertByIterator) { ExpectElements(map1); } +#if LANG_CXX11 +TEST_F(MapImplTest, InsertByInitializerList) { + map_.insert({{1, 100}, {2, 200}}); + ExpectElements({{1, 100}, {2, 200}}); + + map_.insert({{2, 201}, {3, 301}}); + ExpectElements({{1, 100}, {2, 200}, {3, 301}}); +} +#endif + TEST_F(MapImplTest, EraseSingleByKey) { int32 key = 0; int32 value = 100; @@ -954,6 +971,17 @@ TEST_F(MapImplTest, SwapArena) { testing::Pair(9398, 41999))); } +TEST_F(MapImplTest, CopyAssignMapIterator) { + TestMap message; + MapReflectionTester reflection_tester( + unittest::TestMap::descriptor()); + reflection_tester.SetMapFieldsViaMapReflection(&message); + MapIterator it1 = reflection_tester.MapBegin(&message, "map_int32_int32"); + MapIterator it2 = reflection_tester.MapEnd(&message, "map_int32_int32"); + it2 = it1; + EXPECT_EQ(it1.GetKey().GetInt32Value(), it2.GetKey().GetInt32Value()); +} + // Map Field Reflection Test ======================================== static int Func(int i, int j) { @@ -3265,6 +3293,44 @@ TEST(ArenaTest, IsInitialized) { EXPECT_EQ(0, (*message->mutable_map_int32_int32())[0]); } +#if LANG_CXX11 +TEST(MoveTest, MoveConstructorWorks) { + Map<int32, TestAllTypes> original_map; + original_map[42].mutable_optional_nested_message()->set_bb(42); + original_map[43].mutable_optional_nested_message()->set_bb(43); + const auto* nested_msg42_ptr = &original_map[42].optional_nested_message(); + const auto* nested_msg43_ptr = &original_map[43].optional_nested_message(); + + Map<int32, TestAllTypes> moved_to_map(std::move(original_map)); + EXPECT_TRUE(original_map.empty()); + EXPECT_EQ(2, moved_to_map.size()); + EXPECT_EQ(42, moved_to_map[42].optional_nested_message().bb()); + EXPECT_EQ(43, moved_to_map[43].optional_nested_message().bb()); + // This test takes advantage of the fact that pointers are swapped, so there + // should be pointer stability. + EXPECT_EQ(nested_msg42_ptr, &moved_to_map[42].optional_nested_message()); + EXPECT_EQ(nested_msg43_ptr, &moved_to_map[43].optional_nested_message()); +} + +TEST(MoveTest, MoveAssignmentWorks) { + Map<int32, TestAllTypes> original_map; + original_map[42].mutable_optional_nested_message()->set_bb(42); + original_map[43].mutable_optional_nested_message()->set_bb(43); + const auto* nested_msg42_ptr = &original_map[42].optional_nested_message(); + const auto* nested_msg43_ptr = &original_map[43].optional_nested_message(); + + Map<int32, TestAllTypes> moved_to_map = std::move(original_map); + EXPECT_TRUE(original_map.empty()); + EXPECT_EQ(2, moved_to_map.size()); + EXPECT_EQ(42, moved_to_map[42].optional_nested_message().bb()); + EXPECT_EQ(43, moved_to_map[43].optional_nested_message().bb()); + // This test takes advantage of the fact that pointers are swapped, so there + // should be pointer stability. + EXPECT_EQ(nested_msg42_ptr, &moved_to_map[42].optional_nested_message()); + EXPECT_EQ(nested_msg43_ptr, &moved_to_map[43].optional_nested_message()); +} +#endif + } // namespace internal } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/map_test_util.cc b/src/google/protobuf/map_test_util.cc index 4d3ad609..31ac1736 100644 --- a/src/google/protobuf/map_test_util.cc +++ b/src/google/protobuf/map_test_util.cc @@ -760,6 +760,18 @@ Message* MapReflectionTester::GetMapEntryViaReflection(Message* message, return reflection->MutableRepeatedMessage(message, F(field_name), index); } +MapIterator MapReflectionTester::MapBegin(Message* message, + const string& field_name) { + const Reflection* reflection = message->GetReflection(); + return reflection->MapBegin(message, F(field_name)); +} + +MapIterator MapReflectionTester::MapEnd(Message* message, + const string& field_name) { + const Reflection* reflection = message->GetReflection(); + return reflection->MapEnd(message, F(field_name)); +} + void MapReflectionTester::ClearMapFieldsViaReflection( Message* message) { const Reflection* reflection = message->GetReflection(); diff --git a/src/google/protobuf/map_test_util.h b/src/google/protobuf/map_test_util.h index 15c6c289..dd397619 100644 --- a/src/google/protobuf/map_test_util.h +++ b/src/google/protobuf/map_test_util.h @@ -111,6 +111,8 @@ class MapReflectionTester { const MapKey& map_key, MapValueRef* map_val); Message* GetMapEntryViaReflection(Message* message, const string& field_name, int index); + MapIterator MapBegin(Message* message, const string& field_name); + MapIterator MapEnd(Message* message, const string& field_name); private: const FieldDescriptor* F(const string& name); diff --git a/src/google/protobuf/map_type_handler.h b/src/google/protobuf/map_type_handler.h index 301b37fe..7f7b1e0e 100644 --- a/src/google/protobuf/map_type_handler.h +++ b/src/google/protobuf/map_type_handler.h @@ -32,7 +32,6 @@ #define GOOGLE_PROTOBUF_TYPE_HANDLER_H__ #include <google/protobuf/arena.h> -#include <google/protobuf/generated_message_util.h> #include <google/protobuf/wire_format_lite_inl.h> namespace google { @@ -73,7 +72,7 @@ class MapValueInitializer<true, Type> { template <typename Type> class MapValueInitializer<false, Type> { public: - static inline void Initialize(Type& value, int default_enum_value) {} + static inline void Initialize(Type& /* value */, int /* default_enum_value */) {} }; template <typename Type, bool is_arena_constructable> @@ -284,7 +283,7 @@ MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type>::ByteSize( template <typename Type> \ inline int MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::ByteSize( \ const MapEntryAccessorType& value) { \ - return WireFormatLite::DeclaredType##Size(value); \ + return static_cast<int>(WireFormatLite::DeclaredType##Size(value)); \ } GOOGLE_PROTOBUF_BYTE_SIZE(STRING, String) @@ -302,7 +301,7 @@ GOOGLE_PROTOBUF_BYTE_SIZE(ENUM , Enum) #define FIXED_BYTE_SIZE(FieldType, DeclaredType) \ template <typename Type> \ inline int MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::ByteSize( \ - const MapEntryAccessorType& value) { \ + const MapEntryAccessorType& /* value */) { \ return WireFormatLite::k##DeclaredType##Size; \ } @@ -320,7 +319,9 @@ template <typename Type> inline int MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type>::GetCachedSize( const MapEntryAccessorType& value) { - return WireFormatLite::LengthDelimitedSize(value.GetCachedSize()); + return static_cast<int>( + WireFormatLite::LengthDelimitedSize( + static_cast<size_t>(value.GetCachedSize()))); } #define GET_CACHED_SIZE(FieldType, DeclaredType) \ @@ -328,7 +329,7 @@ MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type>::GetCachedSize( inline int \ MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::GetCachedSize( \ const MapEntryAccessorType& value) { \ - return WireFormatLite::DeclaredType##Size(value); \ + return static_cast<int>(WireFormatLite::DeclaredType##Size(value)); \ } GET_CACHED_SIZE(STRING, String) @@ -347,7 +348,7 @@ GET_CACHED_SIZE(ENUM , Enum) template <typename Type> \ inline int \ MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::GetCachedSize( \ - const MapEntryAccessorType& value) { \ + const MapEntryAccessorType& /* value */) { \ return WireFormatLite::k##DeclaredType##Size; \ } @@ -478,20 +479,20 @@ size_t MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type>::SpaceUsedInMapLong( template <typename Type> inline void MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type>::Clear( - Type** value, Arena* arena) { + Type** value, Arena* /* arena */) { if (*value != NULL) (*value)->Clear(); } template <typename Type> inline void MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type>::ClearMaybeByDefaultEnum(Type** value, - Arena* arena, - int default_enum_value) { + Arena* /* arena */, + int /* default_enum_value */) { if (*value != NULL) (*value)->Clear(); } template <typename Type> inline void MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type>::Merge( - const Type& from, Type** to, Arena* arena) { + const Type& from, Type** to, Arena* /* arena */) { (*to)->MergeFrom(from); } @@ -510,14 +511,14 @@ inline void MapTypeHandler<WireFormatLite::TYPE_MESSAGE, template <typename Type> inline void MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type>::Initialize(Type** x, - Arena* arena) { + Arena* /* arena */) { *x = NULL; } template <typename Type> inline void MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type>:: - InitializeMaybeByDefaultEnum(Type** x, int default_enum_value, - Arena* arena) { + InitializeMaybeByDefaultEnum(Type** x, int /* default_enum_value */, + Arena* /* arena */) { *x = NULL; } @@ -582,7 +583,7 @@ inline bool MapTypeHandler<WireFormatLite::TYPE_MESSAGE, template <typename Type> \ inline void MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>:: \ ClearMaybeByDefaultEnum(TypeOnMemory* value, Arena* arena, \ - int default_enum) { \ + int /* default_enum */) { \ Clear(value, arena); \ } \ template <typename Type> \ @@ -597,18 +598,19 @@ inline bool MapTypeHandler<WireFormatLite::TYPE_MESSAGE, } \ template <typename Type> \ inline void MapTypeHandler<WireFormatLite::TYPE_##FieldType, \ - Type>::AssignDefaultValue(TypeOnMemory* value) {} \ + Type>::AssignDefaultValue(TypeOnMemory* /* value */) {} \ template <typename Type> \ inline void \ MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::Initialize( \ - TypeOnMemory* value, Arena* arena) { \ + TypeOnMemory* value, Arena* /* arena */) { \ value->UnsafeSetDefault( \ &::google::protobuf::internal::GetEmptyStringAlreadyInited()); \ } \ template <typename Type> \ inline void MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>:: \ InitializeMaybeByDefaultEnum(TypeOnMemory* value, \ - int default_enum_value, Arena* arena) { \ + int /* default_enum_value */, \ + Arena* arena) { \ Initialize(value, arena); \ } \ template <typename Type> \ @@ -625,12 +627,12 @@ inline bool MapTypeHandler<WireFormatLite::TYPE_MESSAGE, MapTypeHandler<WireFormatLite::TYPE_##FieldType, \ Type>::DefaultIfNotInitialized(const TypeOnMemory& value, \ const TypeOnMemory& \ - default_value) { \ + /* default_value */) { \ return value.Get(); \ } \ template <typename Type> \ inline bool MapTypeHandler<WireFormatLite::TYPE_##FieldType, \ - Type>::IsInitialized(const TypeOnMemory& value) { \ + Type>::IsInitialized(const TypeOnMemory& /* value */) { \ return true; \ } STRING_OR_BYTES_HANDLER_FUNCTIONS(STRING) @@ -648,54 +650,56 @@ STRING_OR_BYTES_HANDLER_FUNCTIONS(BYTES) template <typename Type> \ inline size_t \ MapTypeHandler<WireFormatLite::TYPE_##FieldType, \ - Type>::SpaceUsedInMapEntryLong(const TypeOnMemory& value) { \ + Type>::SpaceUsedInMapEntryLong(const TypeOnMemory& /* value */) { \ return 0; \ } \ template <typename Type> \ inline size_t \ MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::SpaceUsedInMapLong( \ - const TypeOnMemory& value) { \ + const TypeOnMemory& /* value */) { \ return sizeof(Type); \ } \ template <typename Type> \ inline void MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::Clear( \ - TypeOnMemory* value, Arena* arena) { \ + TypeOnMemory* value, Arena* /* arena */) { \ *value = 0; \ } \ template <typename Type> \ inline void MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>:: \ - ClearMaybeByDefaultEnum(TypeOnMemory* value, Arena* arena, \ + ClearMaybeByDefaultEnum(TypeOnMemory* value, Arena* /* arena */, \ int default_enum_value) { \ *value = static_cast<TypeOnMemory>(default_enum_value); \ } \ template <typename Type> \ inline void MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::Merge( \ - const MapEntryAccessorType& from, TypeOnMemory* to, Arena* arena) { \ + const MapEntryAccessorType& from, TypeOnMemory* to, \ + Arena* /* arena */) { \ *to = from; \ } \ template <typename Type> \ inline void MapTypeHandler<WireFormatLite::TYPE_##FieldType, \ - Type>::DeleteNoArena(TypeOnMemory& x) {} \ + Type>::DeleteNoArena(TypeOnMemory& /* x */) {} \ template <typename Type> \ inline void MapTypeHandler<WireFormatLite::TYPE_##FieldType, \ - Type>::AssignDefaultValue(TypeOnMemory* value) {} \ + Type>::AssignDefaultValue(TypeOnMemory* /* value */) {} \ template <typename Type> \ inline void \ MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::Initialize( \ - TypeOnMemory* value, Arena* arena) { \ + TypeOnMemory* value, Arena* /* arena */) { \ *value = 0; \ } \ template <typename Type> \ inline void MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>:: \ InitializeMaybeByDefaultEnum(TypeOnMemory* value, \ - int default_enum_value, Arena* arena) { \ + int default_enum_value, \ + Arena* /* arena */) { \ *value = static_cast<TypeOnMemory>(default_enum_value); \ } \ template <typename Type> \ inline typename MapTypeHandler<WireFormatLite::TYPE_##FieldType, \ Type>::MapEntryAccessorType* \ MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::EnsureMutable( \ - TypeOnMemory* value, Arena* arena) { \ + TypeOnMemory* value, Arena* /* arena */) { \ return value; \ } \ template <typename Type> \ @@ -704,12 +708,12 @@ STRING_OR_BYTES_HANDLER_FUNCTIONS(BYTES) MapTypeHandler<WireFormatLite::TYPE_##FieldType, \ Type>::DefaultIfNotInitialized(const TypeOnMemory& value, \ const TypeOnMemory& \ - default_value) { \ + /* default_value */) { \ return value; \ } \ template <typename Type> \ inline bool MapTypeHandler<WireFormatLite::TYPE_##FieldType, \ - Type>::IsInitialized(const TypeOnMemory& value) { \ + Type>::IsInitialized(const TypeOnMemory& /* value */) { \ return true; \ } PRIMITIVE_HANDLER_FUNCTIONS(INT64) diff --git a/src/google/protobuf/map_unittest.proto b/src/google/protobuf/map_unittest.proto index c6154f04..836dc10b 100644 --- a/src/google/protobuf/map_unittest.proto +++ b/src/google/protobuf/map_unittest.proto @@ -60,6 +60,7 @@ message TestMap { map<int32 , MapEnum > map_int32_enum = 16; map<int32 , ForeignMessage> map_int32_foreign_message = 17; map<string , ForeignMessage> map_string_foreign_message = 18; + map<int32 , TestAllTypes> map_int32_all_types = 19; } message TestMapSubmessage { diff --git a/src/google/protobuf/map_unittest_proto3.proto b/src/google/protobuf/map_unittest_proto3.proto deleted file mode 100644 index 16be2773..00000000 --- a/src/google/protobuf/map_unittest_proto3.proto +++ /dev/null @@ -1,120 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// This file is mostly equivalent to map_unittest.proto, but imports -// unittest_proto3.proto instead of unittest.proto, so that it only -// uses proto3 messages. This makes it suitable for testing -// implementations which only support proto3. -// The TestRequiredMessageMap message has been removed as there are no -// required fields in proto3. -syntax = "proto3"; - -option cc_enable_arenas = true; -option csharp_namespace = "Google.Protobuf.TestProtos"; - -import "google/protobuf/unittest_proto3.proto"; - -// We don't put this in a package within proto2 because we need to make sure -// that the generated code doesn't depend on being in the proto2 namespace. -// In map_test_util.h we do "using namespace unittest = protobuf_unittest". -package protobuf_unittest; - -// Tests maps. -message TestMap { - map<int32 , int32 > map_int32_int32 = 1; - map<int64 , int64 > map_int64_int64 = 2; - map<uint32 , uint32 > map_uint32_uint32 = 3; - map<uint64 , uint64 > map_uint64_uint64 = 4; - map<sint32 , sint32 > map_sint32_sint32 = 5; - map<sint64 , sint64 > map_sint64_sint64 = 6; - map<fixed32 , fixed32 > map_fixed32_fixed32 = 7; - map<fixed64 , fixed64 > map_fixed64_fixed64 = 8; - map<sfixed32, sfixed32> map_sfixed32_sfixed32 = 9; - map<sfixed64, sfixed64> map_sfixed64_sfixed64 = 10; - map<int32 , float > map_int32_float = 11; - map<int32 , double > map_int32_double = 12; - map<bool , bool > map_bool_bool = 13; - map<string , string > map_string_string = 14; - map<int32 , bytes > map_int32_bytes = 15; - map<int32 , MapEnum > map_int32_enum = 16; - map<int32 , ForeignMessage> map_int32_foreign_message = 17; -} - -message TestMapSubmessage { - TestMap test_map = 1; -} - -message TestMessageMap { - map<int32, TestAllTypes> map_int32_message = 1; -} - -// Two map fields share the same entry default instance. -message TestSameTypeMap { - map<int32, int32> map1 = 1; - map<int32, int32> map2 = 2; -} - -enum MapEnum { - MAP_ENUM_FOO = 0; - MAP_ENUM_BAR = 1; - MAP_ENUM_BAZ = 2; -} - -message TestArenaMap { - map<int32 , int32 > map_int32_int32 = 1; - map<int64 , int64 > map_int64_int64 = 2; - map<uint32 , uint32 > map_uint32_uint32 = 3; - map<uint64 , uint64 > map_uint64_uint64 = 4; - map<sint32 , sint32 > map_sint32_sint32 = 5; - map<sint64 , sint64 > map_sint64_sint64 = 6; - map<fixed32 , fixed32 > map_fixed32_fixed32 = 7; - map<fixed64 , fixed64 > map_fixed64_fixed64 = 8; - map<sfixed32, sfixed32> map_sfixed32_sfixed32 = 9; - map<sfixed64, sfixed64> map_sfixed64_sfixed64 = 10; - map<int32 , float > map_int32_float = 11; - map<int32 , double > map_int32_double = 12; - map<bool , bool > map_bool_bool = 13; - map<int32 , MapEnum > map_int32_enum = 14; - map<int32 , ForeignMessage> map_int32_foreign_message = 15; -} - -// Previously, message containing enum called Type cannot be used as value of -// map field. -message MessageContainingEnumCalledType { - enum Type { - TYPE_FOO = 0; - } - map<int32, MessageContainingEnumCalledType> type = 1; -} - -// Previously, message cannot contain map field called "entry". -message MessageContainingMapCalledEntry { - map<int32, int32> entry = 1; -} diff --git a/src/google/protobuf/message.cc b/src/google/protobuf/message.cc index 2134f95f..42ec0337 100644 --- a/src/google/protobuf/message.cc +++ b/src/google/protobuf/message.cc @@ -143,7 +143,13 @@ bool Message::ParsePartialFromIstream(std::istream* input) { void Message::SerializeWithCachedSizes( io::CodedOutputStream* output) const { - WireFormat::SerializeWithCachedSizes(*this, GetCachedSize(), output); + const internal::SerializationTable* table = + static_cast<const internal::SerializationTable*>(InternalGetTable()); + if (table == 0) { + WireFormat::SerializeWithCachedSizes(*this, GetCachedSize(), output); + } else { + internal::TableSerialize(*this, table, output); + } } size_t Message::ByteSizeLong() const { @@ -164,12 +170,12 @@ size_t Message::SpaceUsedLong() const { bool Message::SerializeToFileDescriptor(int file_descriptor) const { io::FileOutputStream output(file_descriptor); - return SerializeToZeroCopyStream(&output); + return SerializeToZeroCopyStream(&output) && output.Flush(); } bool Message::SerializePartialToFileDescriptor(int file_descriptor) const { io::FileOutputStream output(file_descriptor); - return SerializePartialToZeroCopyStream(&output); + return SerializePartialToZeroCopyStream(&output) && output.Flush(); } bool Message::SerializeToOstream(std::ostream* output) const { @@ -191,6 +197,10 @@ bool Message::SerializePartialToOstream(std::ostream* output) const { Reflection::~Reflection() {} +void Reflection::AddAllocatedMessage(Message* /* message */, + const FieldDescriptor* /*field */, + Message* /* new_entry */) const {} + #define HANDLE_TYPE(TYPE, CPPTYPE, CTYPE) \ template<> \ const RepeatedField<TYPE>& Reflection::GetRepeatedField<TYPE>( \ @@ -453,7 +463,7 @@ namespace internal { template<> #if defined(_MSC_VER) && (_MSC_VER >= 1800) // Note: force noinline to workaround MSVC compiler bug with /Zc:inline, issue #240 -GOOGLE_ATTRIBUTE_NOINLINE +GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE #endif Message* GenericTypeHandler<Message>::NewFromPrototype( const Message* prototype, google::protobuf::Arena* arena) { @@ -462,7 +472,7 @@ Message* GenericTypeHandler<Message>::NewFromPrototype( template<> #if defined(_MSC_VER) && (_MSC_VER >= 1800) // Note: force noinline to workaround MSVC compiler bug with /Zc:inline, issue #240 -GOOGLE_ATTRIBUTE_NOINLINE +GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE #endif google::protobuf::Arena* GenericTypeHandler<Message>::GetArena( Message* value) { @@ -471,7 +481,7 @@ google::protobuf::Arena* GenericTypeHandler<Message>::GetArena( template<> #if defined(_MSC_VER) && (_MSC_VER >= 1800) // Note: force noinline to workaround MSVC compiler bug with /Zc:inline, issue #240 -GOOGLE_ATTRIBUTE_NOINLINE +GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE #endif void* GenericTypeHandler<Message>::GetMaybeArenaPointer( Message* value) { diff --git a/src/google/protobuf/message.h b/src/google/protobuf/message.h index c155cbd6..fc630b58 100644 --- a/src/google/protobuf/message.h +++ b/src/google/protobuf/message.h @@ -152,6 +152,9 @@ class CodedOutputStream; // coded_stream.h namespace python { class MapReflectionFriend; // scalar_map_container.h } +namespace expr { +class CelMapReflectionFriend; // field_backed_map_impl.cc +} namespace internal { @@ -254,6 +257,7 @@ class LIBPROTOBUF_EXPORT Message : public MessageLite { // fields defined for the proto. virtual size_t SpaceUsedLong() const; + PROTOBUF_RUNTIME_DEPRECATED("Please use SpaceUsedLong() instead") int SpaceUsed() const { return internal::ToIntSize(SpaceUsedLong()); } // Debugging & Testing---------------------------------------------- @@ -326,18 +330,19 @@ class LIBPROTOBUF_EXPORT Message : public MessageLite { // Typedef for backwards-compatibility. typedef google::protobuf::Reflection Reflection; - // Get a Descriptor for this message's type. This describes what - // fields the message contains, the types of those fields, etc. + // Get a non-owning pointer to a Descriptor for this message's type. This + // describes what fields the message contains, the types of those fields, etc. + // This object remains property of the Message. const Descriptor* GetDescriptor() const { return GetMetadata().descriptor; } - // Get the Reflection interface for this Message, which can be used to - // read and modify the fields of the Message dynamically (in other words, - // without knowing the message type at compile time). This object remains - // property of the Message. + // Get a non-owning pointer to the Reflection interface for this Message, + // which can be used to read and modify the fields of the Message dynamically + // (in other words, without knowing the message type at compile time). This + // object remains property of the Message. // // This method remains virtual in case a subclass does not implement // reflection and wants to override the default behavior. - virtual const Reflection* GetReflection() const { + virtual const Reflection* GetReflection() const PROTOBUF_FINAL { return GetMetadata().reflection; } @@ -404,9 +409,6 @@ class MutableRepeatedFieldRef; // double the message's memory footprint, probably worse. Allocating the // objects on-demand, on the other hand, would be expensive and prone to // memory leaks. So, instead we ended up with this flat interface. -// -// TODO(kenton): Create a utility class which callers can use to read and -// write fields from a Reflection without paying attention to the type. class LIBPROTOBUF_EXPORT Reflection { public: inline Reflection() {} @@ -428,6 +430,7 @@ class LIBPROTOBUF_EXPORT Reflection { // Estimate the amount of memory used by the message object. virtual size_t SpaceUsedLong(const Message& message) const = 0; + PROTOBUF_RUNTIME_DEPRECATED("Please use SpaceUsedLong() instead") int SpaceUsed(const Message& message) const { return internal::ToIntSize(SpaceUsedLong(message)); } @@ -494,11 +497,14 @@ class LIBPROTOBUF_EXPORT Reflection { int index1, int index2) const = 0; - // List all fields of the message which are currently set. This includes - // extensions. Singular fields will only be listed if HasField(field) would - // return true and repeated fields will only be listed if FieldSize(field) - // would return non-zero. Fields (both normal fields and extension fields) - // will be listed ordered by field number. + // List all fields of the message which are currently set, except for unknown + // fields, but including extension known to the parser (i.e. compiled in). + // Singular fields will only be listed if HasField(field) would return true + // and repeated fields will only be listed if FieldSize(field) would return + // non-zero. Fields (both normal fields and extension fields) will be listed + // ordered by field number. + // Use Reflection::GetUnknownFields() or message.unknown_fields() to also get + // access to fields/extensions unknown to the parser. virtual void ListFields( const Message& message, std::vector<const FieldDescriptor*>* output) const = 0; @@ -752,9 +758,9 @@ class LIBPROTOBUF_EXPORT Reflection { // specifyed by 'field' passing ownership to the message. // TODO(tmarek): Make virtual after all subclasses have been // updated. - virtual void AddAllocatedMessage(Message* /* message */, - const FieldDescriptor* /* field */, - Message* /* new_entry */) const {} + virtual void AddAllocatedMessage(Message* message, + const FieldDescriptor* field, + Message* new_entry) const; // Get a RepeatedFieldRef object that can be used to read the underlying @@ -809,6 +815,7 @@ class LIBPROTOBUF_EXPORT Reflection { // // for T = Cord and all protobuf scalar types except enums. template<typename T> + PROTOBUF_RUNTIME_DEPRECATED("Please use GetRepeatedFieldRef() instead") const RepeatedField<T>& GetRepeatedField( const Message&, const FieldDescriptor*) const; @@ -816,6 +823,7 @@ class LIBPROTOBUF_EXPORT Reflection { // // for T = Cord and all protobuf scalar types except enums. template<typename T> + PROTOBUF_RUNTIME_DEPRECATED("Please use GetMutableRepeatedFieldRef() instead") RepeatedField<T>* MutableRepeatedField( Message*, const FieldDescriptor*) const; @@ -824,6 +832,7 @@ class LIBPROTOBUF_EXPORT Reflection { // for T = string, google::protobuf::internal::StringPieceField // google::protobuf::Message & descendants. template<typename T> + PROTOBUF_RUNTIME_DEPRECATED("Please use GetRepeatedFieldRef() instead") const RepeatedPtrField<T>& GetRepeatedPtrField( const Message&, const FieldDescriptor*) const; @@ -832,6 +841,7 @@ class LIBPROTOBUF_EXPORT Reflection { // for T = string, google::protobuf::internal::StringPieceField // google::protobuf::Message & descendants. template<typename T> + PROTOBUF_RUNTIME_DEPRECATED("Please use GetMutableRepeatedFieldRef() instead") RepeatedPtrField<T>* MutableRepeatedPtrField( Message*, const FieldDescriptor*) const; @@ -920,7 +930,7 @@ class LIBPROTOBUF_EXPORT Reflection { // Returns a raw pointer to the repeated field // - // "cpp_type" and "message_type" are decuded from the type parameter T passed + // "cpp_type" and "message_type" are deduced from the type parameter T passed // to Get(Mutable)RepeatedFieldRef. If T is a generated message type, // "message_type" should be set to its descriptor. Otherwise "message_type" // should be set to NULL. Implementations of this method should check whether @@ -943,6 +953,8 @@ class LIBPROTOBUF_EXPORT Reflection { template<typename T, typename Enable> friend class MutableRepeatedFieldRef; friend class ::google::protobuf::python::MapReflectionFriend; +#define GOOGLE_PROTOBUF_HAS_CEL_MAP_REFLECTION_FRIEND + friend class ::google::protobuf::expr::CelMapReflectionFriend; friend class internal::MapFieldReflectionTest; friend class internal::MapKeySorter; friend class internal::WireFormat; diff --git a/src/google/protobuf/message_lite.cc b/src/google/protobuf/message_lite.cc index fda84b51..123b142d 100644 --- a/src/google/protobuf/message_lite.cc +++ b/src/google/protobuf/message_lite.cc @@ -103,15 +103,15 @@ string InitializationErrorMessage(const char* action, // call MergePartialFromCodedStream(). However, when parsing very small // messages, every function call introduces significant overhead. To avoid // this without reproducing code, we use these forced-inline helpers. -GOOGLE_ATTRIBUTE_ALWAYS_INLINE bool InlineMergeFromCodedStream( +GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE bool InlineMergeFromCodedStream( io::CodedInputStream* input, MessageLite* message); -GOOGLE_ATTRIBUTE_ALWAYS_INLINE bool InlineParseFromCodedStream( +GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE bool InlineParseFromCodedStream( io::CodedInputStream* input, MessageLite* message); -GOOGLE_ATTRIBUTE_ALWAYS_INLINE bool InlineParsePartialFromCodedStream( +GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE bool InlineParsePartialFromCodedStream( io::CodedInputStream* input, MessageLite* message); -GOOGLE_ATTRIBUTE_ALWAYS_INLINE bool InlineParseFromArray( +GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE bool InlineParseFromArray( const void* data, int size, MessageLite* message); -GOOGLE_ATTRIBUTE_ALWAYS_INLINE bool InlineParsePartialFromArray( +GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE bool InlineParsePartialFromArray( const void* data, int size, MessageLite* message); inline bool InlineMergeFromCodedStream(io::CodedInputStream* input, @@ -227,19 +227,6 @@ uint8* MessageLite::SerializeWithCachedSizesToArray(uint8* target) const { io::CodedOutputStream::IsDefaultSerializationDeterministic(), target); } -uint8* MessageLite::InternalSerializeWithCachedSizesToArray( - bool deterministic, uint8* target) const { - // We only optimize this when using optimize_for = SPEED. In other cases - // we just use the CodedOutputStream path. - int size = GetCachedSize(); - io::ArrayOutputStream out(target, size); - io::CodedOutputStream coded_out(&out); - coded_out.SetSerializationDeterministic(deterministic); - SerializeWithCachedSizes(&coded_out); - GOOGLE_CHECK(!coded_out.HadError()); - return target + size; -} - bool MessageLite::SerializeToCodedStream(io::CodedOutputStream* output) const { GOOGLE_DCHECK(IsInitialized()) << InitializationErrorMessage("serialize", *this); return SerializePartialToCodedStream(output); @@ -357,6 +344,39 @@ string MessageLite::SerializePartialAsString() const { return output; } +void MessageLite::SerializeWithCachedSizes( + io::CodedOutputStream* output) const { + GOOGLE_DCHECK(InternalGetTable()); + internal::TableSerialize( + *this, + static_cast<const internal::SerializationTable*>(InternalGetTable()), + output); +} + +// The table driven code optimizes the case that the CodedOutputStream buffer +// is large enough to serialize into it directly. +// If the proto is optimized for speed, this method will be overridden by +// generated code for maximum speed. If the proto is optimized for size or +// is lite, then we need to specialize this to avoid infinite recursion. +uint8* MessageLite::InternalSerializeWithCachedSizesToArray( + bool deterministic, uint8* target) const { + const internal::SerializationTable* table = + static_cast<const internal::SerializationTable*>(InternalGetTable()); + if (table == NULL) { + // We only optimize this when using optimize_for = SPEED. In other cases + // we just use the CodedOutputStream path. + int size = GetCachedSize(); + io::ArrayOutputStream out(target, size); + io::CodedOutputStream coded_out(&out); + coded_out.SetSerializationDeterministic(deterministic); + SerializeWithCachedSizes(&coded_out); + GOOGLE_CHECK(!coded_out.HadError()); + return target + size; + } else { + return internal::TableSerializeToArray(*this, table, deterministic, target); + } +} + namespace internal { template<> MessageLite* GenericTypeHandler<MessageLite>::NewFromPrototype( @@ -373,6 +393,14 @@ void GenericTypeHandler<string>::Merge(const string& from, string* to) { *to = from; } + +bool proto3_preserve_unknown_ = true; + +void SetProto3PreserveUnknownsDefault(bool preserve) { + proto3_preserve_unknown_ = preserve; +} + + } // namespace internal } // namespace protobuf diff --git a/src/google/protobuf/message_lite.h b/src/google/protobuf/message_lite.h index 046a736d..0b2b24b2 100644 --- a/src/google/protobuf/message_lite.h +++ b/src/google/protobuf/message_lite.h @@ -42,22 +42,115 @@ #include <climits> #include <google/protobuf/stubs/common.h> #include <google/protobuf/stubs/logging.h> -#include <google/protobuf/generated_message_util.h> - +#include <google/protobuf/stubs/once.h> +#include <google/protobuf/stubs/port.h> namespace google { namespace protobuf { - class Arena; +class Arena; +template <typename T> +class RepeatedPtrField; namespace io { - class CodedInputStream; - class CodedOutputStream; - class ZeroCopyInputStream; - class ZeroCopyOutputStream; +class CodedInputStream; +class CodedOutputStream; +class ZeroCopyInputStream; +class ZeroCopyOutputStream; } namespace internal { - class WireFormatLite; + +class RepeatedPtrFieldBase; +class WireFormatLite; + +#ifndef SWIG +// 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. However this case should not error or +// GOOGLE_CHECK-fail, because the full size_t resolution is still returned from +// ByteSizeLong() and checked against INT_MAX; we can catch the overflow +// there. +inline int ToCachedSize(size_t size) { return static_cast<int>(size); } + +// We mainly calculate sizes in terms of size_t, but some functions that +// compute sizes return "int". These int sizes are expected to always be +// positive. This function is more efficient than casting an int to size_t +// directly on 64-bit platforms because it avoids making the compiler emit a +// sign extending instruction, which we don't want and don't want to pay for. +inline size_t FromIntSize(int size) { + // Convert to unsigned before widening so sign extension is not necessary. + return static_cast<unsigned int>(size); +} + +// For cases where a legacy function returns an integer size. We GOOGLE_DCHECK() +// that the conversion will fit within an integer; if this is false then we +// are losing information. +inline int ToIntSize(size_t size) { + GOOGLE_DCHECK_LE(size, static_cast<size_t>(INT_MAX)); + return static_cast<int>(size); +} + +// This type wraps a variable whose constructor and destructor are explicitly +// called. It is particularly useful for a global variable, without its +// 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. +// +// Pay special attention to the initialization state of the object. +// 1. The object is "uninitialized" to begin with. +// 2. Call DefaultConstruct() only if the object is uninitialized. +// After the call, the object becomes "initialized". +// 3. Call get() and get_mutable() only if the object is initialized. +// 4. Call Destruct() only if the object is initialized. +// After the call, the object becomes uninitialized. +template <typename T> +class ExplicitlyConstructed { + public: + void DefaultConstruct() { + new (&union_) T(); + } + + void Destruct() { + get_mutable()->~T(); + } + +#if LANG_CXX11 + constexpr +#endif + const T& + get() const { + return reinterpret_cast<const T&>(union_); + } + T* get_mutable() { return reinterpret_cast<T*>(&union_); } + + private: + // Prefer c++14 aligned_storage, but for compatibility this will do. + union AlignedUnion { + char space[sizeof(T)]; + int64 align_to_int64; + void* align_to_ptr; + } union_; +}; + +// Default empty string object. Don't use this directly. Instead, call +// GetEmptyString() to get the reference. +extern ExplicitlyConstructed< ::std::string> fixed_address_empty_string; +LIBPROTOBUF_EXPORT extern ProtobufOnceType empty_string_once_init_; +LIBPROTOBUF_EXPORT void InitEmptyString(); + + +LIBPROTOBUF_EXPORT inline const ::std::string& GetEmptyStringAlreadyInited() { + return fixed_address_empty_string.get(); } +LIBPROTOBUF_EXPORT inline const ::std::string& GetEmptyString() { + ::google::protobuf::GoogleOnceInit(&empty_string_once_init_, &InitEmptyString); + return GetEmptyStringAlreadyInited(); +} + +LIBPROTOBUF_EXPORT size_t StringSpaceUsedExcludingSelfLong(const string& str); +#endif // SWIG +} // namespace internal + // Interface to light weight protocol messages. // // This interface is implemented by all protocol message objects. Non-lite @@ -102,18 +195,19 @@ class LIBPROTOBUF_EXPORT MessageLite { // Get the arena, if any, associated with this message. Virtual method // required for generic operations but most arena-related operations should // use the GetArenaNoVirtual() generated-code method. Default implementation - // to reduce code size by avoiding the need for per-type implementations when - // types do not implement arena support. + // to reduce code size by avoiding the need for per-type implementations + // when types do not implement arena support. virtual ::google::protobuf::Arena* GetArena() const { return NULL; } - // Get a pointer that may be equal to this message's arena, or may not be. If - // the value returned by this method is equal to some arena pointer, then this - // message is on that arena; however, if this message is on some arena, this - // method may or may not return that arena's pointer. As a tradeoff, this - // method may be more efficient than GetArena(). The intent is to allow - // underlying representations that use e.g. tagged pointers to sometimes store - // the arena pointer directly, and sometimes in a more indirect way, and allow - // a fastpath comparison against the arena pointer when it's easy to obtain. + // Get a pointer that may be equal to this message's arena, or may not be. + // If the value returned by this method is equal to some arena pointer, then + // this message is on that arena; however, if this message is on some arena, + // this method may or may not return that arena's pointer. As a tradeoff, + // this method may be more efficient than GetArena(). The intent is to allow + // underlying representations that use e.g. tagged pointers to sometimes + // store the arena pointer directly, and sometimes in a more indirect way, + // and allow a fastpath comparison against the arena pointer when it's easy + // to obtain. virtual void* GetMaybeArenaPointer() const { return GetArena(); } // Clear all fields of the message and set them to their default values. @@ -131,19 +225,20 @@ class LIBPROTOBUF_EXPORT MessageLite { // for full messages. See message.h. virtual string InitializationErrorString() const; - // If |other| is the exact same class as this, calls MergeFrom(). Otherwise, + // If |other| is the exact same class as this, calls MergeFrom(). Otherwise, // results are undefined (probably crash). virtual void CheckTypeAndMergeFrom(const MessageLite& other) = 0; // Parsing --------------------------------------------------------- // Methods for parsing in protocol buffer format. Most of these are - // just simple wrappers around MergeFromCodedStream(). Clear() will be called - // before merging the input. - - // Fill the message with a protocol buffer parsed from the given input stream. - // Returns false on a read error or if the input is in the wrong format. A - // successful return does not indicate the entire input is consumed, ensure - // you call ConsumedEntireMessage() to check that if applicable. + // just simple wrappers around MergeFromCodedStream(). Clear() will be + // called before merging the input. + + // Fill the message with a protocol buffer parsed from the given input + // stream. Returns false on a read error or if the input is in the wrong + // format. A successful return does not indicate the entire input is + // consumed, ensure you call ConsumedEntireMessage() to check that if + // applicable. bool ParseFromCodedStream(io::CodedInputStream* input); // Like ParseFromCodedStream(), but accepts messages that are missing // required fields. @@ -249,13 +344,16 @@ class LIBPROTOBUF_EXPORT MessageLite { virtual size_t ByteSizeLong() const = 0; // Legacy ByteSize() API. - int ByteSize() const { return internal::ToIntSize(ByteSizeLong()); } + PROTOBUF_RUNTIME_DEPRECATED("Please use ByteSizeLong() instead") + int ByteSize() const { + return internal::ToIntSize(ByteSizeLong()); + } // Serializes the message without recomputing the size. The message must not // have changed since the last call to ByteSize(), and the value returned by // ByteSize must be non-negative. Otherwise the results are undefined. virtual void SerializeWithCachedSizes( - io::CodedOutputStream* output) const = 0; + io::CodedOutputStream* output) const; // Functions below here are not part of the public interface. It isn't // enforced, but they should be treated as private, and will be private @@ -285,12 +383,48 @@ class LIBPROTOBUF_EXPORT MessageLite { virtual uint8* InternalSerializeWithCachedSizesToArray(bool deterministic, uint8* target) const; + protected: + // CastToBase allows generated code to cast a RepeatedPtrField<T> to + // RepeatedPtrFieldBase. We try to restrict access to RepeatedPtrFieldBase + // because it is an implementation detail that user code should not access + // directly. + template <typename T> + static ::google::protobuf::internal::RepeatedPtrFieldBase* CastToBase( + ::google::protobuf::RepeatedPtrField<T>* repeated) { + return repeated; + } + template <typename T> + static const ::google::protobuf::internal::RepeatedPtrFieldBase& CastToBase( + const ::google::protobuf::RepeatedPtrField<T>& repeated) { + return repeated; + } + private: + // TODO(gerbens) make this a pure abstract function + virtual const void* InternalGetTable() const { return NULL; } + friend class internal::WireFormatLite; + friend class Message; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageLite); }; +namespace internal { + +extern bool LIBPROTOBUF_EXPORT proto3_preserve_unknown_; + +// DO NOT USE: For migration only. Will be removed when Proto3 defaults to +// preserve unknowns. +inline bool GetProto3PreserveUnknownsDefault() { + return proto3_preserve_unknown_; +} + +// DO NOT USE: For migration only. Will be removed when Proto3 defaults to +// preserve unknowns. +void LIBPROTOBUF_EXPORT SetProto3PreserveUnknownsDefault(bool preserve); +} // namespace internal + + } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/message_unittest.cc b/src/google/protobuf/message_unittest.cc index 0469f4ca..a27036e7 100644 --- a/src/google/protobuf/message_unittest.cc +++ b/src/google/protobuf/message_unittest.cc @@ -37,9 +37,7 @@ #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> -#ifdef _MSC_VER -#include <io.h> -#else +#ifndef _MSC_VER #include <unistd.h> #endif #include <sstream> @@ -51,6 +49,7 @@ #include <google/protobuf/io/zero_copy_stream.h> #include <google/protobuf/io/zero_copy_stream_impl.h> #include <google/protobuf/descriptor.pb.h> +#include <google/protobuf/arena.h> #include <google/protobuf/descriptor.h> #include <google/protobuf/generated_message_reflection.h> @@ -59,10 +58,18 @@ #include <google/protobuf/stubs/logging.h> #include <google/protobuf/testing/googletest.h> #include <gtest/gtest.h> +#include <google/protobuf/stubs/io_win32.h> namespace google { namespace protobuf { +#if defined(_WIN32) +// DO NOT include <io.h>, instead create functions in io_win32.{h,cc} and import +// them like we do below. +using google::protobuf::internal::win32::close; +using google::protobuf::internal::win32::open; +#endif + #ifndef O_BINARY #ifdef _O_BINARY #define O_BINARY _O_BINARY @@ -112,8 +119,9 @@ TEST(MessageTest, ParseFromFileDescriptor) { string filename = TestSourceDir() + "/google/protobuf/testdata/golden_message"; int file = open(filename.c_str(), O_RDONLY | O_BINARY); + ASSERT_GE(file, 0); - unittest::TestAllTypes message; + protobuf_unittest::TestAllTypes message; EXPECT_TRUE(message.ParseFromFileDescriptor(file)); TestUtil::ExpectAllFieldsSet(message); @@ -125,8 +133,9 @@ TEST(MessageTest, ParsePackedFromFileDescriptor) { TestSourceDir() + "/google/protobuf/testdata/golden_packed_fields_message"; int file = open(filename.c_str(), O_RDONLY | O_BINARY); + ASSERT_GE(file, 0); - unittest::TestPackedTypes message; + protobuf_unittest::TestPackedTypes message; EXPECT_TRUE(message.ParseFromFileDescriptor(file)); TestUtil::ExpectPackedFieldsSet(message); @@ -248,42 +257,6 @@ TEST(MessageTest, CheckInitialized) { "fields: a, b, c"); } -TEST(MessageTest, CheckOverflow) { - unittest::TestAllTypes message; - // Create a message with size just over 2GB. This triggers integer overflow - // when computing message size. - const string data(1024, 'x'); - Cord one_megabyte; - for (int i = 0; i < 1024; i++) { - one_megabyte.Append(data); - } - - for (int i = 0; i < 2 * 1024 + 1; ++i) { - message.add_repeated_cord()->CopyFrom(one_megabyte); - } - - Cord serialized; - 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 { @@ -422,8 +395,21 @@ TEST(MessageTest, MessageIsStillValidAfterParseFails) { EXPECT_FALSE(message.ParseFromString(invalid_data)); message.Clear(); EXPECT_EQ(0, message.optional_uint64()); + + // invalid data for field "optional_string". Length prefix is 1 but no + // payload. + string invalid_string_data = "\x72\x01"; + { + google::protobuf::Arena arena; + unittest::TestAllTypes* arena_message = + google::protobuf::Arena::CreateMessage<unittest::TestAllTypes>(&arena); + EXPECT_FALSE(arena_message->ParseFromString(invalid_string_data)); + arena_message->Clear(); + EXPECT_EQ("", arena_message->optional_string()); + } } + namespace { void ExpectMessageMerged(const unittest::TestAllTypes& message) { diff --git a/src/google/protobuf/metadata_lite.h b/src/google/protobuf/metadata_lite.h index 64fde0c6..454d088c 100644 --- a/src/google/protobuf/metadata_lite.h +++ b/src/google/protobuf/metadata_lite.h @@ -33,7 +33,8 @@ #include <google/protobuf/stubs/common.h> #include <google/protobuf/arena.h> -#include <google/protobuf/generated_message_util.h> +#include <google/protobuf/message_lite.h> +#include <google/protobuf/stubs/port.h> namespace google { namespace protobuf { @@ -62,7 +63,7 @@ class InternalMetadataWithArenaBase { ptr_ = NULL; } - GOOGLE_ATTRIBUTE_ALWAYS_INLINE const T& unknown_fields() const { + GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE const T& unknown_fields() const { if (GOOGLE_PREDICT_FALSE(have_unknown_fields())) { return PtrValue<Container>()->unknown_fields; } else { @@ -70,7 +71,7 @@ class InternalMetadataWithArenaBase { } } - GOOGLE_ATTRIBUTE_ALWAYS_INLINE T* mutable_unknown_fields() { + GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE T* mutable_unknown_fields() { if (GOOGLE_PREDICT_TRUE(have_unknown_fields())) { return &PtrValue<Container>()->unknown_fields; } else { @@ -78,7 +79,7 @@ class InternalMetadataWithArenaBase { } } - GOOGLE_ATTRIBUTE_ALWAYS_INLINE Arena* arena() const { + GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE Arena* arena() const { if (GOOGLE_PREDICT_FALSE(have_unknown_fields())) { return PtrValue<Container>()->arena; } else { @@ -86,11 +87,11 @@ class InternalMetadataWithArenaBase { } } - GOOGLE_ATTRIBUTE_ALWAYS_INLINE bool have_unknown_fields() const { + GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE bool have_unknown_fields() const { return PtrTag() == kTagContainer; } - GOOGLE_ATTRIBUTE_ALWAYS_INLINE void Swap(Derived* other) { + GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE void Swap(Derived* other) { // Semantics here are that we swap only the unknown fields, not the arena // pointer. We cannot simply swap ptr_ with other->ptr_ because we need to // maintain our own arena ptr. Also, our ptr_ and other's ptr_ may be in @@ -102,19 +103,19 @@ class InternalMetadataWithArenaBase { } } - GOOGLE_ATTRIBUTE_ALWAYS_INLINE void MergeFrom(const Derived& other) { + GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE void MergeFrom(const Derived& other) { if (other.have_unknown_fields()) { static_cast<Derived*>(this)->DoMergeFrom(other.unknown_fields()); } } - GOOGLE_ATTRIBUTE_ALWAYS_INLINE void Clear() { + GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE void Clear() { if (have_unknown_fields()) { static_cast<Derived*>(this)->DoClear(); } } - GOOGLE_ATTRIBUTE_ALWAYS_INLINE void* raw_arena_ptr() const { + GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE void* raw_arena_ptr() const { return ptr_; } @@ -132,7 +133,7 @@ class InternalMetadataWithArenaBase { static const intptr_t kPtrValueMask = ~kPtrTagMask; // Accessors for pointer tag and pointer value. - GOOGLE_ATTRIBUTE_ALWAYS_INLINE int PtrTag() const { + GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE int PtrTag() const { return reinterpret_cast<intptr_t>(ptr_) & kPtrTagMask; } @@ -147,11 +148,14 @@ class InternalMetadataWithArenaBase { Arena* arena; }; - GOOGLE_ATTRIBUTE_NOINLINE T* mutable_unknown_fields_slow() { + GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE T* mutable_unknown_fields_slow() { Arena* my_arena = arena(); Container* container = Arena::Create<Container>(my_arena); + // Two-step assignment works around a bug in clang's static analyzer: + // https://bugs.llvm.org/show_bug.cgi?id=34198. + ptr_ = container; ptr_ = reinterpret_cast<void*>( - reinterpret_cast<intptr_t>(container) | kTagContainer); + reinterpret_cast<intptr_t>(ptr_) | kTagContainer); container->arena = my_arena; return &(container->unknown_fields); } @@ -187,6 +191,32 @@ class InternalMetadataWithArenaLite } }; +// This helper RAII class is needed to efficiently parse unknown fields. We +// should only call mutable_unknown_fields if there are actual unknown fields. +// The obvious thing to just use a stack string and swap it at the end of the +// parse won't work, because the destructor of StringOutputStream needs to be +// called before we can modify the string (it check-fails). Using +// LiteUnknownFieldSetter setter(&_internal_metadata_); +// StringOutputStream stream(setter.buffer()); +// guarantees that the string is only swapped after stream is destroyed. +class LIBPROTOBUF_EXPORT LiteUnknownFieldSetter { + public: + explicit LiteUnknownFieldSetter(InternalMetadataWithArenaLite* metadata) + : metadata_(metadata) { + if (metadata->have_unknown_fields()) { + buffer_.swap(*metadata->mutable_unknown_fields()); + } + } + ~LiteUnknownFieldSetter() { + if (!buffer_.empty()) metadata_->mutable_unknown_fields()->swap(buffer_); + } + string* buffer() { return &buffer_; } + + private: + InternalMetadataWithArenaLite* metadata_; + string buffer_; +}; + } // namespace internal } // namespace protobuf diff --git a/src/google/protobuf/proto3_arena_unittest.cc b/src/google/protobuf/proto3_arena_unittest.cc index 2838e0fc..3a0fb804 100644 --- a/src/google/protobuf/proto3_arena_unittest.cc +++ b/src/google/protobuf/proto3_arena_unittest.cc @@ -129,7 +129,8 @@ TEST(Proto3ArenaTest, Parsing) { ExpectAllFieldsSet(*arena_message); } -TEST(Proto3ArenaTest, UnknownFields) { +TEST(Proto3ArenaTest, UnknownFieldsDefaultDrop) { + ::google::protobuf::internal::SetProto3PreserveUnknownsDefault(false); TestAllTypes original; SetAllFields(&original); @@ -150,6 +151,28 @@ TEST(Proto3ArenaTest, UnknownFields) { arena_message->GetReflection()->GetUnknownFields(*arena_message).empty()); } +TEST(Proto3ArenaTest, UnknownFieldsDefaultPreserve) { + ::google::protobuf::internal::SetProto3PreserveUnknownsDefault(true); + TestAllTypes original; + SetAllFields(&original); + + Arena arena; + TestAllTypes* arena_message = Arena::CreateMessage<TestAllTypes>(&arena); + arena_message->ParseFromString(original.SerializeAsString()); + ExpectAllFieldsSet(*arena_message); + + // In proto3 we can still get a pointer to the UnknownFieldSet through + // reflection API. + UnknownFieldSet* unknown_fields = + arena_message->GetReflection()->MutableUnknownFields(arena_message); + // We can modify this UnknownFieldSet. + unknown_fields->AddVarint(1, 2); + // And the unknown fields should be changed. + ASSERT_NE(original.ByteSize(), arena_message->ByteSize()); + ASSERT_FALSE( + arena_message->GetReflection()->GetUnknownFields(*arena_message).empty()); +} + TEST(Proto3ArenaTest, Swap) { Arena arena1; Arena arena2; diff --git a/src/google/protobuf/reflection_ops.cc b/src/google/protobuf/reflection_ops.cc index d1867311..eb2a0e7a 100644 --- a/src/google/protobuf/reflection_ops.cc +++ b/src/google/protobuf/reflection_ops.cc @@ -31,13 +31,15 @@ // Author: kenton@google.com (Kenton Varda) // Based on original Protocol Buffers design by // Sanjay Ghemawat, Jeff Dean, and others. +#include <google/protobuf/reflection_ops.h> #include <string> #include <vector> -#include <google/protobuf/reflection_ops.h> -#include <google/protobuf/descriptor.h> +#include <google/protobuf/stubs/logging.h> +#include <google/protobuf/stubs/common.h> #include <google/protobuf/descriptor.pb.h> +#include <google/protobuf/descriptor.h> #include <google/protobuf/map_field.h> #include <google/protobuf/unknown_field_set.h> #include <google/protobuf/stubs/strutil.h> @@ -46,6 +48,17 @@ namespace google { namespace protobuf { namespace internal { +static const Reflection* GetReflectionOrDie(const Message& m) { + const Reflection* r = m.GetReflection(); + if (r == NULL) { + const Descriptor* d = m.GetDescriptor(); + const string& mtype = d ? d->name() : "unknown"; + // RawMessage is one known type for which GetReflection() returns NULL. + GOOGLE_LOG(FATAL) << "Message does not support reflection (type " << mtype << ")."; + } + return r; +} + void ReflectionOps::Copy(const Message& from, Message* to) { if (&from == to) return; Clear(to); @@ -61,8 +74,8 @@ void ReflectionOps::Merge(const Message& from, Message* to) { << "(merge " << descriptor->full_name() << " to " << to->GetDescriptor()->full_name() << ")"; - const Reflection* from_reflection = from.GetReflection(); - const Reflection* to_reflection = to->GetReflection(); + const Reflection* from_reflection = GetReflectionOrDie(from); + const Reflection* to_reflection = GetReflectionOrDie(*to); std::vector<const FieldDescriptor*> fields; from_reflection->ListFields(from, &fields); @@ -128,7 +141,7 @@ void ReflectionOps::Merge(const Message& from, Message* to) { } void ReflectionOps::Clear(Message* message) { - const Reflection* reflection = message->GetReflection(); + const Reflection* reflection = GetReflectionOrDie(*message); std::vector<const FieldDescriptor*> fields; reflection->ListFields(*message, &fields); @@ -141,7 +154,7 @@ void ReflectionOps::Clear(Message* message) { bool ReflectionOps::IsInitialized(const Message& message) { const Descriptor* descriptor = message.GetDescriptor(); - const Reflection* reflection = message.GetReflection(); + const Reflection* reflection = GetReflectionOrDie(message); // Check required fields of this message. for (int i = 0; i < descriptor->field_count(); i++) { @@ -201,7 +214,7 @@ bool ReflectionOps::IsInitialized(const Message& message) { } void ReflectionOps::DiscardUnknownFields(Message* message) { - const Reflection* reflection = message->GetReflection(); + const Reflection* reflection = GetReflectionOrDie(*message); reflection->MutableUnknownFields(message)->Clear(); @@ -248,7 +261,7 @@ void ReflectionOps::FindInitializationErrors( const string& prefix, std::vector<string>* errors) { const Descriptor* descriptor = message.GetDescriptor(); - const Reflection* reflection = message.GetReflection(); + const Reflection* reflection = GetReflectionOrDie(message); // Check required fields of this message. for (int i = 0; i < descriptor->field_count(); i++) { diff --git a/src/google/protobuf/repeated_field.cc b/src/google/protobuf/repeated_field.cc index 5ca964c1..310000aa 100644 --- a/src/google/protobuf/repeated_field.cc +++ b/src/google/protobuf/repeated_field.cc @@ -103,6 +103,22 @@ void RepeatedPtrFieldBase::CloseGap(int start, int num) { rep_->allocated_size -= num; } +google::protobuf::MessageLite* RepeatedPtrFieldBase::AddWeak( + const google::protobuf::MessageLite* prototype) { + if (rep_ != NULL && current_size_ < rep_->allocated_size) { + return reinterpret_cast<google::protobuf::MessageLite*>( + rep_->elements[current_size_++]); + } + if (!rep_ || rep_->allocated_size == total_size_) { + Reserve(total_size_ + 1); + } + ++rep_->allocated_size; + google::protobuf::MessageLite* result = prototype ? prototype->New(arena_) : + Arena::CreateMessage<ImplicitWeakMessage>(arena_); + rep_->elements[current_size_++] = result; + return result; +} + } // namespace internal diff --git a/src/google/protobuf/repeated_field.h b/src/google/protobuf/repeated_field.h index a1013f63..5fc619f2 100644 --- a/src/google/protobuf/repeated_field.h +++ b/src/google/protobuf/repeated_field.h @@ -57,10 +57,10 @@ #include <google/protobuf/stubs/casts.h> #include <google/protobuf/stubs/logging.h> #include <google/protobuf/stubs/common.h> -#include <google/protobuf/stubs/type_traits.h> #include <google/protobuf/arena.h> -#include <google/protobuf/generated_message_util.h> +#include <google/protobuf/implicit_weak_message.h> #include <google/protobuf/message_lite.h> +#include <google/protobuf/stubs/port.h> // Forward-declare these so that we can make them friends. @@ -86,7 +86,7 @@ void LogIndexOutOfBounds(int index, int size); template <typename Iter> inline int CalculateReserve(Iter begin, Iter end, std::forward_iterator_tag) { - return std::distance(begin, end); + return static_cast<int>(std::distance(begin, end)); } template <typename Iter> @@ -119,6 +119,11 @@ class RepeatedField PROTOBUF_FINAL { RepeatedField& operator=(const RepeatedField& other); +#if LANG_CXX11 + RepeatedField(RepeatedField&& other) noexcept; + RepeatedField& operator=(RepeatedField&& other) noexcept; +#endif + bool empty() const; int size() const; @@ -274,13 +279,24 @@ class RepeatedField PROTOBUF_FINAL { // a "gap" after the field arena and before the field elements (e.g., when // Element is double and pointer is 32bit). static const size_t kRepHeaderSize; - // Contains arena ptr and the elements array. We also keep the invariant that - // if rep_ is NULL, then arena is NULL. - Rep* rep_; + + // We reuse the Rep* for an Arena* when total_size == 0, to avoid having to do + // an allocation in the constructor when we have an Arena. + union Pointer { + Pointer(Arena* a) : arena(a) {} + Arena* arena; // When total_size_ == 0. + Rep* rep; // When total_size_ != 0. + } ptr_; + + Rep* rep() const { + GOOGLE_DCHECK_GT(total_size_, 0); + return ptr_.rep; + } friend class Arena; typedef void InternalArenaConstructable_; + // Move the contents of |from| into |to|, possibly clobbering |from| in the // process. For primitive types this is just a memcpy(), but it could be // specialized for non-primitive types to, say, swap each element instead. @@ -291,7 +307,7 @@ class RepeatedField PROTOBUF_FINAL { // Internal helper expected by Arena methods. inline Arena* GetArenaNoVirtual() const { - return (rep_ == NULL) ? NULL : rep_->arena; + return (total_size_ == 0) ? ptr_.arena : ptr_.rep->arena; } // Internal helper to delete all elements and deallocate the storage. @@ -370,7 +386,7 @@ struct TypeImplementsMergeBehaviorProbeForMergeFrom { CheckType<U, bool, &U::MergeFrom>*); template<typename U> static HasNoMerge Check(...); - // Resovles to either google::protobuf::internal::true_type or google::protobuf::internal::false_type. + // Resolves to either google::protobuf::internal::true_type or google::protobuf::internal::false_type. typedef google::protobuf::internal::integral_constant<bool, (sizeof(Check<T>(0)) == sizeof(HasMerge))> type; }; @@ -393,7 +409,12 @@ struct TypeImplementsMergeBehavior< ::std::string> { // class TypeHandler { // public: // typedef MyType Type; +// // WeakType is almost always the same as MyType, but we use it in +// // ImplicitWeakTypeHandler. +// typedef MyType WeakType; // static Type* New(); +// static WeakType* NewFromPrototype(const WeakType* prototype, +// ::google::protobuf::Arena* arena); // static void Delete(Type*); // static void Clear(Type*); // static void Merge(const Type& from, Type* to); @@ -403,31 +424,6 @@ struct TypeImplementsMergeBehavior< ::std::string> { // }; class LIBPROTOBUF_EXPORT RepeatedPtrFieldBase { protected: - // The reflection implementation needs to call protected methods directly, - // reinterpreting pointers as being to Message instead of a specific Message - // subclass. - friend class GeneratedMessageReflection; - - // ExtensionSet stores repeated message extensions as - // RepeatedPtrField<MessageLite>, but non-lite ExtensionSets need to implement - // SpaceUsedLong(), and thus need to call SpaceUsedExcludingSelfLong() - // reinterpreting MessageLite as Message. ExtensionSet also needs to make use - // of AddFromCleared(), which is not part of the public interface. - friend class ExtensionSet; - - // The MapFieldBase implementation needs to call protected methods directly, - // reinterpreting pointers as being to Message instead of a specific Message - // subclass. - friend class MapFieldBase; - - // The table-driven MergePartialFromCodedStream implementation needs to - // operate on RepeatedPtrField<MessageLite>. - friend class MergePartialFromCodedStreamHelper; - - // To parse directly into a proto2 generated class, the upb class GMR_Handlers - // needs to be able to modify a RepeatedPtrFieldBase directly. - friend class upb::google_opensource::GMR_Handlers; - RepeatedPtrFieldBase(); explicit RepeatedPtrFieldBase(::google::protobuf::Arena* arena); ~RepeatedPtrFieldBase() {} @@ -440,13 +436,35 @@ class LIBPROTOBUF_EXPORT RepeatedPtrFieldBase { int size() const; template <typename TypeHandler> - const typename TypeHandler::Type& Get(int index) const; - template <typename TypeHandler> typename TypeHandler::Type* Mutable(int index); template <typename TypeHandler> void Delete(int index); template <typename TypeHandler> typename TypeHandler::Type* Add(typename TypeHandler::Type* prototype = NULL); + + public: + // The next few methods are public so that they can be called from generated + // code when implicit weak fields are used, but they should never be called by + // application code. + + template <typename TypeHandler> + const typename TypeHandler::WeakType& Get(int index) const; + + // Creates and adds an element using the given prototype, without introducing + // a link-time dependency on the concrete message type. This method is used to + // implement implicit weak fields. The prototype may be NULL, in which case an + // ImplicitWeakMessage will be used as a placeholder. + google::protobuf::MessageLite* AddWeak(const google::protobuf::MessageLite* prototype); + + template <typename TypeHandler> + void Clear(); + + template <typename TypeHandler> + void MergeFrom(const RepeatedPtrFieldBase& other); + + inline void InternalSwap(RepeatedPtrFieldBase* other); + + protected: #if LANG_CXX11 template <typename TypeHandler> void Add(typename TypeHandler::Type&& value, @@ -456,10 +474,6 @@ class LIBPROTOBUF_EXPORT RepeatedPtrFieldBase { template <typename TypeHandler> void RemoveLast(); template <typename TypeHandler> - void Clear(); - template <typename TypeHandler> - void MergeFrom(const RepeatedPtrFieldBase& other); - template <typename TypeHandler> void CopyFrom(const RepeatedPtrFieldBase& other); void CloseGap(int start, int num); @@ -477,15 +491,14 @@ class LIBPROTOBUF_EXPORT RepeatedPtrFieldBase { template <typename TypeHandler> const typename TypeHandler::Type* const* data() const; - template <typename TypeHandler> - GOOGLE_ATTRIBUTE_ALWAYS_INLINE void Swap(RepeatedPtrFieldBase* other); + template <typename TypeHandler> GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE + void Swap(RepeatedPtrFieldBase* other); void SwapElements(int index1, int index2); template <typename TypeHandler> size_t SpaceUsedExcludingSelfLong() const; - // Advanced memory management -------------------------------------- // Like Add(), but if there are no cleared objects to use, returns NULL. @@ -518,21 +531,16 @@ class LIBPROTOBUF_EXPORT RepeatedPtrFieldBase { template <typename TypeHandler> typename TypeHandler::Type* ReleaseCleared(); - protected: - inline void InternalSwap(RepeatedPtrFieldBase* other); - template <typename TypeHandler> - void AddAllocatedInternal(typename TypeHandler::Type* value, - google::protobuf::internal::true_type); + void AddAllocatedInternal(typename TypeHandler::Type* value, google::protobuf::internal::true_type); template <typename TypeHandler> - void AddAllocatedInternal(typename TypeHandler::Type* value, - google::protobuf::internal::false_type); + void AddAllocatedInternal(typename TypeHandler::Type* value, google::protobuf::internal::false_type); - template <typename TypeHandler> GOOGLE_ATTRIBUTE_NOINLINE + template <typename TypeHandler> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE void AddAllocatedSlowWithCopy(typename TypeHandler::Type* value, Arena* value_arena, Arena* my_arena); - template <typename TypeHandler> GOOGLE_ATTRIBUTE_NOINLINE + template <typename TypeHandler> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE void AddAllocatedSlowWithoutCopy(typename TypeHandler::Type* value); template <typename TypeHandler> @@ -540,7 +548,7 @@ class LIBPROTOBUF_EXPORT RepeatedPtrFieldBase { template <typename TypeHandler> typename TypeHandler::Type* ReleaseLastInternal(google::protobuf::internal::false_type); - template<typename TypeHandler> GOOGLE_ATTRIBUTE_NOINLINE + template<typename TypeHandler> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE void SwapFallback(RepeatedPtrFieldBase* other); inline Arena* GetArenaNoVirtual() const { @@ -597,6 +605,33 @@ class LIBPROTOBUF_EXPORT RepeatedPtrFieldBase { // Reserve() and MergeFrom() to reduce code size. |extend_amount| must be > 0. void** InternalExtend(int extend_amount); + // The reflection implementation needs to call protected methods directly, + // reinterpreting pointers as being to Message instead of a specific Message + // subclass. + friend class GeneratedMessageReflection; + + // ExtensionSet stores repeated message extensions as + // RepeatedPtrField<MessageLite>, but non-lite ExtensionSets need to implement + // SpaceUsedLong(), and thus need to call SpaceUsedExcludingSelfLong() + // reinterpreting MessageLite as Message. ExtensionSet also needs to make use + // of AddFromCleared(), which is not part of the public interface. + friend class ExtensionSet; + + // The MapFieldBase implementation needs to call protected methods directly, + // reinterpreting pointers as being to Message instead of a specific Message + // subclass. + friend class MapFieldBase; + + // The table-driven MergePartialFromCodedStream implementation needs to + // operate on RepeatedPtrField<MessageLite>. + friend class MergePartialFromCodedStreamHelper; + + // To parse directly into a proto2 generated class, the upb class GMR_Handlers + // needs to be able to modify a RepeatedPtrFieldBase directly. + friend class upb::google_opensource::GMR_Handlers; + + friend class AccessorHelper; + GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedPtrFieldBase); }; @@ -604,13 +639,13 @@ template <typename GenericType> class GenericTypeHandler { public: typedef GenericType Type; + typedef GenericType WeakType; #if LANG_CXX11 static const bool Moveable = false; #endif static inline GenericType* New(Arena* arena) { - return ::google::protobuf::Arena::CreateMaybeMessage<Type>( - arena, static_cast<GenericType*>(0)); + return ::google::protobuf::Arena::CreateMaybeMessage<Type>(arena); } static inline GenericType* NewFromPrototype( const GenericType* prototype, ::google::protobuf::Arena* arena = NULL); @@ -627,14 +662,11 @@ class GenericTypeHandler { } static inline void Clear(GenericType* value) { value->Clear(); } - GOOGLE_ATTRIBUTE_NOINLINE static void Merge(const GenericType& from, - GenericType* to); + GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE + static void Merge(const GenericType& from, GenericType* to); static inline size_t SpaceUsedLong(const GenericType& value) { return value.SpaceUsedLong(); } - static inline const Type& default_instance() { - return Type::default_instance(); - } }; template <typename GenericType> @@ -696,28 +728,10 @@ DECLARE_SPECIALIZATIONS_FOR_BASE_PROTO_TYPES(Message) #undef DECLARE_SPECIALIZATIONS_FOR_BASE_PROTO_TYPES -template <> -inline const MessageLite& GenericTypeHandler<MessageLite>::default_instance() { - // Yes, the behavior of the code is undefined, but this function is only - // called when we're already deep into the world of undefined, because the - // caller called Get(index) out of bounds. - MessageLite* null = NULL; - return *null; -} - -template <> -inline const Message& GenericTypeHandler<Message>::default_instance() { - // Yes, the behavior of the code is undefined, but this function is only - // called when we're already deep into the world of undefined, because the - // caller called Get(index) out of bounds. - Message* null = NULL; - return *null; -} - - class StringTypeHandler { public: typedef string Type; + typedef string WeakType; #if LANG_CXX11 static const bool Moveable = std::is_move_constructible<Type>::value && @@ -749,9 +763,6 @@ class StringTypeHandler { } static inline void Clear(string* value) { value->clear(); } static inline void Merge(const string& from, string* to) { *to = from; } - static inline const Type& default_instance() { - return ::google::protobuf::internal::GetEmptyString(); - } static size_t SpaceUsedLong(const string& value) { return sizeof(value) + StringSpaceUsedExcludingSelfLong(value); } @@ -762,7 +773,7 @@ class StringTypeHandler { // RepeatedPtrField is like RepeatedField, but used for repeated strings or // Messages. template <typename Element> -class RepeatedPtrField PROTOBUF_FINAL : public internal::RepeatedPtrFieldBase { +class RepeatedPtrField PROTOBUF_FINAL : private internal::RepeatedPtrFieldBase { public: RepeatedPtrField(); explicit RepeatedPtrField(::google::protobuf::Arena* arena); @@ -774,6 +785,11 @@ class RepeatedPtrField PROTOBUF_FINAL : public internal::RepeatedPtrFieldBase { RepeatedPtrField& operator=(const RepeatedPtrField& other); +#if LANG_CXX11 + RepeatedPtrField(RepeatedPtrField&& other) noexcept; + RepeatedPtrField& operator=(RepeatedPtrField&& other) noexcept; +#endif + bool empty() const; int size() const; @@ -1016,6 +1032,8 @@ class RepeatedPtrField PROTOBUF_FINAL : public internal::RepeatedPtrFieldBase { google::protobuf::internal::false_type); friend class Arena; + friend class MessageLite; + typedef void InternalArenaConstructable_; }; @@ -1026,33 +1044,25 @@ template <typename Element> inline RepeatedField<Element>::RepeatedField() : current_size_(0), total_size_(0), - rep_(NULL) { + ptr_(NULL) { } template <typename Element> inline RepeatedField<Element>::RepeatedField(Arena* arena) : current_size_(0), total_size_(0), - rep_(NULL) { - // In case arena is NULL, then we do not create rep_, as code has an invariant - // `rep_ == NULL then arena == NULL`. - if (arena != NULL) { - rep_ = reinterpret_cast<Rep*>( - ::google::protobuf::Arena::CreateArray<char>(arena, kRepHeaderSize)); - rep_->arena = arena; - } + ptr_(arena) { } template <typename Element> inline RepeatedField<Element>::RepeatedField(const RepeatedField& other) : current_size_(0), total_size_(0), - rep_(NULL) { + ptr_(NULL) { if (other.current_size_ != 0) { - Reserve(other.current_size_); - CopyArray(rep_->elements, - other.rep_->elements, other.current_size_); - current_size_ = other.current_size_; + Reserve(other.size()); + AddNAlreadyReserved(other.size()); + CopyArray(Mutable(0), &other.Get(0), other.size()); } } @@ -1061,7 +1071,7 @@ template <typename Iter> RepeatedField<Element>::RepeatedField(Iter begin, const Iter& end) : current_size_(0), total_size_(0), - rep_(NULL) { + ptr_(NULL) { int reserve = internal::CalculateReserve(begin, end); if (reserve != -1) { Reserve(reserve); @@ -1077,9 +1087,9 @@ RepeatedField<Element>::RepeatedField(Iter begin, const Iter& end) template <typename Element> RepeatedField<Element>::~RepeatedField() { - // See explanation in Reserve(): we need to invoke destructors here for the - // case that Element has a non-trivial destructor. - InternalDeallocate(rep_, total_size_); + if (total_size_ > 0) { + InternalDeallocate(rep(), total_size_); + } } template <typename Element> @@ -1090,6 +1100,37 @@ RepeatedField<Element>::operator=(const RepeatedField& other) { return *this; } +#if LANG_CXX11 + +template <typename Element> +inline RepeatedField<Element>::RepeatedField(RepeatedField&& other) noexcept + : RepeatedField() { + // We don't just call Swap(&other) here because it would perform 3 copies if + // the two fields are on different arenas. + if (other.GetArenaNoVirtual()) { + CopyFrom(other); + } else { + InternalSwap(&other); + } +} + +template <typename Element> +inline RepeatedField<Element>& RepeatedField<Element>::operator=( + RepeatedField&& other) noexcept { + // We don't just call Swap(&other) here because it would perform 3 copies if + // the two fields are on different arenas. + if (this != &other) { + if (this->GetArenaNoVirtual() != other.GetArenaNoVirtual()) { + CopyFrom(other); + } else { + InternalSwap(&other); + } + } + return *this; +} + +#endif // LANG_CXX11 + template <typename Element> inline bool RepeatedField<Element>::empty() const { return current_size_ == 0; @@ -1108,19 +1149,21 @@ inline int RepeatedField<Element>::Capacity() const { template<typename Element> inline void RepeatedField<Element>::AddAlreadyReserved(const Element& value) { GOOGLE_DCHECK_LT(current_size_, total_size_); - rep_->elements[current_size_++] = value; + rep()->elements[current_size_++] = value; } template<typename Element> inline Element* RepeatedField<Element>::AddAlreadyReserved() { GOOGLE_DCHECK_LT(current_size_, total_size_); - return &rep_->elements[current_size_++]; + return &rep()->elements[current_size_++]; } template<typename Element> inline Element* RepeatedField<Element>::AddNAlreadyReserved(int elements) { GOOGLE_DCHECK_LE(current_size_ + elements, total_size_); - Element* ret = &rep_->elements[current_size_]; + // Warning: total_size_ can be NULL if elements == 0 && current_size_ == 0. + // Existing callers depend on this behavior. :( + Element* ret = &ptr_.rep->elements[current_size_]; current_size_ += elements; return ret; } @@ -1130,8 +1173,8 @@ inline void RepeatedField<Element>::Resize(int new_size, const Element& value) { GOOGLE_DCHECK_GE(new_size, 0); if (new_size > current_size_) { Reserve(new_size); - std::fill(&rep_->elements[current_size_], - &rep_->elements[new_size], value); + std::fill(&rep()->elements[current_size_], + &rep()->elements[new_size], value); } current_size_ = new_size; } @@ -1140,33 +1183,33 @@ template <typename Element> inline const Element& RepeatedField<Element>::Get(int index) const { GOOGLE_DCHECK_GE(index, 0); GOOGLE_DCHECK_LT(index, current_size_); - return rep_->elements[index]; + return rep()->elements[index]; } template <typename Element> inline Element* RepeatedField<Element>::Mutable(int index) { GOOGLE_DCHECK_GE(index, 0); GOOGLE_DCHECK_LT(index, current_size_); - return &rep_->elements[index]; + return &rep()->elements[index]; } template <typename Element> inline void RepeatedField<Element>::Set(int index, const Element& value) { GOOGLE_DCHECK_GE(index, 0); GOOGLE_DCHECK_LT(index, current_size_); - rep_->elements[index] = value; + rep()->elements[index] = value; } template <typename Element> inline void RepeatedField<Element>::Add(const Element& value) { if (current_size_ == total_size_) Reserve(total_size_ + 1); - rep_->elements[current_size_++] = value; + rep()->elements[current_size_++] = value; } template <typename Element> inline Element* RepeatedField<Element>::Add() { if (current_size_ == total_size_) Reserve(total_size_ + 1); - return &rep_->elements[current_size_++]; + return &rep()->elements[current_size_++]; } template <typename Element> @@ -1205,10 +1248,10 @@ template <typename Element> inline void RepeatedField<Element>::MergeFrom(const RepeatedField& other) { GOOGLE_DCHECK_NE(&other, this); if (other.current_size_ != 0) { - Reserve(current_size_ + other.current_size_); - CopyArray(rep_->elements + current_size_, - other.rep_->elements, other.current_size_); - current_size_ += other.current_size_; + int existing_size = size(); + Reserve(existing_size + other.size()); + AddNAlreadyReserved(other.size()); + CopyArray(Mutable(existing_size), &other.Get(0), other.size()); } } @@ -1237,18 +1280,17 @@ inline typename RepeatedField<Element>::iterator RepeatedField<Element>::erase( template <typename Element> inline Element* RepeatedField<Element>::mutable_data() { - return rep_ ? rep_->elements : NULL; + return total_size_ > 0 ? rep()->elements : NULL; } template <typename Element> inline const Element* RepeatedField<Element>::data() const { - return rep_ ? rep_->elements : NULL; + return total_size_ > 0 ? rep()->elements : NULL; } template <typename Element> inline const Element* RepeatedField<Element>::unsafe_data() const { - GOOGLE_DCHECK(rep_); - return rep_->elements; + return rep()->elements; } template <typename Element> @@ -1256,7 +1298,7 @@ inline void RepeatedField<Element>::InternalSwap(RepeatedField* other) { GOOGLE_DCHECK(this != other); GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); - std::swap(rep_, other->rep_); + std::swap(ptr_, other->ptr_); std::swap(current_size_, other->current_size_); std::swap(total_size_, other->total_size_); } @@ -1283,43 +1325,43 @@ void RepeatedField<Element>::UnsafeArenaSwap(RepeatedField* other) { template <typename Element> void RepeatedField<Element>::SwapElements(int index1, int index2) { using std::swap; // enable ADL with fallback - swap(rep_->elements[index1], rep_->elements[index2]); + swap(rep()->elements[index1], rep()->elements[index2]); } template <typename Element> inline typename RepeatedField<Element>::iterator RepeatedField<Element>::begin() { - return rep_ ? rep_->elements : NULL; + return total_size_ > 0 ? rep()->elements : NULL; } template <typename Element> inline typename RepeatedField<Element>::const_iterator RepeatedField<Element>::begin() const { - return rep_ ? rep_->elements : NULL; + return total_size_ > 0 ? rep()->elements : NULL; } template <typename Element> inline typename RepeatedField<Element>::const_iterator RepeatedField<Element>::cbegin() const { - return rep_ ? rep_->elements : NULL; + return total_size_ > 0 ? rep()->elements : NULL; } template <typename Element> inline typename RepeatedField<Element>::iterator RepeatedField<Element>::end() { - return rep_ ? rep_->elements + current_size_ : NULL; + return total_size_ > 0 ? rep()->elements + current_size_ : NULL; } template <typename Element> inline typename RepeatedField<Element>::const_iterator RepeatedField<Element>::end() const { - return rep_ ? rep_->elements + current_size_ : NULL; + return total_size_ > 0 ? rep()->elements + current_size_ : NULL; } template <typename Element> inline typename RepeatedField<Element>::const_iterator RepeatedField<Element>::cend() const { - return rep_ ? rep_->elements + current_size_ : NULL; + return total_size_ > 0 ? rep()->elements + current_size_ : NULL; } template <typename Element> inline size_t RepeatedField<Element>::SpaceUsedExcludingSelfLong() const { - return rep_ ? (total_size_ * sizeof(Element) + kRepHeaderSize) : 0; + return total_size_ > 0 ? (total_size_ * sizeof(Element) + kRepHeaderSize) : 0; } // Avoid inlining of Reserve(): new, copy, and delete[] lead to a significant @@ -1327,7 +1369,7 @@ inline size_t RepeatedField<Element>::SpaceUsedExcludingSelfLong() const { template <typename Element> void RepeatedField<Element>::Reserve(int new_size) { if (total_size_ >= new_size) return; - Rep* old_rep = rep_; + Rep* old_rep = total_size_ > 0 ? rep() : NULL; Arena* arena = GetArenaNoVirtual(); new_size = std::max(google::protobuf::internal::kMinRepeatedFieldAllocationSize, std::max(total_size_ * 2, new_size)); @@ -1335,14 +1377,14 @@ void RepeatedField<Element>::Reserve(int new_size) { static_cast<size_t>(new_size), (std::numeric_limits<size_t>::max() - kRepHeaderSize) / sizeof(Element)) << "Requested size is too large to fit into size_t."; - size_t bytes = kRepHeaderSize + sizeof(Element) * new_size; + size_t bytes = kRepHeaderSize + sizeof(Element) * static_cast<size_t>(new_size); if (arena == NULL) { - rep_ = static_cast<Rep*>(::operator new(bytes)); + ptr_.rep = static_cast<Rep*>(::operator new(bytes)); } else { - rep_ = reinterpret_cast<Rep*>( + ptr_.rep = reinterpret_cast<Rep*>( ::google::protobuf::Arena::CreateArray<char>(arena, bytes)); } - rep_->arena = arena; + ptr_.rep->arena = arena; int old_total_size = total_size_; total_size_ = new_size; // Invoke placement-new on newly allocated elements. We shouldn't have to do @@ -1354,13 +1396,13 @@ void RepeatedField<Element>::Reserve(int new_size) { // effect unless its side-effects are required for correctness. // Note that we do this before MoveArray() below because Element's copy // assignment implementation will want an initialized instance first. - Element* e = &rep_->elements[0]; - Element* limit = &rep_->elements[total_size_]; + Element* e = &rep()->elements[0]; + Element* limit = e + total_size_; for (; e < limit; e++) { new (e) Element; } if (current_size_ > 0) { - MoveArray(rep_->elements, old_rep->elements, current_size_); + MoveArray(&rep()->elements[0], old_rep->elements, current_size_); } // Likewise, we need to invoke destructors on the old array. @@ -1399,7 +1441,7 @@ void ElementCopier<Element, HasTrivialCopy>::operator()( template <typename Element> struct ElementCopier<Element, true> { void operator()(Element* to, const Element* from, int array_size) { - memcpy(to, from, array_size * sizeof(Element)); + memcpy(to, from, static_cast<size_t>(array_size) * sizeof(Element)); } }; @@ -1476,14 +1518,13 @@ inline int RepeatedPtrFieldBase::size() const { } template <typename TypeHandler> -inline const typename TypeHandler::Type& +inline const typename TypeHandler::WeakType& RepeatedPtrFieldBase::Get(int index) const { GOOGLE_DCHECK_GE(index, 0); GOOGLE_DCHECK_LT(index, current_size_); return *cast<TypeHandler>(rep_->elements[index]); } - template <typename TypeHandler> inline typename TypeHandler::Type* RepeatedPtrFieldBase::Mutable(int index) { @@ -1592,18 +1633,18 @@ void RepeatedPtrFieldBase::MergeFromInnerLoop( // to avoid a branch within the loop. for (int i = 0; i < already_allocated && i < length; i++) { // Already allocated: use existing element. - typename TypeHandler::Type* other_elem = - reinterpret_cast<typename TypeHandler::Type*>(other_elems[i]); - typename TypeHandler::Type* new_elem = - reinterpret_cast<typename TypeHandler::Type*>(our_elems[i]); + typename TypeHandler::WeakType* other_elem = + reinterpret_cast<typename TypeHandler::WeakType*>(other_elems[i]); + typename TypeHandler::WeakType* new_elem = + reinterpret_cast<typename TypeHandler::WeakType*>(our_elems[i]); TypeHandler::Merge(*other_elem, new_elem); } Arena* arena = GetArenaNoVirtual(); for (int i = already_allocated; i < length; i++) { // Not allocated: alloc a new element first, then merge it. - typename TypeHandler::Type* other_elem = - reinterpret_cast<typename TypeHandler::Type*>(other_elems[i]); - typename TypeHandler::Type* new_elem = + typename TypeHandler::WeakType* other_elem = + reinterpret_cast<typename TypeHandler::WeakType*>(other_elems[i]); + typename TypeHandler::WeakType* new_elem = TypeHandler::NewFromPrototype(other_elem, arena); TypeHandler::Merge(*other_elem, new_elem); our_elems[i] = new_elem; @@ -1651,7 +1692,7 @@ inline void RepeatedPtrFieldBase::SwapElements(int index1, int index2) { template <typename TypeHandler> inline size_t RepeatedPtrFieldBase::SpaceUsedExcludingSelfLong() const { - size_t allocated_bytes = total_size_ * sizeof(void*); + size_t allocated_bytes = static_cast<size_t>(total_size_) * sizeof(void*); if (rep_ != NULL) { for (int i = 0; i < rep_->allocated_size; ++i) { allocated_bytes += TypeHandler::SpaceUsedLong( @@ -1693,7 +1734,6 @@ void RepeatedPtrFieldBase::AddAllocatedInternal( elems[current_size_] = value; current_size_ = current_size_ + 1; rep_->allocated_size = rep_->allocated_size + 1; - return; } else { AddAllocatedSlowWithCopy<TypeHandler>( value, TypeHandler::GetArena(value), arena); @@ -1740,7 +1780,6 @@ void RepeatedPtrFieldBase::AddAllocatedInternal( elems[current_size_] = value; current_size_ = current_size_ + 1; ++rep_->allocated_size; - return; } else { UnsafeArenaAddAllocated<TypeHandler>(value); } @@ -1904,6 +1943,38 @@ inline RepeatedPtrField<Element>& RepeatedPtrField<Element>::operator=( return *this; } +#if LANG_CXX11 + +template <typename Element> +inline RepeatedPtrField<Element>::RepeatedPtrField( + RepeatedPtrField&& other) noexcept + : RepeatedPtrField() { + // We don't just call Swap(&other) here because it would perform 3 copies if + // the two fields are on different arenas. + if (other.GetArenaNoVirtual()) { + CopyFrom(other); + } else { + InternalSwap(&other); + } +} + +template <typename Element> +inline RepeatedPtrField<Element>& RepeatedPtrField<Element>::operator=( + RepeatedPtrField&& other) noexcept { + // We don't just call Swap(&other) here because it would perform 3 copies if + // the two fields are on different arenas. + if (this != &other) { + if (this->GetArenaNoVirtual() != other.GetArenaNoVirtual()) { + CopyFrom(other); + } else { + InternalSwap(&other); + } + } + return *this; +} + +#endif // LANG_CXX11 + template <typename Element> inline bool RepeatedPtrField<Element>::empty() const { return RepeatedPtrFieldBase::empty(); @@ -2188,7 +2259,7 @@ class RepeatedPtrIterator : it_(other.it_) { // Force a compiler error if the other type is not convertible to ours. if (false) { - implicit_cast<Element*, OtherElement*>(0); + implicit_cast<Element*>(static_cast<OtherElement*>(NULL)); } } @@ -2449,6 +2520,12 @@ template<typename T> class RepeatedPtrFieldBackInsertIterator *field_->Add() = *ptr_to_value; return *this; } +#if LANG_CXX11 + RepeatedPtrFieldBackInsertIterator<T>& operator=(T&& value) { + *field_->Add() = std::move(value); + return *this; + } +#endif RepeatedPtrFieldBackInsertIterator<T>& operator*() { return *this; } diff --git a/src/google/protobuf/repeated_field_unittest.cc b/src/google/protobuf/repeated_field_unittest.cc index 043cc746..16919711 100644 --- a/src/google/protobuf/repeated_field_unittest.cc +++ b/src/google/protobuf/repeated_field_unittest.cc @@ -45,17 +45,19 @@ #include <google/protobuf/stubs/logging.h> #include <google/protobuf/stubs/common.h> #include <google/protobuf/unittest.pb.h> +#include <gmock/gmock.h> #include <google/protobuf/testing/googletest.h> #include <gtest/gtest.h> #include <google/protobuf/stubs/strutil.h> #include <google/protobuf/stubs/stl_util.h> namespace google { -using protobuf_unittest::TestAllTypes; - namespace protobuf { namespace { +using ::protobuf_unittest::TestAllTypes; +using ::testing::ElementsAre; + // Test operations on a small RepeatedField. TEST(RepeatedField, Small) { RepeatedField<int> field; @@ -267,15 +269,6 @@ TEST(RepeatedField, MergeFrom) { EXPECT_EQ(5, destination.Get(4)); } -#ifdef PROTOBUF_HAS_DEATH_TEST -#ifndef NDEBUG -TEST(RepeatedField, MergeFromSelf) { - RepeatedField<int> me; - me.Add(3); - EXPECT_DEATH(me.MergeFrom(me), ""); -} -#endif // NDEBUG -#endif // PROTOBUF_HAS_DEATH_TEST TEST(RepeatedField, CopyFrom) { RepeatedField<int> source, destination; @@ -390,6 +383,142 @@ TEST(RepeatedField, SelfAssign) { EXPECT_EQ(8, source.Get(1)); } +#if LANG_CXX11 + +TEST(RepeatedField, MoveConstruct) { + { + RepeatedField<int> source; + source.Add(1); + source.Add(2); + const int* data = source.data(); + RepeatedField<int> destination = std::move(source); + EXPECT_EQ(data, destination.data()); + EXPECT_THAT(destination, ElementsAre(1, 2)); + // This property isn't guaranteed but it's useful to have a test that would + // catch changes in this area. + EXPECT_TRUE(source.empty()); + } + { + Arena arena; + RepeatedField<int>* source = + Arena::CreateMessage<RepeatedField<int>>(&arena); + source->Add(1); + source->Add(2); + RepeatedField<int> destination = std::move(*source); + EXPECT_EQ(NULL, destination.GetArena()); + EXPECT_THAT(destination, ElementsAre(1, 2)); + // This property isn't guaranteed but it's useful to have a test that would + // catch changes in this area. + EXPECT_THAT(*source, ElementsAre(1, 2)); + } +} + +TEST(RepeatedField, MoveAssign) { + { + RepeatedField<int> source; + source.Add(1); + source.Add(2); + RepeatedField<int> destination; + destination.Add(3); + const int* source_data = source.data(); + const int* destination_data = destination.data(); + destination = std::move(source); + EXPECT_EQ(source_data, destination.data()); + EXPECT_THAT(destination, ElementsAre(1, 2)); + // This property isn't guaranteed but it's useful to have a test that would + // catch changes in this area. + EXPECT_EQ(destination_data, source.data()); + EXPECT_THAT(source, ElementsAre(3)); + } + { + Arena arena; + RepeatedField<int>* source = + Arena::CreateMessage<RepeatedField<int>>(&arena); + source->Add(1); + source->Add(2); + RepeatedField<int>* destination = + Arena::CreateMessage<RepeatedField<int>>(&arena); + destination->Add(3); + const int* source_data = source->data(); + const int* destination_data = destination->data(); + *destination = std::move(*source); + EXPECT_EQ(source_data, destination->data()); + EXPECT_THAT(*destination, ElementsAre(1, 2)); + // This property isn't guaranteed but it's useful to have a test that would + // catch changes in this area. + EXPECT_EQ(destination_data, source->data()); + EXPECT_THAT(*source, ElementsAre(3)); + } + { + Arena source_arena; + RepeatedField<int>* source = + Arena::CreateMessage<RepeatedField<int>>(&source_arena); + source->Add(1); + source->Add(2); + Arena destination_arena; + RepeatedField<int>* destination = + Arena::CreateMessage<RepeatedField<int>>(&destination_arena); + destination->Add(3); + *destination = std::move(*source); + EXPECT_THAT(*destination, ElementsAre(1, 2)); + // This property isn't guaranteed but it's useful to have a test that would + // catch changes in this area. + EXPECT_THAT(*source, ElementsAre(1, 2)); + } + { + Arena arena; + RepeatedField<int>* source = + Arena::CreateMessage<RepeatedField<int>>(&arena); + source->Add(1); + source->Add(2); + RepeatedField<int> destination; + destination.Add(3); + destination = std::move(*source); + EXPECT_THAT(destination, ElementsAre(1, 2)); + // This property isn't guaranteed but it's useful to have a test that would + // catch changes in this area. + EXPECT_THAT(*source, ElementsAre(1, 2)); + } + { + RepeatedField<int> source; + source.Add(1); + source.Add(2); + Arena arena; + RepeatedField<int>* destination = + Arena::CreateMessage<RepeatedField<int>>(&arena); + destination->Add(3); + *destination = std::move(source); + EXPECT_THAT(*destination, ElementsAre(1, 2)); + // This property isn't guaranteed but it's useful to have a test that would + // catch changes in this area. + EXPECT_THAT(source, ElementsAre(1, 2)); + } + { + RepeatedField<int> field; + // An alias to defeat -Wself-move. + RepeatedField<int>& alias = field; + field.Add(1); + field.Add(2); + const int* data = field.data(); + field = std::move(alias); + EXPECT_EQ(data, field.data()); + EXPECT_THAT(field, ElementsAre(1, 2)); + } + { + Arena arena; + RepeatedField<int>* field = + Arena::CreateMessage<RepeatedField<int>>(&arena); + field->Add(1); + field->Add(2); + const int* data = field->data(); + *field = std::move(*field); + EXPECT_EQ(data, field->data()); + EXPECT_THAT(*field, ElementsAre(1, 2)); + } +} + +#endif // LANG_CXX11 + TEST(RepeatedField, MutableDataIsMutable) { RepeatedField<int> field; field.Add(1); @@ -783,13 +912,6 @@ TEST(RepeatedPtrField, MergeFrom) { EXPECT_EQ("5", destination.Get(4)); } -#ifdef PROTOBUF_HAS_DEATH_TEST -TEST(RepeatedPtrField, MergeFromSelf) { - RepeatedPtrField<string> me; - me.Add()->assign("1"); - EXPECT_DEATH(me.MergeFrom(me), ""); -} -#endif // PROTOBUF_HAS_DEATH_TEST TEST(RepeatedPtrField, CopyFrom) { RepeatedPtrField<string> source, destination; @@ -923,6 +1045,142 @@ TEST(RepeatedPtrField, SelfAssign) { EXPECT_EQ("8", source.Get(1)); } +#if LANG_CXX11 + +TEST(RepeatedPtrField, MoveConstruct) { + { + RepeatedPtrField<string> source; + *source.Add() = "1"; + *source.Add() = "2"; + const string* const* data = source.data(); + RepeatedPtrField<string> destination = std::move(source); + EXPECT_EQ(data, destination.data()); + EXPECT_THAT(destination, ElementsAre("1", "2")); + // This property isn't guaranteed but it's useful to have a test that would + // catch changes in this area. + EXPECT_TRUE(source.empty()); + } + { + Arena arena; + RepeatedPtrField<string>* source = + Arena::CreateMessage<RepeatedPtrField<string>>(&arena); + *source->Add() = "1"; + *source->Add() = "2"; + RepeatedPtrField<string> destination = std::move(*source); + EXPECT_EQ(NULL, destination.GetArena()); + EXPECT_THAT(destination, ElementsAre("1", "2")); + // This property isn't guaranteed but it's useful to have a test that would + // catch changes in this area. + EXPECT_THAT(*source, ElementsAre("1", "2")); + } +} + +TEST(RepeatedPtrField, MoveAssign) { + { + RepeatedPtrField<string> source; + *source.Add() = "1"; + *source.Add() = "2"; + RepeatedPtrField<string> destination; + *destination.Add() = "3"; + const string* const* source_data = source.data(); + const string* const* destination_data = destination.data(); + destination = std::move(source); + EXPECT_EQ(source_data, destination.data()); + EXPECT_THAT(destination, ElementsAre("1", "2")); + // This property isn't guaranteed but it's useful to have a test that would + // catch changes in this area. + EXPECT_EQ(destination_data, source.data()); + EXPECT_THAT(source, ElementsAre("3")); + } + { + Arena arena; + RepeatedPtrField<string>* source = + Arena::CreateMessage<RepeatedPtrField<string>>(&arena); + *source->Add() = "1"; + *source->Add() = "2"; + RepeatedPtrField<string>* destination = + Arena::CreateMessage<RepeatedPtrField<string>>(&arena); + *destination->Add() = "3"; + const string* const* source_data = source->data(); + const string* const* destination_data = destination->data(); + *destination = std::move(*source); + EXPECT_EQ(source_data, destination->data()); + EXPECT_THAT(*destination, ElementsAre("1", "2")); + // This property isn't guaranteed but it's useful to have a test that would + // catch changes in this area. + EXPECT_EQ(destination_data, source->data()); + EXPECT_THAT(*source, ElementsAre("3")); + } + { + Arena source_arena; + RepeatedPtrField<string>* source = + Arena::CreateMessage<RepeatedPtrField<string>>(&source_arena); + *source->Add() = "1"; + *source->Add() = "2"; + Arena destination_arena; + RepeatedPtrField<string>* destination = + Arena::CreateMessage<RepeatedPtrField<string>>(&destination_arena); + *destination->Add() = "3"; + *destination = std::move(*source); + EXPECT_THAT(*destination, ElementsAre("1", "2")); + // This property isn't guaranteed but it's useful to have a test that would + // catch changes in this area. + EXPECT_THAT(*source, ElementsAre("1", "2")); + } + { + Arena arena; + RepeatedPtrField<string>* source = + Arena::CreateMessage<RepeatedPtrField<string>>(&arena); + *source->Add() = "1"; + *source->Add() = "2"; + RepeatedPtrField<string> destination; + *destination.Add() = "3"; + destination = std::move(*source); + EXPECT_THAT(destination, ElementsAre("1", "2")); + // This property isn't guaranteed but it's useful to have a test that would + // catch changes in this area. + EXPECT_THAT(*source, ElementsAre("1", "2")); + } + { + RepeatedPtrField<string> source; + *source.Add() = "1"; + *source.Add() = "2"; + Arena arena; + RepeatedPtrField<string>* destination = + Arena::CreateMessage<RepeatedPtrField<string>>(&arena); + *destination->Add() = "3"; + *destination = std::move(source); + EXPECT_THAT(*destination, ElementsAre("1", "2")); + // This property isn't guaranteed but it's useful to have a test that would + // catch changes in this area. + EXPECT_THAT(source, ElementsAre("1", "2")); + } + { + RepeatedPtrField<string> field; + // An alias to defeat -Wself-move. + RepeatedPtrField<string>& alias = field; + *field.Add() = "1"; + *field.Add() = "2"; + const string* const* data = field.data(); + field = std::move(alias); + EXPECT_EQ(data, field.data()); + EXPECT_THAT(field, ElementsAre("1", "2")); + } + { + Arena arena; + RepeatedPtrField<string>* field = + Arena::CreateMessage<RepeatedPtrField<string>>(&arena); + *field->Add() = "1"; + *field->Add() = "2"; + const string* const* data = field->data(); + *field = std::move(*field); + EXPECT_EQ(data, field->data()); + EXPECT_THAT(*field, ElementsAre("1", "2")); + } +} + +#endif // LANG_CXX11 + TEST(RepeatedPtrField, MutableDataIsMutable) { RepeatedPtrField<string> field; *field.Add() = "1"; @@ -1586,6 +1844,38 @@ TEST_F(RepeatedFieldInsertionIteratorsTest, EXPECT_EQ(testproto.DebugString(), goldenproto.DebugString()); } +#if LANG_CXX11 +TEST_F(RepeatedFieldInsertionIteratorsTest, MoveStrings) { + std::vector<string> src = {"a", "b", "c", "d"}; + std::vector<string> copy = src; // copy since move leaves in undefined state + TestAllTypes testproto; + std::move(copy.begin(), copy.end(), + RepeatedFieldBackInserter(testproto.mutable_repeated_string())); + + ASSERT_THAT(testproto.repeated_string(), testing::ElementsAreArray(src)); +} + +TEST_F(RepeatedFieldInsertionIteratorsTest, MoveProtos) { + auto make_nested = [](int32 x) { + Nested ret; + ret.set_bb(x); + return ret; + }; + std::vector<Nested> src = {make_nested(3), make_nested(5), make_nested(7)}; + std::vector<Nested> copy = src; // copy since move leaves in undefined state + TestAllTypes testproto; + std::move( + copy.begin(), copy.end(), + RepeatedFieldBackInserter(testproto.mutable_repeated_nested_message())); + + ASSERT_EQ(src.size(), testproto.repeated_nested_message_size()); + for (int i = 0; i < src.size(); ++i) { + EXPECT_EQ(src[i].DebugString(), + testproto.repeated_nested_message(i).DebugString()); + } +} +#endif + } // namespace } // namespace protobuf diff --git a/src/google/protobuf/source_context.pb.cc b/src/google/protobuf/source_context.pb.cc index 3244444a..b9d8f3cb 100644 --- a/src/google/protobuf/source_context.pb.cc +++ b/src/google/protobuf/source_context.pb.cc @@ -1,7 +1,6 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/protobuf/source_context.proto -#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION #include <google/protobuf/source_context.pb.h> #include <algorithm> @@ -15,55 +14,60 @@ #include <google/protobuf/generated_message_reflection.h> #include <google/protobuf/reflection_ops.h> #include <google/protobuf/wire_format.h> +// This is a temporary google only hack +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS +#include "third_party/protobuf/version.h" +#endif // @@protoc_insertion_point(includes) - namespace google { namespace protobuf { -class SourceContextDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<SourceContext> { +class SourceContextDefaultTypeInternal { + public: + ::google::protobuf::internal::ExplicitlyConstructed<SourceContext> + _instance; } _SourceContext_default_instance_; - +} // namespace protobuf +} // namespace google namespace protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto { +void InitDefaultsSourceContextImpl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); +#else + ::google::protobuf::internal::InitProtobufDefaults(); +#endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + { + void* ptr = &::google::protobuf::_SourceContext_default_instance_; + new (ptr) ::google::protobuf::SourceContext(); + ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); + } + ::google::protobuf::SourceContext::InitAsDefaultInstance(); +} -namespace { +void InitDefaultsSourceContext() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsSourceContextImpl); +} ::google::protobuf::Metadata file_level_metadata[1]; -} // namespace - -PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::ParseTableField - const TableStruct::entries[] = { - {0, 0, 0, ::google::protobuf::internal::kInvalidMask, 0, 0}, -}; - -PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::AuxillaryParseTableField - const TableStruct::aux[] = { - ::google::protobuf::internal::AuxillaryParseTableField(), -}; -PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::ParseTable const - TableStruct::schema[] = { - { NULL, NULL, 0, -1, -1, false }, -}; - -const ::google::protobuf::uint32 TableStruct::offsets[] = { +const ::google::protobuf::uint32 TableStruct::offsets[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { ~0u, // no _has_bits_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceContext, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::SourceContext, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceContext, file_name_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::SourceContext, file_name_), }; - -static const ::google::protobuf::internal::MigrationSchema schemas[] = { - { 0, -1, sizeof(SourceContext)}, +static const ::google::protobuf::internal::MigrationSchema schemas[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { + { 0, -1, sizeof(::google::protobuf::SourceContext)}, }; static ::google::protobuf::Message const * const file_default_instances[] = { - reinterpret_cast<const ::google::protobuf::Message*>(&_SourceContext_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_SourceContext_default_instance_), }; -namespace { - void protobuf_AssignDescriptors() { AddDescriptors(); ::google::protobuf::MessageFactory* factory = NULL; @@ -77,33 +81,15 @@ void protobuf_AssignDescriptorsOnce() { ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors); } -void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; +void protobuf_RegisterTypes(const ::std::string&) GOOGLE_PROTOBUF_ATTRIBUTE_COLD; void protobuf_RegisterTypes(const ::std::string&) { protobuf_AssignDescriptorsOnce(); ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 1); } -} // namespace - -void TableStruct::Shutdown() { - _SourceContext_default_instance_.Shutdown(); - delete file_level_metadata[0].reflection; -} - -void TableStruct::InitDefaultsImpl() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - ::google::protobuf::internal::InitProtobufDefaults(); - _SourceContext_default_instance_.DefaultConstruct(); -} - -void InitDefaults() { - static GOOGLE_PROTOBUF_DECLARE_ONCE(once); - ::google::protobuf::GoogleOnceInit(&once, &TableStruct::InitDefaultsImpl); -} void AddDescriptorsImpl() { InitDefaults(); - static const char descriptor[] = { + static const char descriptor[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { "\n$google/protobuf/source_context.proto\022\017" "google.protobuf\"\"\n\rSourceContext\022\021\n\tfile" "_name\030\001 \001(\tB\225\001\n\023com.google.protobufB\022Sou" @@ -116,25 +102,26 @@ void AddDescriptorsImpl() { descriptor, 251); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/source_context.proto", &protobuf_RegisterTypes); - ::google::protobuf::internal::OnShutdown(&TableStruct::Shutdown); } void AddDescriptors() { static GOOGLE_PROTOBUF_DECLARE_ONCE(once); ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl); } -// Force AddDescriptors() to be called at static initialization time. +// Force AddDescriptors() to be called at dynamic initialization time. struct StaticDescriptorInitializer { StaticDescriptorInitializer() { AddDescriptors(); } } static_descriptor_initializer; - } // namespace protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto - +namespace google { +namespace protobuf { // =================================================================== +void SourceContext::InitAsDefaultInstance() { +} #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int SourceContext::kFileNameFieldNumber; #endif // !defined(_MSC_VER) || _MSC_VER >= 1900 @@ -142,7 +129,7 @@ const int SourceContext::kFileNameFieldNumber; SourceContext::SourceContext() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { - protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto::InitDefaultsSourceContext(); } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.SourceContext) @@ -179,26 +166,24 @@ void SourceContext::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* SourceContext::descriptor() { - protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; + ::protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto::protobuf_AssignDescriptorsOnce(); + return ::protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const SourceContext& SourceContext::default_instance() { - protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto::InitDefaultsSourceContext(); return *internal_default_instance(); } -SourceContext* SourceContext::New(::google::protobuf::Arena* arena) const { - SourceContext* n = new SourceContext; - if (arena != NULL) { - arena->Own(n); - } - return n; -} void SourceContext::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.SourceContext) + ::google::protobuf::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + file_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + _internal_metadata_.Clear(); } bool SourceContext::MergePartialFromCodedStream( @@ -214,11 +199,11 @@ bool SourceContext::MergePartialFromCodedStream( // string file_name = 1; case 1: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(10u)) { + static_cast< ::google::protobuf::uint8>(10u /* 10 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_file_name())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( - this->file_name().data(), this->file_name().length(), + this->file_name().data(), static_cast<int>(this->file_name().length()), ::google::protobuf::internal::WireFormatLite::PARSE, "google.protobuf.SourceContext.file_name")); } else { @@ -229,12 +214,11 @@ bool SourceContext::MergePartialFromCodedStream( default: { handle_unusual: - if (tag == 0 || - ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + if (tag == 0) { goto success; } - DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag)); + DO_(::google::protobuf::internal::WireFormat::SkipField( + input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } @@ -257,18 +241,23 @@ void SourceContext::SerializeWithCachedSizes( // string file_name = 1; if (this->file_name().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( - this->file_name().data(), this->file_name().length(), + this->file_name().data(), static_cast<int>(this->file_name().length()), ::google::protobuf::internal::WireFormatLite::SERIALIZE, "google.protobuf.SourceContext.file_name"); ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( 1, this->file_name(), output); } + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + ::google::protobuf::internal::WireFormat::SerializeUnknownFields( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), output); + } // @@protoc_insertion_point(serialize_end:google.protobuf.SourceContext) } ::google::protobuf::uint8* SourceContext::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.SourceContext) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -276,7 +265,7 @@ void SourceContext::SerializeWithCachedSizes( // string file_name = 1; if (this->file_name().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( - this->file_name().data(), this->file_name().length(), + this->file_name().data(), static_cast<int>(this->file_name().length()), ::google::protobuf::internal::WireFormatLite::SERIALIZE, "google.protobuf.SourceContext.file_name"); target = @@ -284,6 +273,10 @@ void SourceContext::SerializeWithCachedSizes( 1, this->file_name(), target); } + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), target); + } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.SourceContext) return target; } @@ -292,6 +285,11 @@ size_t SourceContext::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.SourceContext) size_t total_size = 0; + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance())); + } // string file_name = 1; if (this->file_name().size() > 0) { total_size += 1 + @@ -357,75 +355,26 @@ void SourceContext::Swap(SourceContext* other) { InternalSwap(other); } void SourceContext::InternalSwap(SourceContext* other) { + using std::swap; file_name_.Swap(&other->file_name_); - std::swap(_cached_size_, other->_cached_size_); + _internal_metadata_.Swap(&other->_internal_metadata_); + swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata SourceContext::GetMetadata() const { protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto::file_level_metadata[kIndexInFileMessages]; -} - -#if PROTOBUF_INLINE_NOT_IN_HEADERS -// SourceContext - -// string file_name = 1; -void SourceContext::clear_file_name() { - file_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -const ::std::string& SourceContext::file_name() const { - // @@protoc_insertion_point(field_get:google.protobuf.SourceContext.file_name) - return file_name_.GetNoArena(); -} -void SourceContext::set_file_name(const ::std::string& value) { - - file_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.SourceContext.file_name) -} -#if LANG_CXX11 -void SourceContext::set_file_name(::std::string&& value) { - - file_name_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.SourceContext.file_name) -} -#endif -void SourceContext::set_file_name(const char* value) { - GOOGLE_DCHECK(value != NULL); - - 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) { - - file_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.SourceContext.file_name) -} -::std::string* SourceContext::mutable_file_name() { - - // @@protoc_insertion_point(field_mutable:google.protobuf.SourceContext.file_name) - return file_name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -::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) { - if (file_name != NULL) { - - } else { - - } - file_name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), file_name); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.SourceContext.file_name) + return ::protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto::file_level_metadata[kIndexInFileMessages]; } -#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // @@protoc_insertion_point(namespace_scope) - +} // namespace protobuf +} // namespace google +namespace google { +namespace protobuf { +template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::SourceContext* Arena::Create< ::google::protobuf::SourceContext >(Arena* arena) { + return Arena::CreateInternal< ::google::protobuf::SourceContext >(arena); +} } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/source_context.pb.h b/src/google/protobuf/source_context.pb.h index 23cd7f3e..81893b1a 100644 --- a/src/google/protobuf/source_context.pb.h +++ b/src/google/protobuf/source_context.pb.h @@ -1,19 +1,19 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/protobuf/source_context.proto -#ifndef PROTOBUF_google_2fprotobuf_2fsource_5fcontext_2eproto__INCLUDED -#define PROTOBUF_google_2fprotobuf_2fsource_5fcontext_2eproto__INCLUDED +#ifndef PROTOBUF_google_2fprotobuf_2fsource_5fcontext_2eproto_INCLUDED +#define PROTOBUF_google_2fprotobuf_2fsource_5fcontext_2eproto_INCLUDED #include <string> #include <google/protobuf/stubs/common.h> -#if GOOGLE_PROTOBUF_VERSION < 3003000 +#if GOOGLE_PROTOBUF_VERSION < 3005000 #error This file was generated by a newer version of protoc which is #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3003000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION +#if 3005001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. @@ -30,30 +30,38 @@ #include <google/protobuf/extension_set.h> // IWYU pragma: export #include <google/protobuf/unknown_field_set.h> // @@protoc_insertion_point(includes) -namespace google { -namespace protobuf { -class SourceContext; -class SourceContextDefaultTypeInternal; -LIBPROTOBUF_EXPORT extern SourceContextDefaultTypeInternal _SourceContext_default_instance_; -} // namespace protobuf -} // namespace google - -namespace google { -namespace protobuf { namespace protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto { -// Internal implementation detail -- do not call these. +// Internal implementation detail -- do not use these members. struct LIBPROTOBUF_EXPORT TableStruct { static const ::google::protobuf::internal::ParseTableField entries[]; static const ::google::protobuf::internal::AuxillaryParseTableField aux[]; - static const ::google::protobuf::internal::ParseTable schema[]; + static const ::google::protobuf::internal::ParseTable schema[1]; + static const ::google::protobuf::internal::FieldMetadata field_metadata[]; + static const ::google::protobuf::internal::SerializationTable serialization_table[]; static const ::google::protobuf::uint32 offsets[]; - static void InitDefaultsImpl(); - static void Shutdown(); }; void LIBPROTOBUF_EXPORT AddDescriptors(); -void LIBPROTOBUF_EXPORT InitDefaults(); +void LIBPROTOBUF_EXPORT InitDefaultsSourceContextImpl(); +void LIBPROTOBUF_EXPORT InitDefaultsSourceContext(); +inline void LIBPROTOBUF_EXPORT InitDefaults() { + InitDefaultsSourceContext(); +} } // namespace protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto +namespace google { +namespace protobuf { +class SourceContext; +class SourceContextDefaultTypeInternal; +LIBPROTOBUF_EXPORT extern SourceContextDefaultTypeInternal _SourceContext_default_instance_; +} // namespace protobuf +} // namespace google +namespace google { +namespace protobuf { +template<> LIBPROTOBUF_EXPORT ::google::protobuf::SourceContext* Arena::Create< ::google::protobuf::SourceContext>(Arena*); +} // namespace protobuf +} // namespace google +namespace google { +namespace protobuf { // =================================================================== @@ -68,10 +76,25 @@ class LIBPROTOBUF_EXPORT SourceContext : public ::google::protobuf::Message /* @ CopyFrom(from); return *this; } + #if LANG_CXX11 + SourceContext(SourceContext&& from) noexcept + : SourceContext() { + *this = ::std::move(from); + } + inline SourceContext& operator=(SourceContext&& from) noexcept { + if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + #endif static const ::google::protobuf::Descriptor* descriptor(); static const SourceContext& default_instance(); + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY static inline const SourceContext* internal_default_instance() { return reinterpret_cast<const SourceContext*>( &_SourceContext_default_instance_); @@ -80,12 +103,19 @@ class LIBPROTOBUF_EXPORT SourceContext : public ::google::protobuf::Message /* @ 0; void Swap(SourceContext* other); + friend void swap(SourceContext& a, SourceContext& b) { + a.Swap(&b); + } // implements Message ---------------------------------------------- - inline SourceContext* New() const PROTOBUF_FINAL { return New(NULL); } + inline SourceContext* New() const PROTOBUF_FINAL { + return ::google::protobuf::Arena::Create<SourceContext>(NULL); + } - SourceContext* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + SourceContext* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL { + return ::google::protobuf::Arena::Create<SourceContext>(arena); + } void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const SourceContext& from); @@ -141,14 +171,18 @@ class LIBPROTOBUF_EXPORT SourceContext : public ::google::protobuf::Message /* @ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; ::google::protobuf::internal::ArenaStringPtr file_name_; mutable int _cached_size_; - friend struct protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto::TableStruct; + friend struct ::protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto::TableStruct; + friend void ::protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto::InitDefaultsSourceContextImpl(); }; // =================================================================== // =================================================================== -#if !PROTOBUF_INLINE_NOT_IN_HEADERS +#ifdef __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif // __GNUC__ // SourceContext // string file_name = 1; @@ -204,14 +238,15 @@ inline void SourceContext::set_allocated_file_name(::std::string* file_name) { // @@protoc_insertion_point(field_set_allocated:google.protobuf.SourceContext.file_name) } -#endif // !PROTOBUF_INLINE_NOT_IN_HEADERS +#ifdef __GNUC__ + #pragma GCC diagnostic pop +#endif // __GNUC__ // @@protoc_insertion_point(namespace_scope) - } // namespace protobuf } // namespace google // @@protoc_insertion_point(global_scope) -#endif // PROTOBUF_google_2fprotobuf_2fsource_5fcontext_2eproto__INCLUDED +#endif // PROTOBUF_google_2fprotobuf_2fsource_5fcontext_2eproto_INCLUDED diff --git a/src/google/protobuf/struct.pb.cc b/src/google/protobuf/struct.pb.cc index 207e9efe..309a4d2d 100644 --- a/src/google/protobuf/struct.pb.cc +++ b/src/google/protobuf/struct.pb.cc @@ -1,7 +1,6 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/protobuf/struct.proto -#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION #include <google/protobuf/struct.pb.h> #include <algorithm> @@ -15,16 +14,27 @@ #include <google/protobuf/generated_message_reflection.h> #include <google/protobuf/reflection_ops.h> #include <google/protobuf/wire_format.h> +// This is a temporary google only hack +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS +#include "third_party/protobuf/version.h" +#endif // @@protoc_insertion_point(includes) - namespace google { namespace protobuf { -class Struct_FieldsEntryDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Struct::Struct_FieldsEntry> { -} _Struct_FieldsEntry_default_instance_; -class StructDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Struct> { +class Struct_FieldsEntry_DoNotUseDefaultTypeInternal { + public: + ::google::protobuf::internal::ExplicitlyConstructed<Struct_FieldsEntry_DoNotUse> + _instance; +} _Struct_FieldsEntry_DoNotUse_default_instance_; +class StructDefaultTypeInternal { + public: + ::google::protobuf::internal::ExplicitlyConstructed<Struct> + _instance; } _Struct_default_instance_; -class ValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Value> { - public: +class ValueDefaultTypeInternal { + public: + ::google::protobuf::internal::ExplicitlyConstructed<Value> + _instance; int null_value_; double number_value_; ::google::protobuf::internal::ArenaStringPtr string_value_; @@ -32,85 +42,110 @@ class ValueDefaultTypeInternal : public ::google::protobuf::internal::Explicitly const ::google::protobuf::Struct* struct_value_; const ::google::protobuf::ListValue* list_value_; } _Value_default_instance_; -class ListValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<ListValue> { +class ListValueDefaultTypeInternal { + public: + ::google::protobuf::internal::ExplicitlyConstructed<ListValue> + _instance; } _ListValue_default_instance_; - +} // namespace protobuf +} // namespace google namespace protobuf_google_2fprotobuf_2fstruct_2eproto { +void InitDefaultsListValueImpl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); +#else + ::google::protobuf::internal::InitProtobufDefaults(); +#endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + { + void* ptr = &::google::protobuf::_Struct_FieldsEntry_DoNotUse_default_instance_; + new (ptr) ::google::protobuf::Struct_FieldsEntry_DoNotUse(); + } + { + void* ptr = &::google::protobuf::_Struct_default_instance_; + new (ptr) ::google::protobuf::Struct(); + ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); + } + { + void* ptr = &::google::protobuf::_Value_default_instance_; + new (ptr) ::google::protobuf::Value(); + ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); + } + { + void* ptr = &::google::protobuf::_ListValue_default_instance_; + new (ptr) ::google::protobuf::ListValue(); + ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); + } + ::google::protobuf::Struct_FieldsEntry_DoNotUse::InitAsDefaultInstance(); + ::google::protobuf::Struct::InitAsDefaultInstance(); + ::google::protobuf::Value::InitAsDefaultInstance(); + ::google::protobuf::ListValue::InitAsDefaultInstance(); +} -namespace { +void InitDefaultsListValue() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsListValueImpl); +} ::google::protobuf::Metadata file_level_metadata[4]; const ::google::protobuf::EnumDescriptor* file_level_enum_descriptors[1]; -} // namespace - -PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::ParseTableField - const TableStruct::entries[] = { - {0, 0, 0, ::google::protobuf::internal::kInvalidMask, 0, 0}, -}; - -PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::AuxillaryParseTableField - const TableStruct::aux[] = { - ::google::protobuf::internal::AuxillaryParseTableField(), -}; -PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::ParseTable const - TableStruct::schema[] = { - { NULL, NULL, 0, -1, -1, false }, - { NULL, NULL, 0, -1, -1, false }, - { NULL, NULL, 0, -1, -1, false }, - { NULL, NULL, 0, -1, -1, false }, -}; - -const ::google::protobuf::uint32 TableStruct::offsets[] = { +const ::google::protobuf::uint32 TableStruct::offsets[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Struct_FieldsEntry_DoNotUse, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Struct_FieldsEntry_DoNotUse, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Struct_FieldsEntry_DoNotUse, key_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Struct_FieldsEntry_DoNotUse, value_), + 0, + 1, ~0u, // no _has_bits_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Struct, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Struct, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Struct, fields_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Struct, fields_), ~0u, // no _has_bits_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Value, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Value, _internal_metadata_), ~0u, // no _extensions_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Value, _oneof_case_[0]), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Value, _oneof_case_[0]), ~0u, // no _weak_field_map_ - GOOGLE_PROTOBUF_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET((&_Value_default_instance_), null_value_), - GOOGLE_PROTOBUF_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET((&_Value_default_instance_), number_value_), - GOOGLE_PROTOBUF_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET((&_Value_default_instance_), string_value_), - GOOGLE_PROTOBUF_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET((&_Value_default_instance_), bool_value_), - GOOGLE_PROTOBUF_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET((&_Value_default_instance_), struct_value_), - GOOGLE_PROTOBUF_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET((&_Value_default_instance_), list_value_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Value, kind_), + offsetof(::google::protobuf::ValueDefaultTypeInternal, null_value_), + offsetof(::google::protobuf::ValueDefaultTypeInternal, number_value_), + offsetof(::google::protobuf::ValueDefaultTypeInternal, string_value_), + offsetof(::google::protobuf::ValueDefaultTypeInternal, bool_value_), + offsetof(::google::protobuf::ValueDefaultTypeInternal, struct_value_), + offsetof(::google::protobuf::ValueDefaultTypeInternal, list_value_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Value, kind_), ~0u, // no _has_bits_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ListValue, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::ListValue, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ListValue, values_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::ListValue, values_), }; - -static const ::google::protobuf::internal::MigrationSchema schemas[] = { - { 0, -1, sizeof(Struct)}, - { 6, -1, sizeof(Value)}, - { 18, -1, sizeof(ListValue)}, +static const ::google::protobuf::internal::MigrationSchema schemas[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { + { 0, 7, sizeof(::google::protobuf::Struct_FieldsEntry_DoNotUse)}, + { 9, -1, sizeof(::google::protobuf::Struct)}, + { 15, -1, sizeof(::google::protobuf::Value)}, + { 27, -1, sizeof(::google::protobuf::ListValue)}, }; static ::google::protobuf::Message const * const file_default_instances[] = { - reinterpret_cast<const ::google::protobuf::Message*>(&_Struct_FieldsEntry_default_instance_), - reinterpret_cast<const ::google::protobuf::Message*>(&_Struct_default_instance_), - reinterpret_cast<const ::google::protobuf::Message*>(&_Value_default_instance_), - reinterpret_cast<const ::google::protobuf::Message*>(&_ListValue_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_Struct_FieldsEntry_DoNotUse_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_Struct_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_Value_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_ListValue_default_instance_), }; -namespace { - void protobuf_AssignDescriptors() { AddDescriptors(); ::google::protobuf::MessageFactory* factory = NULL; AssignDescriptors( "google/protobuf/struct.proto", schemas, file_default_instances, TableStruct::offsets, factory, file_level_metadata, file_level_enum_descriptors, NULL); -file_level_metadata[0].reflection = Struct::Struct_FieldsEntry::CreateReflection(file_level_metadata[0].descriptor, _Struct_FieldsEntry_default_instance_.get_mutable()); } void protobuf_AssignDescriptorsOnce() { @@ -118,52 +153,15 @@ void protobuf_AssignDescriptorsOnce() { ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors); } -void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; +void protobuf_RegisterTypes(const ::std::string&) GOOGLE_PROTOBUF_ATTRIBUTE_COLD; void protobuf_RegisterTypes(const ::std::string&) { protobuf_AssignDescriptorsOnce(); ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 4); } -} // namespace - -void TableStruct::Shutdown() { - _Struct_default_instance_.Shutdown(); - delete file_level_metadata[1].reflection; - _Value_default_instance_.Shutdown(); - delete file_level_metadata[2].reflection; - _ListValue_default_instance_.Shutdown(); - delete file_level_metadata[3].reflection; - delete file_level_metadata[0].reflection; -} - -void TableStruct::InitDefaultsImpl() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - ::google::protobuf::internal::InitProtobufDefaults(); - _Struct_FieldsEntry_default_instance_.DefaultConstruct(); - _Struct_default_instance_.DefaultConstruct(); - _Value_default_instance_.DefaultConstruct(); - _ListValue_default_instance_.DefaultConstruct(); - _Struct_FieldsEntry_default_instance_.get_mutable()->set_default_instance(_Struct_FieldsEntry_default_instance_.get_mutable()); - _Struct_FieldsEntry_default_instance_.get_mutable()->InitAsDefaultInstance(); - _Value_default_instance_.null_value_ = 0; - _Value_default_instance_.number_value_ = 0; - _Value_default_instance_.string_value_.UnsafeSetDefault( - &::google::protobuf::internal::GetEmptyStringAlreadyInited()); - _Value_default_instance_.bool_value_ = false; - _Value_default_instance_.struct_value_ = const_cast< ::google::protobuf::Struct*>( - ::google::protobuf::Struct::internal_default_instance()); - _Value_default_instance_.list_value_ = const_cast< ::google::protobuf::ListValue*>( - ::google::protobuf::ListValue::internal_default_instance()); -} - -void InitDefaults() { - static GOOGLE_PROTOBUF_DECLARE_ONCE(once); - ::google::protobuf::GoogleOnceInit(&once, &TableStruct::InitDefaultsImpl); -} void AddDescriptorsImpl() { InitDefaults(); - static const char descriptor[] = { + static const char descriptor[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { "\n\034google/protobuf/struct.proto\022\017google.p" "rotobuf\"\204\001\n\006Struct\0223\n\006fields\030\001 \003(\0132#.goo" "gle.protobuf.Struct.FieldsEntry\032E\n\013Field" @@ -186,22 +184,21 @@ void AddDescriptorsImpl() { descriptor, 641); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/struct.proto", &protobuf_RegisterTypes); - ::google::protobuf::internal::OnShutdown(&TableStruct::Shutdown); } void AddDescriptors() { static GOOGLE_PROTOBUF_DECLARE_ONCE(once); ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl); } -// Force AddDescriptors() to be called at static initialization time. +// Force AddDescriptors() to be called at dynamic initialization time. struct StaticDescriptorInitializer { StaticDescriptorInitializer() { AddDescriptors(); } } static_descriptor_initializer; - } // namespace protobuf_google_2fprotobuf_2fstruct_2eproto - +namespace google { +namespace protobuf { const ::google::protobuf::EnumDescriptor* NullValue_descriptor() { protobuf_google_2fprotobuf_2fstruct_2eproto::protobuf_AssignDescriptorsOnce(); return protobuf_google_2fprotobuf_2fstruct_2eproto::file_level_enum_descriptors[0]; @@ -218,25 +215,25 @@ bool NullValue_IsValid(int value) { // =================================================================== -Struct::Struct_FieldsEntry::Struct_FieldsEntry() {} -Struct::Struct_FieldsEntry::Struct_FieldsEntry(::google::protobuf::Arena* arena) : SuperType(arena) {} -::google::protobuf::Metadata Struct::Struct_FieldsEntry::GetMetadata() const { - protobuf_google_2fprotobuf_2fstruct_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fstruct_2eproto::file_level_metadata[0]; +Struct_FieldsEntry_DoNotUse::Struct_FieldsEntry_DoNotUse() {} +Struct_FieldsEntry_DoNotUse::Struct_FieldsEntry_DoNotUse(::google::protobuf::Arena* arena) : SuperType(arena) {} +void Struct_FieldsEntry_DoNotUse::MergeFrom(const Struct_FieldsEntry_DoNotUse& other) { + MergeFromInternal(other); +} +::google::protobuf::Metadata Struct_FieldsEntry_DoNotUse::GetMetadata() const { + ::protobuf_google_2fprotobuf_2fstruct_2eproto::protobuf_AssignDescriptorsOnce(); + return ::protobuf_google_2fprotobuf_2fstruct_2eproto::file_level_metadata[0]; } -void Struct::Struct_FieldsEntry::MergeFrom( +void Struct_FieldsEntry_DoNotUse::MergeFrom( const ::google::protobuf::Message& other) { ::google::protobuf::Message::MergeFrom(other); } -void Struct::Struct_FieldsEntry::MergeFrom(const Struct_FieldsEntry& other) { - MergeFromInternal(other); -} -#if PROTOBUF_INLINE_NOT_IN_HEADERS -#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== +void Struct::InitAsDefaultInstance() { +} #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int Struct::kFieldsFieldNumber; #endif // !defined(_MSC_VER) || _MSC_VER >= 1900 @@ -244,7 +241,7 @@ const int Struct::kFieldsFieldNumber; Struct::Struct() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { - protobuf_google_2fprotobuf_2fstruct_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fstruct_2eproto::InitDefaultsListValue(); } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Struct) @@ -253,9 +250,7 @@ Struct::Struct(::google::protobuf::Arena* arena) : ::google::protobuf::Message(), _internal_metadata_(arena), fields_(arena) { -#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER - protobuf_google_2fprotobuf_2fstruct_2eproto::InitDefaults(); -#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + ::protobuf_google_2fprotobuf_2fstruct_2eproto::InitDefaultsListValue(); SharedCtor(); RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.Struct) @@ -279,11 +274,7 @@ Struct::~Struct() { } void Struct::SharedDtor() { - ::google::protobuf::Arena* arena = GetArenaNoVirtual(); - if (arena != NULL) { - return; - } - + GOOGLE_DCHECK(GetArenaNoVirtual() == NULL); } void Struct::ArenaDtor(void* object) { @@ -298,22 +289,24 @@ void Struct::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* Struct::descriptor() { - protobuf_google_2fprotobuf_2fstruct_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fstruct_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; + ::protobuf_google_2fprotobuf_2fstruct_2eproto::protobuf_AssignDescriptorsOnce(); + return ::protobuf_google_2fprotobuf_2fstruct_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const Struct& Struct::default_instance() { - protobuf_google_2fprotobuf_2fstruct_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fstruct_2eproto::InitDefaultsListValue(); return *internal_default_instance(); } -Struct* Struct::New(::google::protobuf::Arena* arena) const { - return ::google::protobuf::Arena::CreateMessage<Struct>(arena); -} void Struct::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.Struct) + ::google::protobuf::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + fields_.Clear(); + _internal_metadata_.Clear(); } bool Struct::MergePartialFromCodedStream( @@ -329,9 +322,9 @@ bool Struct::MergePartialFromCodedStream( // map<string, .google.protobuf.Value> fields = 1; case 1: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(10u)) { - Struct_FieldsEntry::Parser< ::google::protobuf::internal::MapField< - Struct_FieldsEntry, + static_cast< ::google::protobuf::uint8>(10u /* 10 & 0xFF */)) { + Struct_FieldsEntry_DoNotUse::Parser< ::google::protobuf::internal::MapField< + Struct_FieldsEntry_DoNotUse, ::std::string, ::google::protobuf::Value, ::google::protobuf::internal::WireFormatLite::TYPE_STRING, ::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE, @@ -340,7 +333,7 @@ bool Struct::MergePartialFromCodedStream( DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, &parser)); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( - parser.key().data(), parser.key().length(), + parser.key().data(), static_cast<int>(parser.key().length()), ::google::protobuf::internal::WireFormatLite::PARSE, "google.protobuf.Struct.FieldsEntry.key")); } else { @@ -351,12 +344,11 @@ bool Struct::MergePartialFromCodedStream( default: { handle_unusual: - if (tag == 0 || - ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + if (tag == 0) { goto success; } - DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag)); + DO_(::google::protobuf::internal::WireFormat::SkipField( + input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } @@ -385,7 +377,7 @@ void Struct::SerializeWithCachedSizes( struct Utf8Check { static void Check(ConstPtr p) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( - p->first.data(), p->first.length(), + p->first.data(), static_cast<int>(p->first.length()), ::google::protobuf::internal::WireFormatLite::SERIALIZE, "google.protobuf.Struct.FieldsEntry.key"); } @@ -400,22 +392,22 @@ void Struct::SerializeWithCachedSizes( for (::google::protobuf::Map< ::std::string, ::google::protobuf::Value >::const_iterator it = this->fields().begin(); it != this->fields().end(); ++it, ++n) { - items[n] = SortItem(&*it); + items[static_cast<ptrdiff_t>(n)] = SortItem(&*it); } - ::std::sort(&items[0], &items[n], Less()); - ::google::protobuf::scoped_ptr<Struct_FieldsEntry> entry; + ::std::sort(&items[0], &items[static_cast<ptrdiff_t>(n)], Less()); + ::google::protobuf::scoped_ptr<Struct_FieldsEntry_DoNotUse> entry; for (size_type i = 0; i < n; i++) { entry.reset(fields_.NewEntryWrapper( - items[i]->first, items[i]->second)); + items[static_cast<ptrdiff_t>(i)]->first, items[static_cast<ptrdiff_t>(i)]->second)); ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 1, *entry, output); if (entry->GetArena() != NULL) { entry.release(); } - Utf8Check::Check(items[i]); + Utf8Check::Check(items[static_cast<ptrdiff_t>(i)]); } } else { - ::google::protobuf::scoped_ptr<Struct_FieldsEntry> entry; + ::google::protobuf::scoped_ptr<Struct_FieldsEntry_DoNotUse> entry; for (::google::protobuf::Map< ::std::string, ::google::protobuf::Value >::const_iterator it = this->fields().begin(); it != this->fields().end(); ++it) { @@ -431,11 +423,16 @@ void Struct::SerializeWithCachedSizes( } } + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + ::google::protobuf::internal::WireFormat::SerializeUnknownFields( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), output); + } // @@protoc_insertion_point(serialize_end:google.protobuf.Struct) } ::google::protobuf::uint8* Struct::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Struct) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -449,7 +446,7 @@ void Struct::SerializeWithCachedSizes( struct Utf8Check { static void Check(ConstPtr p) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( - p->first.data(), p->first.length(), + p->first.data(), static_cast<int>(p->first.length()), ::google::protobuf::internal::WireFormatLite::SERIALIZE, "google.protobuf.Struct.FieldsEntry.key"); } @@ -464,13 +461,13 @@ void Struct::SerializeWithCachedSizes( for (::google::protobuf::Map< ::std::string, ::google::protobuf::Value >::const_iterator it = this->fields().begin(); it != this->fields().end(); ++it, ++n) { - items[n] = SortItem(&*it); + items[static_cast<ptrdiff_t>(n)] = SortItem(&*it); } - ::std::sort(&items[0], &items[n], Less()); - ::google::protobuf::scoped_ptr<Struct_FieldsEntry> entry; + ::std::sort(&items[0], &items[static_cast<ptrdiff_t>(n)], Less()); + ::google::protobuf::scoped_ptr<Struct_FieldsEntry_DoNotUse> entry; for (size_type i = 0; i < n; i++) { entry.reset(fields_.NewEntryWrapper( - items[i]->first, items[i]->second)); + items[static_cast<ptrdiff_t>(i)]->first, items[static_cast<ptrdiff_t>(i)]->second)); target = ::google::protobuf::internal::WireFormatLite:: InternalWriteMessageNoVirtualToArray( 1, *entry, deterministic, target); @@ -478,10 +475,10 @@ void Struct::SerializeWithCachedSizes( if (entry->GetArena() != NULL) { entry.release(); } - Utf8Check::Check(items[i]); + Utf8Check::Check(items[static_cast<ptrdiff_t>(i)]); } } else { - ::google::protobuf::scoped_ptr<Struct_FieldsEntry> entry; + ::google::protobuf::scoped_ptr<Struct_FieldsEntry_DoNotUse> entry; for (::google::protobuf::Map< ::std::string, ::google::protobuf::Value >::const_iterator it = this->fields().begin(); it != this->fields().end(); ++it) { @@ -499,6 +496,10 @@ void Struct::SerializeWithCachedSizes( } } + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), target); + } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Struct) return target; } @@ -507,11 +508,16 @@ size_t Struct::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Struct) size_t total_size = 0; + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance())); + } // map<string, .google.protobuf.Value> fields = 1; total_size += 1 * ::google::protobuf::internal::FromIntSize(this->fields_size()); { - ::google::protobuf::scoped_ptr<Struct_FieldsEntry> entry; + ::google::protobuf::scoped_ptr<Struct_FieldsEntry_DoNotUse> entry; for (::google::protobuf::Map< ::std::string, ::google::protobuf::Value >::const_iterator it = this->fields().begin(); it != this->fields().end(); ++it) { @@ -597,40 +603,61 @@ void Struct::UnsafeArenaSwap(Struct* other) { InternalSwap(other); } void Struct::InternalSwap(Struct* other) { + using std::swap; fields_.Swap(&other->fields_); - std::swap(_cached_size_, other->_cached_size_); + _internal_metadata_.Swap(&other->_internal_metadata_); + swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata Struct::GetMetadata() const { protobuf_google_2fprotobuf_2fstruct_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fstruct_2eproto::file_level_metadata[kIndexInFileMessages]; + return ::protobuf_google_2fprotobuf_2fstruct_2eproto::file_level_metadata[kIndexInFileMessages]; } -#if PROTOBUF_INLINE_NOT_IN_HEADERS -// Struct -// map<string, .google.protobuf.Value> fields = 1; -int Struct::fields_size() const { - return fields_.size(); -} -void Struct::clear_fields() { - fields_.Clear(); +// =================================================================== + +void Value::InitAsDefaultInstance() { + ::google::protobuf::_Value_default_instance_.null_value_ = 0; + ::google::protobuf::_Value_default_instance_.number_value_ = 0; + ::google::protobuf::_Value_default_instance_.string_value_.UnsafeSetDefault( + &::google::protobuf::internal::GetEmptyStringAlreadyInited()); + ::google::protobuf::_Value_default_instance_.bool_value_ = false; + ::google::protobuf::_Value_default_instance_.struct_value_ = const_cast< ::google::protobuf::Struct*>( + ::google::protobuf::Struct::internal_default_instance()); + ::google::protobuf::_Value_default_instance_.list_value_ = const_cast< ::google::protobuf::ListValue*>( + ::google::protobuf::ListValue::internal_default_instance()); } - const ::google::protobuf::Map< ::std::string, ::google::protobuf::Value >& -Struct::fields() const { - // @@protoc_insertion_point(field_map:google.protobuf.Struct.fields) - return fields_.GetMap(); +void Value::set_allocated_struct_value(::google::protobuf::Struct* struct_value) { + ::google::protobuf::Arena* message_arena = GetArenaNoVirtual(); + clear_kind(); + if (struct_value) { + ::google::protobuf::Arena* submessage_arena = + ::google::protobuf::Arena::GetArena(struct_value); + if (message_arena != submessage_arena) { + struct_value = ::google::protobuf::internal::GetOwnedMessage( + message_arena, struct_value, submessage_arena); + } + set_has_struct_value(); + kind_.struct_value_ = struct_value; + } + // @@protoc_insertion_point(field_set_allocated:google.protobuf.Value.struct_value) } - ::google::protobuf::Map< ::std::string, ::google::protobuf::Value >* -Struct::mutable_fields() { - // @@protoc_insertion_point(field_mutable_map:google.protobuf.Struct.fields) - return fields_.MutableMap(); +void Value::set_allocated_list_value(::google::protobuf::ListValue* list_value) { + ::google::protobuf::Arena* message_arena = GetArenaNoVirtual(); + clear_kind(); + if (list_value) { + ::google::protobuf::Arena* submessage_arena = + ::google::protobuf::Arena::GetArena(list_value); + if (message_arena != submessage_arena) { + list_value = ::google::protobuf::internal::GetOwnedMessage( + message_arena, list_value, submessage_arena); + } + set_has_list_value(); + kind_.list_value_ = list_value; + } + // @@protoc_insertion_point(field_set_allocated:google.protobuf.Value.list_value) } - -#endif // PROTOBUF_INLINE_NOT_IN_HEADERS - -// =================================================================== - #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int Value::kNullValueFieldNumber; const int Value::kNumberValueFieldNumber; @@ -643,7 +670,7 @@ const int Value::kListValueFieldNumber; Value::Value() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { - protobuf_google_2fprotobuf_2fstruct_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fstruct_2eproto::InitDefaultsListValue(); } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Value) @@ -651,9 +678,7 @@ Value::Value() Value::Value(::google::protobuf::Arena* arena) : ::google::protobuf::Message(), _internal_metadata_(arena) { -#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER - protobuf_google_2fprotobuf_2fstruct_2eproto::InitDefaults(); -#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + ::protobuf_google_2fprotobuf_2fstruct_2eproto::InitDefaultsListValue(); SharedCtor(); RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.Value) @@ -707,11 +732,7 @@ Value::~Value() { } void Value::SharedDtor() { - ::google::protobuf::Arena* arena = GetArenaNoVirtual(); - if (arena != NULL) { - return; - } - + GOOGLE_DCHECK(GetArenaNoVirtual() == NULL); if (has_kind()) { clear_kind(); } @@ -729,18 +750,15 @@ void Value::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* Value::descriptor() { - protobuf_google_2fprotobuf_2fstruct_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fstruct_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; + ::protobuf_google_2fprotobuf_2fstruct_2eproto::protobuf_AssignDescriptorsOnce(); + return ::protobuf_google_2fprotobuf_2fstruct_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const Value& Value::default_instance() { - protobuf_google_2fprotobuf_2fstruct_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fstruct_2eproto::InitDefaultsListValue(); return *internal_default_instance(); } -Value* Value::New(::google::protobuf::Arena* arena) const { - return ::google::protobuf::Arena::CreateMessage<Value>(arena); -} void Value::clear_kind() { // @@protoc_insertion_point(one_of_clear_start:google.protobuf.Value) @@ -784,7 +802,12 @@ void Value::clear_kind() { void Value::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.Value) + ::google::protobuf::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + clear_kind(); + _internal_metadata_.Clear(); } bool Value::MergePartialFromCodedStream( @@ -800,7 +823,7 @@ bool Value::MergePartialFromCodedStream( // .google.protobuf.NullValue null_value = 1; case 1: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(8u)) { + static_cast< ::google::protobuf::uint8>(8u /* 8 & 0xFF */)) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -815,7 +838,7 @@ bool Value::MergePartialFromCodedStream( // double number_value = 2; case 2: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(17u)) { + static_cast< ::google::protobuf::uint8>(17u /* 17 & 0xFF */)) { clear_kind(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< double, ::google::protobuf::internal::WireFormatLite::TYPE_DOUBLE>( @@ -830,11 +853,11 @@ bool Value::MergePartialFromCodedStream( // string string_value = 3; case 3: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(26u)) { + static_cast< ::google::protobuf::uint8>(26u /* 26 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_string_value())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( - this->string_value().data(), this->string_value().length(), + this->string_value().data(), static_cast<int>(this->string_value().length()), ::google::protobuf::internal::WireFormatLite::PARSE, "google.protobuf.Value.string_value")); } else { @@ -846,7 +869,7 @@ bool Value::MergePartialFromCodedStream( // bool bool_value = 4; case 4: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(32u)) { + static_cast< ::google::protobuf::uint8>(32u /* 32 & 0xFF */)) { clear_kind(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -861,8 +884,8 @@ bool Value::MergePartialFromCodedStream( // .google.protobuf.Struct struct_value = 5; case 5: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(42u)) { - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + static_cast< ::google::protobuf::uint8>(42u /* 42 & 0xFF */)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, mutable_struct_value())); } else { goto handle_unusual; @@ -873,8 +896,8 @@ bool Value::MergePartialFromCodedStream( // .google.protobuf.ListValue list_value = 6; case 6: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(50u)) { - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + static_cast< ::google::protobuf::uint8>(50u /* 50 & 0xFF */)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, mutable_list_value())); } else { goto handle_unusual; @@ -884,12 +907,11 @@ bool Value::MergePartialFromCodedStream( default: { handle_unusual: - if (tag == 0 || - ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + if (tag == 0) { goto success; } - DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag)); + DO_(::google::protobuf::internal::WireFormat::SkipField( + input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } @@ -923,7 +945,7 @@ void Value::SerializeWithCachedSizes( // string string_value = 3; if (has_string_value()) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( - this->string_value().data(), this->string_value().length(), + this->string_value().data(), static_cast<int>(this->string_value().length()), ::google::protobuf::internal::WireFormatLite::SERIALIZE, "google.protobuf.Value.string_value"); ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( @@ -947,11 +969,16 @@ void Value::SerializeWithCachedSizes( 6, *kind_.list_value_, output); } + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + ::google::protobuf::internal::WireFormat::SerializeUnknownFields( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), output); + } // @@protoc_insertion_point(serialize_end:google.protobuf.Value) } ::google::protobuf::uint8* Value::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Value) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -970,7 +997,7 @@ void Value::SerializeWithCachedSizes( // string string_value = 3; if (has_string_value()) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( - this->string_value().data(), this->string_value().length(), + this->string_value().data(), static_cast<int>(this->string_value().length()), ::google::protobuf::internal::WireFormatLite::SERIALIZE, "google.protobuf.Value.string_value"); target = @@ -986,17 +1013,21 @@ void Value::SerializeWithCachedSizes( // .google.protobuf.Struct struct_value = 5; if (has_struct_value()) { target = ::google::protobuf::internal::WireFormatLite:: - InternalWriteMessageNoVirtualToArray( + InternalWriteMessageToArray( 5, *kind_.struct_value_, deterministic, target); } // .google.protobuf.ListValue list_value = 6; if (has_list_value()) { target = ::google::protobuf::internal::WireFormatLite:: - InternalWriteMessageNoVirtualToArray( + InternalWriteMessageToArray( 6, *kind_.list_value_, deterministic, target); } + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), target); + } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Value) return target; } @@ -1005,6 +1036,11 @@ size_t Value::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Value) size_t total_size = 0; + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance())); + } switch (kind_case()) { // .google.protobuf.NullValue null_value = 1; case kNullValue: { @@ -1032,14 +1068,14 @@ size_t Value::ByteSizeLong() const { // .google.protobuf.Struct struct_value = 5; case kStructValue: { total_size += 1 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + ::google::protobuf::internal::WireFormatLite::MessageSize( *kind_.struct_value_); break; } // .google.protobuf.ListValue list_value = 6; case kListValue: { total_size += 1 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + ::google::protobuf::internal::WireFormatLite::MessageSize( *kind_.list_value_); break; } @@ -1145,405 +1181,23 @@ void Value::UnsafeArenaSwap(Value* other) { InternalSwap(other); } void Value::InternalSwap(Value* other) { - std::swap(kind_, other->kind_); - std::swap(_oneof_case_[0], other->_oneof_case_[0]); - std::swap(_cached_size_, other->_cached_size_); + using std::swap; + swap(kind_, other->kind_); + swap(_oneof_case_[0], other->_oneof_case_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata Value::GetMetadata() const { protobuf_google_2fprotobuf_2fstruct_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fstruct_2eproto::file_level_metadata[kIndexInFileMessages]; -} - -#if PROTOBUF_INLINE_NOT_IN_HEADERS -// Value - -// .google.protobuf.NullValue null_value = 1; -bool Value::has_null_value() const { - return kind_case() == kNullValue; -} -void Value::set_has_null_value() { - _oneof_case_[0] = kNullValue; -} -void Value::clear_null_value() { - if (has_null_value()) { - kind_.null_value_ = 0; - clear_has_kind(); - } -} -::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) { - if (!has_null_value()) { - clear_kind(); - set_has_null_value(); - } - kind_.null_value_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.Value.null_value) -} - -// double number_value = 2; -bool Value::has_number_value() const { - return kind_case() == kNumberValue; -} -void Value::set_has_number_value() { - _oneof_case_[0] = kNumberValue; -} -void Value::clear_number_value() { - if (has_number_value()) { - kind_.number_value_ = 0; - clear_has_kind(); - } -} -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) { - if (!has_number_value()) { - clear_kind(); - set_has_number_value(); - } - kind_.number_value_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.Value.number_value) -} - -// string string_value = 3; -bool Value::has_string_value() const { - return kind_case() == kStringValue; -} -void Value::set_has_string_value() { - _oneof_case_[0] = kStringValue; -} -void Value::clear_string_value() { - if (has_string_value()) { - kind_.string_value_.Destroy(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); - clear_has_kind(); - } -} -const ::std::string& Value::string_value() const { - // @@protoc_insertion_point(field_get:google.protobuf.Value.string_value) - if (has_string_value()) { - return kind_.string_value_.Get(); - } - return *&::google::protobuf::internal::GetEmptyStringAlreadyInited(); -} -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_.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) { - GOOGLE_DCHECK(value != NULL); - if (!has_string_value()) { - clear_kind(); - set_has_string_value(); - kind_.string_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - } - 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) { - if (!has_string_value()) { - clear_kind(); - set_has_string_value(); - kind_.string_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - } - kind_.string_value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( - reinterpret_cast<const char*>(value), size), - GetArenaNoVirtual()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.Value.string_value) -} -::std::string* Value::mutable_string_value() { - 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) -} -::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_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); - } else { - return NULL; - } -} -::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_.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) + return ::protobuf_google_2fprotobuf_2fstruct_2eproto::file_level_metadata[kIndexInFileMessages]; } -// bool bool_value = 4; -bool Value::has_bool_value() const { - return kind_case() == kBoolValue; -} -void Value::set_has_bool_value() { - _oneof_case_[0] = kBoolValue; -} -void Value::clear_bool_value() { - if (has_bool_value()) { - kind_.bool_value_ = false; - clear_has_kind(); - } -} -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) { - if (!has_bool_value()) { - clear_kind(); - set_has_bool_value(); - } - kind_.bool_value_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.Value.bool_value) -} - -// .google.protobuf.Struct struct_value = 5; -bool Value::has_struct_value() const { - return kind_case() == kStructValue; -} -void Value::set_has_struct_value() { - _oneof_case_[0] = kStructValue; -} -void Value::clear_struct_value() { - if (has_struct_value()) { - if (GetArenaNoVirtual() == NULL) { - delete kind_.struct_value_; - } - clear_has_kind(); - } -} - const ::google::protobuf::Struct& Value::struct_value() const { - // @@protoc_insertion_point(field_get:google.protobuf.Value.struct_value) - return has_struct_value() - ? *kind_.struct_value_ - : ::google::protobuf::Struct::default_instance(); -} -::google::protobuf::Struct* Value::mutable_struct_value() { - if (!has_struct_value()) { - clear_kind(); - set_has_struct_value(); - 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_; - kind_.struct_value_ = NULL; - return temp; - } else { - return NULL; - } -} - 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_unsafe_arena_set_allocated:google.protobuf.Value.struct_value) -} - -// .google.protobuf.ListValue list_value = 6; -bool Value::has_list_value() const { - return kind_case() == kListValue; -} -void Value::set_has_list_value() { - _oneof_case_[0] = kListValue; -} -void Value::clear_list_value() { - if (has_list_value()) { - if (GetArenaNoVirtual() == NULL) { - delete kind_.list_value_; - } - clear_has_kind(); - } -} - const ::google::protobuf::ListValue& Value::list_value() const { - // @@protoc_insertion_point(field_get:google.protobuf.Value.list_value) - return has_list_value() - ? *kind_.list_value_ - : ::google::protobuf::ListValue::default_instance(); -} -::google::protobuf::ListValue* Value::mutable_list_value() { - if (!has_list_value()) { - clear_kind(); - set_has_list_value(); - 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_; - kind_.list_value_ = NULL; - return temp; - } else { - return NULL; - } -} - 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_unsafe_arena_set_allocated:google.protobuf.Value.list_value) -} - -bool Value::has_kind() const { - return kind_case() != KIND_NOT_SET; -} -void Value::clear_has_kind() { - _oneof_case_[0] = KIND_NOT_SET; -} -Value::KindCase Value::kind_case() const { - return Value::KindCase(_oneof_case_[0]); -} -#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== +void ListValue::InitAsDefaultInstance() { +} #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int ListValue::kValuesFieldNumber; #endif // !defined(_MSC_VER) || _MSC_VER >= 1900 @@ -1551,7 +1205,7 @@ const int ListValue::kValuesFieldNumber; ListValue::ListValue() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { - protobuf_google_2fprotobuf_2fstruct_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fstruct_2eproto::InitDefaultsListValue(); } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.ListValue) @@ -1560,9 +1214,7 @@ ListValue::ListValue(::google::protobuf::Arena* arena) : ::google::protobuf::Message(), _internal_metadata_(arena), values_(arena) { -#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER - protobuf_google_2fprotobuf_2fstruct_2eproto::InitDefaults(); -#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + ::protobuf_google_2fprotobuf_2fstruct_2eproto::InitDefaultsListValue(); SharedCtor(); RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.ListValue) @@ -1586,11 +1238,7 @@ ListValue::~ListValue() { } void ListValue::SharedDtor() { - ::google::protobuf::Arena* arena = GetArenaNoVirtual(); - if (arena != NULL) { - return; - } - + GOOGLE_DCHECK(GetArenaNoVirtual() == NULL); } void ListValue::ArenaDtor(void* object) { @@ -1605,22 +1253,24 @@ void ListValue::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* ListValue::descriptor() { - protobuf_google_2fprotobuf_2fstruct_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fstruct_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; + ::protobuf_google_2fprotobuf_2fstruct_2eproto::protobuf_AssignDescriptorsOnce(); + return ::protobuf_google_2fprotobuf_2fstruct_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const ListValue& ListValue::default_instance() { - protobuf_google_2fprotobuf_2fstruct_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fstruct_2eproto::InitDefaultsListValue(); return *internal_default_instance(); } -ListValue* ListValue::New(::google::protobuf::Arena* arena) const { - return ::google::protobuf::Arena::CreateMessage<ListValue>(arena); -} void ListValue::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.ListValue) + ::google::protobuf::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + values_.Clear(); + _internal_metadata_.Clear(); } bool ListValue::MergePartialFromCodedStream( @@ -1636,8 +1286,8 @@ bool ListValue::MergePartialFromCodedStream( // repeated .google.protobuf.Value values = 1; case 1: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(10u)) { - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + static_cast< ::google::protobuf::uint8>(10u /* 10 & 0xFF */)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, add_values())); } else { goto handle_unusual; @@ -1647,12 +1297,11 @@ bool ListValue::MergePartialFromCodedStream( default: { handle_unusual: - if (tag == 0 || - ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + if (tag == 0) { goto success; } - DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag)); + DO_(::google::protobuf::internal::WireFormat::SkipField( + input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } @@ -1673,27 +1322,40 @@ void ListValue::SerializeWithCachedSizes( (void) cached_has_bits; // repeated .google.protobuf.Value values = 1; - for (unsigned int i = 0, n = this->values_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->values_size()); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 1, this->values(i), output); + 1, + this->values(static_cast<int>(i)), + output); } + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + ::google::protobuf::internal::WireFormat::SerializeUnknownFields( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), output); + } // @@protoc_insertion_point(serialize_end:google.protobuf.ListValue) } ::google::protobuf::uint8* ListValue::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.ListValue) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; // repeated .google.protobuf.Value values = 1; - for (unsigned int i = 0, n = this->values_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->values_size()); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: - InternalWriteMessageNoVirtualToArray( - 1, this->values(i), deterministic, target); + InternalWriteMessageToArray( + 1, this->values(static_cast<int>(i)), deterministic, target); } + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), target); + } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.ListValue) return target; } @@ -1702,14 +1364,19 @@ size_t ListValue::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.ListValue) size_t total_size = 0; + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance())); + } // repeated .google.protobuf.Value values = 1; { - unsigned int count = this->values_size(); + unsigned int count = static_cast<unsigned int>(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)); + ::google::protobuf::internal::WireFormatLite::MessageSize( + this->values(static_cast<int>(i))); } } @@ -1783,52 +1450,35 @@ void ListValue::UnsafeArenaSwap(ListValue* other) { InternalSwap(other); } void ListValue::InternalSwap(ListValue* other) { - values_.InternalSwap(&other->values_); - std::swap(_cached_size_, other->_cached_size_); + using std::swap; + CastToBase(&values_)->InternalSwap(CastToBase(&other->values_)); + _internal_metadata_.Swap(&other->_internal_metadata_); + swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata ListValue::GetMetadata() const { protobuf_google_2fprotobuf_2fstruct_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fstruct_2eproto::file_level_metadata[kIndexInFileMessages]; + return ::protobuf_google_2fprotobuf_2fstruct_2eproto::file_level_metadata[kIndexInFileMessages]; } -#if PROTOBUF_INLINE_NOT_IN_HEADERS -// ListValue -// repeated .google.protobuf.Value values = 1; -int ListValue::values_size() const { - return values_.size(); -} -void ListValue::clear_values() { - values_.Clear(); -} -const ::google::protobuf::Value& ListValue::values(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.ListValue.values) - return values_.Get(index); -} -::google::protobuf::Value* ListValue::mutable_values(int index) { - // @@protoc_insertion_point(field_mutable:google.protobuf.ListValue.values) - return values_.Mutable(index); +// @@protoc_insertion_point(namespace_scope) +} // namespace protobuf +} // namespace google +namespace google { +namespace protobuf { +template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::Struct_FieldsEntry_DoNotUse* Arena::CreateMessage< ::google::protobuf::Struct_FieldsEntry_DoNotUse >(Arena* arena) { + return Arena::CreateMessageInternal< ::google::protobuf::Struct_FieldsEntry_DoNotUse >(arena); } -::google::protobuf::Value* ListValue::add_values() { - // @@protoc_insertion_point(field_add:google.protobuf.ListValue.values) - return values_.Add(); +template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::Struct* Arena::CreateMessage< ::google::protobuf::Struct >(Arena* arena) { + return Arena::CreateMessageInternal< ::google::protobuf::Struct >(arena); } -::google::protobuf::RepeatedPtrField< ::google::protobuf::Value >* -ListValue::mutable_values() { - // @@protoc_insertion_point(field_mutable_list:google.protobuf.ListValue.values) - return &values_; +template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::Value* Arena::CreateMessage< ::google::protobuf::Value >(Arena* arena) { + return Arena::CreateMessageInternal< ::google::protobuf::Value >(arena); } -const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Value >& -ListValue::values() const { - // @@protoc_insertion_point(field_list:google.protobuf.ListValue.values) - return values_; +template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::ListValue* Arena::CreateMessage< ::google::protobuf::ListValue >(Arena* arena) { + return Arena::CreateMessageInternal< ::google::protobuf::ListValue >(arena); } - -#endif // PROTOBUF_INLINE_NOT_IN_HEADERS - -// @@protoc_insertion_point(namespace_scope) - } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/struct.pb.h b/src/google/protobuf/struct.pb.h index a37a5652..91aa3cf2 100644 --- a/src/google/protobuf/struct.pb.h +++ b/src/google/protobuf/struct.pb.h @@ -1,19 +1,19 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/protobuf/struct.proto -#ifndef PROTOBUF_google_2fprotobuf_2fstruct_2eproto__INCLUDED -#define PROTOBUF_google_2fprotobuf_2fstruct_2eproto__INCLUDED +#ifndef PROTOBUF_google_2fprotobuf_2fstruct_2eproto_INCLUDED +#define PROTOBUF_google_2fprotobuf_2fstruct_2eproto_INCLUDED #include <string> #include <google/protobuf/stubs/common.h> -#if GOOGLE_PROTOBUF_VERSION < 3003000 +#if GOOGLE_PROTOBUF_VERSION < 3005000 #error This file was generated by a newer version of protoc which is #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3003000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION +#if 3005001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. @@ -29,10 +29,29 @@ #include <google/protobuf/repeated_field.h> // IWYU pragma: export #include <google/protobuf/extension_set.h> // IWYU pragma: export #include <google/protobuf/map.h> // IWYU pragma: export +#include <google/protobuf/map_entry.h> #include <google/protobuf/map_field_inl.h> #include <google/protobuf/generated_enum_reflection.h> #include <google/protobuf/unknown_field_set.h> // @@protoc_insertion_point(includes) + +namespace protobuf_google_2fprotobuf_2fstruct_2eproto { +// Internal implementation detail -- do not use these members. +struct LIBPROTOBUF_EXPORT TableStruct { + static const ::google::protobuf::internal::ParseTableField entries[]; + static const ::google::protobuf::internal::AuxillaryParseTableField aux[]; + static const ::google::protobuf::internal::ParseTable schema[4]; + static const ::google::protobuf::internal::FieldMetadata field_metadata[]; + static const ::google::protobuf::internal::SerializationTable serialization_table[]; + static const ::google::protobuf::uint32 offsets[]; +}; +void LIBPROTOBUF_EXPORT AddDescriptors(); +void LIBPROTOBUF_EXPORT InitDefaultsListValueImpl(); +void LIBPROTOBUF_EXPORT InitDefaultsListValue(); +inline void LIBPROTOBUF_EXPORT InitDefaults() { + InitDefaultsListValue(); +} +} // namespace protobuf_google_2fprotobuf_2fstruct_2eproto namespace google { namespace protobuf { class ListValue; @@ -41,31 +60,24 @@ LIBPROTOBUF_EXPORT extern ListValueDefaultTypeInternal _ListValue_default_instan class Struct; class StructDefaultTypeInternal; LIBPROTOBUF_EXPORT extern StructDefaultTypeInternal _Struct_default_instance_; -class Struct_FieldsEntry; -class Struct_FieldsEntryDefaultTypeInternal; -LIBPROTOBUF_EXPORT extern Struct_FieldsEntryDefaultTypeInternal _Struct_FieldsEntry_default_instance_; +class Struct_FieldsEntry_DoNotUse; +class Struct_FieldsEntry_DoNotUseDefaultTypeInternal; +LIBPROTOBUF_EXPORT extern Struct_FieldsEntry_DoNotUseDefaultTypeInternal _Struct_FieldsEntry_DoNotUse_default_instance_; class Value; class ValueDefaultTypeInternal; LIBPROTOBUF_EXPORT extern ValueDefaultTypeInternal _Value_default_instance_; } // namespace protobuf } // namespace google - namespace google { namespace protobuf { - -namespace protobuf_google_2fprotobuf_2fstruct_2eproto { -// Internal implementation detail -- do not call these. -struct LIBPROTOBUF_EXPORT TableStruct { - static const ::google::protobuf::internal::ParseTableField entries[]; - static const ::google::protobuf::internal::AuxillaryParseTableField aux[]; - static const ::google::protobuf::internal::ParseTable schema[]; - static const ::google::protobuf::uint32 offsets[]; - static void InitDefaultsImpl(); - static void Shutdown(); -}; -void LIBPROTOBUF_EXPORT AddDescriptors(); -void LIBPROTOBUF_EXPORT InitDefaults(); -} // namespace protobuf_google_2fprotobuf_2fstruct_2eproto +template<> LIBPROTOBUF_EXPORT ::google::protobuf::ListValue* Arena::CreateMessage< ::google::protobuf::ListValue>(Arena*); +template<> LIBPROTOBUF_EXPORT ::google::protobuf::Struct* Arena::CreateMessage< ::google::protobuf::Struct>(Arena*); +template<> LIBPROTOBUF_EXPORT ::google::protobuf::Struct_FieldsEntry_DoNotUse* Arena::CreateMessage< ::google::protobuf::Struct_FieldsEntry_DoNotUse>(Arena*); +template<> LIBPROTOBUF_EXPORT ::google::protobuf::Value* Arena::CreateMessage< ::google::protobuf::Value>(Arena*); +} // namespace protobuf +} // namespace google +namespace google { +namespace protobuf { enum NullValue { NULL_VALUE = 0, @@ -89,6 +101,24 @@ inline bool NullValue_Parse( } // =================================================================== +class Struct_FieldsEntry_DoNotUse : public ::google::protobuf::internal::MapEntry<Struct_FieldsEntry_DoNotUse, + ::std::string, ::google::protobuf::Value, + ::google::protobuf::internal::WireFormatLite::TYPE_STRING, + ::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE, + 0 > { +public: + typedef ::google::protobuf::internal::MapEntry<Struct_FieldsEntry_DoNotUse, + ::std::string, ::google::protobuf::Value, + ::google::protobuf::internal::WireFormatLite::TYPE_STRING, + ::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE, + 0 > SuperType; + Struct_FieldsEntry_DoNotUse(); + Struct_FieldsEntry_DoNotUse(::google::protobuf::Arena* arena); + void MergeFrom(const Struct_FieldsEntry_DoNotUse& other); + static const Struct_FieldsEntry_DoNotUse* internal_default_instance() { return reinterpret_cast<const Struct_FieldsEntry_DoNotUse*>(&_Struct_FieldsEntry_DoNotUse_default_instance_); } + void MergeFrom(const ::google::protobuf::Message& other) PROTOBUF_FINAL; + ::google::protobuf::Metadata GetMetadata() const; +}; // ------------------------------------------------------------------- @@ -103,7 +133,21 @@ class LIBPROTOBUF_EXPORT Struct : public ::google::protobuf::Message /* @@protoc CopyFrom(from); return *this; } + #if LANG_CXX11 + Struct(Struct&& from) noexcept + : Struct() { + *this = ::std::move(from); + } + inline Struct& operator=(Struct&& from) noexcept { + if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + #endif inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { return GetArenaNoVirtual(); } @@ -113,6 +157,7 @@ class LIBPROTOBUF_EXPORT Struct : public ::google::protobuf::Message /* @@protoc static const ::google::protobuf::Descriptor* descriptor(); static const Struct& default_instance(); + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY static inline const Struct* internal_default_instance() { return reinterpret_cast<const Struct*>( &_Struct_default_instance_); @@ -122,12 +167,19 @@ class LIBPROTOBUF_EXPORT Struct : public ::google::protobuf::Message /* @@protoc void UnsafeArenaSwap(Struct* other); void Swap(Struct* other); + friend void swap(Struct& a, Struct& b) { + a.Swap(&b); + } // implements Message ---------------------------------------------- - inline Struct* New() const PROTOBUF_FINAL { return New(NULL); } + inline Struct* New() const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<Struct>(NULL); + } - Struct* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + Struct* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<Struct>(arena); + } void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const Struct& from); @@ -182,37 +234,18 @@ class LIBPROTOBUF_EXPORT Struct : public ::google::protobuf::Message /* @@protoc private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - friend class ::google::protobuf::Arena; + template <typename T> friend class ::google::protobuf::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - public: - class Struct_FieldsEntry : public ::google::protobuf::internal::MapEntry<Struct_FieldsEntry, - ::std::string, ::google::protobuf::Value, - ::google::protobuf::internal::WireFormatLite::TYPE_STRING, - ::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE, - 0 > { - public: - typedef ::google::protobuf::internal::MapEntry<Struct_FieldsEntry, - ::std::string, ::google::protobuf::Value, - ::google::protobuf::internal::WireFormatLite::TYPE_STRING, - ::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE, - 0 > SuperType; - Struct_FieldsEntry(); - Struct_FieldsEntry(::google::protobuf::Arena* arena); - void MergeFrom(const ::google::protobuf::Message& other) PROTOBUF_FINAL; - void MergeFrom(const Struct_FieldsEntry& other); - static const Message* internal_default_instance() { return reinterpret_cast<const Message*>(&_Struct_FieldsEntry_default_instance_); } - ::google::protobuf::Metadata GetMetadata() const; - }; ::google::protobuf::internal::MapField< - Struct_FieldsEntry, + Struct_FieldsEntry_DoNotUse, ::std::string, ::google::protobuf::Value, ::google::protobuf::internal::WireFormatLite::TYPE_STRING, ::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE, 0 > fields_; - private: mutable int _cached_size_; - friend struct protobuf_google_2fprotobuf_2fstruct_2eproto::TableStruct; + friend struct ::protobuf_google_2fprotobuf_2fstruct_2eproto::TableStruct; + friend void ::protobuf_google_2fprotobuf_2fstruct_2eproto::InitDefaultsListValueImpl(); }; // ------------------------------------------------------------------- @@ -227,7 +260,21 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_ CopyFrom(from); return *this; } + #if LANG_CXX11 + Value(Value&& from) noexcept + : Value() { + *this = ::std::move(from); + } + inline Value& operator=(Value&& from) noexcept { + if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + #endif inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { return GetArenaNoVirtual(); } @@ -247,6 +294,7 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_ KIND_NOT_SET = 0, }; + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY static inline const Value* internal_default_instance() { return reinterpret_cast<const Value*>( &_Value_default_instance_); @@ -256,12 +304,19 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_ void UnsafeArenaSwap(Value* other); void Swap(Value* other); + friend void swap(Value& a, Value& b) { + a.Swap(&b); + } // implements Message ---------------------------------------------- - inline Value* New() const PROTOBUF_FINAL { return New(NULL); } + inline Value* New() const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<Value>(NULL); + } - Value* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + Value* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<Value>(arena); + } void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const Value& from); @@ -328,12 +383,21 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_ static const int kStringValueFieldNumber = 3; const ::std::string& string_value() const; void set_string_value(const ::std::string& value); + #if LANG_CXX11 + void set_string_value(::std::string&& value); + #endif void set_string_value(const char* value); void set_string_value(const char* value, size_t size); ::std::string* mutable_string_value(); ::std::string* release_string_value(); void set_allocated_string_value(::std::string* string_value); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") ::std::string* unsafe_arena_release_string_value(); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") void unsafe_arena_set_allocated_string_value( ::std::string* string_value); @@ -350,37 +414,25 @@ 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(); + ::google::protobuf::Struct* mutable_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); + ::google::protobuf::Struct* unsafe_arena_release_struct_value(); // .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(); + ::google::protobuf::ListValue* mutable_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); + ::google::protobuf::ListValue* unsafe_arena_release_list_value(); KindCase kind_case() const; // @@protoc_insertion_point(class_scope:google.protobuf.Value) @@ -397,7 +449,7 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_ inline void clear_has_kind(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - friend class ::google::protobuf::Arena; + template <typename T> friend class ::google::protobuf::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; union KindUnion { @@ -412,7 +464,8 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_ mutable int _cached_size_; ::google::protobuf::uint32 _oneof_case_[1]; - friend struct protobuf_google_2fprotobuf_2fstruct_2eproto::TableStruct; + friend struct ::protobuf_google_2fprotobuf_2fstruct_2eproto::TableStruct; + friend void ::protobuf_google_2fprotobuf_2fstruct_2eproto::InitDefaultsListValueImpl(); }; // ------------------------------------------------------------------- @@ -427,7 +480,21 @@ class LIBPROTOBUF_EXPORT ListValue : public ::google::protobuf::Message /* @@pro CopyFrom(from); return *this; } + #if LANG_CXX11 + ListValue(ListValue&& from) noexcept + : ListValue() { + *this = ::std::move(from); + } + inline ListValue& operator=(ListValue&& from) noexcept { + if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + #endif inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { return GetArenaNoVirtual(); } @@ -437,6 +504,7 @@ class LIBPROTOBUF_EXPORT ListValue : public ::google::protobuf::Message /* @@pro static const ::google::protobuf::Descriptor* descriptor(); static const ListValue& default_instance(); + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY static inline const ListValue* internal_default_instance() { return reinterpret_cast<const ListValue*>( &_ListValue_default_instance_); @@ -446,12 +514,19 @@ class LIBPROTOBUF_EXPORT ListValue : public ::google::protobuf::Message /* @@pro void UnsafeArenaSwap(ListValue* other); void Swap(ListValue* other); + friend void swap(ListValue& a, ListValue& b) { + a.Swap(&b); + } // implements Message ---------------------------------------------- - inline ListValue* New() const PROTOBUF_FINAL { return New(NULL); } + inline ListValue* New() const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<ListValue>(NULL); + } - ListValue* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + ListValue* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<ListValue>(arena); + } void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const ListValue& from); @@ -496,11 +571,11 @@ class LIBPROTOBUF_EXPORT ListValue : public ::google::protobuf::Message /* @@pro int values_size() const; void clear_values(); static const int kValuesFieldNumber = 1; - const ::google::protobuf::Value& values(int index) const; ::google::protobuf::Value* mutable_values(int index); - ::google::protobuf::Value* add_values(); ::google::protobuf::RepeatedPtrField< ::google::protobuf::Value >* mutable_values(); + const ::google::protobuf::Value& values(int index) const; + ::google::protobuf::Value* add_values(); const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Value >& values() const; @@ -508,19 +583,23 @@ class LIBPROTOBUF_EXPORT ListValue : public ::google::protobuf::Message /* @@pro private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - friend class ::google::protobuf::Arena; + template <typename T> friend class ::google::protobuf::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::Value > values_; mutable int _cached_size_; - friend struct protobuf_google_2fprotobuf_2fstruct_2eproto::TableStruct; + friend struct ::protobuf_google_2fprotobuf_2fstruct_2eproto::TableStruct; + friend void ::protobuf_google_2fprotobuf_2fstruct_2eproto::InitDefaultsListValueImpl(); }; // =================================================================== // =================================================================== -#if !PROTOBUF_INLINE_NOT_IN_HEADERS +#ifdef __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif // __GNUC__ // ------------------------------------------------------------------- // Struct @@ -636,6 +715,19 @@ inline void Value::set_string_value(const ::std::string& value) { GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.Value.string_value) } +#if LANG_CXX11 +inline void Value::set_string_value(::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_.Set( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Value.string_value) +} +#endif inline void Value::set_string_value(const char* value) { GOOGLE_DCHECK(value != NULL); if (!has_string_value()) { @@ -654,7 +746,8 @@ inline void Value::set_string_value(const char* value, set_has_string_value(); kind_.string_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - kind_.string_value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + kind_.string_value_.Set( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Value.string_value) @@ -679,17 +772,6 @@ inline ::std::string* Value::release_string_value() { 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; - } -} inline void Value::set_allocated_string_value(::std::string* string_value) { if (!has_string_value()) { kind_.string_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -702,6 +784,17 @@ inline void Value::set_allocated_string_value(::std::string* string_value) { } // @@protoc_insertion_point(field_set_allocated:google.protobuf.Value.string_value) } +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; + } +} inline void Value::unsafe_arena_set_allocated_string_value(::std::string* string_value) { GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); if (!has_string_value()) { @@ -759,60 +852,27 @@ inline void Value::clear_struct_value() { clear_has_kind(); } } -inline const ::google::protobuf::Struct& Value::struct_value() const { - // @@protoc_insertion_point(field_get:google.protobuf.Value.struct_value) - return has_struct_value() - ? *kind_.struct_value_ - : ::google::protobuf::Struct::default_instance(); -} -inline ::google::protobuf::Struct* Value::mutable_struct_value() { - if (!has_struct_value()) { - clear_kind(); - set_has_struct_value(); - 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; + if (GetArenaNoVirtual() != NULL) { + temp = ::google::protobuf::internal::DuplicateIfNonNull(temp, NULL); } + 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 const ::google::protobuf::Struct& Value::struct_value() const { + // @@protoc_insertion_point(field_get:google.protobuf.Value.struct_value) + return has_struct_value() + ? *kind_.struct_value_ + : *reinterpret_cast< ::google::protobuf::Struct*>(&::google::protobuf::_Struct_default_instance_); } -inline ::google::protobuf::Struct* Value::unsafe_arena_release_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(); @@ -823,7 +883,7 @@ inline ::google::protobuf::Struct* Value::unsafe_arena_release_struct_value() { return NULL; } } -inline void Value::unsafe_arena_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(); @@ -831,6 +891,16 @@ inline void Value::unsafe_arena_set_allocated_struct_value(::google::protobuf:: } // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Value.struct_value) } +inline ::google::protobuf::Struct* Value::mutable_struct_value() { + if (!has_struct_value()) { + clear_kind(); + set_has_struct_value(); + 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.ListValue list_value = 6; inline bool Value::has_list_value() const { @@ -847,60 +917,27 @@ inline void Value::clear_list_value() { clear_has_kind(); } } -inline const ::google::protobuf::ListValue& Value::list_value() const { - // @@protoc_insertion_point(field_get:google.protobuf.Value.list_value) - return has_list_value() - ? *kind_.list_value_ - : ::google::protobuf::ListValue::default_instance(); -} -inline ::google::protobuf::ListValue* Value::mutable_list_value() { - if (!has_list_value()) { - clear_kind(); - set_has_list_value(); - 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; + if (GetArenaNoVirtual() != NULL) { + temp = ::google::protobuf::internal::DuplicateIfNonNull(temp, NULL); } + 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 const ::google::protobuf::ListValue& Value::list_value() const { + // @@protoc_insertion_point(field_get:google.protobuf.Value.list_value) + return has_list_value() + ? *kind_.list_value_ + : *reinterpret_cast< ::google::protobuf::ListValue*>(&::google::protobuf::_ListValue_default_instance_); } -inline ::google::protobuf::ListValue* Value::unsafe_arena_release_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(); @@ -911,7 +948,7 @@ inline ::google::protobuf::ListValue* Value::unsafe_arena_release_list_value() return NULL; } } -inline void Value::unsafe_arena_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(); @@ -919,6 +956,16 @@ inline void Value::unsafe_arena_set_allocated_list_value(::google::protobuf::Li } // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Value.list_value) } +inline ::google::protobuf::ListValue* Value::mutable_list_value() { + if (!has_list_value()) { + clear_kind(); + set_has_list_value(); + 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 bool Value::has_kind() const { return kind_case() != KIND_NOT_SET; @@ -940,30 +987,32 @@ inline int ListValue::values_size() const { inline void ListValue::clear_values() { values_.Clear(); } -inline const ::google::protobuf::Value& ListValue::values(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.ListValue.values) - return values_.Get(index); -} inline ::google::protobuf::Value* ListValue::mutable_values(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.ListValue.values) return values_.Mutable(index); } -inline ::google::protobuf::Value* ListValue::add_values() { - // @@protoc_insertion_point(field_add:google.protobuf.ListValue.values) - return values_.Add(); -} inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::Value >* ListValue::mutable_values() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.ListValue.values) return &values_; } +inline const ::google::protobuf::Value& ListValue::values(int index) const { + // @@protoc_insertion_point(field_get:google.protobuf.ListValue.values) + return values_.Get(index); +} +inline ::google::protobuf::Value* ListValue::add_values() { + // @@protoc_insertion_point(field_add:google.protobuf.ListValue.values) + return values_.Add(); +} inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Value >& ListValue::values() const { // @@protoc_insertion_point(field_list:google.protobuf.ListValue.values) return values_; } -#endif // !PROTOBUF_INLINE_NOT_IN_HEADERS +#ifdef __GNUC__ + #pragma GCC diagnostic pop +#endif // __GNUC__ // ------------------------------------------------------------------- // ------------------------------------------------------------------- @@ -973,11 +1022,9 @@ ListValue::values() const { // @@protoc_insertion_point(namespace_scope) - } // namespace protobuf } // namespace google -#ifndef SWIG namespace google { namespace protobuf { @@ -989,8 +1036,7 @@ inline const EnumDescriptor* GetEnumDescriptor< ::google::protobuf::NullValue>() } // namespace protobuf } // namespace google -#endif // SWIG // @@protoc_insertion_point(global_scope) -#endif // PROTOBUF_google_2fprotobuf_2fstruct_2eproto__INCLUDED +#endif // PROTOBUF_google_2fprotobuf_2fstruct_2eproto_INCLUDED diff --git a/src/google/protobuf/stubs/atomicops.h b/src/google/protobuf/stubs/atomicops.h index 75aee306..cb4553b1 100644 --- a/src/google/protobuf/stubs/atomicops.h +++ b/src/google/protobuf/stubs/atomicops.h @@ -63,28 +63,22 @@ namespace google { namespace protobuf { namespace internal { -#if defined(GOOGLE_PROTOBUF_ARCH_POWER) -#if defined(_LP64) || defined(__LP64__) -typedef int32 Atomic32; -typedef intptr_t Atomic64; +#ifdef GOOGLE_PROTOBUF_ARCH_32_BIT + typedef intptr_t Atomic32; + typedef int64 Atomic64; #else -typedef intptr_t Atomic32; -typedef int64 Atomic64; -#endif -#else -typedef int32 Atomic32; -#ifdef GOOGLE_PROTOBUF_ARCH_64_BIT -// We need to be able to go between Atomic64 and AtomicWord implicitly. This -// means Atomic64 and AtomicWord should be the same type on 64-bit. -#if defined(__ILP32__) || defined(GOOGLE_PROTOBUF_OS_NACL) -// NaCl's intptr_t is not actually 64-bits on 64-bit! -// http://code.google.com/p/nativeclient/issues/detail?id=1162 -// sparcv9's pointer type is 32bits -typedef int64 Atomic64; -#else -typedef intptr_t Atomic64; -#endif -#endif + // We need to be able to go between Atomic64 and AtomicWord implicitly. This + // means Atomic64 and AtomicWord should be the same type on 64-bit. + #if defined(__ILP32__) || defined(GOOGLE_PROTOBUF_OS_NACL) + // NaCl's intptr_t is not actually 64-bits on 64-bit! + // http://code.google.com/p/nativeclient/issues/detail?id=1162 + // sparcv9's pointer type is 32bits + typedef intptr_t Atomic32; + typedef int64 Atomic64; + #else + typedef int32 Atomic32; + typedef intptr_t Atomic64; + #endif #endif // Use AtomicWord for a machine-sized pointer. It will use the Atomic32 or @@ -236,12 +230,6 @@ Atomic64 Release_Load(volatile const Atomic64* ptr); #error GOOGLE_PROTOBUF_ATOMICOPS_ERROR #endif -// On some platforms we need additional declarations to make AtomicWord -// compatible with our other Atomic* types. -#if defined(GOOGLE_PROTOBUF_OS_APPLE) -#include <google/protobuf/stubs/atomicops_internals_atomicword_compat.h> -#endif - #undef GOOGLE_PROTOBUF_ATOMICOPS_ERROR #endif // GOOGLE_PROTOBUF_NO_THREAD_SAFETY diff --git a/src/google/protobuf/stubs/atomicops_internals_atomicword_compat.h b/src/google/protobuf/stubs/atomicops_internals_atomicword_compat.h deleted file mode 100644 index eb198ff5..00000000 --- a/src/google/protobuf/stubs/atomicops_internals_atomicword_compat.h +++ /dev/null @@ -1,122 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2012 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// This file is an internal atomic implementation, use atomicops.h instead. - -#ifndef GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_ATOMICWORD_COMPAT_H_ -#define GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_ATOMICWORD_COMPAT_H_ - -// AtomicWord is a synonym for intptr_t, and Atomic32 is a synonym for int32, -// which in turn means int. On some LP32 platforms, intptr_t is an int, but -// on others, it's a long. When AtomicWord and Atomic32 are based on different -// fundamental types, their pointers are incompatible. -// -// This file defines function overloads to allow both AtomicWord and Atomic32 -// data to be used with this interface. -// -// On LP64 platforms, AtomicWord and Atomic64 are both always long, -// so this problem doesn't occur. - -#if !defined(GOOGLE_PROTOBUF_ARCH_64_BIT) - -namespace google { -namespace protobuf { -namespace internal { - -inline AtomicWord NoBarrier_CompareAndSwap(volatile AtomicWord* ptr, - AtomicWord old_value, - AtomicWord new_value) { - return NoBarrier_CompareAndSwap( - reinterpret_cast<volatile Atomic32*>(ptr), old_value, new_value); -} - -inline AtomicWord NoBarrier_AtomicExchange(volatile AtomicWord* ptr, - AtomicWord new_value) { - return NoBarrier_AtomicExchange( - reinterpret_cast<volatile Atomic32*>(ptr), new_value); -} - -inline AtomicWord NoBarrier_AtomicIncrement(volatile AtomicWord* ptr, - AtomicWord increment) { - return NoBarrier_AtomicIncrement( - reinterpret_cast<volatile Atomic32*>(ptr), increment); -} - -inline AtomicWord Barrier_AtomicIncrement(volatile AtomicWord* ptr, - AtomicWord increment) { - return Barrier_AtomicIncrement( - reinterpret_cast<volatile Atomic32*>(ptr), increment); -} - -inline AtomicWord Acquire_CompareAndSwap(volatile AtomicWord* ptr, - AtomicWord old_value, - AtomicWord new_value) { - return Acquire_CompareAndSwap( - reinterpret_cast<volatile Atomic32*>(ptr), old_value, new_value); -} - -inline AtomicWord Release_CompareAndSwap(volatile AtomicWord* ptr, - AtomicWord old_value, - AtomicWord new_value) { - return Release_CompareAndSwap( - reinterpret_cast<volatile Atomic32*>(ptr), old_value, new_value); -} - -inline void NoBarrier_Store(volatile AtomicWord *ptr, AtomicWord value) { - NoBarrier_Store(reinterpret_cast<volatile Atomic32*>(ptr), value); -} - -inline void Acquire_Store(volatile AtomicWord* ptr, AtomicWord value) { - return Acquire_Store(reinterpret_cast<volatile Atomic32*>(ptr), value); -} - -inline void Release_Store(volatile AtomicWord* ptr, AtomicWord value) { - return Release_Store(reinterpret_cast<volatile Atomic32*>(ptr), value); -} - -inline AtomicWord NoBarrier_Load(volatile const AtomicWord *ptr) { - return NoBarrier_Load(reinterpret_cast<volatile const Atomic32*>(ptr)); -} - -inline AtomicWord Acquire_Load(volatile const AtomicWord* ptr) { - return Acquire_Load(reinterpret_cast<volatile const Atomic32*>(ptr)); -} - -inline AtomicWord Release_Load(volatile const AtomicWord* ptr) { - return Release_Load(reinterpret_cast<volatile const Atomic32*>(ptr)); -} - -} // namespace internal -} // namespace protobuf -} // namespace google - -#endif // !defined(GOOGLE_PROTOBUF_ARCH_64_BIT) - -#endif // GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_ATOMICWORD_COMPAT_H_ diff --git a/src/google/protobuf/stubs/atomicops_internals_generic_gcc.h b/src/google/protobuf/stubs/atomicops_internals_generic_gcc.h index 0b0b06ce..075c406a 100644 --- a/src/google/protobuf/stubs/atomicops_internals_generic_gcc.h +++ b/src/google/protobuf/stubs/atomicops_internals_generic_gcc.h @@ -146,6 +146,14 @@ inline Atomic64 NoBarrier_Load(volatile const Atomic64* ptr) { return __atomic_load_n(ptr, __ATOMIC_RELAXED); } +inline Atomic64 Release_CompareAndSwap(volatile Atomic64* ptr, + Atomic64 old_value, + Atomic64 new_value) { + __atomic_compare_exchange_n(ptr, &old_value, new_value, false, + __ATOMIC_RELEASE, __ATOMIC_ACQUIRE); + return old_value; +} + #endif // defined(__LP64__) } // namespace internal diff --git a/src/google/protobuf/stubs/common.cc b/src/google/protobuf/stubs/common.cc index 14655916..574c7405 100644..100755 --- a/src/google/protobuf/stubs/common.cc +++ b/src/google/protobuf/stubs/common.cc @@ -30,6 +30,7 @@ // Author: kenton@google.com (Kenton Varda) +#include <google/protobuf/message_lite.h> // TODO(gerbens) ideally remove this. #include <google/protobuf/stubs/common.h> #include <google/protobuf/stubs/once.h> #include <google/protobuf/stubs/status.h> @@ -416,13 +417,30 @@ uint32 ghtonl(uint32 x) { namespace internal { typedef void OnShutdownFunc(); -vector<void (*)()>* shutdown_functions = NULL; -Mutex* shutdown_functions_mutex = NULL; +struct ShutdownData { + ~ShutdownData() { + for (int i = 0; i < functions.size(); i++) { + functions[i](); + } + for (int i = 0; i < strings.size(); i++) { + strings[i]->~string(); + } + for (int i = 0; i < messages.size(); i++) { + messages[i]->~MessageLite(); + } + } + + std::vector<void (*)()> functions; + std::vector<const std::string*> strings; + std::vector<const MessageLite*> messages; + Mutex mutex; +}; + +ShutdownData* shutdown_data = NULL; GOOGLE_PROTOBUF_DECLARE_ONCE(shutdown_functions_init); void InitShutdownFunctions() { - shutdown_functions = new vector<void (*)()>; - shutdown_functions_mutex = new Mutex; + shutdown_data = new ShutdownData; } inline void InitShutdownFunctionsOnce() { @@ -431,8 +449,20 @@ inline void InitShutdownFunctionsOnce() { void OnShutdown(void (*func)()) { InitShutdownFunctionsOnce(); - MutexLock lock(shutdown_functions_mutex); - shutdown_functions->push_back(func); + MutexLock lock(&shutdown_data->mutex); + shutdown_data->functions.push_back(func); +} + +void OnShutdownDestroyString(const std::string* ptr) { + InitShutdownFunctionsOnce(); + MutexLock lock(&shutdown_data->mutex); + shutdown_data->strings.push_back(ptr); +} + +void OnShutdownDestroyMessage(const void* ptr) { + InitShutdownFunctionsOnce(); + MutexLock lock(&shutdown_data->mutex); + shutdown_data->messages.push_back(static_cast<const MessageLite*>(ptr)); } } // namespace internal @@ -445,15 +475,10 @@ void ShutdownProtobufLibrary() { // called. // Make it safe to call this multiple times. - if (internal::shutdown_functions == NULL) return; + if (internal::shutdown_data == NULL) return; - for (int i = 0; i < internal::shutdown_functions->size(); i++) { - internal::shutdown_functions->at(i)(); - } - delete internal::shutdown_functions; - internal::shutdown_functions = NULL; - delete internal::shutdown_functions_mutex; - internal::shutdown_functions_mutex = NULL; + delete internal::shutdown_data; + internal::shutdown_data = NULL; } #if PROTOBUF_USE_EXCEPTIONS diff --git a/src/google/protobuf/stubs/common.h b/src/google/protobuf/stubs/common.h index 60874e09..04660b81 100644 --- a/src/google/protobuf/stubs/common.h +++ b/src/google/protobuf/stubs/common.h @@ -101,27 +101,27 @@ namespace internal { // The current version, represented as a single integer to make comparison // easier: major * 10^6 + minor * 10^3 + micro -#define GOOGLE_PROTOBUF_VERSION 3003000 +#define GOOGLE_PROTOBUF_VERSION 3005001 // A suffix string for alpha, beta or rc releases. Empty for stable releases. #define GOOGLE_PROTOBUF_VERSION_SUFFIX "" // The minimum library version which works with the current version of the // headers. -#define GOOGLE_PROTOBUF_MIN_LIBRARY_VERSION 3003000 +#define GOOGLE_PROTOBUF_MIN_LIBRARY_VERSION 3005000 // The minimum header version which works with the current version of // the library. This constant should only be used by protoc's C++ code // generator. -static const int kMinHeaderVersionForLibrary = 3003000; +static const int kMinHeaderVersionForLibrary = 3005000; // The minimum protoc version which works with the current version of the // headers. -#define GOOGLE_PROTOBUF_MIN_PROTOC_VERSION 3003000 +#define GOOGLE_PROTOBUF_MIN_PROTOC_VERSION 3005000 // The minimum header version which works with the current version of // protoc. This constant should only be used in VerifyVersion(). -static const int kMinHeaderVersionForProtoc = 3003000; +static const int kMinHeaderVersionForProtoc = 3005000; // Verifies that the headers and libraries are compatible. Use the macro // below to call this. @@ -200,6 +200,10 @@ namespace internal { // Register a function to be called when ShutdownProtocolBuffers() is called. LIBPROTOBUF_EXPORT void OnShutdown(void (*func)()); +// Destroy the string (call string destructor) +LIBPROTOBUF_EXPORT void OnShutdownDestroyString(const std::string* ptr); +// Destroy (not delete) the message +LIBPROTOBUF_EXPORT void OnShutdownDestroyMessage(const void* ptr); } // namespace internal @@ -225,14 +229,7 @@ class FatalException : public std::exception { // This is at the end of the file instead of the beginning to work around a bug // in some versions of MSVC. -// TODO(acozzette): remove these using statements -using std::istream; -using std::map; -using std::ostream; -using std::pair; -using std::set; using std::string; -using std::vector; } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/stubs/common_unittest.cc b/src/google/protobuf/stubs/common_unittest.cc index f9e2cfd4..798a2a27 100644 --- a/src/google/protobuf/stubs/common_unittest.cc +++ b/src/google/protobuf/stubs/common_unittest.cc @@ -75,7 +75,7 @@ TEST(CommonTest, IntMinMaxConstants) { EXPECT_EQ(0, kuint64max + 1); } -vector<string> captured_messages_; +std::vector<string> captured_messages_; void CaptureLog(LogLevel level, const char* filename, int line, const string& message) { diff --git a/src/google/protobuf/stubs/fastmem.h b/src/google/protobuf/stubs/fastmem.h index 763a6e60..1f1f6ed3 100644 --- a/src/google/protobuf/stubs/fastmem.h +++ b/src/google/protobuf/stubs/fastmem.h @@ -111,7 +111,8 @@ inline int fastmemcmp_inlined(const char *a, const char *b, size_t n) { b += sizeof(uint32); } while (a < a_limit) { - int d = static_cast<uint32>(*a++) - static_cast<uint32>(*b++); + int d = + static_cast<int>(static_cast<uint32>(*a++) - static_cast<uint32>(*b++)); if (d) return d; } return 0; diff --git a/src/google/protobuf/stubs/hash.h b/src/google/protobuf/stubs/hash.h index be998b29..daf8ec57 100644 --- a/src/google/protobuf/stubs/hash.h +++ b/src/google/protobuf/stubs/hash.h @@ -40,10 +40,9 @@ #define GOOGLE_PROTOBUF_HAVE_HASH_MAP 1 #define GOOGLE_PROTOBUF_HAVE_HASH_SET 1 -#define GOOGLE_PROTOBUF_HAVE_64BIT_HASH 1 // Use C++11 unordered_{map|set} if available. -#if ((_LIBCPP_STD_VER >= 11) || \ +#if ((defined(_LIBCPP_STD_VER) && _LIBCPP_STD_VER >= 11) || \ (((__cplusplus >= 201103L) || defined(__GXX_EXPERIMENTAL_CXX0X)) && \ (__GLIBCXX__ > 20090421))) # define GOOGLE_PROTOBUF_HAS_CXX11_HASH @@ -93,8 +92,11 @@ # define GOOGLE_PROTOBUF_HASH_SET_CLASS hash_set # endif -# if __GNUC__ == 4 && __GNUC__MINOR__ <= 1 -# undef GOOGLE_PROTOBUF_HAVE_64BIT_HASH +// GCC <= 4.1 does not define std::tr1::hash for `long long int` or `long long unsigned int` +# if __GNUC__ == 4 && defined(__GNUC__MINOR__) && __GNUC__MINOR__ <= 1 +# undef GOOGLE_PROTOBUF_HAS_TR1 +# undef GOOGLE_PROTOBUF_HAVE_HASH_MAP +# undef GOOGLE_PROTOBUF_HAVE_HASH_SET # endif // Version checks for MSC. @@ -348,7 +350,7 @@ struct hash<const char*> { inline size_t operator()(const char* str) const { size_t result = 0; for (; *str != '\0'; str++) { - result = 5 * result + *str; + result = 5 * result + static_cast<size_t>(*str); } return result; } @@ -406,8 +408,8 @@ struct hash<string> { }; template <typename First, typename Second> -struct hash<pair<First, Second> > { - inline size_t operator()(const pair<First, Second>& key) const { +struct hash<std::pair<First, Second> > { + inline size_t operator()(const std::pair<First, Second>& key) const { size_t first_hash = hash<First>()(key.first); size_t second_hash = hash<Second>()(key.second); @@ -418,8 +420,8 @@ struct hash<pair<First, Second> > { static const size_t bucket_size = 4; static const size_t min_buckets = 8; - inline bool operator()(const pair<First, Second>& a, - const pair<First, Second>& b) const { + inline bool operator()(const std::pair<First, Second>& a, + const std::pair<First, Second>& b) const { return a < b; } }; diff --git a/src/google/protobuf/stubs/io_win32.cc b/src/google/protobuf/stubs/io_win32.cc new file mode 100644 index 00000000..5ead98c8 --- /dev/null +++ b/src/google/protobuf/stubs/io_win32.cc @@ -0,0 +1,414 @@ +// 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. + +// Author: laszlocsomor@google.com (Laszlo Csomor) +// +// Implementation for long-path-aware open/mkdir/access/etc. on Windows, as well +// as for the supporting utility functions. +// +// These functions convert the input path to an absolute Windows path +// with "\\?\" prefix, then pass that to _wopen/_wmkdir/_waccess/etc. +// (declared in <io.h>) respectively. This allows working with files/directories +// whose paths are longer than MAX_PATH (260 chars). +// +// This file is only used on Windows, it's empty on other platforms. + +#if defined(_WIN32) + +// Comment this out to fall back to using the ANSI versions (open, mkdir, ...) +// instead of the Unicode ones (_wopen, _wmkdir, ...). Doing so can be useful to +// debug failing tests if that's caused by the long path support. +#define SUPPORT_LONGPATHS + +#include <ctype.h> +#include <direct.h> +#include <errno.h> +#include <fcntl.h> +#include <io.h> +#include <sys/stat.h> +#include <sys/types.h> +#include <wctype.h> +#include <windows.h> + +#include <google/protobuf/stubs/io_win32.h> +#include <google/protobuf/stubs/scoped_ptr.h> + +#include <memory> +#include <sstream> +#include <string> +#include <vector> + +namespace google { +namespace protobuf { +namespace internal { +namespace win32 { +namespace { + +using std::string; +using std::wstring; + +template <typename char_type> +struct CharTraits { + static bool is_alpha(char_type ch); +}; + +template <> +struct CharTraits<char> { + static bool is_alpha(char ch) { return isalpha(ch); } +}; + +template <> +struct CharTraits<wchar_t> { + static bool is_alpha(wchar_t ch) { return iswalpha(ch); } +}; + +template <typename char_type> +bool null_or_empty(const char_type* s) { + return s == NULL || *s == 0; +} + +// Returns true if the path starts with a drive letter, e.g. "c:". +// Note that this won't check for the "\" after the drive letter, so this also +// returns true for "c:foo" (which is "c:\${PWD}\foo"). +// This check requires that a path not have a longpath prefix ("\\?\"). +template <typename char_type> +bool has_drive_letter(const char_type* ch) { + return CharTraits<char_type>::is_alpha(ch[0]) && ch[1] == ':'; +} + +// Returns true if the path starts with a longpath prefix ("\\?\"). +template <typename char_type> +bool has_longpath_prefix(const char_type* path) { + return path[0] == '\\' && path[1] == '\\' && path[2] == '?' && + path[3] == '\\'; +} + +template <typename char_type> +bool is_separator(char_type c) { + return c == '/' || c == '\\'; +} + +// Returns true if the path starts with a drive specifier (e.g. "c:\"). +template <typename char_type> +bool is_path_absolute(const char_type* path) { + return has_drive_letter(path) && is_separator(path[2]); +} + +template <typename char_type> +bool is_drive_relative(const char_type* path) { + return has_drive_letter(path) && (path[2] == 0 || !is_separator(path[2])); +} + +wstring join_paths(const wstring& path1, const wstring& path2) { + if (path1.empty() || is_path_absolute(path2.c_str()) || + has_longpath_prefix(path2.c_str())) { + return path2; + } + if (path2.empty()) { + return path1; + } + + if (is_separator(path1[path1.size() - 1])) { + return is_separator(path2[0]) ? (path1 + path2.substr(1)) + : (path1 + path2); + } else { + return is_separator(path2[0]) ? (path1 + path2) + : (path1 + L'\\' + path2); + } +} + +wstring normalize(wstring path) { + if (has_longpath_prefix(path.c_str())) { + path = path.substr(4); + } + + static const wstring dot(L"."); + static const wstring dotdot(L".."); + const WCHAR* p = path.c_str(); + + std::vector<wstring> segments; + int segment_start = -1; + // Find the path segments in `path` (separated by "/"). + for (int i = 0;; ++i) { + if (!is_separator(p[i]) && p[i] != L'\0') { + // The current character does not end a segment, so start one unless it's + // already started. + if (segment_start < 0) { + segment_start = i; + } + } else if (segment_start >= 0 && i > segment_start) { + // The current character is "/" or "\0", so this ends a segment. + // Add that to `segments` if there's anything to add; handle "." and "..". + wstring segment(p, segment_start, i - segment_start); + segment_start = -1; + if (segment == dotdot) { + if (!segments.empty() && + (!has_drive_letter(segments[0].c_str()) || segments.size() > 1)) { + segments.pop_back(); + } + } else if (segment != dot && !segment.empty()) { + segments.push_back(segment); + } + } + if (p[i] == L'\0') { + break; + } + } + + // Handle the case when `path` is just a drive specifier (or some degenerate + // form of it, e.g. "c:\.."). + if (segments.size() == 1 && segments[0].size() == 2 && + has_drive_letter(segments[0].c_str())) { + return segments[0] + L'\\'; + } + + // Join all segments. + bool first = true; + std::wstringstream result; + for (int i = 0; i < segments.size(); ++i) { + if (!first) { + result << L'\\'; + } + first = false; + result << segments[i]; + } + // Preserve trailing separator if the input contained it. + if (!path.empty() && is_separator(p[path.size() - 1])) { + result << L'\\'; + } + return result.str(); +} + +bool as_windows_path(const char* path, wstring* result) { + if (null_or_empty(path)) { + result->clear(); + return true; + } + wstring wpath; + if (!strings::utf8_to_wcs(path, &wpath)) { + return false; + } + if (has_longpath_prefix(wpath.c_str())) { + *result = wpath; + return true; + } + if (is_separator(path[0]) || is_drive_relative(path)) { + return false; + } + + + if (!is_path_absolute(wpath.c_str())) { + int size = ::GetCurrentDirectoryW(0, NULL); + if (size == 0 && GetLastError() != ERROR_INSUFFICIENT_BUFFER) { + return false; + } + scoped_array<WCHAR> wcwd(new WCHAR[size]); + ::GetCurrentDirectoryW(size, wcwd.get()); + wpath = join_paths(wcwd.get(), wpath); + } + wpath = normalize(wpath); + if (!has_longpath_prefix(wpath.c_str())) { + // Add the "\\?\" prefix unconditionally. This way we prevent the Win32 API + // from processing the path and "helpfully" removing trailing dots from the + // path, for example. + // See https://github.com/bazelbuild/bazel/issues/2935 + wpath = wstring(L"\\\\?\\") + wpath; + } + *result = wpath; + return true; +} + +} // namespace + +int open(const char* path, int flags, int mode) { +#ifdef SUPPORT_LONGPATHS + wstring wpath; + if (!as_windows_path(path, &wpath)) { + errno = ENOENT; + return -1; + } + return ::_wopen(wpath.c_str(), flags, mode); +#else + return ::_open(path, flags, mode); +#endif +} + +int mkdir(const char* path, int _mode) { +#ifdef SUPPORT_LONGPATHS + wstring wpath; + if (!as_windows_path(path, &wpath)) { + errno = ENOENT; + return -1; + } + return ::_wmkdir(wpath.c_str()); +#else // not SUPPORT_LONGPATHS + return ::_mkdir(path); +#endif // not SUPPORT_LONGPATHS +} + +int access(const char* path, int mode) { +#ifdef SUPPORT_LONGPATHS + wstring wpath; + if (!as_windows_path(path, &wpath)) { + errno = ENOENT; + return -1; + } + return ::_waccess(wpath.c_str(), mode); +#else + return ::_access(path, mode); +#endif +} + +int chdir(const char* path) { +#ifdef SUPPORT_LONGPATHS + wstring wpath; + if (!as_windows_path(path, &wpath)) { + errno = ENOENT; + return -1; + } + return ::_wchdir(wpath.c_str()); +#else + return ::_chdir(path); +#endif +} + +int stat(const char* path, struct _stat* buffer) { +#ifdef SUPPORT_LONGPATHS + wstring wpath; + if (!as_windows_path(path, &wpath)) { + errno = ENOENT; + return -1; + } + return ::_wstat(wpath.c_str(), buffer); +#else // not SUPPORT_LONGPATHS + return ::_stat(path, buffer); +#endif // not SUPPORT_LONGPATHS +} + +FILE* fopen(const char* path, const char* mode) { +#ifdef SUPPORT_LONGPATHS + if (null_or_empty(path)) { + errno = EINVAL; + return NULL; + } + wstring wpath; + if (!as_windows_path(path, &wpath)) { + errno = ENOENT; + return NULL; + } + wstring wmode; + if (!strings::utf8_to_wcs(mode, &wmode)) { + errno = EINVAL; + return NULL; + } + return ::_wfopen(wpath.c_str(), wmode.c_str()); +#else + return ::fopen(path, mode); +#endif +} + +int close(int fd) { return ::close(fd); } + +int dup(int fd) { return ::_dup(fd); } + +int dup2(int fd1, int fd2) { return ::_dup2(fd1, fd2); } + +int read(int fd, void* buffer, size_t size) { + return ::_read(fd, buffer, size); +} + +int setmode(int fd, int mode) { return ::_setmode(fd, mode); } + +int write(int fd, const void* buffer, size_t size) { + return ::_write(fd, buffer, size); +} + +wstring testonly_utf8_to_winpath(const char* path) { + wstring wpath; + return as_windows_path(path, &wpath) ? wpath : wstring(); +} + +namespace strings { + +bool wcs_to_mbs(const WCHAR* s, string* out, bool outUtf8) { + if (null_or_empty(s)) { + out->clear(); + return true; + } + BOOL usedDefaultChar = FALSE; + SetLastError(0); + int size = WideCharToMultiByte( + outUtf8 ? CP_UTF8 : CP_ACP, 0, s, -1, NULL, 0, NULL, + outUtf8 ? NULL : &usedDefaultChar); + if ((size == 0 && GetLastError() != ERROR_INSUFFICIENT_BUFFER) + || usedDefaultChar) { + return false; + } + scoped_array<CHAR> astr(new CHAR[size]); + WideCharToMultiByte( + outUtf8 ? CP_UTF8 : CP_ACP, 0, s, -1, astr.get(), size, NULL, NULL); + out->assign(astr.get()); + return true; +} + +bool mbs_to_wcs(const char* s, wstring* out, bool inUtf8) { + if (null_or_empty(s)) { + out->clear(); + return true; + } + + SetLastError(0); + int size = + MultiByteToWideChar(inUtf8 ? CP_UTF8 : CP_ACP, 0, s, -1, NULL, 0); + if (size == 0 && GetLastError() != ERROR_INSUFFICIENT_BUFFER) { + return false; + } + scoped_array<WCHAR> wstr(new WCHAR[size]); + MultiByteToWideChar( + inUtf8 ? CP_UTF8 : CP_ACP, 0, s, -1, wstr.get(), size + 1); + out->assign(wstr.get()); + return true; +} + +bool utf8_to_wcs(const char* input, wstring* out) { + return mbs_to_wcs(input, out, true); +} + +bool wcs_to_utf8(const wchar_t* input, string* out) { + return wcs_to_mbs(input, out, true); +} + +} // namespace strings +} // namespace win32 +} // namespace internal +} // namespace protobuf +} // namespace google + +#endif // defined(_WIN32) diff --git a/src/google/protobuf/stubs/io_win32.h b/src/google/protobuf/stubs/io_win32.h new file mode 100644 index 00000000..9e17d253 --- /dev/null +++ b/src/google/protobuf/stubs/io_win32.h @@ -0,0 +1,115 @@ +// 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. + +// Author: laszlocsomor@google.com (Laszlo Csomor) +// +// This file contains the declarations for Windows implementations of +// commonly used POSIX functions such as open(2) and access(2), as well +// as macro definitions for flags of these functions. +// +// By including this file you'll redefine open/access/etc. to +// ::google::protobuf::internal::win32::{open/access/etc.}. +// Make sure you don't include a header that attempts to redeclare or +// redefine these functions, that'll lead to confusing compilation +// errors. It's best to #include this file as the last one to ensure that. +// +// This file is only used on Windows, it's empty on other platforms. + +#ifndef GOOGLE_PROTOBUF_STUBS_IO_WIN32_H__ +#define GOOGLE_PROTOBUF_STUBS_IO_WIN32_H__ + +#if defined(_WIN32) + +#include <string> +#include <google/protobuf/stubs/port.h> + +// Compilers on Windows other than MSVC (e.g. Cygwin, MinGW32) define the +// following functions already, except for mkdir. +namespace google { +namespace protobuf { +namespace internal { +namespace win32 { + +LIBPROTOBUF_EXPORT FILE* fopen(const char* path, const char* mode); +LIBPROTOBUF_EXPORT int access(const char* path, int mode); +LIBPROTOBUF_EXPORT int chdir(const char* path); +LIBPROTOBUF_EXPORT int close(int fd); +LIBPROTOBUF_EXPORT int dup(int fd); +LIBPROTOBUF_EXPORT int dup2(int fd1, int fd2); +LIBPROTOBUF_EXPORT int mkdir(const char* path, int _mode); +LIBPROTOBUF_EXPORT int open(const char* path, int flags, int mode = 0); +LIBPROTOBUF_EXPORT int read(int fd, void* buffer, size_t size); +LIBPROTOBUF_EXPORT int setmode(int fd, int mode); +LIBPROTOBUF_EXPORT int stat(const char* path, struct _stat* buffer); +LIBPROTOBUF_EXPORT int write(int fd, const void* buffer, size_t size); +LIBPROTOBUF_EXPORT std::wstring testonly_utf8_to_winpath(const char* path); + +namespace strings { + +// Convert from UTF-16 to Active-Code-Page-encoded or to UTF-8-encoded text. +LIBPROTOBUF_EXPORT bool wcs_to_mbs( + const wchar_t* s, std::string* out, bool outUtf8); + +// Convert from Active-Code-Page-encoded or UTF-8-encoded text to UTF-16. +LIBPROTOBUF_EXPORT bool mbs_to_wcs( + const char* s, std::wstring* out, bool inUtf8); + +// Convert from UTF-8-encoded text to UTF-16. +LIBPROTOBUF_EXPORT bool utf8_to_wcs(const char* input, std::wstring* out); + +// Convert from UTF-16-encoded text to UTF-8. +LIBPROTOBUF_EXPORT bool wcs_to_utf8(const wchar_t* input, std::string* out); + +} // namespace strings + +} // namespace win32 +} // namespace internal +} // namespace protobuf +} // namespace google + +#ifndef W_OK +#define W_OK 02 // not defined by MSVC for whatever reason +#endif + +#ifndef F_OK +#define F_OK 00 // not defined by MSVC for whatever reason +#endif + +#ifndef STDIN_FILENO +#define STDIN_FILENO 0 +#endif + +#ifndef STDOUT_FILENO +#define STDOUT_FILENO 1 +#endif + +#endif // defined(_WIN32) + +#endif // GOOGLE_PROTOBUF_STUBS_IO_WIN32_H__ diff --git a/src/google/protobuf/stubs/io_win32_unittest.cc b/src/google/protobuf/stubs/io_win32_unittest.cc new file mode 100644 index 00000000..b216aece --- /dev/null +++ b/src/google/protobuf/stubs/io_win32_unittest.cc @@ -0,0 +1,453 @@ +// 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. + +// Author: laszlocsomor@google.com (Laszlo Csomor) +// +// Unit tests for long-path-aware open/mkdir/access/etc. on Windows, as well as +// for the supporting utility functions. +// +// This file is only used on Windows, it's empty on other platforms. + +#if defined(_WIN32) + +#define WIN32_LEAN_AND_MEAN +#include <errno.h> +#include <fcntl.h> +#include <stdlib.h> +#include <string.h> +#include <sys/stat.h> +#include <sys/types.h> +#include <wchar.h> +#include <windows.h> + +#include <google/protobuf/stubs/io_win32.h> +#include <google/protobuf/stubs/scoped_ptr.h> +#include <gtest/gtest.h> + +#include <memory> +#include <sstream> +#include <string> + +namespace google { +namespace protobuf { +namespace internal { +namespace win32 { +namespace { + +const char kUtf8Text[] = { + 'h', 'i', ' ', + // utf-8: 11010000 10011111, utf-16: 100 0001 1111 = 0x041F + 0xd0, 0x9f, + // utf-8: 11010001 10000000, utf-16: 100 0100 0000 = 0x0440 + 0xd1, 0x80, + // utf-8: 11010000 10111000, utf-16: 100 0011 1000 = 0x0438 + 0xd0, 0xb8, + // utf-8: 11010000 10110010, utf-16: 100 0011 0010 = 0x0432 + 0xd0, 0xb2, + // utf-8: 11010000 10110101, utf-16: 100 0011 0101 = 0x0435 + 0xd0, 0xb5, + // utf-8: 11010001 10000010, utf-16: 100 0100 0010 = 0x0442 + 0xd1, 0x82, 0 +}; + +const wchar_t kUtf16Text[] = { + L'h', L'i', L' ', + L'\x41f', L'\x440', L'\x438', L'\x432', L'\x435', L'\x442', 0 +}; + +using std::string; +using std::wstring; + +class IoWin32Test : public ::testing::Test { + public: + void SetUp(); + void TearDown(); + + protected: + bool CreateAllUnder(wstring path); + bool DeleteAllUnder(wstring path); + + WCHAR working_directory[MAX_PATH]; + string test_tmpdir; + wstring wtest_tmpdir; +}; + +#define ASSERT_INITIALIZED \ + { \ + EXPECT_FALSE(test_tmpdir.empty()); \ + EXPECT_FALSE(wtest_tmpdir.empty()); \ + } + +namespace { +void StripTrailingSlashes(string* str) { + int i = str->size() - 1; + for (; i >= 0 && ((*str)[i] == '/' || (*str)[i] == '\\'); --i) {} + str->resize(i+1); +} + +bool GetEnvVarAsUtf8(const WCHAR* name, string* result) { + DWORD size = ::GetEnvironmentVariableW(name, NULL, 0); + if (size > 0 && GetLastError() != ERROR_ENVVAR_NOT_FOUND) { + scoped_array<WCHAR> wcs(new WCHAR[size]); + ::GetEnvironmentVariableW(name, wcs.get(), size); + // GetEnvironmentVariableA retrieves an Active-Code-Page-encoded text which + // we'd first need to convert to UTF-16 then to UTF-8, because there seems + // to be no API function to do that conversion directly. + // GetEnvironmentVariableW retrieves an UTF-16-encoded text, which we need + // to convert to UTF-8. + return strings::wcs_to_utf8(wcs.get(), result); + } else { + return false; + } +} + +bool GetCwdAsUtf8(string* result) { + DWORD size = ::GetCurrentDirectoryW(0, NULL); + if (size > 0) { + scoped_array<WCHAR> wcs(new WCHAR[size]); + ::GetCurrentDirectoryW(size, wcs.get()); + // GetCurrentDirectoryA retrieves an Active-Code-Page-encoded text which + // we'd first need to convert to UTF-16 then to UTF-8, because there seems + // to be no API function to do that conversion directly. + // GetCurrentDirectoryW retrieves an UTF-16-encoded text, which we need + // to convert to UTF-8. + return strings::wcs_to_utf8(wcs.get(), result); + } else { + return false; + } +} + +} // namespace + +void IoWin32Test::SetUp() { + test_tmpdir.clear(); + wtest_tmpdir.clear(); + EXPECT_GT(::GetCurrentDirectoryW(MAX_PATH, working_directory), 0); + + string tmp; + bool ok = false; + if (!ok) { + // Bazel sets this environment variable when it runs tests. + ok = GetEnvVarAsUtf8(L"TEST_TMPDIR", &tmp); + } + if (!ok) { + // Bazel 0.8.0 sets this environment for every build and test action. + ok = GetEnvVarAsUtf8(L"TEMP", &tmp); + } + if (!ok) { + // Bazel 0.8.0 sets this environment for every build and test action. + ok = GetEnvVarAsUtf8(L"TMP", &tmp); + } + if (!ok) { + // Fall back to using the current directory. + ok = GetCwdAsUtf8(&tmp); + } + if (!ok || tmp.empty()) { + FAIL() << "Cannot find a temp directory."; + } + + StripTrailingSlashes(&tmp); + std::stringstream result; + // Deleting files and directories is asynchronous on Windows, and if TearDown + // just deleted the previous temp directory, sometimes we cannot recreate the + // same directory. + // Use a counter so every test method gets its own temp directory. + static unsigned int counter = 0; + result << tmp << "\\w32tst" << counter++ << ".tmp"; + test_tmpdir = result.str(); + wtest_tmpdir = testonly_utf8_to_winpath(test_tmpdir.c_str()); + ASSERT_FALSE(wtest_tmpdir.empty()); + ASSERT_TRUE(DeleteAllUnder(wtest_tmpdir)); + ASSERT_TRUE(CreateAllUnder(wtest_tmpdir)); +} + +void IoWin32Test::TearDown() { + if (!wtest_tmpdir.empty()) { + DeleteAllUnder(wtest_tmpdir); + } + ::SetCurrentDirectoryW(working_directory); +} + +bool IoWin32Test::CreateAllUnder(wstring path) { + // Prepend UNC prefix if the path doesn't have it already. Don't bother + // checking if the path is shorter than MAX_PATH, let's just do it + // unconditionally. + if (path.find(L"\\\\?\\") != 0) { + path = wstring(L"\\\\?\\") + path; + } + if (::CreateDirectoryW(path.c_str(), NULL) || + GetLastError() == ERROR_ALREADY_EXISTS || + GetLastError() == ERROR_ACCESS_DENIED) { + return true; + } + if (GetLastError() == ERROR_PATH_NOT_FOUND) { + size_t pos = path.find_last_of(L'\\'); + if (pos != wstring::npos) { + wstring parent(path, 0, pos); + if (CreateAllUnder(parent) && CreateDirectoryW(path.c_str(), NULL)) { + return true; + } + } + } + return false; +} + +bool IoWin32Test::DeleteAllUnder(wstring path) { + static const wstring kDot(L"."); + static const wstring kDotDot(L".."); + + // Prepend UNC prefix if the path doesn't have it already. Don't bother + // checking if the path is shorter than MAX_PATH, let's just do it + // unconditionally. + if (path.find(L"\\\\?\\") != 0) { + path = wstring(L"\\\\?\\") + path; + } + // Append "\" if necessary. + if (path[path.size() - 1] != L'\\') { + path.push_back(L'\\'); + } + + WIN32_FIND_DATAW metadata; + HANDLE handle = ::FindFirstFileW((path + L"*").c_str(), &metadata); + if (handle == INVALID_HANDLE_VALUE) { + return true; // directory doesn't exist + } + + bool result = true; + do { + wstring childname = metadata.cFileName; + if (kDot != childname && kDotDot != childname) { + wstring childpath = path + childname; + if ((metadata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0) { + // If this is not a junction, delete its contents recursively. + // Finally delete this directory/junction too. + if (((metadata.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) == 0 && + !DeleteAllUnder(childpath)) || + !::RemoveDirectoryW(childpath.c_str())) { + result = false; + break; + } + } else { + if (!::DeleteFileW(childpath.c_str())) { + result = false; + break; + } + } + } + } while (::FindNextFileW(handle, &metadata)); + ::FindClose(handle); + return result; +} + +TEST_F(IoWin32Test, AccessTest) { + ASSERT_INITIALIZED; + + string path = test_tmpdir; + while (path.size() < MAX_PATH - 30) { + path += "\\accesstest"; + EXPECT_EQ(mkdir(path.c_str(), 0644), 0); + } + string file = path + "\\file.txt"; + int fd = open(file.c_str(), O_CREAT | O_WRONLY, 0644); + if (fd > 0) { + EXPECT_EQ(close(fd), 0); + } else { + EXPECT_TRUE(false); + } + + EXPECT_EQ(access(test_tmpdir.c_str(), F_OK), 0); + EXPECT_EQ(access(path.c_str(), F_OK), 0); + EXPECT_EQ(access(path.c_str(), W_OK), 0); + EXPECT_EQ(access(file.c_str(), F_OK | W_OK), 0); + EXPECT_NE(access((file + ".blah").c_str(), F_OK), 0); + EXPECT_NE(access((file + ".blah").c_str(), W_OK), 0); + + EXPECT_EQ(access(".", F_OK), 0); + EXPECT_EQ(access(".", W_OK), 0); + EXPECT_EQ(access((test_tmpdir + "/accesstest").c_str(), F_OK | W_OK), 0); + ASSERT_EQ(access((test_tmpdir + "/./normalize_me/.././accesstest").c_str(), + F_OK | W_OK), + 0); + EXPECT_NE(access("io_win32_unittest.AccessTest.nonexistent", F_OK), 0); + EXPECT_NE(access("io_win32_unittest.AccessTest.nonexistent", W_OK), 0); + + ASSERT_EQ(access("c:bad", F_OK), -1); + ASSERT_EQ(errno, ENOENT); + ASSERT_EQ(access("/tmp/bad", F_OK), -1); + ASSERT_EQ(errno, ENOENT); + ASSERT_EQ(access("\\bad", F_OK), -1); + ASSERT_EQ(errno, ENOENT); +} + +TEST_F(IoWin32Test, OpenTest) { + ASSERT_INITIALIZED; + + string path = test_tmpdir; + while (path.size() < MAX_PATH) { + path += "\\opentest"; + EXPECT_EQ(mkdir(path.c_str(), 0644), 0); + } + string file = path + "\\file.txt"; + int fd = open(file.c_str(), O_CREAT | O_WRONLY, 0644); + if (fd > 0) { + EXPECT_EQ(write(fd, "hello", 5), 5); + EXPECT_EQ(close(fd), 0); + } else { + EXPECT_TRUE(false); + } + + ASSERT_EQ(open("c:bad.txt", O_CREAT | O_WRONLY, 0644), -1); + ASSERT_EQ(errno, ENOENT); + ASSERT_EQ(open("/tmp/bad.txt", O_CREAT | O_WRONLY, 0644), -1); + ASSERT_EQ(errno, ENOENT); + ASSERT_EQ(open("\\bad.txt", O_CREAT | O_WRONLY, 0644), -1); + ASSERT_EQ(errno, ENOENT); +} + +TEST_F(IoWin32Test, MkdirTest) { + ASSERT_INITIALIZED; + + string path = test_tmpdir; + do { + path += "\\mkdirtest"; + ASSERT_EQ(mkdir(path.c_str(), 0644), 0); + } while (path.size() <= MAX_PATH); + + ASSERT_EQ(mkdir("c:bad", 0644), -1); + ASSERT_EQ(errno, ENOENT); + ASSERT_EQ(mkdir("/tmp/bad", 0644), -1); + ASSERT_EQ(errno, ENOENT); + ASSERT_EQ(mkdir("\\bad", 0644), -1); + ASSERT_EQ(errno, ENOENT); +} + +TEST_F(IoWin32Test, MkdirTestNonAscii) { + ASSERT_INITIALIZED; + + // Create a non-ASCII path. + // Ensure that we can create the directory using SetCurrentDirectoryW. + EXPECT_TRUE(CreateDirectoryW((wtest_tmpdir + L"\\1").c_str(), NULL)); + EXPECT_TRUE(CreateDirectoryW((wtest_tmpdir + L"\\1\\" + kUtf16Text).c_str(), NULL)); + // Ensure that we can create a very similarly named directory using mkdir. + // We don't attemp to delete and recreate the same directory, because on + // Windows, deleting files and directories seems to be asynchronous. + EXPECT_EQ(mkdir((test_tmpdir + "\\2").c_str(), 0644), 0); + EXPECT_EQ(mkdir((test_tmpdir + "\\2\\" + kUtf8Text).c_str(), 0644), 0); +} + +TEST_F(IoWin32Test, ChdirTest) { + string path("C:\\"); + EXPECT_EQ(access(path.c_str(), F_OK), 0); + ASSERT_EQ(chdir(path.c_str()), 0); + + // Do not try to chdir into the test_tmpdir, it may already contain directory + // names with trailing dots. + // Instead test here with an obviously dot-trailed path. If the win32_chdir + // function would not convert the path to absolute and prefix with "\\?\" then + // the Win32 API would ignore the trailing dot, but because of the prefixing + // there'll be no path processing done, so we'll actually attempt to chdir + // into "C:\some\path\foo." + path = test_tmpdir + "/foo."; + EXPECT_EQ(mkdir(path.c_str(), 644), 0); + EXPECT_EQ(access(path.c_str(), F_OK), 0); + ASSERT_NE(chdir(path.c_str()), 0); +} + +TEST_F(IoWin32Test, ChdirTestNonAscii) { + ASSERT_INITIALIZED; + + // Create a directory with a non-ASCII path and ensure we can cd into it. + wstring wNonAscii(wtest_tmpdir + L"\\" + kUtf16Text); + string nonAscii; + EXPECT_TRUE(strings::wcs_to_utf8(wNonAscii.c_str(), &nonAscii)); + EXPECT_TRUE(CreateDirectoryW(wNonAscii.c_str(), NULL)); + WCHAR cwd[MAX_PATH]; + EXPECT_TRUE(GetCurrentDirectoryW(MAX_PATH, cwd)); + // Ensure that we can cd into the path using SetCurrentDirectoryW. + EXPECT_TRUE(SetCurrentDirectoryW(wNonAscii.c_str())); + EXPECT_TRUE(SetCurrentDirectoryW(cwd)); + // Ensure that we can cd into the path using chdir. + ASSERT_EQ(chdir(nonAscii.c_str()), 0); + // Ensure that the GetCurrentDirectoryW returns the desired path. + EXPECT_TRUE(GetCurrentDirectoryW(MAX_PATH, cwd)); + ASSERT_EQ(wNonAscii, cwd); +} + +TEST_F(IoWin32Test, AsWindowsPathTest) { + DWORD size = GetCurrentDirectoryW(0, NULL); + scoped_array<wchar_t> cwd_str(new wchar_t[size]); + EXPECT_GT(GetCurrentDirectoryW(size, cwd_str.get()), 0); + wstring cwd = wstring(L"\\\\?\\") + cwd_str.get(); + + ASSERT_EQ(testonly_utf8_to_winpath("relative_mkdirtest"), + cwd + L"\\relative_mkdirtest"); + ASSERT_EQ(testonly_utf8_to_winpath("preserve//\\trailing///"), + cwd + L"\\preserve\\trailing\\"); + ASSERT_EQ(testonly_utf8_to_winpath("./normalize_me\\/../blah"), + cwd + L"\\blah"); + std::ostringstream relpath; + for (wchar_t* p = cwd_str.get(); *p; ++p) { + if (*p == '/' || *p == '\\') { + relpath << "../"; + } + } + relpath << ".\\/../\\./beyond-toplevel"; + ASSERT_EQ(testonly_utf8_to_winpath(relpath.str().c_str()), + wstring(L"\\\\?\\") + cwd_str.get()[0] + L":\\beyond-toplevel"); + + // Absolute unix paths lack drive letters, driveless absolute windows paths + // do too. Neither can be converted to a drive-specifying absolute Windows + // path. + ASSERT_EQ(testonly_utf8_to_winpath("/absolute/unix/path"), L""); + // Though valid on Windows, we also don't support UNC paths (\\UNC\\blah). + ASSERT_EQ(testonly_utf8_to_winpath("\\driveless\\absolute"), L""); + // Though valid in cmd.exe, drive-relative paths are not supported. + ASSERT_EQ(testonly_utf8_to_winpath("c:foo"), L""); + ASSERT_EQ(testonly_utf8_to_winpath("c:/foo"), L"\\\\?\\c:\\foo"); + ASSERT_EQ(testonly_utf8_to_winpath("\\\\?\\C:\\foo"), L"\\\\?\\C:\\foo"); +} + +TEST_F(IoWin32Test, Utf8Utf16ConversionTest) { + string mbs; + wstring wcs; + ASSERT_TRUE(strings::utf8_to_wcs(kUtf8Text, &wcs)); + ASSERT_TRUE(strings::wcs_to_utf8(kUtf16Text, &mbs)); + ASSERT_EQ(wcs, kUtf16Text); + ASSERT_EQ(mbs, kUtf8Text); +} + +} // namespace +} // namespace win32 +} // namespace internal +} // namespace protobuf +} // namespace google + +#endif // defined(_WIN32) + diff --git a/src/google/protobuf/stubs/map_util.h b/src/google/protobuf/stubs/map_util.h index 887f12a6..16cbfac4 100644 --- a/src/google/protobuf/stubs/map_util.h +++ b/src/google/protobuf/stubs/map_util.h @@ -708,7 +708,7 @@ void AppendKeysFromMap(const MapContainer& map_container, // without the complexity of a SFINAE-based solution.) template <class MapContainer, class KeyType> void AppendKeysFromMap(const MapContainer& map_container, - vector<KeyType>* key_container) { + std::vector<KeyType>* key_container) { GOOGLE_CHECK(key_container != NULL); // We now have the opportunity to call reserve(). Calling reserve() every // time is a bad idea for some use cases: libstdc++'s implementation of @@ -752,7 +752,7 @@ void AppendValuesFromMap(const MapContainer& map_container, // without the complexity of a SFINAE-based solution.) template <class MapContainer, class ValueType> void AppendValuesFromMap(const MapContainer& map_container, - vector<ValueType>* value_container) { + std::vector<ValueType>* value_container) { GOOGLE_CHECK(value_container != NULL); // See AppendKeysFromMap for why this is done. if (value_container->empty()) { diff --git a/src/google/protobuf/stubs/mathlimits.h b/src/google/protobuf/stubs/mathlimits.h index 275d9539..2391ac4c 100644 --- a/src/google/protobuf/stubs/mathlimits.h +++ b/src/google/protobuf/stubs/mathlimits.h @@ -43,18 +43,23 @@ #ifndef UTIL_MATH_MATHLIMITS_H__ #define UTIL_MATH_MATHLIMITS_H__ -// GCC 4.9 has a bug that makes it impossible to use isinf and isnan when both -// <math.h> and <cmath> get pulled into the same translation unit. -// Unfortunately it is difficult to prevent this from happening, so to work -// around the problem we use std::isinf and std::isnan from <cmath> for C++11 -// builds and otherwise use the plain isinf and isnan functions from <math.h>. // Note that for Windows we do something different because it does not support // the plain isinf and isnan. #if __cplusplus >= 201103L +// GCC 4.9 has a bug that makes isinf and isnan ambigious when both <math.h> +// and <cmath> get pulled into the same translation unit. We use the ones in +// std:: namespace explicitly for C++11 #include <cmath> +#define GOOGLE_PROTOBUF_USE_STD_CMATH +#elif _GLIBCXX_USE_C99_MATH && !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC +// libstdc++ <cmath> header undefines the global macros and put functions in +// std:: namespace even before C++11. Use the ones in std:: instead too. +#include <cmath> +#define GOOGLE_PROTOBUF_USE_STD_CMATH #else #include <math.h> #endif + #include <string.h> #include <cfloat> @@ -229,7 +234,7 @@ DECL_UNSIGNED_INT_LIMITS(unsigned long long int) // For non-Windows builds we use the std:: versions of isinf and isnan if they // are available; see the comment about <cmath> at the top of this file for the // details on why we need to do this. -#if __cplusplus >= 201103L +#ifdef GOOGLE_PROTOBUF_USE_STD_CMATH #define ISINF std::isinf #define ISNAN std::isnan #else diff --git a/src/google/protobuf/stubs/mutex.h b/src/google/protobuf/stubs/mutex.h index 7ef1cb69..174290f6 100644 --- a/src/google/protobuf/stubs/mutex.h +++ b/src/google/protobuf/stubs/mutex.h @@ -70,14 +70,6 @@ class LIBPROTOBUF_EXPORT Mutex { GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Mutex); }; -// Undefine the macros to workaround the conflicts with Google internal -// MutexLock implementation. -// TODO(liujisi): Remove the undef once internal macros are removed. -#undef MutexLock -#undef ReaderMutexLock -#undef WriterMutexLock -#undef MutexLockMaybe - // MutexLock(mu) acquires mu when constructed and releases it when destroyed. class LIBPROTOBUF_EXPORT MutexLock { public: diff --git a/src/google/protobuf/stubs/platform_macros.h b/src/google/protobuf/stubs/platform_macros.h index 7a54060d..c3a64dd2 100644 --- a/src/google/protobuf/stubs/platform_macros.h +++ b/src/google/protobuf/stubs/platform_macros.h @@ -50,6 +50,9 @@ #elif defined(_M_ARM) || defined(__ARMEL__) #define GOOGLE_PROTOBUF_ARCH_ARM 1 #define GOOGLE_PROTOBUF_ARCH_32_BIT 1 +#elif defined(_M_ARM64) +#define GOOGLE_PROTOBUF_ARCH_ARM 1 +#define GOOGLE_PROTOBUF_ARCH_64_BIT 1 #elif defined(__aarch64__) #define GOOGLE_PROTOBUF_ARCH_AARCH64 1 #define GOOGLE_PROTOBUF_ARCH_64_BIT 1 diff --git a/src/google/protobuf/stubs/port.h b/src/google/protobuf/stubs/port.h index 0afd55d7..27849298 100644 --- a/src/google/protobuf/stubs/port.h +++ b/src/google/protobuf/stubs/port.h @@ -97,6 +97,8 @@ #include <byteswap.h> // IWYU pragma: export #endif +#define PROTOBUF_RUNTIME_DEPRECATED(message) + // =================================================================== // from google3/base/port.h @@ -108,6 +110,18 @@ #define LANG_CXX11 1 #endif +#if LANG_CXX11 && !defined(__NVCC__) +#define PROTOBUF_CXX11 1 +#else +#define PROTOBUF_CXX11 0 +#endif + +#if PROTOBUF_CXX11 +#define PROTOBUF_FINAL final +#else +#define PROTOBUF_FINAL +#endif + namespace google { namespace protobuf { @@ -177,6 +191,8 @@ static const uint64 kuint64max = GOOGLE_ULONGLONG(0xFFFFFFFFFFFFFFFF); #endif #endif +#define GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE GOOGLE_ATTRIBUTE_ALWAYS_INLINE + #ifndef GOOGLE_ATTRIBUTE_NOINLINE #if defined(__GNUC__) && (__GNUC__ > 3 ||(__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) // For functions we want to force not inline. @@ -191,23 +207,7 @@ static const uint64 kuint64max = GOOGLE_ULONGLONG(0xFFFFFFFFFFFFFFFF); #endif #endif -#ifndef GOOGLE_ATTRIBUTE_NORETURN -#ifdef __GNUC__ -// Tell the compiler that a given function never returns. -#define GOOGLE_ATTRIBUTE_NORETURN __attribute__((noreturn)) -#else -#define GOOGLE_ATTRIBUTE_NORETURN -#endif -#endif - -#ifndef GOOGLE_ATTRIBUTE_DEPRECATED -#ifdef __GNUC__ -// If the method/variable/type is used anywhere, produce a warning. -#define GOOGLE_ATTRIBUTE_DEPRECATED __attribute__((deprecated)) -#else -#define GOOGLE_ATTRIBUTE_DEPRECATED -#endif -#endif +#define GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE GOOGLE_ATTRIBUTE_NOINLINE #ifndef GOOGLE_PREDICT_TRUE #ifdef __GNUC__ @@ -237,30 +237,62 @@ static const uint64 kuint64max = GOOGLE_ULONGLONG(0xFFFFFFFFFFFFFFFF); #define GOOGLE_SAFE_CONCURRENT_WRITES_END() #endif -#if defined(__clang__) && defined(__has_cpp_attribute) \ - && !defined(GOOGLE_PROTOBUF_OS_APPLE) -# if defined(GOOGLE_PROTOBUF_OS_NACL) || defined(EMSCRIPTEN) || \ - __has_cpp_attribute(clang::fallthrough) -# define GOOGLE_FALLTHROUGH_INTENDED [[clang::fallthrough]] -# endif -#endif - -#ifndef GOOGLE_FALLTHROUGH_INTENDED -# define GOOGLE_FALLTHROUGH_INTENDED -#endif - #define GOOGLE_GUARDED_BY(x) #define GOOGLE_ATTRIBUTE_COLD #ifdef GOOGLE_PROTOBUF_DONT_USE_UNALIGNED # define GOOGLE_PROTOBUF_USE_UNALIGNED 0 #else -// x86 and x86-64 can perform unaligned loads/stores directly. -# define GOOGLE_PROTOBUF_USE_UNALIGNED defined(_M_X64) || \ - defined(__x86_64__) || defined(_M_IX86) || defined(__i386__) +# if defined(_M_X64) || defined(__x86_64__) || defined(_M_IX86) || defined(__i386__) +# define GOOGLE_PROTOBUF_USE_UNALIGNED 1 +# else +# define GOOGLE_PROTOBUF_USE_UNALIGNED 0 +# endif #endif -#if GOOGLE_PROTOBUF_USE_UNALIGNED +#define GOOGLE_PROTOBUF_ATTRIBUTE_COLD GOOGLE_ATTRIBUTE_COLD + +#if defined(ADDRESS_SANITIZER) || defined(THREAD_SANITIZER) ||\ + defined(MEMORY_SANITIZER) + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus +uint16_t __sanitizer_unaligned_load16(const void *p); +uint32_t __sanitizer_unaligned_load32(const void *p); +uint64_t __sanitizer_unaligned_load64(const void *p); +void __sanitizer_unaligned_store16(void *p, uint16_t v); +void __sanitizer_unaligned_store32(void *p, uint32_t v); +void __sanitizer_unaligned_store64(void *p, uint64_t v); +#ifdef __cplusplus +} // extern "C" +#endif // __cplusplus + +inline uint16 GOOGLE_UNALIGNED_LOAD16(const void *p) { + return __sanitizer_unaligned_load16(p); +} + +inline uint32 GOOGLE_UNALIGNED_LOAD32(const void *p) { + return __sanitizer_unaligned_load32(p); +} + +inline uint64 GOOGLE_UNALIGNED_LOAD64(const void *p) { + return __sanitizer_unaligned_load64(p); +} + +inline void GOOGLE_UNALIGNED_STORE16(void *p, uint16 v) { + __sanitizer_unaligned_store16(p, v); +} + +inline void GOOGLE_UNALIGNED_STORE32(void *p, uint32 v) { + __sanitizer_unaligned_store32(p, v); +} + +inline void GOOGLE_UNALIGNED_STORE64(void *p, uint64 v) { + __sanitizer_unaligned_store64(p, v); +} + +#elif GOOGLE_PROTOBUF_USE_UNALIGNED #define GOOGLE_UNALIGNED_LOAD16(_p) (*reinterpret_cast<const uint16 *>(_p)) #define GOOGLE_UNALIGNED_LOAD32(_p) (*reinterpret_cast<const uint32 *>(_p)) @@ -302,6 +334,13 @@ inline void GOOGLE_UNALIGNED_STORE64(void *p, uint64 v) { } #endif +#if defined(GOOGLE_PROTOBUF_OS_NACL) \ + || (defined(__ANDROID__) && defined(__clang__) \ + && (__clang_major__ == 3 && __clang_minor__ == 8) \ + && (__clang_patchlevel__ < 275480)) +# define GOOGLE_PROTOBUF_USE_PORTABLE_LOG2 +#endif + #if defined(_MSC_VER) #define GOOGLE_THREAD_LOCAL __declspec(thread) #else @@ -354,7 +393,7 @@ class Bits { public: static uint32 Log2FloorNonZero(uint32 n) { #if defined(__GNUC__) - return 31 ^ __builtin_clz(n); + return 31 ^ static_cast<uint32>(__builtin_clz(n)); #elif defined(COMPILER_MSVC) && defined(_M_IX86) _asm { bsr ebx, n @@ -367,13 +406,14 @@ class Bits { } static uint32 Log2FloorNonZero64(uint64 n) { - // arm-nacl-clang runs into an instruction-selection failure when it - // encounters __builtin_clzll: + // Older versions of clang run into an instruction-selection failure when + // it encounters __builtin_clzll: // https://bugs.chromium.org/p/nativeclient/issues/detail?id=4395 - // To work around this, when we build for NaCl we use the portable + // This includes arm-nacl-clang and clang in older Android NDK versions. + // To work around this, when we build with those we use the portable // implementation instead. -#if defined(__GNUC__) && !defined(GOOGLE_PROTOBUF_OS_NACL) - return 63 ^ __builtin_clzll(n); +#if defined(__GNUC__) && !defined(GOOGLE_PROTOBUF_USE_PORTABLE_LOG2) + return 63 ^ static_cast<uint32>(__builtin_clzll(n)); #else return Log2FloorNonZero64_Portable(n); #endif @@ -400,9 +440,9 @@ class Bits { const uint32 topbits = static_cast<uint32>(n >> 32); if (topbits == 0) { // Top bits are zero, so scan in bottom bits - return Log2FloorNonZero(static_cast<uint32>(n)); + return static_cast<int>(Log2FloorNonZero(static_cast<uint32>(n))); } else { - return 32 + Log2FloorNonZero(topbits); + return 32 + static_cast<int>(Log2FloorNonZero(topbits)); } } }; @@ -467,6 +507,12 @@ class BigEndian { } }; +#ifndef GOOGLE_ATTRIBUTE_SECTION_VARIABLE +#define GOOGLE_ATTRIBUTE_SECTION_VARIABLE(name) +#endif + +#define GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(name) + } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/stubs/status.cc b/src/google/protobuf/stubs/status.cc index dd1bd614..2bfbe0b4 100644 --- a/src/google/protobuf/stubs/status.cc +++ b/src/google/protobuf/stubs/status.cc @@ -124,7 +124,7 @@ string Status::ToString() const { } } -ostream& operator<<(ostream& os, const Status& x) { +std::ostream& operator<<(std::ostream& os, const Status& x) { os << x.ToString(); return os; } diff --git a/src/google/protobuf/stubs/status.h b/src/google/protobuf/stubs/status.h index 614ab994..c5d38f0b 100644 --- a/src/google/protobuf/stubs/status.h +++ b/src/google/protobuf/stubs/status.h @@ -106,7 +106,7 @@ class LIBPROTOBUF_EXPORT Status { }; // Prints a human-readable representation of 'x' to 'os'. -LIBPROTOBUF_EXPORT ostream& operator<<(ostream& os, const Status& x); +LIBPROTOBUF_EXPORT std::ostream& operator<<(std::ostream& os, const Status& x); #define EXPECT_OK(value) EXPECT_TRUE((value).ok()) diff --git a/src/google/protobuf/stubs/stringpiece.h b/src/google/protobuf/stubs/stringpiece.h index 8910688b..563ff75d 100644 --- a/src/google/protobuf/stubs/stringpiece.h +++ b/src/google/protobuf/stubs/stringpiece.h @@ -292,7 +292,7 @@ class LIBPROTOBUF_EXPORT StringPiece { int compare(StringPiece x) const { const stringpiece_ssize_type min_size = length_ < x.length_ ? length_ : x.length_; - int r = memcmp(ptr_, x.ptr_, min_size); + int r = memcmp(ptr_, x.ptr_, static_cast<size_t>(min_size)); if (r < 0) return -1; if (r > 0) return 1; if (length_ < x.length_) return -1; @@ -310,7 +310,7 @@ class LIBPROTOBUF_EXPORT StringPiece { // "as_string()" method defined here for existing code. string ToString() const { if (ptr_ == NULL) return string(); - return string(data(), size()); + return string(data(), static_cast<size_type>(size())); } operator string() const { @@ -321,12 +321,14 @@ class LIBPROTOBUF_EXPORT StringPiece { void AppendToString(string* target) const; bool starts_with(StringPiece x) const { - return (length_ >= x.length_) && (memcmp(ptr_, x.ptr_, x.length_) == 0); + return (length_ >= x.length_) && + (memcmp(ptr_, x.ptr_, static_cast<size_t>(x.length_)) == 0); } bool ends_with(StringPiece x) const { return ((length_ >= x.length_) && - (memcmp(ptr_ + (length_-x.length_), x.ptr_, x.length_) == 0)); + (memcmp(ptr_ + (length_-x.length_), x.ptr_, + static_cast<size_t>(x.length_)) == 0)); } // Checks whether StringPiece starts with x and if so advances the beginning @@ -398,7 +400,7 @@ inline bool operator==(StringPiece x, StringPiece y) { } return x.data() == y.data() || len <= 0 || - memcmp(x.data(), y.data(), len) == 0; + memcmp(x.data(), y.data(), static_cast<size_t>(len)) == 0; } inline bool operator!=(StringPiece x, StringPiece y) { @@ -408,7 +410,7 @@ inline bool operator!=(StringPiece x, StringPiece y) { inline bool operator<(StringPiece x, StringPiece y) { const stringpiece_ssize_type min_size = x.size() < y.size() ? x.size() : y.size(); - const int r = memcmp(x.data(), y.data(), min_size); + const int r = memcmp(x.data(), y.data(), static_cast<size_t>(min_size)); return (r < 0) || (r == 0 && x.size() < y.size()); } @@ -458,7 +460,9 @@ struct StringPiecePod { return size_; } - std::string ToString() const { return std::string(data_, size_); } + std::string ToString() const { + return std::string(data_, static_cast<size_t>(size_)); + } private: const char* data_; stringpiece_ssize_type size_; @@ -473,7 +477,7 @@ template<> struct hash<StringPiece> { size_t operator()(const StringPiece& s) const { size_t result = 0; for (const char *str = s.data(), *end = str + s.size(); str < end; str++) { - result = 5 * result + *str; + result = 5 * result + static_cast<size_t>(*str); } return result; } diff --git a/src/google/protobuf/stubs/stringprintf.cc b/src/google/protobuf/stubs/stringprintf.cc index 83fdfe45..d98b9b87 100644 --- a/src/google/protobuf/stubs/stringprintf.cc +++ b/src/google/protobuf/stubs/stringprintf.cc @@ -137,7 +137,7 @@ const int kStringPrintfVectorMaxArgs = 32; // and we can fix the problem or protect against an attack. static const char string_printf_empty_block[256] = { '\0' }; -string StringPrintfVector(const char* format, const vector<string>& v) { +string StringPrintfVector(const char* format, const std::vector<string>& v) { GOOGLE_CHECK_LE(v.size(), kStringPrintfVectorMaxArgs) << "StringPrintfVector currently only supports up to " << kStringPrintfVectorMaxArgs << " arguments. " diff --git a/src/google/protobuf/stubs/stringprintf.h b/src/google/protobuf/stubs/stringprintf.h index ab1ab558..7183ec6a 100644 --- a/src/google/protobuf/stubs/stringprintf.h +++ b/src/google/protobuf/stubs/stringprintf.h @@ -68,7 +68,7 @@ LIBPROTOBUF_EXPORT extern const int kStringPrintfVectorMaxArgs; // You can use this version when all your arguments are strings, but // you don't know how many arguments you'll have at compile time. // StringPrintfVector will LOG(FATAL) if v.size() > kStringPrintfVectorMaxArgs -LIBPROTOBUF_EXPORT extern string StringPrintfVector(const char* format, const vector<string>& v); +LIBPROTOBUF_EXPORT extern string StringPrintfVector(const char* format, const std::vector<string>& v); } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/stubs/structurally_valid.cc b/src/google/protobuf/stubs/structurally_valid.cc index d79a6ee4..b2239682 100644 --- a/src/google/protobuf/stubs/structurally_valid.cc +++ b/src/google/protobuf/stubs/structurally_valid.cc @@ -1,4 +1,33 @@ -// Copyright 2005-2008 Google Inc. All Rights Reserved. +// 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. + // Author: jrm@google.com (Jim Meehan) #include <google/protobuf/stubs/common.h> diff --git a/src/google/protobuf/stubs/structurally_valid_unittest.cc b/src/google/protobuf/stubs/structurally_valid_unittest.cc index 90888885..eec07a87 100644 --- a/src/google/protobuf/stubs/structurally_valid_unittest.cc +++ b/src/google/protobuf/stubs/structurally_valid_unittest.cc @@ -1,3 +1,33 @@ +// 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. + // Copyright 2008 Google Inc. All Rights Reserved. // Author: xpeng@google.com (Peter Peng) diff --git a/src/google/protobuf/stubs/strutil.cc b/src/google/protobuf/stubs/strutil.cc index 336894b5..28bcd3b2 100644 --- a/src/google/protobuf/stubs/strutil.cc +++ b/src/google/protobuf/stubs/strutil.cc @@ -226,8 +226,8 @@ void SplitStringToIteratorUsing(const string& full, void SplitStringUsing(const string& full, const char* delim, - vector<string>* result) { - std::back_insert_iterator< vector<string> > it(*result); + std::vector<string>* result) { + std::back_insert_iterator< std::vector<string> > it(*result); SplitStringToIteratorUsing(full, delim, it); } @@ -264,8 +264,8 @@ void SplitStringToIteratorAllowEmpty(const StringType& full, } void SplitStringAllowEmpty(const string& full, const char* delim, - vector<string>* result) { - std::back_insert_iterator<vector<string> > it(*result); + std::vector<string>* result) { + std::back_insert_iterator<std::vector<string> > it(*result); SplitStringToIteratorAllowEmpty(full, delim, 0, it); } @@ -303,7 +303,7 @@ static void JoinStringsIterator(const ITERATOR& start, } } -void JoinStrings(const vector<string>& components, +void JoinStrings(const std::vector<string>& components, const char* delim, string * result) { JoinStringsIterator(components.begin(), components.end(), delim, result); @@ -332,7 +332,7 @@ int UnescapeCEscapeSequences(const char* source, char* dest) { } int UnescapeCEscapeSequences(const char* source, char* dest, - vector<string> *errors) { + std::vector<string> *errors) { GOOGLE_DCHECK(errors == NULL) << "Error reporting not implemented."; char* d = dest; @@ -468,7 +468,7 @@ int UnescapeCEscapeString(const string& src, string* dest) { } int UnescapeCEscapeString(const string& src, string* dest, - vector<string> *errors) { + std::vector<string> *errors) { scoped_array<char> unescaped(new char[src.size() + 1]); int len = UnescapeCEscapeSequences(src.c_str(), unescaped.get(), errors); GOOGLE_CHECK(dest); @@ -1401,7 +1401,7 @@ char* FloatToBuffer(float value, char* buffer) { float parsed_value; if (!safe_strtof(buffer, &parsed_value) || parsed_value != value) { int snprintf_result = - snprintf(buffer, kFloatToBufferSize, "%.*g", FLT_DIG+2, value); + snprintf(buffer, kFloatToBufferSize, "%.*g", FLT_DIG+3, value); // Should never overflow; see above. GOOGLE_DCHECK(snprintf_result > 0 && snprintf_result < kFloatToBufferSize); diff --git a/src/google/protobuf/stubs/strutil.h b/src/google/protobuf/stubs/strutil.h index df28c94d..a839b8b3 100644 --- a/src/google/protobuf/stubs/strutil.h +++ b/src/google/protobuf/stubs/strutil.h @@ -213,7 +213,7 @@ LIBPROTOBUF_EXPORT string StringReplace(const string& s, const string& oldsub, // over all of them. // ---------------------------------------------------------------------- LIBPROTOBUF_EXPORT void SplitStringUsing(const string& full, const char* delim, - vector<string>* res); + std::vector<string>* res); // Split a string using one or more byte delimiters, presented // as a nul-terminated c string. Append the components to 'result'. @@ -225,15 +225,15 @@ LIBPROTOBUF_EXPORT void SplitStringUsing(const string& full, const char* delim, // ---------------------------------------------------------------------- LIBPROTOBUF_EXPORT void SplitStringAllowEmpty(const string& full, const char* delim, - vector<string>* result); + std::vector<string>* result); // ---------------------------------------------------------------------- // Split() // Split a string using a character delimiter. // ---------------------------------------------------------------------- -inline vector<string> Split( +inline std::vector<string> Split( const string& full, const char* delim, bool skip_empty = true) { - vector<string> result; + std::vector<string> result; if (skip_empty) { SplitStringUsing(full, delim, &result); } else { @@ -250,10 +250,10 @@ inline vector<string> Split( // another takes a pointer to the target string. In the latter case the // target string is cleared and overwritten. // ---------------------------------------------------------------------- -LIBPROTOBUF_EXPORT void JoinStrings(const vector<string>& components, +LIBPROTOBUF_EXPORT void JoinStrings(const std::vector<string>& components, const char* delim, string* result); -inline string JoinStrings(const vector<string>& components, +inline string JoinStrings(const std::vector<string>& components, const char* delim) { string result; JoinStrings(components, delim, &result); @@ -285,15 +285,15 @@ inline string JoinStrings(const vector<string>& components, // // Errors: In the first form of the call, errors are reported with // LOG(ERROR). The same is true for the second form of the call if -// the pointer to the string vector is NULL; otherwise, error -// messages are stored in the vector. In either case, the effect on +// the pointer to the string std::vector is NULL; otherwise, error +// messages are stored in the std::vector. In either case, the effect on // the dest array is not defined, but rest of the source will be // processed. // ---------------------------------------------------------------------- LIBPROTOBUF_EXPORT int UnescapeCEscapeSequences(const char* source, char* dest); LIBPROTOBUF_EXPORT int UnescapeCEscapeSequences(const char* source, char* dest, - vector<string> *errors); + std::vector<string> *errors); // ---------------------------------------------------------------------- // UnescapeCEscapeString() @@ -312,7 +312,7 @@ LIBPROTOBUF_EXPORT int UnescapeCEscapeSequences(const char* source, char* dest, LIBPROTOBUF_EXPORT int UnescapeCEscapeString(const string& src, string* dest); LIBPROTOBUF_EXPORT int UnescapeCEscapeString(const string& src, string* dest, - vector<string> *errors); + std::vector<string> *errors); LIBPROTOBUF_EXPORT string UnescapeCEscapeString(const string& src); // ---------------------------------------------------------------------- diff --git a/src/google/protobuf/stubs/strutil_unittest.cc b/src/google/protobuf/stubs/strutil_unittest.cc index 5d62fc4a..6bf0f598 100644 --- a/src/google/protobuf/stubs/strutil_unittest.cc +++ b/src/google/protobuf/stubs/strutil_unittest.cc @@ -782,7 +782,7 @@ TEST(Base64, EscapeAndUnescape) { reinterpret_cast<const unsigned char*>(base64_strings[i].plaintext); int plain_length = strlen(base64_strings[i].plaintext); int cypher_length = strlen(base64_strings[i].cyphertext); - vector<char> buffer(cypher_length+1); + std::vector<char> buffer(cypher_length+1); int encode_length = WebSafeBase64Escape(unsigned_plaintext, plain_length, &buffer[0], diff --git a/src/google/protobuf/stubs/time.cc b/src/google/protobuf/stubs/time.cc index 49c0412c..6def637e 100644 --- a/src/google/protobuf/stubs/time.cc +++ b/src/google/protobuf/stubs/time.cc @@ -80,9 +80,9 @@ bool ValidateDateTime(const DateTime& time) { return false; } if (time.month == 2 && IsLeapYear(time.year)) { - return time.month <= kDaysInMonth[time.month] + 1; + return time.day <= kDaysInMonth[time.month] + 1; } else { - return time.month <= kDaysInMonth[time.month]; + return time.day <= kDaysInMonth[time.month]; } } diff --git a/src/google/protobuf/stubs/time_test.cc b/src/google/protobuf/stubs/time_test.cc index 59e9d1c7..53da9480 100644 --- a/src/google/protobuf/stubs/time_test.cc +++ b/src/google/protobuf/stubs/time_test.cc @@ -149,6 +149,59 @@ TEST(DateTimeTest, LeapYear) { CreateTimestamp(2400, 3, 1) - CreateTimestamp(2400, 2, 29)); } +TEST(DateTimeTest, WrongDays) { + int64 seconds; + DateTime time; + time.hour = 0; + time.minute = 0; + time.second = 0; + time.month = 2; + + // Non-leap year. + time.year = 2015; + time.day = 29; + ASSERT_FALSE(DateTimeToSeconds(time, &seconds)); + + // Leap year. + time.year = 2016; + time.day = 29; + ASSERT_TRUE(DateTimeToSeconds(time, &seconds)); + time.day = 30; + ASSERT_FALSE(DateTimeToSeconds(time, &seconds)); + + // Non-leap year. + time.year = 2100; + time.day = 29; + ASSERT_FALSE(DateTimeToSeconds(time, &seconds)); + + // Leap year. + time.year = 2400; + time.day = 29; + ASSERT_TRUE(DateTimeToSeconds(time, &seconds)); + time.day = 30; + ASSERT_FALSE(DateTimeToSeconds(time, &seconds)); + + // Non-february + time.year = 2015; + time.month = 1; + time.day = 0; + ASSERT_FALSE(DateTimeToSeconds(time, &seconds)); + time.day = 1; + ASSERT_TRUE(DateTimeToSeconds(time, &seconds)); + time.day = 31; + ASSERT_TRUE(DateTimeToSeconds(time, &seconds)); + time.day = 32; + ASSERT_FALSE(DateTimeToSeconds(time, &seconds)); + + // Bad month + time.year = 2015; + time.month = 0; + time.day = 1; + ASSERT_FALSE(DateTimeToSeconds(time, &seconds)); + time.month = 13; + ASSERT_FALSE(DateTimeToSeconds(time, &seconds)); +} + TEST(DateTimeTest, StringFormat) { DateTime start, end; start.year = 1; diff --git a/src/google/protobuf/stubs/type_traits_unittest.cc b/src/google/protobuf/stubs/type_traits_unittest.cc index 49c10ace..0e54b952 100644 --- a/src/google/protobuf/stubs/type_traits_unittest.cc +++ b/src/google/protobuf/stubs/type_traits_unittest.cc @@ -253,7 +253,7 @@ TEST(TypeTraitsTest, TestIsPointer) { EXPECT_TRUE(is_pointer<const void* volatile>::value); EXPECT_TRUE(is_pointer<char** const volatile>::value); EXPECT_FALSE(is_pointer<const int>::value); - EXPECT_FALSE(is_pointer<volatile vector<int*> >::value); + EXPECT_FALSE(is_pointer<volatile std::vector<int*> >::value); EXPECT_FALSE(is_pointer<const volatile double>::value); } diff --git a/src/google/protobuf/test_messages_proto2.proto b/src/google/protobuf/test_messages_proto2.proto new file mode 100644 index 00000000..60dbfc75 --- /dev/null +++ b/src/google/protobuf/test_messages_proto2.proto @@ -0,0 +1,216 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Test schema for proto2 messages. This test schema is used by: +// +// - conformance tests +// + +syntax = "proto2"; + +package protobuf_test_messages.proto2; +option java_package = "com.google.protobuf_test_messages.proto2"; + +// This is the default, but we specify it here explicitly. +option optimize_for = SPEED; + +option cc_enable_arenas = true; + +// This proto includes every type of field in both singular and repeated +// forms. +// +// Also, crucially, all messages and enums in this file are eventually +// submessages of this message. So for example, a fuzz test of TestAllTypes +// could trigger bugs that occur in any message type in this file. We verify +// this stays true in a unit test. +message TestAllTypesProto2 { + message NestedMessage { + optional int32 a = 1; + optional TestAllTypesProto2 corecursive = 2; + } + + enum NestedEnum { + FOO = 0; + BAR = 1; + BAZ = 2; + NEG = -1; // Intentionally negative. + } + + // Singular + optional int32 optional_int32 = 1; + optional int64 optional_int64 = 2; + optional uint32 optional_uint32 = 3; + optional uint64 optional_uint64 = 4; + optional sint32 optional_sint32 = 5; + optional sint64 optional_sint64 = 6; + optional fixed32 optional_fixed32 = 7; + optional fixed64 optional_fixed64 = 8; + optional sfixed32 optional_sfixed32 = 9; + optional sfixed64 optional_sfixed64 = 10; + optional float optional_float = 11; + optional double optional_double = 12; + optional bool optional_bool = 13; + optional string optional_string = 14; + optional bytes optional_bytes = 15; + + optional NestedMessage optional_nested_message = 18; + optional ForeignMessageProto2 optional_foreign_message = 19; + + optional NestedEnum optional_nested_enum = 21; + optional ForeignEnumProto2 optional_foreign_enum = 22; + + optional string optional_string_piece = 24 [ctype=STRING_PIECE]; + optional string optional_cord = 25 [ctype=CORD]; + + optional TestAllTypesProto2 recursive_message = 27; + + // Repeated + repeated int32 repeated_int32 = 31; + repeated int64 repeated_int64 = 32; + repeated uint32 repeated_uint32 = 33; + repeated uint64 repeated_uint64 = 34; + repeated sint32 repeated_sint32 = 35; + repeated sint64 repeated_sint64 = 36; + repeated fixed32 repeated_fixed32 = 37; + repeated fixed64 repeated_fixed64 = 38; + repeated sfixed32 repeated_sfixed32 = 39; + repeated sfixed64 repeated_sfixed64 = 40; + repeated float repeated_float = 41; + repeated double repeated_double = 42; + repeated bool repeated_bool = 43; + repeated string repeated_string = 44; + repeated bytes repeated_bytes = 45; + + repeated NestedMessage repeated_nested_message = 48; + repeated ForeignMessageProto2 repeated_foreign_message = 49; + + repeated NestedEnum repeated_nested_enum = 51; + repeated ForeignEnumProto2 repeated_foreign_enum = 52; + + repeated string repeated_string_piece = 54 [ctype=STRING_PIECE]; + repeated string repeated_cord = 55 [ctype=CORD]; + + // Map + map < int32, int32> map_int32_int32 = 56; + map < int64, int64> map_int64_int64 = 57; + map < uint32, uint32> map_uint32_uint32 = 58; + map < uint64, uint64> map_uint64_uint64 = 59; + map < sint32, sint32> map_sint32_sint32 = 60; + map < sint64, sint64> map_sint64_sint64 = 61; + map < fixed32, fixed32> map_fixed32_fixed32 = 62; + map < fixed64, fixed64> map_fixed64_fixed64 = 63; + map <sfixed32, sfixed32> map_sfixed32_sfixed32 = 64; + map <sfixed64, sfixed64> map_sfixed64_sfixed64 = 65; + map < int32, float> map_int32_float = 66; + map < int32, double> map_int32_double = 67; + map < bool, bool> map_bool_bool = 68; + map < string, string> map_string_string = 69; + map < string, bytes> map_string_bytes = 70; + map < string, NestedMessage> map_string_nested_message = 71; + map < string, ForeignMessageProto2> map_string_foreign_message = 72; + map < string, NestedEnum> map_string_nested_enum = 73; + map < string, ForeignEnumProto2> map_string_foreign_enum = 74; + + oneof oneof_field { + uint32 oneof_uint32 = 111; + NestedMessage oneof_nested_message = 112; + string oneof_string = 113; + bytes oneof_bytes = 114; + bool oneof_bool = 115; + uint64 oneof_uint64 = 116; + float oneof_float = 117; + double oneof_double = 118; + NestedEnum oneof_enum = 119; + } + + // extensions + extensions 120 to 200; + + // groups + optional group Data = 201 { + optional int32 group_int32 = 202; + optional uint32 group_uint32 = 203; + }; + + // Test field-name-to-JSON-name convention. + // (protobuf says names can be any valid C/C++ identifier.) + optional int32 fieldname1 = 401; + optional int32 field_name2 = 402; + optional int32 _field_name3 = 403; + optional int32 field__name4_ = 404; + optional int32 field0name5 = 405; + optional int32 field_0_name6 = 406; + optional int32 fieldName7 = 407; + optional int32 FieldName8 = 408; + optional int32 field_Name9 = 409; + optional int32 Field_Name10 = 410; + optional int32 FIELD_NAME11 = 411; + optional int32 FIELD_name12 = 412; + optional int32 __field_name13 = 413; + optional int32 __Field_name14 = 414; + optional int32 field__name15 = 415; + optional int32 field__Name16 = 416; + optional int32 field_name17__ = 417; + optional int32 Field_name18__ = 418; + + // message_set test case. + message MessageSetCorrect { + option message_set_wire_format = true; + extensions 4 to max; + } + + message MessageSetCorrectExtension1 { + extend MessageSetCorrect { + optional MessageSetCorrectExtension1 message_set_extension = 1547769; + } + optional string str = 25; + } + + message MessageSetCorrectExtension2 { + extend MessageSetCorrect { + optional MessageSetCorrectExtension2 message_set_extension = 4135312; + } + optional int32 i = 9; + } +} + +message ForeignMessageProto2 { + optional int32 c = 1; +} + +enum ForeignEnumProto2 { + FOREIGN_FOO = 0; + FOREIGN_BAR = 1; + FOREIGN_BAZ = 2; +} + +extend TestAllTypesProto2 { + optional int32 extension_int32 = 120; +} diff --git a/src/google/protobuf/test_messages_proto3.proto b/src/google/protobuf/test_messages_proto3.proto index 79230334..4f295aac 100644 --- a/src/google/protobuf/test_messages_proto3.proto +++ b/src/google/protobuf/test_messages_proto3.proto @@ -39,6 +39,7 @@ syntax = "proto3"; package protobuf_test_messages.proto3; option java_package = "com.google.protobuf_test_messages.proto3"; +option objc_class_prefix = "Proto3"; // This is the default, but we specify it here explicitly. option optimize_for = SPEED; @@ -59,10 +60,10 @@ option cc_enable_arenas = true; // submessages of this message. So for example, a fuzz test of TestAllTypes // could trigger bugs that occur in any message type in this file. We verify // this stays true in a unit test. -message TestAllTypes { +message TestAllTypesProto3 { message NestedMessage { int32 a = 1; - TestAllTypes corecursive = 2; + TestAllTypesProto3 corecursive = 2; } enum NestedEnum { @@ -98,7 +99,7 @@ message TestAllTypes { string optional_string_piece = 24 [ctype=STRING_PIECE]; string optional_cord = 25 [ctype=CORD]; - TestAllTypes recursive_message = 27; + TestAllTypesProto3 recursive_message = 27; // Repeated repeated int32 repeated_int32 = 31; @@ -214,6 +215,9 @@ message TestAllTypes { int32 field__Name16 = 416; int32 field_name17__ = 417; int32 Field_name18__ = 418; + + // Reserved for testing unknown fields + reserved 501 to 510; } message ForeignMessage { diff --git a/src/google/protobuf/testing/file.cc b/src/google/protobuf/testing/file.cc index 470512ed..26cb0a67 100644 --- a/src/google/protobuf/testing/file.cc +++ b/src/google/protobuf/testing/file.cc @@ -38,24 +38,31 @@ #ifdef _MSC_VER #define WIN32_LEAN_AND_MEAN // yeah, right #include <windows.h> // Find*File(). :( -#include <io.h> -#include <direct.h> +// #include <direct.h> #else #include <dirent.h> #include <unistd.h> #endif #include <errno.h> +#include <google/protobuf/stubs/io_win32.h> + namespace google { namespace protobuf { #ifdef _WIN32 -#define mkdir(name, mode) mkdir(name) // Windows doesn't have symbolic links. #define lstat stat -#ifndef F_OK -#define F_OK 00 // not defined by MSVC for whatever reason +// DO NOT include <io.h>, instead create functions in io_win32.{h,cc} and import +// them like we do below. #endif + +#ifdef _WIN32 +using google::protobuf::internal::win32::access; +using google::protobuf::internal::win32::chdir; +using google::protobuf::internal::win32::fopen; +using google::protobuf::internal::win32::mkdir; +using google::protobuf::internal::win32::stat; #endif bool File::Exists(const string& name) { @@ -113,6 +120,9 @@ void File::WriteStringToFileOrDie(const string& contents, const string& name) { } bool File::CreateDir(const string& name, int mode) { + if (!name.empty()) { + GOOGLE_CHECK_OK(name[name.size() - 1] != '.'); + } return mkdir(name.c_str(), mode) == 0; } diff --git a/src/google/protobuf/testing/googletest.cc b/src/google/protobuf/testing/googletest.cc index d45706b6..8c89e5af 100644 --- a/src/google/protobuf/testing/googletest.cc +++ b/src/google/protobuf/testing/googletest.cc @@ -33,14 +33,14 @@ #include <google/protobuf/testing/googletest.h> #include <google/protobuf/testing/file.h> +#include <google/protobuf/stubs/io_win32.h> #include <google/protobuf/stubs/strutil.h> #include <sys/stat.h> #include <sys/types.h> #include <errno.h> #include <stdlib.h> #ifdef _MSC_VER -#include <io.h> -#include <direct.h> +// #include <direct.h> #else #include <unistd.h> #endif @@ -53,7 +53,13 @@ namespace google { namespace protobuf { #ifdef _WIN32 -#define mkdir(name, mode) mkdir(name) +// DO NOT include <io.h>, instead create functions in io_win32.{h,cc} and import +// them like we do below. +using google::protobuf::internal::win32::close; +using google::protobuf::internal::win32::dup2; +using google::protobuf::internal::win32::dup; +using google::protobuf::internal::win32::mkdir; +using google::protobuf::internal::win32::open; #endif #ifndef O_BINARY @@ -111,14 +117,32 @@ string GetTemporaryDirectoryName() { char b[L_tmpnam + 1]; // HPUX multithread return 0 if s is 0 string result = tmpnam(b); #ifdef _WIN32 + // Avoid a trailing dot by changing it to an underscore. On Win32 the names of + // files and directories can, but should not, end with dot. + // + // In MS-DOS and FAT16 filesystem the filenames were 8dot3 style so it didn't + // make sense to have a name ending in dot without an extension, so the shell + // silently ignored trailing dots. To this day the Win32 API still maintains + // this behavior and silently ignores trailing dots in path arguments of + // functions such as CreateFile{A,W}. Even POSIX API function implementations + // seem to wrap the Win32 API functions (e.g. CreateDirectoryA) and behave + // this way. + // It's possible to avoid this behavior and create files / directories with + // trailing dots (using CreateFileW / CreateDirectoryW and prefixing the path + // with "\\?\") but these will be degenerate in the sense that you cannot + // chdir into such directories (or navigate into them with Windows Explorer) + // nor can you open such files with some programs (e.g. Notepad). + if (result[result.size() - 1] == '.') { + result[result.size() - 1] = '_'; + } // On Win32, tmpnam() returns a file prefixed with '\', but which is supposed // to be used in the current working directory. WTF? if (HasPrefixString(result, "\\")) { result.erase(0, 1); } - // The Win32 API accepts forward slashes as a path delimiter even though - // backslashes are standard. Let's avoid confusion and use only forward - // slashes. + // The Win32 API accepts forward slashes as a path delimiter as long as the + // path doesn't use the "\\?\" prefix. + // Let's avoid confusion and use only forward slashes. result = StringReplace(result, "\\", "/", true); #endif // _WIN32 return result; @@ -239,7 +263,7 @@ ScopedMemoryLog::~ScopedMemoryLog() { active_log_ = NULL; } -const vector<string>& ScopedMemoryLog::GetMessages(LogLevel level) { +const std::vector<string>& ScopedMemoryLog::GetMessages(LogLevel level) { GOOGLE_CHECK(level == ERROR || level == WARNING); return messages_[level]; @@ -262,6 +286,8 @@ namespace { struct ForceShutdown { ~ForceShutdown() { ShutdownProtobufLibrary(); + // Test to shutdown the library twice, which should succeed. + ShutdownProtobufLibrary(); } } force_shutdown; diff --git a/src/google/protobuf/testing/googletest.h b/src/google/protobuf/testing/googletest.h index c0d99e69..81637486 100644 --- a/src/google/protobuf/testing/googletest.h +++ b/src/google/protobuf/testing/googletest.h @@ -37,9 +37,10 @@ #include <map> #include <vector> #include <google/protobuf/stubs/common.h> - +#include <gmock/gmock.h> // Disable death tests if we use exceptions in CHECK(). -#if !PROTOBUF_USE_EXCEPTIONS && defined(GTEST_HAS_DEATH_TEST) +#if !PROTOBUF_USE_EXCEPTIONS && defined(GTEST_HAS_DEATH_TEST) && \ + !GTEST_OS_WINDOWS #define PROTOBUF_HAS_DEATH_TEST #endif @@ -82,10 +83,10 @@ class ScopedMemoryLog { virtual ~ScopedMemoryLog(); // Fetches all messages with the given severity level. - const vector<string>& GetMessages(LogLevel error); + const std::vector<string>& GetMessages(LogLevel error); private: - map<LogLevel, vector<string> > messages_; + std::map<LogLevel, std::vector<string> > messages_; LogHandler* old_handler_; static void HandleLog(LogLevel level, const char* filename, int line, diff --git a/src/google/protobuf/testing/zcgunzip.cc b/src/google/protobuf/testing/zcgunzip.cc index 76f8cfe1..349ad86e 100644 --- a/src/google/protobuf/testing/zcgunzip.cc +++ b/src/google/protobuf/testing/zcgunzip.cc @@ -72,7 +72,10 @@ int main(int argc, const char** argv) { } if (inlen > 0) { int err = write(STDOUT_FILENO, inptr, inlen); - assert(err == inlen); + if (err != inlen) { + fprintf(stderr, "write unexpectedly returned %d.\n", err); + return 1; + } } } diff --git a/src/google/protobuf/text_format.cc b/src/google/protobuf/text_format.cc index 04c887e0..eed2a768 100644 --- a/src/google/protobuf/text_format.cc +++ b/src/google/protobuf/text_format.cc @@ -42,20 +42,21 @@ #include <google/protobuf/text_format.h> -#include <google/protobuf/descriptor.h> -#include <google/protobuf/dynamic_message.h> -#include <google/protobuf/repeated_field.h> -#include <google/protobuf/wire_format_lite.h> +#include <google/protobuf/stubs/stringprintf.h> +#include <google/protobuf/any.h> #include <google/protobuf/io/strtod.h> #include <google/protobuf/io/coded_stream.h> +#include <google/protobuf/io/tokenizer.h> #include <google/protobuf/io/zero_copy_stream.h> #include <google/protobuf/io/zero_copy_stream_impl.h> -#include <google/protobuf/unknown_field_set.h> #include <google/protobuf/descriptor.pb.h> -#include <google/protobuf/io/tokenizer.h> -#include <google/protobuf/any.h> -#include <google/protobuf/stubs/stringprintf.h> +#include <google/protobuf/descriptor.h> +#include <google/protobuf/dynamic_message.h> +#include <google/protobuf/repeated_field.h> +#include <google/protobuf/unknown_field_set.h> +#include <google/protobuf/wire_format_lite.h> #include <google/protobuf/stubs/strutil.h> + #include <google/protobuf/stubs/map_util.h> #include <google/protobuf/stubs/stl_util.h> @@ -364,7 +365,7 @@ class TextFormat::Parser::ParserImpl { const Descriptor* descriptor = message->GetDescriptor(); string field_name; - + bool reserved_field = false; const FieldDescriptor* field = NULL; int start_line = tokenizer_.current().line; int start_column = tokenizer_.current().column; @@ -426,6 +427,8 @@ class TextFormat::Parser::ParserImpl { if (allow_field_number_ && safe_strto32(field_name, &field_number)) { if (descriptor->IsExtensionNumber(field_number)) { field = reflection->FindKnownExtensionByNumber(field_number); + } else if (descriptor->IsReservedNumber(field_number)) { + reserved_field = true; } else { field = descriptor->FindFieldByNumber(field_number); } @@ -454,9 +457,13 @@ class TextFormat::Parser::ParserImpl { LowerString(&lower_field_name); field = descriptor->FindFieldByLowercaseName(lower_field_name); } + + if (field == NULL) { + reserved_field = descriptor->IsReservedName(field_name); + } } - if (field == NULL) { + if (field == NULL && !reserved_field) { if (!allow_unknown_field_) { ReportError("Message type \"" + descriptor->full_name() + "\" has no field named \"" + field_name + "\"."); @@ -468,9 +475,10 @@ class TextFormat::Parser::ParserImpl { } } - // Skips unknown field. + // Skips unknown or reserved fields. if (field == NULL) { - GOOGLE_CHECK(allow_unknown_field_); + GOOGLE_CHECK(allow_unknown_field_ || reserved_field); + // Try to guess the type of this field. // If this field is not a message, there should be a ":" between the // field name and the field value and also the field value should not @@ -1147,7 +1155,8 @@ label_skip_parsing: // =========================================================================== // Internal class for writing text to the io::ZeroCopyOutputStream. Adapted // from the Printer found in //google/protobuf/io/printer.h -class TextFormat::Printer::TextGenerator { +class TextFormat::Printer::TextGenerator + : public TextFormat::BaseTextGenerator { public: explicit TextGenerator(io::ZeroCopyOutputStream* output, int initial_indent_level) @@ -1156,9 +1165,8 @@ class TextFormat::Printer::TextGenerator { buffer_size_(0), at_start_of_line_(true), failed_(false), - indent_(""), + indent_level_(initial_indent_level), initial_indent_level_(initial_indent_level) { - indent_.resize(initial_indent_level_ * 2, ' '); } ~TextGenerator() { @@ -1173,50 +1181,45 @@ class TextFormat::Printer::TextGenerator { // inserted at the beginning of each line of text. Indent() may be called // multiple times to produce deeper indents. void Indent() { - indent_ += " "; + ++indent_level_; } // Reduces the current indent level by two spaces, or crashes if the indent // level is zero. void Outdent() { - if (indent_.empty() || - indent_.size() < initial_indent_level_ * 2) { + if (indent_level_ == 0 || + indent_level_ < initial_indent_level_) { GOOGLE_LOG(DFATAL) << " Outdent() without matching Indent()."; return; } - indent_.resize(indent_.size() - 2); - } - - // Print text to the output stream. - void Print(const string& str) { - Print(str.data(), str.size()); - } - - // Print text to the output stream. - void Print(const char* text) { - Print(text, strlen(text)); + --indent_level_; } // Print text to the output stream. void Print(const char* text, size_t size) { - size_t pos = 0; // The number of bytes we've written so far. - - for (size_t i = 0; i < size; i++) { - if (text[i] == '\n') { - // Saw newline. If there is more text, we may need to insert an indent - // here. So, write what we have so far, including the '\n'. - Write(text + pos, i - pos + 1); - pos = i + 1; - - // Setting this true will cause the next Write() to insert an indent - // first. + if (indent_level_ > 0) { + size_t pos = 0; // The number of bytes we've written so far. + for (size_t i = 0; i < size; i++) { + if (text[i] == '\n') { + // Saw newline. If there is more text, we may need to insert an + // indent here. So, write what we have so far, including the '\n'. + Write(text + pos, i - pos + 1); + pos = i + 1; + + // Setting this true will cause the next Write() to insert an indent + // first. + at_start_of_line_ = true; + } + } + // Write the rest. + Write(text + pos, size - pos); + } else { + Write(text, size); + if (size > 0 && text[size - 1] == '\n') { at_start_of_line_ = true; } } - - // Write the rest. - Write(text + pos, size - pos); } // True if any write to the underlying stream failed. (We don't just @@ -1234,15 +1237,39 @@ class TextFormat::Printer::TextGenerator { if (at_start_of_line_) { // Insert an indent. at_start_of_line_ = false; - Write(indent_.data(), indent_.size()); + WriteIndent(); if (failed_) return; } while (size > buffer_size_) { // Data exceeds space in the buffer. Copy what we can and request a // new buffer. - memcpy(buffer_, data, buffer_size_); - data += buffer_size_; + if (buffer_size_ > 0) { + memcpy(buffer_, data, buffer_size_); + data += buffer_size_; + size -= buffer_size_; + } + void* void_buffer = NULL; + failed_ = !output_->Next(&void_buffer, &buffer_size_); + if (failed_) return; + buffer_ = reinterpret_cast<char*>(void_buffer); + } + + // Buffer is big enough to receive the data; copy it. + memcpy(buffer_, data, size); + buffer_ += size; + buffer_size_ -= size; + } + + void WriteIndent() { + if (indent_level_ == 0) { return; } + GOOGLE_DCHECK(!failed_); + int size = 2 * indent_level_; + + while (size > buffer_size_) { + // Data exceeds space in the buffer. Write what we can and request a new + // buffer. + memset(buffer_, ' ', buffer_size_); size -= buffer_size_; void* void_buffer; failed_ = !output_->Next(&void_buffer, &buffer_size_); @@ -1251,7 +1278,7 @@ class TextFormat::Printer::TextGenerator { } // Buffer is big enough to receive the data; copy it. - memcpy(buffer_, data, size); + memset(buffer_, ' ', size); buffer_ += size; buffer_size_ -= size; } @@ -1262,7 +1289,7 @@ class TextFormat::Printer::TextGenerator { bool at_start_of_line_; bool failed_; - string indent_; + int indent_level_; int initial_indent_level_; }; @@ -1380,90 +1407,274 @@ bool TextFormat::Parser::ParseFieldValueFromString( // =========================================================================== -// The default implementation for FieldValuePrinter. The base class just -// does simple formatting. That way, deriving classes could decide to fallback -// to that behavior. +TextFormat::BaseTextGenerator::~BaseTextGenerator() {} + +namespace { + +// A BaseTextGenerator that writes to a string. +class StringBaseTextGenerator : public TextFormat::BaseTextGenerator { + public: + void Print(const char* text, size_t size) { output_.append(text, size); } + +// Some compilers do not support ref-qualifiers even in C++11 mode. +// Disable the optimization for now and revisit it later. +#if 0 // LANG_CXX11 + string Consume() && { return std::move(output_); } +#else // !LANG_CXX11 + const string& Get() { return output_; } +#endif // LANG_CXX11 + + private: + string output_; +}; + +} // namespace + +// The default implementation for FieldValuePrinter. We just delegate the +// implementation to the default FastFieldValuePrinter to avoid duplicating the +// logic. TextFormat::FieldValuePrinter::FieldValuePrinter() {} TextFormat::FieldValuePrinter::~FieldValuePrinter() {} + +#if 0 // LANG_CXX11 +#define FORWARD_IMPL(fn, ...) \ + StringBaseTextGenerator generator; \ + delegate_.fn(__VA_ARGS__, &generator); \ + return std::move(generator).Consume() +#else // !LANG_CXX11 +#define FORWARD_IMPL(fn, ...) \ + StringBaseTextGenerator generator; \ + delegate_.fn(__VA_ARGS__, &generator); \ + return generator.Get() +#endif // LANG_CXX11 + string TextFormat::FieldValuePrinter::PrintBool(bool val) const { - return val ? "true" : "false"; + FORWARD_IMPL(PrintBool, val); } string TextFormat::FieldValuePrinter::PrintInt32(int32 val) const { - return SimpleItoa(val); + FORWARD_IMPL(PrintInt32, val); } string TextFormat::FieldValuePrinter::PrintUInt32(uint32 val) const { - return SimpleItoa(val); + FORWARD_IMPL(PrintUInt32, val); } string TextFormat::FieldValuePrinter::PrintInt64(int64 val) const { - return SimpleItoa(val); + FORWARD_IMPL(PrintInt64, val); } string TextFormat::FieldValuePrinter::PrintUInt64(uint64 val) const { - return SimpleItoa(val); + FORWARD_IMPL(PrintUInt64, val); } string TextFormat::FieldValuePrinter::PrintFloat(float val) const { - return SimpleFtoa(val); + FORWARD_IMPL(PrintFloat, val); } string TextFormat::FieldValuePrinter::PrintDouble(double val) const { - return SimpleDtoa(val); + FORWARD_IMPL(PrintDouble, val); } string TextFormat::FieldValuePrinter::PrintString(const string& val) const { - string printed("\""); - CEscapeAndAppend(val, &printed); - printed.push_back('\"'); - return printed; + FORWARD_IMPL(PrintString, val); } string TextFormat::FieldValuePrinter::PrintBytes(const string& val) const { return PrintString(val); } string TextFormat::FieldValuePrinter::PrintEnum(int32 val, const string& name) const { - return name; + FORWARD_IMPL(PrintEnum, val, name); } string TextFormat::FieldValuePrinter::PrintFieldName( const Message& message, const Reflection* reflection, const FieldDescriptor* field) const { - if (field->is_extension()) { - // We special-case MessageSet elements for compatibility with proto1. - if (field->containing_type()->options().message_set_wire_format() - && field->type() == FieldDescriptor::TYPE_MESSAGE - && field->is_optional() - && field->extension_scope() == field->message_type()) { - return StrCat("[", field->message_type()->full_name(), "]"); - } else { - return StrCat("[", field->full_name(), "]"); - } - } else if (field->type() == FieldDescriptor::TYPE_GROUP) { - // Groups must be serialized with their original capitalization. - return field->message_type()->name(); - } else { - return field->name(); - } + FORWARD_IMPL(PrintFieldName, message, reflection, field); } string TextFormat::FieldValuePrinter::PrintMessageStart( const Message& message, int field_index, int field_count, bool single_line_mode) const { - return single_line_mode ? " { " : " {\n"; + FORWARD_IMPL(PrintMessageStart, message, field_index, field_count, + single_line_mode); } string TextFormat::FieldValuePrinter::PrintMessageEnd( const Message& message, int field_index, int field_count, bool single_line_mode) const { - return single_line_mode ? "} " : "}\n"; + FORWARD_IMPL(PrintMessageEnd, message, field_index, field_count, + single_line_mode); +} +#undef FORWARD_IMPL + +TextFormat::FastFieldValuePrinter::FastFieldValuePrinter() {} +TextFormat::FastFieldValuePrinter::~FastFieldValuePrinter() {} +void TextFormat::FastFieldValuePrinter::PrintBool( + bool val, BaseTextGenerator* generator) const { + if (val) { + generator->PrintLiteral("true"); + } else { + generator->PrintLiteral("false"); + } +} +void TextFormat::FastFieldValuePrinter::PrintInt32( + int32 val, BaseTextGenerator* generator) const { + generator->PrintString(SimpleItoa(val)); +} +void TextFormat::FastFieldValuePrinter::PrintUInt32( + uint32 val, BaseTextGenerator* generator) const { + generator->PrintString(SimpleItoa(val)); +} +void TextFormat::FastFieldValuePrinter::PrintInt64( + int64 val, BaseTextGenerator* generator) const { + generator->PrintString(SimpleItoa(val)); +} +void TextFormat::FastFieldValuePrinter::PrintUInt64( + uint64 val, BaseTextGenerator* generator) const { + generator->PrintString(SimpleItoa(val)); +} +void TextFormat::FastFieldValuePrinter::PrintFloat( + float val, BaseTextGenerator* generator) const { + generator->PrintString(SimpleFtoa(val)); +} +void TextFormat::FastFieldValuePrinter::PrintDouble( + double val, BaseTextGenerator* generator) const { + generator->PrintString(SimpleDtoa(val)); +} +void TextFormat::FastFieldValuePrinter::PrintEnum( + int32 val, const string& name, BaseTextGenerator* generator) const { + generator->PrintString(name); +} + +void TextFormat::FastFieldValuePrinter::PrintString( + const string& val, BaseTextGenerator* generator) const { + generator->PrintLiteral("\""); + generator->PrintString(CEscape(val)); + generator->PrintLiteral("\""); +} +void TextFormat::FastFieldValuePrinter::PrintBytes( + const string& val, BaseTextGenerator* generator) const { + PrintString(val, generator); +} +void TextFormat::FastFieldValuePrinter::PrintFieldName( + const Message& message, const Reflection* reflection, + const FieldDescriptor* field, BaseTextGenerator* generator) const { + if (field->is_extension()) { + generator->PrintLiteral("["); + // We special-case MessageSet elements for compatibility with proto1. + if (field->containing_type()->options().message_set_wire_format() && + field->type() == FieldDescriptor::TYPE_MESSAGE && + field->is_optional() && + field->extension_scope() == field->message_type()) { + generator->PrintString(field->message_type()->full_name()); + } else { + generator->PrintString(field->full_name()); + } + generator->PrintLiteral("]"); + } else if (field->type() == FieldDescriptor::TYPE_GROUP) { + // Groups must be serialized with their original capitalization. + generator->PrintString(field->message_type()->name()); + } else { + generator->PrintString(field->name()); + } +} +void TextFormat::FastFieldValuePrinter::PrintMessageStart( + const Message& message, int field_index, int field_count, + bool single_line_mode, BaseTextGenerator* generator) const { + if (single_line_mode) { + generator->PrintLiteral(" { "); + } else { + generator->PrintLiteral(" {\n"); + } +} +void TextFormat::FastFieldValuePrinter::PrintMessageEnd( + const Message& message, int field_index, int field_count, + bool single_line_mode, BaseTextGenerator* generator) const { + if (single_line_mode) { + generator->PrintLiteral("} "); + } else { + generator->PrintLiteral("}\n"); + } } namespace { + +// A legacy compatibility wrapper. Takes ownership of the delegate. +class FieldValuePrinterWrapper : public TextFormat::FastFieldValuePrinter { + public: + explicit FieldValuePrinterWrapper( + const TextFormat::FieldValuePrinter* delegate) + : delegate_(delegate) {} + + void SetDelegate(const TextFormat::FieldValuePrinter* delegate) { + delegate_.reset(delegate); + } + + void PrintBool(bool val, TextFormat::BaseTextGenerator* generator) const { + generator->PrintString(delegate_->PrintBool(val)); + } + void PrintInt32(int32 val, TextFormat::BaseTextGenerator* generator) const { + generator->PrintString(delegate_->PrintInt32(val)); + } + void PrintUInt32(uint32 val, TextFormat::BaseTextGenerator* generator) const { + generator->PrintString(delegate_->PrintUInt32(val)); + } + void PrintInt64(int64 val, TextFormat::BaseTextGenerator* generator) const { + generator->PrintString(delegate_->PrintInt64(val)); + } + void PrintUInt64(uint64 val, TextFormat::BaseTextGenerator* generator) const { + generator->PrintString(delegate_->PrintUInt64(val)); + } + void PrintFloat(float val, TextFormat::BaseTextGenerator* generator) const { + generator->PrintString(delegate_->PrintFloat(val)); + } + void PrintDouble(double val, TextFormat::BaseTextGenerator* generator) const { + generator->PrintString(delegate_->PrintDouble(val)); + } + void PrintString(const string& val, + TextFormat::BaseTextGenerator* generator) const { + generator->PrintString(delegate_->PrintString(val)); + } + void PrintBytes(const string& val, + TextFormat::BaseTextGenerator* generator) const { + generator->PrintString(delegate_->PrintBytes(val)); + } + void PrintEnum(int32 val, const string& name, + TextFormat::BaseTextGenerator* generator) const { + generator->PrintString(delegate_->PrintEnum(val, name)); + } + void PrintFieldName(const Message& message, const Reflection* reflection, + const FieldDescriptor* field, + TextFormat::BaseTextGenerator* generator) const { + generator->PrintString( + delegate_->PrintFieldName(message, reflection, field)); + } + void PrintMessageStart(const Message& message, int field_index, + int field_count, bool single_line_mode, + TextFormat::BaseTextGenerator* generator) const { + generator->PrintString(delegate_->PrintMessageStart( + message, field_index, field_count, single_line_mode)); + } + void PrintMessageEnd(const Message& message, int field_index, int field_count, + bool single_line_mode, + TextFormat::BaseTextGenerator* generator) const { + generator->PrintString(delegate_->PrintMessageEnd( + message, field_index, field_count, single_line_mode)); + } + + private: + google::protobuf::scoped_ptr<const TextFormat::FieldValuePrinter> delegate_; +}; + // Our own specialization: for UTF8 escaped strings. -class FieldValuePrinterUtf8Escaping : public TextFormat::FieldValuePrinter { +class FastFieldValuePrinterUtf8Escaping + : public TextFormat::FastFieldValuePrinter { public: - virtual string PrintString(const string& val) const { - return StrCat("\"", strings::Utf8SafeCEscape(val), "\""); + void PrintString(const string& val, + TextFormat::BaseTextGenerator* generator) const { + generator->PrintLiteral("\""); + generator->PrintString(strings::Utf8SafeCEscape(val)); + generator->PrintLiteral("\""); } - virtual string PrintBytes(const string& val) const { - return TextFormat::FieldValuePrinter::PrintString(val); + void PrintBytes(const string& val, + TextFormat::BaseTextGenerator* generator) const { + return FastFieldValuePrinter::PrintString(val, generator); } }; @@ -1486,19 +1697,39 @@ TextFormat::Printer::~Printer() { } void TextFormat::Printer::SetUseUtf8StringEscaping(bool as_utf8) { - SetDefaultFieldValuePrinter(as_utf8 - ? new FieldValuePrinterUtf8Escaping() - : new FieldValuePrinter()); + SetDefaultFieldValuePrinter(as_utf8 ? new FastFieldValuePrinterUtf8Escaping() + : new FastFieldValuePrinter()); } void TextFormat::Printer::SetDefaultFieldValuePrinter( const FieldValuePrinter* printer) { + default_field_value_printer_.reset(new FieldValuePrinterWrapper(printer)); +} + +void TextFormat::Printer::SetDefaultFieldValuePrinter( + const FastFieldValuePrinter* printer) { default_field_value_printer_.reset(printer); } bool TextFormat::Printer::RegisterFieldValuePrinter( const FieldDescriptor* field, const FieldValuePrinter* printer) { + if (field == NULL || printer == NULL) { + return false; + } + FieldValuePrinterWrapper* const wrapper = + new FieldValuePrinterWrapper(NULL); + if (custom_printers_.insert(std::make_pair(field, wrapper)).second) { + wrapper->SetDelegate(printer); + return true; + } else { + delete wrapper; + return false; + } +} + +bool TextFormat::Printer::RegisterFieldValuePrinter( + const FieldDescriptor* field, const FastFieldValuePrinter* printer) { return field != NULL && printer != NULL && custom_printers_.insert(std::make_pair(field, printer)).second; } @@ -1527,7 +1758,7 @@ bool TextFormat::Printer::Print(const Message& message, io::ZeroCopyOutputStream* output) const { TextGenerator generator(output, initial_indent_level_); - Print(message, generator); + Print(message, &generator); // Output false if the generator failed internally. return !generator.failed(); @@ -1538,7 +1769,7 @@ bool TextFormat::Printer::PrintUnknownFields( io::ZeroCopyOutputStream* output) const { TextGenerator generator(output, initial_indent_level_); - PrintUnknownFields(unknown_fields, generator); + PrintUnknownFields(unknown_fields, &generator); // Output false if the generator failed internally. return !generator.failed(); @@ -1556,7 +1787,7 @@ struct FieldIndexSorter { } // namespace bool TextFormat::Printer::PrintAny(const Message& message, - TextGenerator& generator) const { + TextGenerator* generator) const { const FieldDescriptor* type_url_field; const FieldDescriptor* value_field; if (!internal::GetAnyFieldDescriptors(message, &type_url_field, @@ -1589,20 +1820,21 @@ bool TextFormat::Printer::PrintAny(const Message& message, GOOGLE_LOG(WARNING) << type_url << ": failed to parse contents"; return false; } - generator.Print(StrCat("[", type_url, "]")); - const FieldValuePrinter* printer = FindWithDefault( + generator->PrintLiteral("["); + generator->PrintString(type_url); + generator->PrintLiteral("]"); + const FastFieldValuePrinter* printer = FindWithDefault( custom_printers_, value_field, default_field_value_printer_.get()); - generator.Print( - printer->PrintMessageStart(message, -1, 0, single_line_mode_)); - generator.Indent(); + printer->PrintMessageStart(message, -1, 0, single_line_mode_, generator); + generator->Indent(); Print(*value_message, generator); - generator.Outdent(); - generator.Print(printer->PrintMessageEnd(message, -1, 0, single_line_mode_)); + generator->Outdent(); + printer->PrintMessageEnd(message, -1, 0, single_line_mode_, generator); return true; } void TextFormat::Printer::Print(const Message& message, - TextGenerator& generator) const { + TextGenerator* generator) const { const Descriptor* descriptor = message.GetDescriptor(); const Reflection* reflection = message.GetReflection(); if (descriptor->full_name() == internal::kAnyFullTypeName && expand_any_ && @@ -1634,13 +1866,13 @@ void TextFormat::Printer::PrintFieldValueToString( io::StringOutputStream output_stream(output); TextGenerator generator(&output_stream, initial_indent_level_); - PrintFieldValue(message, message.GetReflection(), field, index, generator); + PrintFieldValue(message, message.GetReflection(), field, index, &generator); } void TextFormat::Printer::PrintField(const Message& message, const Reflection* reflection, const FieldDescriptor* field, - TextGenerator& generator) const { + TextGenerator* generator) const { if (use_short_repeated_primitives_ && field->is_repeated() && field->cpp_type() != FieldDescriptor::CPPTYPE_STRING && @@ -1669,92 +1901,88 @@ void TextFormat::Printer::PrintField(const Message& message, PrintFieldName(message, reflection, field, generator); if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { - const FieldValuePrinter* printer = FindWithDefault( + const FastFieldValuePrinter* printer = FindWithDefault( custom_printers_, field, default_field_value_printer_.get()); const Message& sub_message = field->is_repeated() ? (is_map ? *map_entries[j] : reflection->GetRepeatedMessage(message, field, j)) : reflection->GetMessage(message, field); - generator.Print( - printer->PrintMessageStart( - sub_message, field_index, count, single_line_mode_)); - generator.Indent(); + printer->PrintMessageStart(sub_message, field_index, count, + single_line_mode_, generator); + generator->Indent(); Print(sub_message, generator); - generator.Outdent(); - generator.Print( - printer->PrintMessageEnd( - sub_message, field_index, count, single_line_mode_)); + generator->Outdent(); + printer->PrintMessageEnd(sub_message, field_index, count, + single_line_mode_, generator); } else { - generator.Print(": "); + generator->PrintLiteral(": "); // Write the field value. PrintFieldValue(message, reflection, field, field_index, generator); if (single_line_mode_) { - generator.Print(" "); + generator->PrintLiteral(" "); } else { - generator.Print("\n"); + generator->PrintLiteral("\n"); } } } } void TextFormat::Printer::PrintShortRepeatedField( - const Message& message, - const Reflection* reflection, - const FieldDescriptor* field, - TextGenerator& generator) const { + const Message& message, const Reflection* reflection, + const FieldDescriptor* field, TextGenerator* generator) const { // Print primitive repeated field in short form. PrintFieldName(message, reflection, field, generator); int size = reflection->FieldSize(message, field); - generator.Print(": ["); + generator->PrintLiteral(": ["); for (int i = 0; i < size; i++) { - if (i > 0) generator.Print(", "); + if (i > 0) generator->PrintLiteral(", "); PrintFieldValue(message, reflection, field, i, generator); } if (single_line_mode_) { - generator.Print("] "); + generator->PrintLiteral("] "); } else { - generator.Print("]\n"); + generator->PrintLiteral("]\n"); } } void TextFormat::Printer::PrintFieldName(const Message& message, const Reflection* reflection, const FieldDescriptor* field, - TextGenerator& generator) const { + TextGenerator* generator) const { // if use_field_number_ is true, prints field number instead // of field name. if (use_field_number_) { - generator.Print(SimpleItoa(field->number())); + generator->PrintString(SimpleItoa(field->number())); return; } - const FieldValuePrinter* printer = FindWithDefault( + const FastFieldValuePrinter* printer = FindWithDefault( custom_printers_, field, default_field_value_printer_.get()); - generator.Print(printer->PrintFieldName(message, reflection, field)); + printer->PrintFieldName(message, reflection, field, generator); } -void TextFormat::Printer::PrintFieldValue( - const Message& message, - const Reflection* reflection, - const FieldDescriptor* field, - int index, - TextGenerator& generator) const { +void TextFormat::Printer::PrintFieldValue(const Message& message, + const Reflection* reflection, + const FieldDescriptor* field, + int index, + TextGenerator* generator) const { GOOGLE_DCHECK(field->is_repeated() || (index == -1)) << "Index must be -1 for non-repeated fields"; - const FieldValuePrinter* printer - = FindWithDefault(custom_printers_, field, - default_field_value_printer_.get()); + const FastFieldValuePrinter* printer = FindWithDefault( + custom_printers_, field, default_field_value_printer_.get()); switch (field->cpp_type()) { -#define OUTPUT_FIELD(CPPTYPE, METHOD) \ - case FieldDescriptor::CPPTYPE_##CPPTYPE: \ - generator.Print(printer->Print##METHOD(field->is_repeated() \ - ? reflection->GetRepeated##METHOD(message, field, index) \ - : reflection->Get##METHOD(message, field))); \ - break +#define OUTPUT_FIELD(CPPTYPE, METHOD) \ + case FieldDescriptor::CPPTYPE_##CPPTYPE: \ + printer->Print##METHOD( \ + field->is_repeated() \ + ? reflection->GetRepeated##METHOD(message, field, index) \ + : reflection->Get##METHOD(message, field), \ + generator); \ + break OUTPUT_FIELD( INT32, Int32); OUTPUT_FIELD( INT64, Int64); @@ -1780,10 +2008,10 @@ void TextFormat::Printer::PrintFieldValue( value_to_print = &truncated_value; } if (field->type() == FieldDescriptor::TYPE_STRING) { - generator.Print(printer->PrintString(*value_to_print)); + printer->PrintString(*value_to_print, generator); } else { GOOGLE_DCHECK_EQ(field->type(), FieldDescriptor::TYPE_BYTES); - generator.Print(printer->PrintBytes(*value_to_print)); + printer->PrintBytes(*value_to_print, generator); } break; } @@ -1795,7 +2023,7 @@ void TextFormat::Printer::PrintFieldValue( const EnumValueDescriptor* enum_desc = field->enum_type()->FindValueByNumber(enum_value); if (enum_desc != NULL) { - generator.Print(printer->PrintEnum(enum_value, enum_desc->name())); + printer->PrintEnum(enum_value, enum_desc->name(), generator); } else { // Ordinarily, enum_desc should not be null, because proto2 has the // invariant that set enum field values must be in-range, but with the @@ -1803,8 +2031,8 @@ void TextFormat::Printer::PrintFieldValue( // it is possible for the user to force an unknown integer value. So we // simply use the integer value itself as the enum value name in this // case. - generator.Print(printer->PrintEnum(enum_value, - StringPrintf("%d", enum_value))); + printer->PrintEnum(enum_value, StringPrintf("%d", enum_value), + generator); } break; } @@ -1867,90 +2095,93 @@ static string PaddedHex(IntType value) { } void TextFormat::Printer::PrintUnknownFields( - const UnknownFieldSet& unknown_fields, TextGenerator& generator) const { + const UnknownFieldSet& unknown_fields, TextGenerator* generator) const { for (int i = 0; i < unknown_fields.field_count(); i++) { const UnknownField& field = unknown_fields.field(i); string field_number = SimpleItoa(field.number()); switch (field.type()) { case UnknownField::TYPE_VARINT: - generator.Print(field_number); - generator.Print(": "); - generator.Print(SimpleItoa(field.varint())); + generator->PrintString(field_number); + generator->PrintLiteral(": "); + generator->PrintString(SimpleItoa(field.varint())); if (single_line_mode_) { - generator.Print(" "); + generator->PrintLiteral(" "); } else { - generator.Print("\n"); + generator->PrintLiteral("\n"); } break; case UnknownField::TYPE_FIXED32: { - generator.Print(field_number); - generator.Print(": 0x"); - generator.Print( + generator->PrintString(field_number); + generator->PrintLiteral(": 0x"); + generator->PrintString( StrCat(strings::Hex(field.fixed32(), strings::ZERO_PAD_8))); if (single_line_mode_) { - generator.Print(" "); + generator->PrintLiteral(" "); } else { - generator.Print("\n"); + generator->PrintLiteral("\n"); } break; } case UnknownField::TYPE_FIXED64: { - generator.Print(field_number); - generator.Print(": 0x"); - generator.Print( + generator->PrintString(field_number); + generator->PrintLiteral(": 0x"); + generator->PrintString( StrCat(strings::Hex(field.fixed64(), strings::ZERO_PAD_16))); if (single_line_mode_) { - generator.Print(" "); + generator->PrintLiteral(" "); } else { - generator.Print("\n"); + generator->PrintLiteral("\n"); } break; } case UnknownField::TYPE_LENGTH_DELIMITED: { - generator.Print(field_number); + generator->PrintString(field_number); const string& value = field.length_delimited(); UnknownFieldSet embedded_unknown_fields; if (!value.empty() && embedded_unknown_fields.ParseFromString(value)) { // This field is parseable as a Message. // So it is probably an embedded message. if (single_line_mode_) { - generator.Print(" { "); + generator->PrintLiteral(" { "); } else { - generator.Print(" {\n"); - generator.Indent(); + generator->PrintLiteral(" {\n"); + generator->Indent(); } PrintUnknownFields(embedded_unknown_fields, generator); if (single_line_mode_) { - generator.Print("} "); + generator->PrintLiteral("} "); } else { - generator.Outdent(); - generator.Print("}\n"); + generator->Outdent(); + generator->PrintLiteral("}\n"); } } else { // This field is not parseable as a Message. // So it is probably just a plain string. - string printed(": \""); - CEscapeAndAppend(value, &printed); - printed.append(single_line_mode_ ? "\" " : "\"\n"); - generator.Print(printed); + generator->PrintLiteral(": \""); + generator->PrintString(CEscape(value)); + if (single_line_mode_) { + generator->PrintLiteral("\" "); + } else { + generator->PrintLiteral("\"\n"); + } } break; } case UnknownField::TYPE_GROUP: - generator.Print(field_number); + generator->PrintString(field_number); if (single_line_mode_) { - generator.Print(" { "); + generator->PrintLiteral(" { "); } else { - generator.Print(" {\n"); - generator.Indent(); + generator->PrintLiteral(" {\n"); + generator->Indent(); } PrintUnknownFields(field.group(), generator); if (single_line_mode_) { - generator.Print("} "); + generator->PrintLiteral("} "); } else { - generator.Outdent(); - generator.Print("}\n"); + generator->Outdent(); + generator->PrintLiteral("}\n"); } break; } diff --git a/src/google/protobuf/text_format.h b/src/google/protobuf/text_format.h index 560fd391..a2670d6b 100644 --- a/src/google/protobuf/text_format.h +++ b/src/google/protobuf/text_format.h @@ -49,6 +49,7 @@ #include <google/protobuf/stubs/common.h> #include <google/protobuf/descriptor.h> #include <google/protobuf/message.h> +#include <google/protobuf/message_lite.h> namespace google { namespace protobuf { @@ -65,21 +66,22 @@ namespace io { class LIBPROTOBUF_EXPORT TextFormat { public: // Outputs a textual representation of the given message to the given - // output stream. + // output stream. Returns false if printing fails. static bool Print(const Message& message, io::ZeroCopyOutputStream* output); // Print the fields in an UnknownFieldSet. They are printed by tag number // only. Embedded messages are heuristically identified by attempting to - // parse them. + // parse them. Returns false if printing fails. static bool PrintUnknownFields(const UnknownFieldSet& unknown_fields, io::ZeroCopyOutputStream* output); // Like Print(), but outputs directly to a string. // Note: output will be cleared prior to printing, and will be left empty - // even if printing fails. + // even if printing fails. Returns false if printing fails. static bool PrintToString(const Message& message, string* output); - // Like PrintUnknownFields(), but outputs directly to a string. + // Like PrintUnknownFields(), but outputs directly to a string. Returns false + // if printing fails. static bool PrintUnknownFieldsToString(const UnknownFieldSet& unknown_fields, string* output); @@ -92,12 +94,58 @@ class LIBPROTOBUF_EXPORT TextFormat { int index, string* output); - // The default printer that converts scalar values from fields into - // their string representation. - // You can derive from this FieldValuePrinter if you want to have - // fields to be printed in a different way and register it at the - // Printer. - class LIBPROTOBUF_EXPORT FieldValuePrinter { + class LIBPROTOBUF_EXPORT BaseTextGenerator { + public: + virtual ~BaseTextGenerator(); + // Print text to the output stream. + virtual void Print(const char* text, size_t size) = 0; + + void PrintString(const string& str) { Print(str.data(), str.size()); } + + template <size_t n> + void PrintLiteral(const char (&text)[n]) { + Print(text, n - 1); // n includes the terminating zero character. + } + }; + + // The default printer that converts scalar values from fields into their + // string representation. + // You can derive from this FastFieldValuePrinter if you want to have fields + // to be printed in a different way and register it at the Printer. + class LIBPROTOBUF_EXPORT FastFieldValuePrinter { + public: + FastFieldValuePrinter(); + virtual ~FastFieldValuePrinter(); + virtual void PrintBool(bool val, BaseTextGenerator* generator) const; + virtual void PrintInt32(int32 val, BaseTextGenerator* generator) const; + virtual void PrintUInt32(uint32 val, BaseTextGenerator* generator) const; + virtual void PrintInt64(int64 val, BaseTextGenerator* generator) const; + virtual void PrintUInt64(uint64 val, BaseTextGenerator* generator) const; + virtual void PrintFloat(float val, BaseTextGenerator* generator) const; + virtual void PrintDouble(double val, BaseTextGenerator* generator) const; + virtual void PrintString(const string& val, + BaseTextGenerator* generator) const; + virtual void PrintBytes(const string& val, + BaseTextGenerator* generator) const; + virtual void PrintEnum(int32 val, const string& name, + BaseTextGenerator* generator) const; + virtual void PrintFieldName(const Message& message, + const Reflection* reflection, + const FieldDescriptor* field, + BaseTextGenerator* generator) const; + virtual void PrintMessageStart(const Message& message, int field_index, + int field_count, bool single_line_mode, + BaseTextGenerator* generator) const; + virtual void PrintMessageEnd(const Message& message, int field_index, + int field_count, bool single_line_mode, + BaseTextGenerator* generator) const; + + private: + GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FastFieldValuePrinter); + }; + + class LIBPROTOBUF_EXPORT PROTOBUF_RUNTIME_DEPRECATED("Please use FastFieldValuePrinter") + FieldValuePrinter { public: FieldValuePrinter(); virtual ~FieldValuePrinter(); @@ -124,6 +172,7 @@ class LIBPROTOBUF_EXPORT TextFormat { bool single_line_mode) const; private: + FastFieldValuePrinter delegate_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FieldValuePrinter); }; @@ -162,7 +211,7 @@ class LIBPROTOBUF_EXPORT TextFormat { single_line_mode_ = single_line_mode; } - bool IsInSingleLineMode() { + bool IsInSingleLineMode() const { return single_line_mode_; } @@ -183,12 +232,13 @@ class LIBPROTOBUF_EXPORT TextFormat { // Set true to output UTF-8 instead of ASCII. The only difference // is that bytes >= 0x80 in string fields will not be escaped, // because they are assumed to be part of UTF-8 multi-byte - // sequences. This will change the default FieldValuePrinter. + // sequences. This will change the default FastFieldValuePrinter. void SetUseUtf8StringEscaping(bool as_utf8); - // Set the default FieldValuePrinter that is used for all fields that + // Set the default (Fast)FieldValuePrinter that is used for all fields that // don't have a field-specific printer registered. // Takes ownership of the printer. + void SetDefaultFieldValuePrinter(const FastFieldValuePrinter* printer); void SetDefaultFieldValuePrinter(const FieldValuePrinter* printer); // Sets whether we want to hide unknown fields or not. @@ -233,13 +283,15 @@ class LIBPROTOBUF_EXPORT TextFormat { truncate_string_field_longer_than_ = truncate_string_field_longer_than; } - // Register a custom field-specific FieldValuePrinter for fields + // Register a custom field-specific (Fast)FieldValuePrinter for fields // with a particular FieldDescriptor. // Returns "true" if the registration succeeded, or "false", if there is // already a printer for that FieldDescriptor. // Takes ownership of the printer on successful registration. bool RegisterFieldValuePrinter(const FieldDescriptor* field, const FieldValuePrinter* printer); + bool RegisterFieldValuePrinter(const FieldDescriptor* field, + const FastFieldValuePrinter* printer); private: // Forward declaration of an internal class used to print the text @@ -248,43 +300,38 @@ class LIBPROTOBUF_EXPORT TextFormat { // Internal Print method, used for writing to the OutputStream via // the TextGenerator class. - void Print(const Message& message, - TextGenerator& generator) const; + void Print(const Message& message, TextGenerator* generator) const; // Print a single field. - void PrintField(const Message& message, - const Reflection* reflection, + void PrintField(const Message& message, const Reflection* reflection, const FieldDescriptor* field, - TextGenerator& generator) const; + TextGenerator* generator) const; // Print a repeated primitive field in short form. void PrintShortRepeatedField(const Message& message, const Reflection* reflection, const FieldDescriptor* field, - TextGenerator& generator) const; + TextGenerator* generator) const; // Print the name of a field -- i.e. everything that comes before the // ':' for a single name/value pair. - void PrintFieldName(const Message& message, - const Reflection* reflection, + void PrintFieldName(const Message& message, const Reflection* reflection, const FieldDescriptor* field, - TextGenerator& generator) const; + TextGenerator* generator) const; // Outputs a textual representation of the value of the field supplied on // the message supplied or the default value if not set. - void PrintFieldValue(const Message& message, - const Reflection* reflection, - const FieldDescriptor* field, - int index, - TextGenerator& generator) const; + void PrintFieldValue(const Message& message, const Reflection* reflection, + const FieldDescriptor* field, int index, + TextGenerator* generator) const; // Print the fields in an UnknownFieldSet. They are printed by tag number // only. Embedded messages are heuristically identified by attempting to // parse them. void PrintUnknownFields(const UnknownFieldSet& unknown_fields, - TextGenerator& generator) const; + TextGenerator* generator) const; - bool PrintAny(const Message& message, TextGenerator& generator) const; + bool PrintAny(const Message& message, TextGenerator* generator) const; int initial_indent_level_; @@ -302,9 +349,9 @@ class LIBPROTOBUF_EXPORT TextFormat { int64 truncate_string_field_longer_than_; - google::protobuf::scoped_ptr<const FieldValuePrinter> default_field_value_printer_; - typedef std::map<const FieldDescriptor*, - const FieldValuePrinter*> CustomPrinterMap; + google::protobuf::scoped_ptr<const FastFieldValuePrinter> default_field_value_printer_; + typedef std::map<const FieldDescriptor*, const FastFieldValuePrinter*> + CustomPrinterMap; CustomPrinterMap custom_printers_; }; diff --git a/src/google/protobuf/text_format_unittest.cc b/src/google/protobuf/text_format_unittest.cc index 422a86b4..f823bcb2 100644 --- a/src/google/protobuf/text_format_unittest.cc +++ b/src/google/protobuf/text_format_unittest.cc @@ -53,6 +53,7 @@ #include <google/protobuf/unittest_mset_wire_format.pb.h> #include <google/protobuf/io/tokenizer.h> #include <google/protobuf/io/zero_copy_stream_impl.h> + #include <google/protobuf/stubs/strutil.h> #include <google/protobuf/stubs/substitute.h> #include <google/protobuf/testing/googletest.h> @@ -454,13 +455,29 @@ TEST_F(TextFormatTest, FieldSpecificCustomPrinter) { EXPECT_EQ("optional_int32: value-is(42)\nrepeated_int32: 42\n", text); } +TEST_F(TextFormatTest, FieldSpecificCustomPrinterRegisterSameFieldTwice) { + protobuf_unittest::TestAllTypes message; + TextFormat::Printer printer; + const FieldDescriptor* const field = + message.GetDescriptor()->FindFieldByName("optional_int32"); + ASSERT_TRUE(printer.RegisterFieldValuePrinter( + field, new CustomInt32FieldValuePrinter())); + const TextFormat::FieldValuePrinter* const rejected = + new CustomInt32FieldValuePrinter(); + ASSERT_FALSE(printer.RegisterFieldValuePrinter(field, rejected)); + delete rejected; +} + TEST_F(TextFormatTest, ErrorCasesRegisteringFieldValuePrinterShouldFail) { protobuf_unittest::TestAllTypes message; TextFormat::Printer printer; // NULL printer. EXPECT_FALSE(printer.RegisterFieldValuePrinter( message.GetDescriptor()->FindFieldByName("optional_int32"), - NULL)); + static_cast<const TextFormat::FieldValuePrinter*>(NULL))); + EXPECT_FALSE(printer.RegisterFieldValuePrinter( + message.GetDescriptor()->FindFieldByName("optional_int32"), + static_cast<const TextFormat::FastFieldValuePrinter*>(NULL))); // Because registration fails, the ownership of this printer is never taken. TextFormat::FieldValuePrinter my_field_printer; // NULL field diff --git a/src/google/protobuf/timestamp.pb.cc b/src/google/protobuf/timestamp.pb.cc index b2fe28a4..f57d4d66 100644 --- a/src/google/protobuf/timestamp.pb.cc +++ b/src/google/protobuf/timestamp.pb.cc @@ -1,7 +1,6 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/protobuf/timestamp.proto -#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION #include <google/protobuf/timestamp.pb.h> #include <algorithm> @@ -15,56 +14,61 @@ #include <google/protobuf/generated_message_reflection.h> #include <google/protobuf/reflection_ops.h> #include <google/protobuf/wire_format.h> +// This is a temporary google only hack +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS +#include "third_party/protobuf/version.h" +#endif // @@protoc_insertion_point(includes) - namespace google { namespace protobuf { -class TimestampDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Timestamp> { +class TimestampDefaultTypeInternal { + public: + ::google::protobuf::internal::ExplicitlyConstructed<Timestamp> + _instance; } _Timestamp_default_instance_; - +} // namespace protobuf +} // namespace google namespace protobuf_google_2fprotobuf_2ftimestamp_2eproto { +void InitDefaultsTimestampImpl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); +#else + ::google::protobuf::internal::InitProtobufDefaults(); +#endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + { + void* ptr = &::google::protobuf::_Timestamp_default_instance_; + new (ptr) ::google::protobuf::Timestamp(); + ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); + } + ::google::protobuf::Timestamp::InitAsDefaultInstance(); +} -namespace { +void InitDefaultsTimestamp() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsTimestampImpl); +} ::google::protobuf::Metadata file_level_metadata[1]; -} // namespace - -PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::ParseTableField - const TableStruct::entries[] = { - {0, 0, 0, ::google::protobuf::internal::kInvalidMask, 0, 0}, -}; - -PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::AuxillaryParseTableField - const TableStruct::aux[] = { - ::google::protobuf::internal::AuxillaryParseTableField(), -}; -PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::ParseTable const - TableStruct::schema[] = { - { NULL, NULL, 0, -1, -1, false }, -}; - -const ::google::protobuf::uint32 TableStruct::offsets[] = { +const ::google::protobuf::uint32 TableStruct::offsets[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { ~0u, // no _has_bits_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Timestamp, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Timestamp, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Timestamp, seconds_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Timestamp, nanos_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Timestamp, seconds_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Timestamp, nanos_), }; - -static const ::google::protobuf::internal::MigrationSchema schemas[] = { - { 0, -1, sizeof(Timestamp)}, +static const ::google::protobuf::internal::MigrationSchema schemas[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { + { 0, -1, sizeof(::google::protobuf::Timestamp)}, }; static ::google::protobuf::Message const * const file_default_instances[] = { - reinterpret_cast<const ::google::protobuf::Message*>(&_Timestamp_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_Timestamp_default_instance_), }; -namespace { - void protobuf_AssignDescriptors() { AddDescriptors(); ::google::protobuf::MessageFactory* factory = NULL; @@ -78,33 +82,15 @@ void protobuf_AssignDescriptorsOnce() { ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors); } -void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; +void protobuf_RegisterTypes(const ::std::string&) GOOGLE_PROTOBUF_ATTRIBUTE_COLD; void protobuf_RegisterTypes(const ::std::string&) { protobuf_AssignDescriptorsOnce(); ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 1); } -} // namespace - -void TableStruct::Shutdown() { - _Timestamp_default_instance_.Shutdown(); - delete file_level_metadata[0].reflection; -} - -void TableStruct::InitDefaultsImpl() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - ::google::protobuf::internal::InitProtobufDefaults(); - _Timestamp_default_instance_.DefaultConstruct(); -} - -void InitDefaults() { - static GOOGLE_PROTOBUF_DECLARE_ONCE(once); - ::google::protobuf::GoogleOnceInit(&once, &TableStruct::InitDefaultsImpl); -} void AddDescriptorsImpl() { InitDefaults(); - static const char descriptor[] = { + static const char descriptor[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { "\n\037google/protobuf/timestamp.proto\022\017googl" "e.protobuf\"+\n\tTimestamp\022\017\n\007seconds\030\001 \001(\003" "\022\r\n\005nanos\030\002 \001(\005B~\n\023com.google.protobufB\016" @@ -116,25 +102,26 @@ void AddDescriptorsImpl() { descriptor, 231); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/timestamp.proto", &protobuf_RegisterTypes); - ::google::protobuf::internal::OnShutdown(&TableStruct::Shutdown); } void AddDescriptors() { static GOOGLE_PROTOBUF_DECLARE_ONCE(once); ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl); } -// Force AddDescriptors() to be called at static initialization time. +// Force AddDescriptors() to be called at dynamic initialization time. struct StaticDescriptorInitializer { StaticDescriptorInitializer() { AddDescriptors(); } } static_descriptor_initializer; - } // namespace protobuf_google_2fprotobuf_2ftimestamp_2eproto - +namespace google { +namespace protobuf { // =================================================================== +void Timestamp::InitAsDefaultInstance() { +} #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int Timestamp::kSecondsFieldNumber; const int Timestamp::kNanosFieldNumber; @@ -143,7 +130,7 @@ const int Timestamp::kNanosFieldNumber; Timestamp::Timestamp() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { - protobuf_google_2fprotobuf_2ftimestamp_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2ftimestamp_2eproto::InitDefaultsTimestamp(); } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Timestamp) @@ -151,9 +138,7 @@ Timestamp::Timestamp() Timestamp::Timestamp(::google::protobuf::Arena* arena) : ::google::protobuf::Message(), _internal_metadata_(arena) { -#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER - protobuf_google_2fprotobuf_2ftimestamp_2eproto::InitDefaults(); -#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + ::protobuf_google_2fprotobuf_2ftimestamp_2eproto::InitDefaultsTimestamp(); SharedCtor(); RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.Timestamp) @@ -164,14 +149,15 @@ Timestamp::Timestamp(const Timestamp& from) _cached_size_(0) { _internal_metadata_.MergeFrom(from._internal_metadata_); ::memcpy(&seconds_, &from.seconds_, - reinterpret_cast<char*>(&nanos_) - - reinterpret_cast<char*>(&seconds_) + sizeof(nanos_)); + static_cast<size_t>(reinterpret_cast<char*>(&nanos_) - + reinterpret_cast<char*>(&seconds_)) + sizeof(nanos_)); // @@protoc_insertion_point(copy_constructor:google.protobuf.Timestamp) } void Timestamp::SharedCtor() { - ::memset(&seconds_, 0, reinterpret_cast<char*>(&nanos_) - - reinterpret_cast<char*>(&seconds_) + sizeof(nanos_)); + ::memset(&seconds_, 0, static_cast<size_t>( + reinterpret_cast<char*>(&nanos_) - + reinterpret_cast<char*>(&seconds_)) + sizeof(nanos_)); _cached_size_ = 0; } @@ -181,11 +167,7 @@ Timestamp::~Timestamp() { } void Timestamp::SharedDtor() { - ::google::protobuf::Arena* arena = GetArenaNoVirtual(); - if (arena != NULL) { - return; - } - + GOOGLE_DCHECK(GetArenaNoVirtual() == NULL); } void Timestamp::ArenaDtor(void* object) { @@ -200,23 +182,26 @@ void Timestamp::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* Timestamp::descriptor() { - protobuf_google_2fprotobuf_2ftimestamp_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2ftimestamp_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; + ::protobuf_google_2fprotobuf_2ftimestamp_2eproto::protobuf_AssignDescriptorsOnce(); + return ::protobuf_google_2fprotobuf_2ftimestamp_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const Timestamp& Timestamp::default_instance() { - protobuf_google_2fprotobuf_2ftimestamp_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2ftimestamp_2eproto::InitDefaultsTimestamp(); return *internal_default_instance(); } -Timestamp* Timestamp::New(::google::protobuf::Arena* arena) const { - return ::google::protobuf::Arena::CreateMessage<Timestamp>(arena); -} void Timestamp::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.Timestamp) - ::memset(&seconds_, 0, reinterpret_cast<char*>(&nanos_) - - reinterpret_cast<char*>(&seconds_) + sizeof(nanos_)); + ::google::protobuf::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + ::memset(&seconds_, 0, static_cast<size_t>( + reinterpret_cast<char*>(&nanos_) - + reinterpret_cast<char*>(&seconds_)) + sizeof(nanos_)); + _internal_metadata_.Clear(); } bool Timestamp::MergePartialFromCodedStream( @@ -232,7 +217,7 @@ bool Timestamp::MergePartialFromCodedStream( // int64 seconds = 1; case 1: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(8u)) { + static_cast< ::google::protobuf::uint8>(8u /* 8 & 0xFF */)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>( @@ -246,7 +231,7 @@ bool Timestamp::MergePartialFromCodedStream( // int32 nanos = 2; case 2: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(16u)) { + static_cast< ::google::protobuf::uint8>(16u /* 16 & 0xFF */)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -259,12 +244,11 @@ bool Timestamp::MergePartialFromCodedStream( default: { handle_unusual: - if (tag == 0 || - ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + if (tag == 0) { goto success; } - DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag)); + DO_(::google::protobuf::internal::WireFormat::SkipField( + input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } @@ -294,11 +278,16 @@ void Timestamp::SerializeWithCachedSizes( ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->nanos(), output); } + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + ::google::protobuf::internal::WireFormat::SerializeUnknownFields( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), output); + } // @@protoc_insertion_point(serialize_end:google.protobuf.Timestamp) } ::google::protobuf::uint8* Timestamp::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Timestamp) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -313,6 +302,10 @@ void Timestamp::SerializeWithCachedSizes( target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->nanos(), target); } + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), target); + } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Timestamp) return target; } @@ -321,6 +314,11 @@ size_t Timestamp::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Timestamp) size_t total_size = 0; + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance())); + } // int64 seconds = 1; if (this->seconds() != 0) { total_size += 1 + @@ -410,51 +408,27 @@ void Timestamp::UnsafeArenaSwap(Timestamp* other) { InternalSwap(other); } void Timestamp::InternalSwap(Timestamp* other) { - std::swap(seconds_, other->seconds_); - std::swap(nanos_, other->nanos_); - std::swap(_cached_size_, other->_cached_size_); + using std::swap; + swap(seconds_, other->seconds_); + swap(nanos_, other->nanos_); + _internal_metadata_.Swap(&other->_internal_metadata_); + swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata Timestamp::GetMetadata() const { protobuf_google_2fprotobuf_2ftimestamp_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2ftimestamp_2eproto::file_level_metadata[kIndexInFileMessages]; + return ::protobuf_google_2fprotobuf_2ftimestamp_2eproto::file_level_metadata[kIndexInFileMessages]; } -#if PROTOBUF_INLINE_NOT_IN_HEADERS -// Timestamp - -// int64 seconds = 1; -void Timestamp::clear_seconds() { - seconds_ = GOOGLE_LONGLONG(0); -} -::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) { - - seconds_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.Timestamp.seconds) -} - -// int32 nanos = 2; -void Timestamp::clear_nanos() { - nanos_ = 0; -} -::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) { - - nanos_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.Timestamp.nanos) -} - -#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // @@protoc_insertion_point(namespace_scope) - +} // namespace protobuf +} // namespace google +namespace google { +namespace protobuf { +template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::Timestamp* Arena::CreateMessage< ::google::protobuf::Timestamp >(Arena* arena) { + return Arena::CreateMessageInternal< ::google::protobuf::Timestamp >(arena); +} } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/timestamp.pb.h b/src/google/protobuf/timestamp.pb.h index 98478540..a0f9605c 100644 --- a/src/google/protobuf/timestamp.pb.h +++ b/src/google/protobuf/timestamp.pb.h @@ -1,19 +1,19 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/protobuf/timestamp.proto -#ifndef PROTOBUF_google_2fprotobuf_2ftimestamp_2eproto__INCLUDED -#define PROTOBUF_google_2fprotobuf_2ftimestamp_2eproto__INCLUDED +#ifndef PROTOBUF_google_2fprotobuf_2ftimestamp_2eproto_INCLUDED +#define PROTOBUF_google_2fprotobuf_2ftimestamp_2eproto_INCLUDED #include <string> #include <google/protobuf/stubs/common.h> -#if GOOGLE_PROTOBUF_VERSION < 3003000 +#if GOOGLE_PROTOBUF_VERSION < 3005000 #error This file was generated by a newer version of protoc which is #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3003000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION +#if 3005001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. @@ -30,30 +30,38 @@ #include <google/protobuf/extension_set.h> // IWYU pragma: export #include <google/protobuf/unknown_field_set.h> // @@protoc_insertion_point(includes) -namespace google { -namespace protobuf { -class Timestamp; -class TimestampDefaultTypeInternal; -LIBPROTOBUF_EXPORT extern TimestampDefaultTypeInternal _Timestamp_default_instance_; -} // namespace protobuf -} // namespace google - -namespace google { -namespace protobuf { namespace protobuf_google_2fprotobuf_2ftimestamp_2eproto { -// Internal implementation detail -- do not call these. +// Internal implementation detail -- do not use these members. struct LIBPROTOBUF_EXPORT TableStruct { static const ::google::protobuf::internal::ParseTableField entries[]; static const ::google::protobuf::internal::AuxillaryParseTableField aux[]; - static const ::google::protobuf::internal::ParseTable schema[]; + static const ::google::protobuf::internal::ParseTable schema[1]; + static const ::google::protobuf::internal::FieldMetadata field_metadata[]; + static const ::google::protobuf::internal::SerializationTable serialization_table[]; static const ::google::protobuf::uint32 offsets[]; - static void InitDefaultsImpl(); - static void Shutdown(); }; void LIBPROTOBUF_EXPORT AddDescriptors(); -void LIBPROTOBUF_EXPORT InitDefaults(); +void LIBPROTOBUF_EXPORT InitDefaultsTimestampImpl(); +void LIBPROTOBUF_EXPORT InitDefaultsTimestamp(); +inline void LIBPROTOBUF_EXPORT InitDefaults() { + InitDefaultsTimestamp(); +} } // namespace protobuf_google_2fprotobuf_2ftimestamp_2eproto +namespace google { +namespace protobuf { +class Timestamp; +class TimestampDefaultTypeInternal; +LIBPROTOBUF_EXPORT extern TimestampDefaultTypeInternal _Timestamp_default_instance_; +} // namespace protobuf +} // namespace google +namespace google { +namespace protobuf { +template<> LIBPROTOBUF_EXPORT ::google::protobuf::Timestamp* Arena::CreateMessage< ::google::protobuf::Timestamp>(Arena*); +} // namespace protobuf +} // namespace google +namespace google { +namespace protobuf { // =================================================================== @@ -68,7 +76,21 @@ class LIBPROTOBUF_EXPORT Timestamp : public ::google::protobuf::Message /* @@pro CopyFrom(from); return *this; } + #if LANG_CXX11 + Timestamp(Timestamp&& from) noexcept + : Timestamp() { + *this = ::std::move(from); + } + inline Timestamp& operator=(Timestamp&& from) noexcept { + if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + #endif inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { return GetArenaNoVirtual(); } @@ -78,6 +100,7 @@ class LIBPROTOBUF_EXPORT Timestamp : public ::google::protobuf::Message /* @@pro static const ::google::protobuf::Descriptor* descriptor(); static const Timestamp& default_instance(); + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY static inline const Timestamp* internal_default_instance() { return reinterpret_cast<const Timestamp*>( &_Timestamp_default_instance_); @@ -87,12 +110,19 @@ class LIBPROTOBUF_EXPORT Timestamp : public ::google::protobuf::Message /* @@pro void UnsafeArenaSwap(Timestamp* other); void Swap(Timestamp* other); + friend void swap(Timestamp& a, Timestamp& b) { + a.Swap(&b); + } // implements Message ---------------------------------------------- - inline Timestamp* New() const PROTOBUF_FINAL { return New(NULL); } + inline Timestamp* New() const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<Timestamp>(NULL); + } - Timestamp* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + Timestamp* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<Timestamp>(arena); + } void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const Timestamp& from); @@ -149,20 +179,24 @@ class LIBPROTOBUF_EXPORT Timestamp : public ::google::protobuf::Message /* @@pro private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - friend class ::google::protobuf::Arena; + template <typename T> friend class ::google::protobuf::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; ::google::protobuf::int64 seconds_; ::google::protobuf::int32 nanos_; mutable int _cached_size_; - friend struct protobuf_google_2fprotobuf_2ftimestamp_2eproto::TableStruct; + friend struct ::protobuf_google_2fprotobuf_2ftimestamp_2eproto::TableStruct; + friend void ::protobuf_google_2fprotobuf_2ftimestamp_2eproto::InitDefaultsTimestampImpl(); }; // =================================================================== // =================================================================== -#if !PROTOBUF_INLINE_NOT_IN_HEADERS +#ifdef __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif // __GNUC__ // Timestamp // int64 seconds = 1; @@ -193,14 +227,15 @@ inline void Timestamp::set_nanos(::google::protobuf::int32 value) { // @@protoc_insertion_point(field_set:google.protobuf.Timestamp.nanos) } -#endif // !PROTOBUF_INLINE_NOT_IN_HEADERS +#ifdef __GNUC__ + #pragma GCC diagnostic pop +#endif // __GNUC__ // @@protoc_insertion_point(namespace_scope) - } // namespace protobuf } // namespace google // @@protoc_insertion_point(global_scope) -#endif // PROTOBUF_google_2fprotobuf_2ftimestamp_2eproto__INCLUDED +#endif // PROTOBUF_google_2fprotobuf_2ftimestamp_2eproto_INCLUDED diff --git a/src/google/protobuf/timestamp.proto b/src/google/protobuf/timestamp.proto index b7cbd175..eafb3fa0 100644 --- a/src/google/protobuf/timestamp.proto +++ b/src/google/protobuf/timestamp.proto @@ -103,7 +103,9 @@ option objc_class_prefix = "GPB"; // {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional // seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution), // are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone -// is required, though only UTC (as indicated by "Z") is presently supported. +// is required. A proto3 JSON serializer should always use UTC (as indicated by +// "Z") when printing the Timestamp type and a proto3 JSON parser should be +// able to accept both UTC and other timezones (as indicated by an offset). // // For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past // 01:30 UTC on January 15, 2017. @@ -114,8 +116,8 @@ option objc_class_prefix = "GPB"; // to this format using [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) // with the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one // can use the Joda Time's [`ISODateTimeFormat.dateTime()`]( -// http://joda-time.sourceforge.net/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime()) -// to obtain a formatter capable of generating timestamps in this format. +// http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime-- +// ) to obtain a formatter capable of generating timestamps in this format. // // message Timestamp { diff --git a/src/google/protobuf/type.pb.cc b/src/google/protobuf/type.pb.cc index 8f017a89..a2edabb6 100644 --- a/src/google/protobuf/type.pb.cc +++ b/src/google/protobuf/type.pb.cc @@ -1,7 +1,6 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/protobuf/type.proto -#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION #include <google/protobuf/type.pb.h> #include <algorithm> @@ -15,121 +14,227 @@ #include <google/protobuf/generated_message_reflection.h> #include <google/protobuf/reflection_ops.h> #include <google/protobuf/wire_format.h> +// This is a temporary google only hack +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS +#include "third_party/protobuf/version.h" +#endif // @@protoc_insertion_point(includes) - namespace google { namespace protobuf { -class TypeDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Type> { +class TypeDefaultTypeInternal { + public: + ::google::protobuf::internal::ExplicitlyConstructed<Type> + _instance; } _Type_default_instance_; -class FieldDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Field> { +class FieldDefaultTypeInternal { + public: + ::google::protobuf::internal::ExplicitlyConstructed<Field> + _instance; } _Field_default_instance_; -class EnumDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Enum> { +class EnumDefaultTypeInternal { + public: + ::google::protobuf::internal::ExplicitlyConstructed<Enum> + _instance; } _Enum_default_instance_; -class EnumValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<EnumValue> { +class EnumValueDefaultTypeInternal { + public: + ::google::protobuf::internal::ExplicitlyConstructed<EnumValue> + _instance; } _EnumValue_default_instance_; -class OptionDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Option> { +class OptionDefaultTypeInternal { + public: + ::google::protobuf::internal::ExplicitlyConstructed<Option> + _instance; } _Option_default_instance_; - +} // namespace protobuf +} // namespace google namespace protobuf_google_2fprotobuf_2ftype_2eproto { +void InitDefaultsTypeImpl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); +#else + ::google::protobuf::internal::InitProtobufDefaults(); +#endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaultsField(); + protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaultsOption(); + protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto::InitDefaultsSourceContext(); + { + void* ptr = &::google::protobuf::_Type_default_instance_; + new (ptr) ::google::protobuf::Type(); + ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); + } + ::google::protobuf::Type::InitAsDefaultInstance(); +} -namespace { +void InitDefaultsType() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsTypeImpl); +} -::google::protobuf::Metadata file_level_metadata[5]; -const ::google::protobuf::EnumDescriptor* file_level_enum_descriptors[3]; +void InitDefaultsFieldImpl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; -} // namespace +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); +#else + ::google::protobuf::internal::InitProtobufDefaults(); +#endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaultsOption(); + { + void* ptr = &::google::protobuf::_Field_default_instance_; + new (ptr) ::google::protobuf::Field(); + ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); + } + ::google::protobuf::Field::InitAsDefaultInstance(); +} -PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::ParseTableField - const TableStruct::entries[] = { - {0, 0, 0, ::google::protobuf::internal::kInvalidMask, 0, 0}, -}; +void InitDefaultsField() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsFieldImpl); +} -PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::AuxillaryParseTableField - const TableStruct::aux[] = { - ::google::protobuf::internal::AuxillaryParseTableField(), -}; -PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::ParseTable const - TableStruct::schema[] = { - { NULL, NULL, 0, -1, -1, false }, - { NULL, NULL, 0, -1, -1, false }, - { NULL, NULL, 0, -1, -1, false }, - { NULL, NULL, 0, -1, -1, false }, - { NULL, NULL, 0, -1, -1, false }, -}; +void InitDefaultsEnumImpl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; -const ::google::protobuf::uint32 TableStruct::offsets[] = { +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); +#else + ::google::protobuf::internal::InitProtobufDefaults(); +#endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaultsEnumValue(); + protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaultsOption(); + protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto::InitDefaultsSourceContext(); + { + void* ptr = &::google::protobuf::_Enum_default_instance_; + new (ptr) ::google::protobuf::Enum(); + ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); + } + ::google::protobuf::Enum::InitAsDefaultInstance(); +} + +void InitDefaultsEnum() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsEnumImpl); +} + +void InitDefaultsEnumValueImpl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); +#else + ::google::protobuf::internal::InitProtobufDefaults(); +#endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaultsOption(); + { + void* ptr = &::google::protobuf::_EnumValue_default_instance_; + new (ptr) ::google::protobuf::EnumValue(); + ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); + } + ::google::protobuf::EnumValue::InitAsDefaultInstance(); +} + +void InitDefaultsEnumValue() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsEnumValueImpl); +} + +void InitDefaultsOptionImpl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); +#else + ::google::protobuf::internal::InitProtobufDefaults(); +#endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + protobuf_google_2fprotobuf_2fany_2eproto::InitDefaultsAny(); + { + void* ptr = &::google::protobuf::_Option_default_instance_; + new (ptr) ::google::protobuf::Option(); + ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); + } + ::google::protobuf::Option::InitAsDefaultInstance(); +} + +void InitDefaultsOption() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsOptionImpl); +} + +::google::protobuf::Metadata file_level_metadata[5]; +const ::google::protobuf::EnumDescriptor* file_level_enum_descriptors[3]; + +const ::google::protobuf::uint32 TableStruct::offsets[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { ~0u, // no _has_bits_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Type, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Type, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Type, name_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Type, fields_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Type, oneofs_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Type, options_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Type, source_context_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Type, syntax_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Type, name_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Type, fields_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Type, oneofs_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Type, options_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Type, source_context_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Type, syntax_), ~0u, // no _has_bits_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Field, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, kind_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, cardinality_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, number_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, name_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, type_url_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, oneof_index_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, packed_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, options_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, json_name_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, default_value_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Field, kind_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Field, cardinality_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Field, number_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Field, name_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Field, type_url_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Field, oneof_index_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Field, packed_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Field, options_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Field, json_name_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Field, default_value_), ~0u, // no _has_bits_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Enum, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Enum, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Enum, name_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Enum, enumvalue_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Enum, options_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Enum, source_context_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Enum, syntax_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Enum, name_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Enum, enumvalue_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Enum, options_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Enum, source_context_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Enum, syntax_), ~0u, // no _has_bits_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValue, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::EnumValue, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValue, name_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValue, number_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValue, options_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::EnumValue, name_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::EnumValue, number_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::EnumValue, options_), ~0u, // no _has_bits_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Option, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Option, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Option, name_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Option, value_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Option, name_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Option, value_), }; - -static const ::google::protobuf::internal::MigrationSchema schemas[] = { - { 0, -1, sizeof(Type)}, - { 11, -1, sizeof(Field)}, - { 26, -1, sizeof(Enum)}, - { 36, -1, sizeof(EnumValue)}, - { 44, -1, sizeof(Option)}, +static const ::google::protobuf::internal::MigrationSchema schemas[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { + { 0, -1, sizeof(::google::protobuf::Type)}, + { 11, -1, sizeof(::google::protobuf::Field)}, + { 26, -1, sizeof(::google::protobuf::Enum)}, + { 36, -1, sizeof(::google::protobuf::EnumValue)}, + { 44, -1, sizeof(::google::protobuf::Option)}, }; static ::google::protobuf::Message const * const file_default_instances[] = { - reinterpret_cast<const ::google::protobuf::Message*>(&_Type_default_instance_), - reinterpret_cast<const ::google::protobuf::Message*>(&_Field_default_instance_), - reinterpret_cast<const ::google::protobuf::Message*>(&_Enum_default_instance_), - reinterpret_cast<const ::google::protobuf::Message*>(&_EnumValue_default_instance_), - reinterpret_cast<const ::google::protobuf::Message*>(&_Option_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_Type_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_Field_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_Enum_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_EnumValue_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_Option_default_instance_), }; -namespace { - void protobuf_AssignDescriptors() { AddDescriptors(); ::google::protobuf::MessageFactory* factory = NULL; @@ -143,53 +248,15 @@ void protobuf_AssignDescriptorsOnce() { ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors); } -void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; +void protobuf_RegisterTypes(const ::std::string&) GOOGLE_PROTOBUF_ATTRIBUTE_COLD; void protobuf_RegisterTypes(const ::std::string&) { protobuf_AssignDescriptorsOnce(); ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 5); } -} // namespace - -void TableStruct::Shutdown() { - _Type_default_instance_.Shutdown(); - delete file_level_metadata[0].reflection; - _Field_default_instance_.Shutdown(); - delete file_level_metadata[1].reflection; - _Enum_default_instance_.Shutdown(); - delete file_level_metadata[2].reflection; - _EnumValue_default_instance_.Shutdown(); - delete file_level_metadata[3].reflection; - _Option_default_instance_.Shutdown(); - delete file_level_metadata[4].reflection; -} - -void TableStruct::InitDefaultsImpl() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - ::google::protobuf::internal::InitProtobufDefaults(); - ::google::protobuf::protobuf_google_2fprotobuf_2fany_2eproto::InitDefaults(); - ::google::protobuf::protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto::InitDefaults(); - _Type_default_instance_.DefaultConstruct(); - _Field_default_instance_.DefaultConstruct(); - _Enum_default_instance_.DefaultConstruct(); - _EnumValue_default_instance_.DefaultConstruct(); - _Option_default_instance_.DefaultConstruct(); - _Type_default_instance_.get_mutable()->source_context_ = const_cast< ::google::protobuf::SourceContext*>( - ::google::protobuf::SourceContext::internal_default_instance()); - _Enum_default_instance_.get_mutable()->source_context_ = const_cast< ::google::protobuf::SourceContext*>( - ::google::protobuf::SourceContext::internal_default_instance()); - _Option_default_instance_.get_mutable()->value_ = const_cast< ::google::protobuf::Any*>( - ::google::protobuf::Any::internal_default_instance()); -} - -void InitDefaults() { - static GOOGLE_PROTOBUF_DECLARE_ONCE(once); - ::google::protobuf::GoogleOnceInit(&once, &TableStruct::InitDefaultsImpl); -} void AddDescriptorsImpl() { InitDefaults(); - static const char descriptor[] = { + static const char descriptor[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { "\n\032google/protobuf/type.proto\022\017google.pro" "tobuf\032\031google/protobuf/any.proto\032$google" "/protobuf/source_context.proto\"\327\001\n\004Type\022" @@ -235,24 +302,23 @@ void AddDescriptorsImpl() { descriptor, 1594); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/type.proto", &protobuf_RegisterTypes); - ::google::protobuf::protobuf_google_2fprotobuf_2fany_2eproto::AddDescriptors(); - ::google::protobuf::protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto::AddDescriptors(); - ::google::protobuf::internal::OnShutdown(&TableStruct::Shutdown); + ::protobuf_google_2fprotobuf_2fany_2eproto::AddDescriptors(); + ::protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto::AddDescriptors(); } void AddDescriptors() { static GOOGLE_PROTOBUF_DECLARE_ONCE(once); ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl); } -// Force AddDescriptors() to be called at static initialization time. +// Force AddDescriptors() to be called at dynamic initialization time. struct StaticDescriptorInitializer { StaticDescriptorInitializer() { AddDescriptors(); } } static_descriptor_initializer; - } // namespace protobuf_google_2fprotobuf_2ftype_2eproto - +namespace google { +namespace protobuf { const ::google::protobuf::EnumDescriptor* Field_Kind_descriptor() { protobuf_google_2fprotobuf_2ftype_2eproto::protobuf_AssignDescriptorsOnce(); return protobuf_google_2fprotobuf_2ftype_2eproto::file_level_enum_descriptors[0]; @@ -350,25 +416,9 @@ bool Syntax_IsValid(int value) { // =================================================================== -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::InitAsDefaultInstance() { + ::google::protobuf::_Type_default_instance_._instance.get_mutable()->source_context_ = const_cast< ::google::protobuf::SourceContext*>( + ::google::protobuf::SourceContext::internal_default_instance()); } void Type::unsafe_arena_set_allocated_source_context( ::google::protobuf::SourceContext* source_context) { @@ -383,6 +433,12 @@ void Type::unsafe_arena_set_allocated_source_context( } // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Type.source_context) } +void Type::clear_source_context() { + if (GetArenaNoVirtual() == NULL && source_context_ != NULL) { + delete source_context_; + } + source_context_ = NULL; +} #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int Type::kNameFieldNumber; const int Type::kFieldsFieldNumber; @@ -395,7 +451,7 @@ const int Type::kSyntaxFieldNumber; Type::Type() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { - protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaultsType(); } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Type) @@ -406,9 +462,7 @@ Type::Type(::google::protobuf::Arena* arena) fields_(arena), oneofs_(arena), options_(arena) { -#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER - protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaults(); -#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + ::protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaultsType(); SharedCtor(); RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.Type) @@ -437,8 +491,9 @@ Type::Type(const Type& from) void Type::SharedCtor() { name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - ::memset(&source_context_, 0, reinterpret_cast<char*>(&syntax_) - - reinterpret_cast<char*>(&source_context_) + sizeof(syntax_)); + ::memset(&source_context_, 0, static_cast<size_t>( + reinterpret_cast<char*>(&syntax_) - + reinterpret_cast<char*>(&source_context_)) + sizeof(syntax_)); _cached_size_ = 0; } @@ -448,15 +503,9 @@ Type::~Type() { } void Type::SharedDtor() { - ::google::protobuf::Arena* arena = GetArenaNoVirtual(); - if (arena != NULL) { - return; - } - - name_.Destroy(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), arena); - if (this != internal_default_instance()) { - delete source_context_; - } + GOOGLE_DCHECK(GetArenaNoVirtual() == NULL); + name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (this != internal_default_instance()) delete source_context_; } void Type::ArenaDtor(void* object) { @@ -471,21 +520,22 @@ void Type::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* Type::descriptor() { - protobuf_google_2fprotobuf_2ftype_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2ftype_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; + ::protobuf_google_2fprotobuf_2ftype_2eproto::protobuf_AssignDescriptorsOnce(); + return ::protobuf_google_2fprotobuf_2ftype_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const Type& Type::default_instance() { - protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaultsType(); return *internal_default_instance(); } -Type* Type::New(::google::protobuf::Arena* arena) const { - return ::google::protobuf::Arena::CreateMessage<Type>(arena); -} void Type::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.Type) + ::google::protobuf::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + fields_.Clear(); oneofs_.Clear(); options_.Clear(); @@ -495,6 +545,7 @@ void Type::Clear() { } source_context_ = NULL; syntax_ = 0; + _internal_metadata_.Clear(); } bool Type::MergePartialFromCodedStream( @@ -510,11 +561,11 @@ bool Type::MergePartialFromCodedStream( // string name = 1; case 1: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(10u)) { + static_cast< ::google::protobuf::uint8>(10u /* 10 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( - this->name().data(), this->name().length(), + this->name().data(), static_cast<int>(this->name().length()), ::google::protobuf::internal::WireFormatLite::PARSE, "google.protobuf.Type.name")); } else { @@ -526,8 +577,8 @@ bool Type::MergePartialFromCodedStream( // repeated .google.protobuf.Field fields = 2; case 2: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(18u)) { - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + static_cast< ::google::protobuf::uint8>(18u /* 18 & 0xFF */)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, add_fields())); } else { goto handle_unusual; @@ -538,12 +589,12 @@ bool Type::MergePartialFromCodedStream( // repeated string oneofs = 3; case 3: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(26u)) { + static_cast< ::google::protobuf::uint8>(26u /* 26 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->add_oneofs())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->oneofs(this->oneofs_size() - 1).data(), - this->oneofs(this->oneofs_size() - 1).length(), + static_cast<int>(this->oneofs(this->oneofs_size() - 1).length()), ::google::protobuf::internal::WireFormatLite::PARSE, "google.protobuf.Type.oneofs")); } else { @@ -555,8 +606,8 @@ bool Type::MergePartialFromCodedStream( // repeated .google.protobuf.Option options = 4; case 4: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(34u)) { - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + static_cast< ::google::protobuf::uint8>(34u /* 34 & 0xFF */)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, add_options())); } else { goto handle_unusual; @@ -567,8 +618,8 @@ bool Type::MergePartialFromCodedStream( // .google.protobuf.SourceContext source_context = 5; case 5: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(42u)) { - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + static_cast< ::google::protobuf::uint8>(42u /* 42 & 0xFF */)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, mutable_source_context())); } else { goto handle_unusual; @@ -579,7 +630,7 @@ bool Type::MergePartialFromCodedStream( // .google.protobuf.Syntax syntax = 6; case 6: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(48u)) { + static_cast< ::google::protobuf::uint8>(48u /* 48 & 0xFF */)) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -593,12 +644,11 @@ bool Type::MergePartialFromCodedStream( default: { handle_unusual: - if (tag == 0 || - ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + if (tag == 0) { goto success; } - DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag)); + DO_(::google::protobuf::internal::WireFormat::SkipField( + input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } @@ -621,7 +671,7 @@ void Type::SerializeWithCachedSizes( // string name = 1; if (this->name().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( - this->name().data(), this->name().length(), + this->name().data(), static_cast<int>(this->name().length()), ::google::protobuf::internal::WireFormatLite::SERIALIZE, "google.protobuf.Type.name"); ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( @@ -629,15 +679,18 @@ void Type::SerializeWithCachedSizes( } // repeated .google.protobuf.Field fields = 2; - for (unsigned int i = 0, n = this->fields_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->fields_size()); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 2, this->fields(i), output); + 2, + this->fields(static_cast<int>(i)), + output); } // repeated string oneofs = 3; for (int i = 0, n = this->oneofs_size(); i < n; i++) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( - this->oneofs(i).data(), this->oneofs(i).length(), + this->oneofs(i).data(), static_cast<int>(this->oneofs(i).length()), ::google::protobuf::internal::WireFormatLite::SERIALIZE, "google.protobuf.Type.oneofs"); ::google::protobuf::internal::WireFormatLite::WriteString( @@ -645,15 +698,18 @@ void Type::SerializeWithCachedSizes( } // repeated .google.protobuf.Option options = 4; - for (unsigned int i = 0, n = this->options_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->options_size()); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 4, this->options(i), output); + 4, + this->options(static_cast<int>(i)), + output); } // .google.protobuf.SourceContext source_context = 5; if (this->has_source_context()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 5, *this->source_context_, output); + 5, *source_context_, output); } // .google.protobuf.Syntax syntax = 6; @@ -662,11 +718,16 @@ void Type::SerializeWithCachedSizes( 6, this->syntax(), output); } + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + ::google::protobuf::internal::WireFormat::SerializeUnknownFields( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), output); + } // @@protoc_insertion_point(serialize_end:google.protobuf.Type) } ::google::protobuf::uint8* Type::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Type) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -674,7 +735,7 @@ void Type::SerializeWithCachedSizes( // string name = 1; if (this->name().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( - this->name().data(), this->name().length(), + this->name().data(), static_cast<int>(this->name().length()), ::google::protobuf::internal::WireFormatLite::SERIALIZE, "google.protobuf.Type.name"); target = @@ -683,16 +744,17 @@ void Type::SerializeWithCachedSizes( } // repeated .google.protobuf.Field fields = 2; - for (unsigned int i = 0, n = this->fields_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->fields_size()); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: - InternalWriteMessageNoVirtualToArray( - 2, this->fields(i), deterministic, target); + InternalWriteMessageToArray( + 2, this->fields(static_cast<int>(i)), deterministic, target); } // repeated string oneofs = 3; for (int i = 0, n = this->oneofs_size(); i < n; i++) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( - this->oneofs(i).data(), this->oneofs(i).length(), + this->oneofs(i).data(), static_cast<int>(this->oneofs(i).length()), ::google::protobuf::internal::WireFormatLite::SERIALIZE, "google.protobuf.Type.oneofs"); target = ::google::protobuf::internal::WireFormatLite:: @@ -700,17 +762,18 @@ void Type::SerializeWithCachedSizes( } // repeated .google.protobuf.Option options = 4; - for (unsigned int i = 0, n = this->options_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->options_size()); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: - InternalWriteMessageNoVirtualToArray( - 4, this->options(i), deterministic, target); + InternalWriteMessageToArray( + 4, this->options(static_cast<int>(i)), deterministic, target); } // .google.protobuf.SourceContext source_context = 5; if (this->has_source_context()) { target = ::google::protobuf::internal::WireFormatLite:: - InternalWriteMessageNoVirtualToArray( - 5, *this->source_context_, deterministic, target); + InternalWriteMessageToArray( + 5, *source_context_, deterministic, target); } // .google.protobuf.Syntax syntax = 6; @@ -719,6 +782,10 @@ void Type::SerializeWithCachedSizes( 6, this->syntax(), target); } + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), target); + } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Type) return target; } @@ -727,14 +794,19 @@ size_t Type::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Type) size_t total_size = 0; + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance())); + } // repeated .google.protobuf.Field fields = 2; { - unsigned int count = this->fields_size(); + unsigned int count = static_cast<unsigned int>(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)); + ::google::protobuf::internal::WireFormatLite::MessageSize( + this->fields(static_cast<int>(i))); } } @@ -748,12 +820,12 @@ size_t Type::ByteSizeLong() const { // repeated .google.protobuf.Option options = 4; { - unsigned int count = this->options_size(); + unsigned int count = static_cast<unsigned int>(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)); + ::google::protobuf::internal::WireFormatLite::MessageSize( + this->options(static_cast<int>(i))); } } @@ -767,8 +839,8 @@ size_t Type::ByteSizeLong() const { // .google.protobuf.SourceContext source_context = 5; if (this->has_source_context()) { total_size += 1 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - *this->source_context_); + ::google::protobuf::internal::WireFormatLite::MessageSize( + *source_context_); } // .google.protobuf.Syntax syntax = 6; @@ -858,288 +930,27 @@ void Type::UnsafeArenaSwap(Type* other) { InternalSwap(other); } void Type::InternalSwap(Type* other) { - fields_.InternalSwap(&other->fields_); - oneofs_.InternalSwap(&other->oneofs_); - options_.InternalSwap(&other->options_); + using std::swap; + CastToBase(&fields_)->InternalSwap(CastToBase(&other->fields_)); + oneofs_.InternalSwap(CastToBase(&other->oneofs_)); + CastToBase(&options_)->InternalSwap(CastToBase(&other->options_)); name_.Swap(&other->name_); - std::swap(source_context_, other->source_context_); - std::swap(syntax_, other->syntax_); - std::swap(_cached_size_, other->_cached_size_); + swap(source_context_, other->source_context_); + swap(syntax_, other->syntax_); + _internal_metadata_.Swap(&other->_internal_metadata_); + swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata Type::GetMetadata() const { protobuf_google_2fprotobuf_2ftype_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2ftype_2eproto::file_level_metadata[kIndexInFileMessages]; -} - -#if PROTOBUF_INLINE_NOT_IN_HEADERS -// Type - -// string name = 1; -void Type::clear_name() { - name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); -} -const ::std::string& Type::name() const { - // @@protoc_insertion_point(field_get:google.protobuf.Type.name) - return name_.Get(); -} -void Type::set_name(const ::std::string& 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) { - GOOGLE_DCHECK(value != NULL); - - 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) { - - name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( - reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.Type.name) -} -::std::string* Type::mutable_name() { - - // @@protoc_insertion_point(field_mutable:google.protobuf.Type.name) - return name_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); -} -::std::string* Type::release_name() { - // @@protoc_insertion_point(field_release:google.protobuf.Type.name) - - return name_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); -} -::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_.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 { - return fields_.size(); -} -void Type::clear_fields() { - fields_.Clear(); -} -const ::google::protobuf::Field& Type::fields(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.Type.fields) - return fields_.Get(index); -} -::google::protobuf::Field* Type::mutable_fields(int index) { - // @@protoc_insertion_point(field_mutable:google.protobuf.Type.fields) - return fields_.Mutable(index); -} -::google::protobuf::Field* Type::add_fields() { - // @@protoc_insertion_point(field_add:google.protobuf.Type.fields) - return fields_.Add(); -} -::google::protobuf::RepeatedPtrField< ::google::protobuf::Field >* -Type::mutable_fields() { - // @@protoc_insertion_point(field_mutable_list:google.protobuf.Type.fields) - return &fields_; -} -const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Field >& -Type::fields() const { - // @@protoc_insertion_point(field_list:google.protobuf.Type.fields) - return fields_; -} - -// repeated string oneofs = 3; -int Type::oneofs_size() const { - return oneofs_.size(); -} -void Type::clear_oneofs() { - oneofs_.Clear(); -} -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) { - // @@protoc_insertion_point(field_mutable:google.protobuf.Type.oneofs) - return oneofs_.Mutable(index); -} -void Type::set_oneofs(int index, const ::std::string& value) { - // @@protoc_insertion_point(field_set:google.protobuf.Type.oneofs) - oneofs_.Mutable(index)->assign(value); -} -#if LANG_CXX11 -void Type::set_oneofs(int index, ::std::string&& value) { - // @@protoc_insertion_point(field_set:google.protobuf.Type.oneofs) - oneofs_.Mutable(index)->assign(std::move(value)); -} -#endif -void Type::set_oneofs(int index, const char* value) { - GOOGLE_DCHECK(value != NULL); - 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) { - oneofs_.Mutable(index)->assign( - reinterpret_cast<const char*>(value), size); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.Type.oneofs) -} -::std::string* Type::add_oneofs() { - // @@protoc_insertion_point(field_add_mutable:google.protobuf.Type.oneofs) - return oneofs_.Add(); -} -void Type::add_oneofs(const ::std::string& value) { - oneofs_.Add()->assign(value); - // @@protoc_insertion_point(field_add:google.protobuf.Type.oneofs) -} -#if LANG_CXX11 -void Type::add_oneofs(::std::string&& value) { - oneofs_.Add(std::move(value)); - // @@protoc_insertion_point(field_add:google.protobuf.Type.oneofs) -} -#endif -void Type::add_oneofs(const char* value) { - GOOGLE_DCHECK(value != NULL); - oneofs_.Add()->assign(value); - // @@protoc_insertion_point(field_add_char:google.protobuf.Type.oneofs) -} -void Type::add_oneofs(const char* value, size_t size) { - oneofs_.Add()->assign(reinterpret_cast<const char*>(value), size); - // @@protoc_insertion_point(field_add_pointer:google.protobuf.Type.oneofs) -} -const ::google::protobuf::RepeatedPtrField< ::std::string>& -Type::oneofs() const { - // @@protoc_insertion_point(field_list:google.protobuf.Type.oneofs) - return oneofs_; -} -::google::protobuf::RepeatedPtrField< ::std::string>* -Type::mutable_oneofs() { - // @@protoc_insertion_point(field_mutable_list:google.protobuf.Type.oneofs) - return &oneofs_; -} - -// repeated .google.protobuf.Option options = 4; -int Type::options_size() const { - return options_.size(); -} -void Type::clear_options() { - options_.Clear(); -} -const ::google::protobuf::Option& Type::options(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.Type.options) - return options_.Get(index); -} -::google::protobuf::Option* Type::mutable_options(int index) { - // @@protoc_insertion_point(field_mutable:google.protobuf.Type.options) - return options_.Mutable(index); -} -::google::protobuf::Option* Type::add_options() { - // @@protoc_insertion_point(field_add:google.protobuf.Type.options) - return options_.Add(); -} -::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >* -Type::mutable_options() { - // @@protoc_insertion_point(field_mutable_list:google.protobuf.Type.options) - return &options_; -} -const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >& -Type::options() const { - // @@protoc_insertion_point(field_list:google.protobuf.Type.options) - return options_; -} - -// .google.protobuf.SourceContext source_context = 5; -bool Type::has_source_context() const { - return this != internal_default_instance() && source_context_ != NULL; -} -void Type::clear_source_context() { - if (GetArenaNoVirtual() == NULL && source_context_ != NULL) delete source_context_; - source_context_ = NULL; -} -const ::google::protobuf::SourceContext& Type::source_context() const { - // @@protoc_insertion_point(field_get:google.protobuf.Type.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) { - _slow_mutable_source_context(); - } - // @@protoc_insertion_point(field_mutable:google.protobuf.Type.source_context) - return source_context_; -} -::google::protobuf::SourceContext* Type::release_source_context() { - // @@protoc_insertion_point(field_release:google.protobuf.Type.source_context) - - 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) { - ::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) { - - } else { - - } - // @@protoc_insertion_point(field_set_allocated:google.protobuf.Type.source_context) -} - -// .google.protobuf.Syntax syntax = 6; -void Type::clear_syntax() { - syntax_ = 0; -} -::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) { - - syntax_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.Type.syntax) + return ::protobuf_google_2fprotobuf_2ftype_2eproto::file_level_metadata[kIndexInFileMessages]; } -#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== +void Field::InitAsDefaultInstance() { +} #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int Field::kKindFieldNumber; const int Field::kCardinalityFieldNumber; @@ -1156,7 +967,7 @@ const int Field::kDefaultValueFieldNumber; Field::Field() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { - protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaultsField(); } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Field) @@ -1165,9 +976,7 @@ Field::Field(::google::protobuf::Arena* arena) : ::google::protobuf::Message(), _internal_metadata_(arena), options_(arena) { -#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER - protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaults(); -#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + ::protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaultsField(); SharedCtor(); RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.Field) @@ -1199,8 +1008,8 @@ Field::Field(const Field& from) GetArenaNoVirtual()); } ::memcpy(&kind_, &from.kind_, - reinterpret_cast<char*>(&packed_) - - reinterpret_cast<char*>(&kind_) + sizeof(packed_)); + static_cast<size_t>(reinterpret_cast<char*>(&packed_) - + reinterpret_cast<char*>(&kind_)) + sizeof(packed_)); // @@protoc_insertion_point(copy_constructor:google.protobuf.Field) } @@ -1209,8 +1018,9 @@ void Field::SharedCtor() { type_url_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); json_name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); default_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - ::memset(&kind_, 0, reinterpret_cast<char*>(&packed_) - - reinterpret_cast<char*>(&kind_) + sizeof(packed_)); + ::memset(&kind_, 0, static_cast<size_t>( + reinterpret_cast<char*>(&packed_) - + reinterpret_cast<char*>(&kind_)) + sizeof(packed_)); _cached_size_ = 0; } @@ -1220,15 +1030,11 @@ Field::~Field() { } void Field::SharedDtor() { - ::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); + GOOGLE_DCHECK(GetArenaNoVirtual() == NULL); + 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()); } void Field::ArenaDtor(void* object) { @@ -1243,28 +1049,31 @@ void Field::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* Field::descriptor() { - protobuf_google_2fprotobuf_2ftype_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2ftype_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; + ::protobuf_google_2fprotobuf_2ftype_2eproto::protobuf_AssignDescriptorsOnce(); + return ::protobuf_google_2fprotobuf_2ftype_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const Field& Field::default_instance() { - protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaultsField(); return *internal_default_instance(); } -Field* Field::New(::google::protobuf::Arena* arena) const { - return ::google::protobuf::Arena::CreateMessage<Field>(arena); -} void Field::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.Field) + ::google::protobuf::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + options_.Clear(); name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); type_url_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); json_name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); default_value_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); - ::memset(&kind_, 0, reinterpret_cast<char*>(&packed_) - - reinterpret_cast<char*>(&kind_) + sizeof(packed_)); + ::memset(&kind_, 0, static_cast<size_t>( + reinterpret_cast<char*>(&packed_) - + reinterpret_cast<char*>(&kind_)) + sizeof(packed_)); + _internal_metadata_.Clear(); } bool Field::MergePartialFromCodedStream( @@ -1280,7 +1089,7 @@ bool Field::MergePartialFromCodedStream( // .google.protobuf.Field.Kind kind = 1; case 1: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(8u)) { + static_cast< ::google::protobuf::uint8>(8u /* 8 & 0xFF */)) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -1295,7 +1104,7 @@ bool Field::MergePartialFromCodedStream( // .google.protobuf.Field.Cardinality cardinality = 2; case 2: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(16u)) { + static_cast< ::google::protobuf::uint8>(16u /* 16 & 0xFF */)) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -1310,7 +1119,7 @@ bool Field::MergePartialFromCodedStream( // int32 number = 3; case 3: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(24u)) { + static_cast< ::google::protobuf::uint8>(24u /* 24 & 0xFF */)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -1324,11 +1133,11 @@ bool Field::MergePartialFromCodedStream( // string name = 4; case 4: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(34u)) { + static_cast< ::google::protobuf::uint8>(34u /* 34 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( - this->name().data(), this->name().length(), + this->name().data(), static_cast<int>(this->name().length()), ::google::protobuf::internal::WireFormatLite::PARSE, "google.protobuf.Field.name")); } else { @@ -1340,11 +1149,11 @@ bool Field::MergePartialFromCodedStream( // string type_url = 6; case 6: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(50u)) { + static_cast< ::google::protobuf::uint8>(50u /* 50 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_type_url())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( - this->type_url().data(), this->type_url().length(), + this->type_url().data(), static_cast<int>(this->type_url().length()), ::google::protobuf::internal::WireFormatLite::PARSE, "google.protobuf.Field.type_url")); } else { @@ -1356,7 +1165,7 @@ bool Field::MergePartialFromCodedStream( // int32 oneof_index = 7; case 7: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(56u)) { + static_cast< ::google::protobuf::uint8>(56u /* 56 & 0xFF */)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -1370,7 +1179,7 @@ bool Field::MergePartialFromCodedStream( // bool packed = 8; case 8: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(64u)) { + static_cast< ::google::protobuf::uint8>(64u /* 64 & 0xFF */)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -1384,8 +1193,8 @@ bool Field::MergePartialFromCodedStream( // repeated .google.protobuf.Option options = 9; case 9: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(74u)) { - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + static_cast< ::google::protobuf::uint8>(74u /* 74 & 0xFF */)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, add_options())); } else { goto handle_unusual; @@ -1396,11 +1205,11 @@ bool Field::MergePartialFromCodedStream( // string json_name = 10; case 10: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(82u)) { + static_cast< ::google::protobuf::uint8>(82u /* 82 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_json_name())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( - this->json_name().data(), this->json_name().length(), + this->json_name().data(), static_cast<int>(this->json_name().length()), ::google::protobuf::internal::WireFormatLite::PARSE, "google.protobuf.Field.json_name")); } else { @@ -1412,11 +1221,11 @@ bool Field::MergePartialFromCodedStream( // string default_value = 11; case 11: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(90u)) { + static_cast< ::google::protobuf::uint8>(90u /* 90 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_default_value())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( - this->default_value().data(), this->default_value().length(), + this->default_value().data(), static_cast<int>(this->default_value().length()), ::google::protobuf::internal::WireFormatLite::PARSE, "google.protobuf.Field.default_value")); } else { @@ -1427,12 +1236,11 @@ bool Field::MergePartialFromCodedStream( default: { handle_unusual: - if (tag == 0 || - ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + if (tag == 0) { goto success; } - DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag)); + DO_(::google::protobuf::internal::WireFormat::SkipField( + input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } @@ -1472,7 +1280,7 @@ void Field::SerializeWithCachedSizes( // string name = 4; if (this->name().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( - this->name().data(), this->name().length(), + this->name().data(), static_cast<int>(this->name().length()), ::google::protobuf::internal::WireFormatLite::SERIALIZE, "google.protobuf.Field.name"); ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( @@ -1482,7 +1290,7 @@ void Field::SerializeWithCachedSizes( // string type_url = 6; if (this->type_url().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( - this->type_url().data(), this->type_url().length(), + this->type_url().data(), static_cast<int>(this->type_url().length()), ::google::protobuf::internal::WireFormatLite::SERIALIZE, "google.protobuf.Field.type_url"); ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( @@ -1500,15 +1308,18 @@ void Field::SerializeWithCachedSizes( } // repeated .google.protobuf.Option options = 9; - for (unsigned int i = 0, n = this->options_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->options_size()); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 9, this->options(i), output); + 9, + this->options(static_cast<int>(i)), + output); } // string json_name = 10; if (this->json_name().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( - this->json_name().data(), this->json_name().length(), + this->json_name().data(), static_cast<int>(this->json_name().length()), ::google::protobuf::internal::WireFormatLite::SERIALIZE, "google.protobuf.Field.json_name"); ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( @@ -1518,18 +1329,23 @@ void Field::SerializeWithCachedSizes( // string default_value = 11; if (this->default_value().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( - this->default_value().data(), this->default_value().length(), + this->default_value().data(), static_cast<int>(this->default_value().length()), ::google::protobuf::internal::WireFormatLite::SERIALIZE, "google.protobuf.Field.default_value"); ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( 11, this->default_value(), output); } + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + ::google::protobuf::internal::WireFormat::SerializeUnknownFields( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), output); + } // @@protoc_insertion_point(serialize_end:google.protobuf.Field) } ::google::protobuf::uint8* Field::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Field) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -1554,7 +1370,7 @@ void Field::SerializeWithCachedSizes( // string name = 4; if (this->name().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( - this->name().data(), this->name().length(), + this->name().data(), static_cast<int>(this->name().length()), ::google::protobuf::internal::WireFormatLite::SERIALIZE, "google.protobuf.Field.name"); target = @@ -1565,7 +1381,7 @@ void Field::SerializeWithCachedSizes( // string type_url = 6; if (this->type_url().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( - this->type_url().data(), this->type_url().length(), + this->type_url().data(), static_cast<int>(this->type_url().length()), ::google::protobuf::internal::WireFormatLite::SERIALIZE, "google.protobuf.Field.type_url"); target = @@ -1584,16 +1400,17 @@ void Field::SerializeWithCachedSizes( } // repeated .google.protobuf.Option options = 9; - for (unsigned int i = 0, n = this->options_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->options_size()); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: - InternalWriteMessageNoVirtualToArray( - 9, this->options(i), deterministic, target); + InternalWriteMessageToArray( + 9, this->options(static_cast<int>(i)), deterministic, target); } // string json_name = 10; if (this->json_name().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( - this->json_name().data(), this->json_name().length(), + this->json_name().data(), static_cast<int>(this->json_name().length()), ::google::protobuf::internal::WireFormatLite::SERIALIZE, "google.protobuf.Field.json_name"); target = @@ -1604,7 +1421,7 @@ void Field::SerializeWithCachedSizes( // string default_value = 11; if (this->default_value().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( - this->default_value().data(), this->default_value().length(), + this->default_value().data(), static_cast<int>(this->default_value().length()), ::google::protobuf::internal::WireFormatLite::SERIALIZE, "google.protobuf.Field.default_value"); target = @@ -1612,6 +1429,10 @@ void Field::SerializeWithCachedSizes( 11, this->default_value(), target); } + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), target); + } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Field) return target; } @@ -1620,14 +1441,19 @@ size_t Field::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Field) size_t total_size = 0; + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance())); + } // repeated .google.protobuf.Option options = 9; { - unsigned int count = this->options_size(); + unsigned int count = static_cast<unsigned int>(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)); + ::google::protobuf::internal::WireFormatLite::MessageSize( + this->options(static_cast<int>(i))); } } @@ -1787,418 +1613,32 @@ void Field::UnsafeArenaSwap(Field* other) { InternalSwap(other); } void Field::InternalSwap(Field* other) { - options_.InternalSwap(&other->options_); + using std::swap; + CastToBase(&options_)->InternalSwap(CastToBase(&other->options_)); name_.Swap(&other->name_); type_url_.Swap(&other->type_url_); json_name_.Swap(&other->json_name_); default_value_.Swap(&other->default_value_); - std::swap(kind_, other->kind_); - std::swap(cardinality_, other->cardinality_); - std::swap(number_, other->number_); - std::swap(oneof_index_, other->oneof_index_); - std::swap(packed_, other->packed_); - std::swap(_cached_size_, other->_cached_size_); + swap(kind_, other->kind_); + swap(cardinality_, other->cardinality_); + swap(number_, other->number_); + swap(oneof_index_, other->oneof_index_); + swap(packed_, other->packed_); + _internal_metadata_.Swap(&other->_internal_metadata_); + swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata Field::GetMetadata() const { protobuf_google_2fprotobuf_2ftype_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2ftype_2eproto::file_level_metadata[kIndexInFileMessages]; -} - -#if PROTOBUF_INLINE_NOT_IN_HEADERS -// Field - -// .google.protobuf.Field.Kind kind = 1; -void Field::clear_kind() { - kind_ = 0; -} -::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) { - - kind_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.Field.kind) -} - -// .google.protobuf.Field.Cardinality cardinality = 2; -void Field::clear_cardinality() { - cardinality_ = 0; -} -::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) { - - cardinality_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.Field.cardinality) -} - -// int32 number = 3; -void Field::clear_number() { - number_ = 0; -} -::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) { - - number_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.Field.number) -} - -// string name = 4; -void Field::clear_name() { - name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); -} -const ::std::string& Field::name() const { - // @@protoc_insertion_point(field_get:google.protobuf.Field.name) - return name_.Get(); -} -void Field::set_name(const ::std::string& 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) { - GOOGLE_DCHECK(value != NULL); - - 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) { - - name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( - reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.Field.name) -} -::std::string* Field::mutable_name() { - - // @@protoc_insertion_point(field_mutable:google.protobuf.Field.name) - return name_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); -} -::std::string* Field::release_name() { - // @@protoc_insertion_point(field_release:google.protobuf.Field.name) - - return name_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); -} -::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_.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) -} - -// string type_url = 6; -void Field::clear_type_url() { - type_url_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); -} -const ::std::string& Field::type_url() const { - // @@protoc_insertion_point(field_get:google.protobuf.Field.type_url) - return type_url_.Get(); -} -void Field::set_type_url(const ::std::string& 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) { - GOOGLE_DCHECK(value != NULL); - - 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) { - - type_url_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( - reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.Field.type_url) -} -::std::string* Field::mutable_type_url() { - - // @@protoc_insertion_point(field_mutable:google.protobuf.Field.type_url) - return type_url_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); -} -::std::string* Field::release_type_url() { - // @@protoc_insertion_point(field_release:google.protobuf.Field.type_url) - - return type_url_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); -} -::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_.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) -} - -// int32 oneof_index = 7; -void Field::clear_oneof_index() { - oneof_index_ = 0; -} -::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) { - - oneof_index_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.Field.oneof_index) + return ::protobuf_google_2fprotobuf_2ftype_2eproto::file_level_metadata[kIndexInFileMessages]; } -// bool packed = 8; -void Field::clear_packed() { - packed_ = false; -} -bool Field::packed() const { - // @@protoc_insertion_point(field_get:google.protobuf.Field.packed) - return packed_; -} -void Field::set_packed(bool value) { - - packed_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.Field.packed) -} - -// repeated .google.protobuf.Option options = 9; -int Field::options_size() const { - return options_.size(); -} -void Field::clear_options() { - options_.Clear(); -} -const ::google::protobuf::Option& Field::options(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.Field.options) - return options_.Get(index); -} -::google::protobuf::Option* Field::mutable_options(int index) { - // @@protoc_insertion_point(field_mutable:google.protobuf.Field.options) - return options_.Mutable(index); -} -::google::protobuf::Option* Field::add_options() { - // @@protoc_insertion_point(field_add:google.protobuf.Field.options) - return options_.Add(); -} -::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >* -Field::mutable_options() { - // @@protoc_insertion_point(field_mutable_list:google.protobuf.Field.options) - return &options_; -} -const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >& -Field::options() const { - // @@protoc_insertion_point(field_list:google.protobuf.Field.options) - return options_; -} - -// string json_name = 10; -void Field::clear_json_name() { - json_name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); -} -const ::std::string& Field::json_name() const { - // @@protoc_insertion_point(field_get:google.protobuf.Field.json_name) - return json_name_.Get(); -} -void Field::set_json_name(const ::std::string& 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) { - GOOGLE_DCHECK(value != NULL); - - 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) { - - json_name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( - reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.Field.json_name) -} -::std::string* Field::mutable_json_name() { - - // @@protoc_insertion_point(field_mutable:google.protobuf.Field.json_name) - return json_name_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); -} -::std::string* Field::release_json_name() { - // @@protoc_insertion_point(field_release:google.protobuf.Field.json_name) - - 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) { - if (json_name != NULL) { - - } else { - - } - 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) -} - -// string default_value = 11; -void Field::clear_default_value() { - default_value_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); -} -const ::std::string& Field::default_value() const { - // @@protoc_insertion_point(field_get:google.protobuf.Field.default_value) - return default_value_.Get(); -} -void Field::set_default_value(const ::std::string& 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) { - GOOGLE_DCHECK(value != NULL); - - 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) { - - default_value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( - reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.Field.default_value) -} -::std::string* Field::mutable_default_value() { - - // @@protoc_insertion_point(field_mutable:google.protobuf.Field.default_value) - return default_value_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); -} -::std::string* Field::release_default_value() { - // @@protoc_insertion_point(field_release:google.protobuf.Field.default_value) - - 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) { - if (default_value != NULL) { - - } else { - - } - 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::InitAsDefaultInstance() { + ::google::protobuf::_Enum_default_instance_._instance.get_mutable()->source_context_ = const_cast< ::google::protobuf::SourceContext*>( + ::google::protobuf::SourceContext::internal_default_instance()); } void Enum::unsafe_arena_set_allocated_source_context( ::google::protobuf::SourceContext* source_context) { @@ -2213,6 +1653,12 @@ void Enum::unsafe_arena_set_allocated_source_context( } // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Enum.source_context) } +void Enum::clear_source_context() { + if (GetArenaNoVirtual() == NULL && source_context_ != NULL) { + delete source_context_; + } + source_context_ = NULL; +} #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int Enum::kNameFieldNumber; const int Enum::kEnumvalueFieldNumber; @@ -2224,7 +1670,7 @@ const int Enum::kSyntaxFieldNumber; Enum::Enum() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { - protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaultsEnum(); } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Enum) @@ -2234,9 +1680,7 @@ Enum::Enum(::google::protobuf::Arena* arena) _internal_metadata_(arena), enumvalue_(arena), options_(arena) { -#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER - protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaults(); -#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + ::protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaultsEnum(); SharedCtor(); RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.Enum) @@ -2264,8 +1708,9 @@ Enum::Enum(const Enum& from) void Enum::SharedCtor() { name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - ::memset(&source_context_, 0, reinterpret_cast<char*>(&syntax_) - - reinterpret_cast<char*>(&source_context_) + sizeof(syntax_)); + ::memset(&source_context_, 0, static_cast<size_t>( + reinterpret_cast<char*>(&syntax_) - + reinterpret_cast<char*>(&source_context_)) + sizeof(syntax_)); _cached_size_ = 0; } @@ -2275,15 +1720,9 @@ Enum::~Enum() { } void Enum::SharedDtor() { - ::google::protobuf::Arena* arena = GetArenaNoVirtual(); - if (arena != NULL) { - return; - } - - name_.Destroy(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), arena); - if (this != internal_default_instance()) { - delete source_context_; - } + GOOGLE_DCHECK(GetArenaNoVirtual() == NULL); + name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (this != internal_default_instance()) delete source_context_; } void Enum::ArenaDtor(void* object) { @@ -2298,21 +1737,22 @@ void Enum::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* Enum::descriptor() { - protobuf_google_2fprotobuf_2ftype_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2ftype_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; + ::protobuf_google_2fprotobuf_2ftype_2eproto::protobuf_AssignDescriptorsOnce(); + return ::protobuf_google_2fprotobuf_2ftype_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const Enum& Enum::default_instance() { - protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaultsEnum(); return *internal_default_instance(); } -Enum* Enum::New(::google::protobuf::Arena* arena) const { - return ::google::protobuf::Arena::CreateMessage<Enum>(arena); -} void Enum::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.Enum) + ::google::protobuf::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + enumvalue_.Clear(); options_.Clear(); name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); @@ -2321,6 +1761,7 @@ void Enum::Clear() { } source_context_ = NULL; syntax_ = 0; + _internal_metadata_.Clear(); } bool Enum::MergePartialFromCodedStream( @@ -2336,11 +1777,11 @@ bool Enum::MergePartialFromCodedStream( // string name = 1; case 1: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(10u)) { + static_cast< ::google::protobuf::uint8>(10u /* 10 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( - this->name().data(), this->name().length(), + this->name().data(), static_cast<int>(this->name().length()), ::google::protobuf::internal::WireFormatLite::PARSE, "google.protobuf.Enum.name")); } else { @@ -2352,8 +1793,8 @@ bool Enum::MergePartialFromCodedStream( // repeated .google.protobuf.EnumValue enumvalue = 2; case 2: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(18u)) { - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + static_cast< ::google::protobuf::uint8>(18u /* 18 & 0xFF */)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, add_enumvalue())); } else { goto handle_unusual; @@ -2364,8 +1805,8 @@ bool Enum::MergePartialFromCodedStream( // repeated .google.protobuf.Option options = 3; case 3: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(26u)) { - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + static_cast< ::google::protobuf::uint8>(26u /* 26 & 0xFF */)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, add_options())); } else { goto handle_unusual; @@ -2376,8 +1817,8 @@ bool Enum::MergePartialFromCodedStream( // .google.protobuf.SourceContext source_context = 4; case 4: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(34u)) { - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + static_cast< ::google::protobuf::uint8>(34u /* 34 & 0xFF */)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, mutable_source_context())); } else { goto handle_unusual; @@ -2388,7 +1829,7 @@ bool Enum::MergePartialFromCodedStream( // .google.protobuf.Syntax syntax = 5; case 5: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(40u)) { + static_cast< ::google::protobuf::uint8>(40u /* 40 & 0xFF */)) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -2402,12 +1843,11 @@ bool Enum::MergePartialFromCodedStream( default: { handle_unusual: - if (tag == 0 || - ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + if (tag == 0) { goto success; } - DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag)); + DO_(::google::protobuf::internal::WireFormat::SkipField( + input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } @@ -2430,7 +1870,7 @@ void Enum::SerializeWithCachedSizes( // string name = 1; if (this->name().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( - this->name().data(), this->name().length(), + this->name().data(), static_cast<int>(this->name().length()), ::google::protobuf::internal::WireFormatLite::SERIALIZE, "google.protobuf.Enum.name"); ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( @@ -2438,21 +1878,27 @@ void Enum::SerializeWithCachedSizes( } // repeated .google.protobuf.EnumValue enumvalue = 2; - for (unsigned int i = 0, n = this->enumvalue_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->enumvalue_size()); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 2, this->enumvalue(i), output); + 2, + this->enumvalue(static_cast<int>(i)), + output); } // repeated .google.protobuf.Option options = 3; - for (unsigned int i = 0, n = this->options_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->options_size()); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 3, this->options(i), output); + 3, + this->options(static_cast<int>(i)), + output); } // .google.protobuf.SourceContext source_context = 4; if (this->has_source_context()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 4, *this->source_context_, output); + 4, *source_context_, output); } // .google.protobuf.Syntax syntax = 5; @@ -2461,11 +1907,16 @@ void Enum::SerializeWithCachedSizes( 5, this->syntax(), output); } + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + ::google::protobuf::internal::WireFormat::SerializeUnknownFields( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), output); + } // @@protoc_insertion_point(serialize_end:google.protobuf.Enum) } ::google::protobuf::uint8* Enum::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Enum) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -2473,7 +1924,7 @@ void Enum::SerializeWithCachedSizes( // string name = 1; if (this->name().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( - this->name().data(), this->name().length(), + this->name().data(), static_cast<int>(this->name().length()), ::google::protobuf::internal::WireFormatLite::SERIALIZE, "google.protobuf.Enum.name"); target = @@ -2482,24 +1933,26 @@ void Enum::SerializeWithCachedSizes( } // repeated .google.protobuf.EnumValue enumvalue = 2; - for (unsigned int i = 0, n = this->enumvalue_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->enumvalue_size()); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: - InternalWriteMessageNoVirtualToArray( - 2, this->enumvalue(i), deterministic, target); + InternalWriteMessageToArray( + 2, this->enumvalue(static_cast<int>(i)), deterministic, target); } // repeated .google.protobuf.Option options = 3; - for (unsigned int i = 0, n = this->options_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->options_size()); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: - InternalWriteMessageNoVirtualToArray( - 3, this->options(i), deterministic, target); + InternalWriteMessageToArray( + 3, this->options(static_cast<int>(i)), deterministic, target); } // .google.protobuf.SourceContext source_context = 4; if (this->has_source_context()) { target = ::google::protobuf::internal::WireFormatLite:: - InternalWriteMessageNoVirtualToArray( - 4, *this->source_context_, deterministic, target); + InternalWriteMessageToArray( + 4, *source_context_, deterministic, target); } // .google.protobuf.Syntax syntax = 5; @@ -2508,6 +1961,10 @@ void Enum::SerializeWithCachedSizes( 5, this->syntax(), target); } + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), target); + } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Enum) return target; } @@ -2516,25 +1973,30 @@ size_t Enum::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Enum) size_t total_size = 0; + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance())); + } // repeated .google.protobuf.EnumValue enumvalue = 2; { - unsigned int count = this->enumvalue_size(); + unsigned int count = static_cast<unsigned int>(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)); + ::google::protobuf::internal::WireFormatLite::MessageSize( + this->enumvalue(static_cast<int>(i))); } } // repeated .google.protobuf.Option options = 3; { - unsigned int count = this->options_size(); + unsigned int count = static_cast<unsigned int>(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)); + ::google::protobuf::internal::WireFormatLite::MessageSize( + this->options(static_cast<int>(i))); } } @@ -2548,8 +2010,8 @@ size_t Enum::ByteSizeLong() const { // .google.protobuf.SourceContext source_context = 4; if (this->has_source_context()) { total_size += 1 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - *this->source_context_); + ::google::protobuf::internal::WireFormatLite::MessageSize( + *source_context_); } // .google.protobuf.Syntax syntax = 5; @@ -2638,218 +2100,26 @@ void Enum::UnsafeArenaSwap(Enum* other) { InternalSwap(other); } void Enum::InternalSwap(Enum* other) { - enumvalue_.InternalSwap(&other->enumvalue_); - options_.InternalSwap(&other->options_); + using std::swap; + CastToBase(&enumvalue_)->InternalSwap(CastToBase(&other->enumvalue_)); + CastToBase(&options_)->InternalSwap(CastToBase(&other->options_)); name_.Swap(&other->name_); - std::swap(source_context_, other->source_context_); - std::swap(syntax_, other->syntax_); - std::swap(_cached_size_, other->_cached_size_); + swap(source_context_, other->source_context_); + swap(syntax_, other->syntax_); + _internal_metadata_.Swap(&other->_internal_metadata_); + swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata Enum::GetMetadata() const { protobuf_google_2fprotobuf_2ftype_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2ftype_2eproto::file_level_metadata[kIndexInFileMessages]; -} - -#if PROTOBUF_INLINE_NOT_IN_HEADERS -// Enum - -// string name = 1; -void Enum::clear_name() { - name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); -} -const ::std::string& Enum::name() const { - // @@protoc_insertion_point(field_get:google.protobuf.Enum.name) - return name_.Get(); -} -void Enum::set_name(const ::std::string& 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) { - GOOGLE_DCHECK(value != NULL); - - 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) { - - name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( - reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.Enum.name) -} -::std::string* Enum::mutable_name() { - - // @@protoc_insertion_point(field_mutable:google.protobuf.Enum.name) - return name_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); -} -::std::string* Enum::release_name() { - // @@protoc_insertion_point(field_release:google.protobuf.Enum.name) - - 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) { - if (name != NULL) { - - } else { - - } - 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 { - return enumvalue_.size(); -} -void Enum::clear_enumvalue() { - enumvalue_.Clear(); -} -const ::google::protobuf::EnumValue& Enum::enumvalue(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.Enum.enumvalue) - return enumvalue_.Get(index); -} -::google::protobuf::EnumValue* Enum::mutable_enumvalue(int index) { - // @@protoc_insertion_point(field_mutable:google.protobuf.Enum.enumvalue) - return enumvalue_.Mutable(index); -} -::google::protobuf::EnumValue* Enum::add_enumvalue() { - // @@protoc_insertion_point(field_add:google.protobuf.Enum.enumvalue) - return enumvalue_.Add(); -} -::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumValue >* -Enum::mutable_enumvalue() { - // @@protoc_insertion_point(field_mutable_list:google.protobuf.Enum.enumvalue) - return &enumvalue_; -} -const ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumValue >& -Enum::enumvalue() const { - // @@protoc_insertion_point(field_list:google.protobuf.Enum.enumvalue) - return enumvalue_; -} - -// repeated .google.protobuf.Option options = 3; -int Enum::options_size() const { - return options_.size(); -} -void Enum::clear_options() { - options_.Clear(); -} -const ::google::protobuf::Option& Enum::options(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.Enum.options) - return options_.Get(index); -} -::google::protobuf::Option* Enum::mutable_options(int index) { - // @@protoc_insertion_point(field_mutable:google.protobuf.Enum.options) - return options_.Mutable(index); -} -::google::protobuf::Option* Enum::add_options() { - // @@protoc_insertion_point(field_add:google.protobuf.Enum.options) - return options_.Add(); -} -::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >* -Enum::mutable_options() { - // @@protoc_insertion_point(field_mutable_list:google.protobuf.Enum.options) - return &options_; -} -const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >& -Enum::options() const { - // @@protoc_insertion_point(field_list:google.protobuf.Enum.options) - return options_; -} - -// .google.protobuf.SourceContext source_context = 4; -bool Enum::has_source_context() const { - return this != internal_default_instance() && source_context_ != NULL; -} -void Enum::clear_source_context() { - if (GetArenaNoVirtual() == NULL && source_context_ != NULL) delete source_context_; - source_context_ = NULL; -} -const ::google::protobuf::SourceContext& Enum::source_context() const { - // @@protoc_insertion_point(field_get:google.protobuf.Enum.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) { - _slow_mutable_source_context(); - } - // @@protoc_insertion_point(field_mutable:google.protobuf.Enum.source_context) - return source_context_; -} -::google::protobuf::SourceContext* Enum::release_source_context() { - // @@protoc_insertion_point(field_release:google.protobuf.Enum.source_context) - - 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) { - ::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) { - - } else { - - } - // @@protoc_insertion_point(field_set_allocated:google.protobuf.Enum.source_context) -} - -// .google.protobuf.Syntax syntax = 5; -void Enum::clear_syntax() { - syntax_ = 0; -} -::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) { - - syntax_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.Enum.syntax) + return ::protobuf_google_2fprotobuf_2ftype_2eproto::file_level_metadata[kIndexInFileMessages]; } -#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== +void EnumValue::InitAsDefaultInstance() { +} #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int EnumValue::kNameFieldNumber; const int EnumValue::kNumberFieldNumber; @@ -2859,7 +2129,7 @@ const int EnumValue::kOptionsFieldNumber; EnumValue::EnumValue() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { - protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaultsEnumValue(); } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.EnumValue) @@ -2868,9 +2138,7 @@ EnumValue::EnumValue(::google::protobuf::Arena* arena) : ::google::protobuf::Message(), _internal_metadata_(arena), options_(arena) { -#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER - protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaults(); -#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + ::protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaultsEnumValue(); SharedCtor(); RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.EnumValue) @@ -2902,12 +2170,8 @@ EnumValue::~EnumValue() { } void EnumValue::SharedDtor() { - ::google::protobuf::Arena* arena = GetArenaNoVirtual(); - if (arena != NULL) { - return; - } - - name_.Destroy(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), arena); + GOOGLE_DCHECK(GetArenaNoVirtual() == NULL); + name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } void EnumValue::ArenaDtor(void* object) { @@ -2922,24 +2186,26 @@ void EnumValue::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* EnumValue::descriptor() { - protobuf_google_2fprotobuf_2ftype_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2ftype_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; + ::protobuf_google_2fprotobuf_2ftype_2eproto::protobuf_AssignDescriptorsOnce(); + return ::protobuf_google_2fprotobuf_2ftype_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const EnumValue& EnumValue::default_instance() { - protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaultsEnumValue(); return *internal_default_instance(); } -EnumValue* EnumValue::New(::google::protobuf::Arena* arena) const { - return ::google::protobuf::Arena::CreateMessage<EnumValue>(arena); -} void EnumValue::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.EnumValue) + ::google::protobuf::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + options_.Clear(); name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); number_ = 0; + _internal_metadata_.Clear(); } bool EnumValue::MergePartialFromCodedStream( @@ -2955,11 +2221,11 @@ bool EnumValue::MergePartialFromCodedStream( // string name = 1; case 1: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(10u)) { + static_cast< ::google::protobuf::uint8>(10u /* 10 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( - this->name().data(), this->name().length(), + this->name().data(), static_cast<int>(this->name().length()), ::google::protobuf::internal::WireFormatLite::PARSE, "google.protobuf.EnumValue.name")); } else { @@ -2971,7 +2237,7 @@ bool EnumValue::MergePartialFromCodedStream( // int32 number = 2; case 2: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(16u)) { + static_cast< ::google::protobuf::uint8>(16u /* 16 & 0xFF */)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -2985,8 +2251,8 @@ bool EnumValue::MergePartialFromCodedStream( // repeated .google.protobuf.Option options = 3; case 3: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(26u)) { - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + static_cast< ::google::protobuf::uint8>(26u /* 26 & 0xFF */)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, add_options())); } else { goto handle_unusual; @@ -2996,12 +2262,11 @@ bool EnumValue::MergePartialFromCodedStream( default: { handle_unusual: - if (tag == 0 || - ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + if (tag == 0) { goto success; } - DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag)); + DO_(::google::protobuf::internal::WireFormat::SkipField( + input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } @@ -3024,7 +2289,7 @@ void EnumValue::SerializeWithCachedSizes( // string name = 1; if (this->name().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( - this->name().data(), this->name().length(), + this->name().data(), static_cast<int>(this->name().length()), ::google::protobuf::internal::WireFormatLite::SERIALIZE, "google.protobuf.EnumValue.name"); ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( @@ -3037,16 +2302,24 @@ void EnumValue::SerializeWithCachedSizes( } // repeated .google.protobuf.Option options = 3; - for (unsigned int i = 0, n = this->options_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->options_size()); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 3, this->options(i), output); + 3, + this->options(static_cast<int>(i)), + output); } + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + ::google::protobuf::internal::WireFormat::SerializeUnknownFields( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), output); + } // @@protoc_insertion_point(serialize_end:google.protobuf.EnumValue) } ::google::protobuf::uint8* EnumValue::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.EnumValue) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -3054,7 +2327,7 @@ void EnumValue::SerializeWithCachedSizes( // string name = 1; if (this->name().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( - this->name().data(), this->name().length(), + this->name().data(), static_cast<int>(this->name().length()), ::google::protobuf::internal::WireFormatLite::SERIALIZE, "google.protobuf.EnumValue.name"); target = @@ -3068,12 +2341,17 @@ void EnumValue::SerializeWithCachedSizes( } // repeated .google.protobuf.Option options = 3; - for (unsigned int i = 0, n = this->options_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast<unsigned int>(this->options_size()); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: - InternalWriteMessageNoVirtualToArray( - 3, this->options(i), deterministic, target); + InternalWriteMessageToArray( + 3, this->options(static_cast<int>(i)), deterministic, target); } + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), target); + } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.EnumValue) return target; } @@ -3082,14 +2360,19 @@ size_t EnumValue::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.EnumValue) size_t total_size = 0; + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance())); + } // repeated .google.protobuf.Option options = 3; { - unsigned int count = this->options_size(); + unsigned int count = static_cast<unsigned int>(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)); + ::google::protobuf::internal::WireFormatLite::MessageSize( + this->options(static_cast<int>(i))); } } @@ -3183,154 +2466,25 @@ void EnumValue::UnsafeArenaSwap(EnumValue* other) { InternalSwap(other); } void EnumValue::InternalSwap(EnumValue* other) { - options_.InternalSwap(&other->options_); + using std::swap; + CastToBase(&options_)->InternalSwap(CastToBase(&other->options_)); name_.Swap(&other->name_); - std::swap(number_, other->number_); - std::swap(_cached_size_, other->_cached_size_); + swap(number_, other->number_); + _internal_metadata_.Swap(&other->_internal_metadata_); + swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata EnumValue::GetMetadata() const { protobuf_google_2fprotobuf_2ftype_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2ftype_2eproto::file_level_metadata[kIndexInFileMessages]; + return ::protobuf_google_2fprotobuf_2ftype_2eproto::file_level_metadata[kIndexInFileMessages]; } -#if PROTOBUF_INLINE_NOT_IN_HEADERS -// EnumValue - -// string name = 1; -void EnumValue::clear_name() { - name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); -} -const ::std::string& EnumValue::name() const { - // @@protoc_insertion_point(field_get:google.protobuf.EnumValue.name) - return name_.Get(); -} -void EnumValue::set_name(const ::std::string& 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) { - GOOGLE_DCHECK(value != NULL); - - 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) { - - name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( - reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.EnumValue.name) -} -::std::string* EnumValue::mutable_name() { - - // @@protoc_insertion_point(field_mutable:google.protobuf.EnumValue.name) - return name_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); -} -::std::string* EnumValue::release_name() { - // @@protoc_insertion_point(field_release:google.protobuf.EnumValue.name) - - return name_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); -} -::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_.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) -} - -// int32 number = 2; -void EnumValue::clear_number() { - number_ = 0; -} -::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) { - - number_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.EnumValue.number) -} - -// repeated .google.protobuf.Option options = 3; -int EnumValue::options_size() const { - return options_.size(); -} -void EnumValue::clear_options() { - options_.Clear(); -} -const ::google::protobuf::Option& EnumValue::options(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.EnumValue.options) - return options_.Get(index); -} -::google::protobuf::Option* EnumValue::mutable_options(int index) { - // @@protoc_insertion_point(field_mutable:google.protobuf.EnumValue.options) - return options_.Mutable(index); -} -::google::protobuf::Option* EnumValue::add_options() { - // @@protoc_insertion_point(field_add:google.protobuf.EnumValue.options) - return options_.Add(); -} -::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >* -EnumValue::mutable_options() { - // @@protoc_insertion_point(field_mutable_list:google.protobuf.EnumValue.options) - return &options_; -} -const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >& -EnumValue::options() const { - // @@protoc_insertion_point(field_list:google.protobuf.EnumValue.options) - return options_; -} - -#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== -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::InitAsDefaultInstance() { + ::google::protobuf::_Option_default_instance_._instance.get_mutable()->value_ = const_cast< ::google::protobuf::Any*>( + ::google::protobuf::Any::internal_default_instance()); } void Option::unsafe_arena_set_allocated_value( ::google::protobuf::Any* value) { @@ -3345,6 +2499,12 @@ void Option::unsafe_arena_set_allocated_value( } // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Option.value) } +void Option::clear_value() { + if (GetArenaNoVirtual() == NULL && value_ != NULL) { + delete value_; + } + value_ = NULL; +} #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int Option::kNameFieldNumber; const int Option::kValueFieldNumber; @@ -3353,7 +2513,7 @@ const int Option::kValueFieldNumber; Option::Option() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { - protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaultsOption(); } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Option) @@ -3361,9 +2521,7 @@ Option::Option() Option::Option(::google::protobuf::Arena* arena) : ::google::protobuf::Message(), _internal_metadata_(arena) { -#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER - protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaults(); -#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + ::protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaultsOption(); SharedCtor(); RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.Option) @@ -3398,15 +2556,9 @@ Option::~Option() { } void Option::SharedDtor() { - ::google::protobuf::Arena* arena = GetArenaNoVirtual(); - if (arena != NULL) { - return; - } - - name_.Destroy(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), arena); - if (this != internal_default_instance()) { - delete value_; - } + GOOGLE_DCHECK(GetArenaNoVirtual() == NULL); + name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (this != internal_default_instance()) delete value_; } void Option::ArenaDtor(void* object) { @@ -3421,26 +2573,28 @@ void Option::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* Option::descriptor() { - protobuf_google_2fprotobuf_2ftype_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2ftype_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; + ::protobuf_google_2fprotobuf_2ftype_2eproto::protobuf_AssignDescriptorsOnce(); + return ::protobuf_google_2fprotobuf_2ftype_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const Option& Option::default_instance() { - protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaultsOption(); return *internal_default_instance(); } -Option* Option::New(::google::protobuf::Arena* arena) const { - return ::google::protobuf::Arena::CreateMessage<Option>(arena); -} void Option::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.Option) + ::google::protobuf::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); if (GetArenaNoVirtual() == NULL && value_ != NULL) { delete value_; } value_ = NULL; + _internal_metadata_.Clear(); } bool Option::MergePartialFromCodedStream( @@ -3456,11 +2610,11 @@ bool Option::MergePartialFromCodedStream( // string name = 1; case 1: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(10u)) { + static_cast< ::google::protobuf::uint8>(10u /* 10 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( - this->name().data(), this->name().length(), + this->name().data(), static_cast<int>(this->name().length()), ::google::protobuf::internal::WireFormatLite::PARSE, "google.protobuf.Option.name")); } else { @@ -3472,8 +2626,8 @@ bool Option::MergePartialFromCodedStream( // .google.protobuf.Any value = 2; case 2: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(18u)) { - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + static_cast< ::google::protobuf::uint8>(18u /* 18 & 0xFF */)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, mutable_value())); } else { goto handle_unusual; @@ -3483,12 +2637,11 @@ bool Option::MergePartialFromCodedStream( default: { handle_unusual: - if (tag == 0 || - ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + if (tag == 0) { goto success; } - DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag)); + DO_(::google::protobuf::internal::WireFormat::SkipField( + input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } @@ -3511,7 +2664,7 @@ void Option::SerializeWithCachedSizes( // string name = 1; if (this->name().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( - this->name().data(), this->name().length(), + this->name().data(), static_cast<int>(this->name().length()), ::google::protobuf::internal::WireFormatLite::SERIALIZE, "google.protobuf.Option.name"); ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( @@ -3521,14 +2674,19 @@ void Option::SerializeWithCachedSizes( // .google.protobuf.Any value = 2; if (this->has_value()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 2, *this->value_, output); + 2, *value_, output); } + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + ::google::protobuf::internal::WireFormat::SerializeUnknownFields( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), output); + } // @@protoc_insertion_point(serialize_end:google.protobuf.Option) } ::google::protobuf::uint8* Option::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Option) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -3536,7 +2694,7 @@ void Option::SerializeWithCachedSizes( // string name = 1; if (this->name().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( - this->name().data(), this->name().length(), + this->name().data(), static_cast<int>(this->name().length()), ::google::protobuf::internal::WireFormatLite::SERIALIZE, "google.protobuf.Option.name"); target = @@ -3547,10 +2705,14 @@ void Option::SerializeWithCachedSizes( // .google.protobuf.Any value = 2; if (this->has_value()) { target = ::google::protobuf::internal::WireFormatLite:: - InternalWriteMessageNoVirtualToArray( - 2, *this->value_, deterministic, target); + InternalWriteMessageToArray( + 2, *value_, deterministic, target); } + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), target); + } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Option) return target; } @@ -3559,6 +2721,11 @@ size_t Option::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Option) size_t total_size = 0; + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance())); + } // string name = 1; if (this->name().size() > 0) { total_size += 1 + @@ -3569,8 +2736,8 @@ size_t Option::ByteSizeLong() const { // .google.protobuf.Any value = 2; if (this->has_value()) { total_size += 1 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - *this->value_); + ::google::protobuf::internal::WireFormatLite::MessageSize( + *value_); } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); @@ -3648,141 +2815,39 @@ void Option::UnsafeArenaSwap(Option* other) { InternalSwap(other); } void Option::InternalSwap(Option* other) { + using std::swap; name_.Swap(&other->name_); - std::swap(value_, other->value_); - std::swap(_cached_size_, other->_cached_size_); + swap(value_, other->value_); + _internal_metadata_.Swap(&other->_internal_metadata_); + swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata Option::GetMetadata() const { protobuf_google_2fprotobuf_2ftype_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2ftype_2eproto::file_level_metadata[kIndexInFileMessages]; + return ::protobuf_google_2fprotobuf_2ftype_2eproto::file_level_metadata[kIndexInFileMessages]; } -#if PROTOBUF_INLINE_NOT_IN_HEADERS -// Option -// string name = 1; -void Option::clear_name() { - name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); -} -const ::std::string& Option::name() const { - // @@protoc_insertion_point(field_get:google.protobuf.Option.name) - return name_.Get(); -} -void Option::set_name(const ::std::string& value) { - - name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); - // @@protoc_insertion_point(field_set:google.protobuf.Option.name) -} -void Option::set_name(const char* value) { - GOOGLE_DCHECK(value != NULL); - - name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), - GetArenaNoVirtual()); - // @@protoc_insertion_point(field_set_char:google.protobuf.Option.name) -} -void Option::set_name(const char* value, - size_t size) { - - name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( - reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.Option.name) -} -::std::string* Option::mutable_name() { - - // @@protoc_insertion_point(field_mutable:google.protobuf.Option.name) - return name_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); -} -::std::string* Option::release_name() { - // @@protoc_insertion_point(field_release:google.protobuf.Option.name) - - return name_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); -} -::std::string* Option::unsafe_arena_release_name() { - // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Option.name) - GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); - - return name_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); -} -void Option::set_allocated_name(::std::string* name) { - if (name != NULL) { - - } else { - - } - name_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name, - GetArenaNoVirtual()); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.Option.name) -} -void Option::unsafe_arena_set_allocated_name( - ::std::string* name) { - GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); - if (name != NULL) { - - } else { - - } - name_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - name, GetArenaNoVirtual()); - // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Option.name) -} - -// .google.protobuf.Any value = 2; -bool Option::has_value() const { - return this != internal_default_instance() && value_ != NULL; -} -void Option::clear_value() { - if (GetArenaNoVirtual() == NULL && value_ != NULL) delete value_; - value_ = NULL; +// @@protoc_insertion_point(namespace_scope) +} // namespace protobuf +} // namespace google +namespace google { +namespace protobuf { +template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::Type* Arena::CreateMessage< ::google::protobuf::Type >(Arena* arena) { + return Arena::CreateMessageInternal< ::google::protobuf::Type >(arena); } -const ::google::protobuf::Any& Option::value() const { - // @@protoc_insertion_point(field_get:google.protobuf.Option.value) - return value_ != NULL ? *value_ - : *::google::protobuf::Any::internal_default_instance(); +template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::Field* Arena::CreateMessage< ::google::protobuf::Field >(Arena* arena) { + return Arena::CreateMessageInternal< ::google::protobuf::Field >(arena); } -::google::protobuf::Any* Option::mutable_value() { - - if (value_ == NULL) { - _slow_mutable_value(); - } - // @@protoc_insertion_point(field_mutable:google.protobuf.Option.value) - return value_; +template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::Enum* Arena::CreateMessage< ::google::protobuf::Enum >(Arena* arena) { + return Arena::CreateMessageInternal< ::google::protobuf::Enum >(arena); } -::google::protobuf::Any* Option::release_value() { - // @@protoc_insertion_point(field_release:google.protobuf.Option.value) - - if (GetArenaNoVirtual() != NULL) { - return _slow_release_value(); - } else { - ::google::protobuf::Any* temp = value_; - value_ = NULL; - return temp; - } +template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::EnumValue* Arena::CreateMessage< ::google::protobuf::EnumValue >(Arena* arena) { + return Arena::CreateMessageInternal< ::google::protobuf::EnumValue >(arena); } - void Option::set_allocated_value(::google::protobuf::Any* value) { - ::google::protobuf::Arena* message_arena = GetArenaNoVirtual(); - if (message_arena == NULL) { - delete value_; - } - if (value != NULL) { - if (message_arena != NULL) { - message_arena->Own(value); - } - } - value_ = value; - if (value) { - - } else { - - } - // @@protoc_insertion_point(field_set_allocated:google.protobuf.Option.value) +template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::Option* Arena::CreateMessage< ::google::protobuf::Option >(Arena* arena) { + return Arena::CreateMessageInternal< ::google::protobuf::Option >(arena); } - -#endif // PROTOBUF_INLINE_NOT_IN_HEADERS - -// @@protoc_insertion_point(namespace_scope) - } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/type.pb.h b/src/google/protobuf/type.pb.h index c1cd4164..49bed8ee 100644 --- a/src/google/protobuf/type.pb.h +++ b/src/google/protobuf/type.pb.h @@ -1,19 +1,19 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/protobuf/type.proto -#ifndef PROTOBUF_google_2fprotobuf_2ftype_2eproto__INCLUDED -#define PROTOBUF_google_2fprotobuf_2ftype_2eproto__INCLUDED +#ifndef PROTOBUF_google_2fprotobuf_2ftype_2eproto_INCLUDED +#define PROTOBUF_google_2fprotobuf_2ftype_2eproto_INCLUDED #include <string> #include <google/protobuf/stubs/common.h> -#if GOOGLE_PROTOBUF_VERSION < 3003000 +#if GOOGLE_PROTOBUF_VERSION < 3005000 #error This file was generated by a newer version of protoc which is #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3003000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION +#if 3005001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. @@ -33,11 +33,38 @@ #include <google/protobuf/any.pb.h> #include <google/protobuf/source_context.pb.h> // @@protoc_insertion_point(includes) + +namespace protobuf_google_2fprotobuf_2ftype_2eproto { +// Internal implementation detail -- do not use these members. +struct LIBPROTOBUF_EXPORT TableStruct { + static const ::google::protobuf::internal::ParseTableField entries[]; + static const ::google::protobuf::internal::AuxillaryParseTableField aux[]; + static const ::google::protobuf::internal::ParseTable schema[5]; + static const ::google::protobuf::internal::FieldMetadata field_metadata[]; + static const ::google::protobuf::internal::SerializationTable serialization_table[]; + static const ::google::protobuf::uint32 offsets[]; +}; +void LIBPROTOBUF_EXPORT AddDescriptors(); +void LIBPROTOBUF_EXPORT InitDefaultsTypeImpl(); +void LIBPROTOBUF_EXPORT InitDefaultsType(); +void LIBPROTOBUF_EXPORT InitDefaultsFieldImpl(); +void LIBPROTOBUF_EXPORT InitDefaultsField(); +void LIBPROTOBUF_EXPORT InitDefaultsEnumImpl(); +void LIBPROTOBUF_EXPORT InitDefaultsEnum(); +void LIBPROTOBUF_EXPORT InitDefaultsEnumValueImpl(); +void LIBPROTOBUF_EXPORT InitDefaultsEnumValue(); +void LIBPROTOBUF_EXPORT InitDefaultsOptionImpl(); +void LIBPROTOBUF_EXPORT InitDefaultsOption(); +inline void LIBPROTOBUF_EXPORT InitDefaults() { + InitDefaultsType(); + InitDefaultsField(); + InitDefaultsEnum(); + InitDefaultsEnumValue(); + InitDefaultsOption(); +} +} // namespace protobuf_google_2fprotobuf_2ftype_2eproto namespace google { namespace protobuf { -class Any; -class AnyDefaultTypeInternal; -LIBPROTOBUF_EXPORT extern AnyDefaultTypeInternal _Any_default_instance_; class Enum; class EnumDefaultTypeInternal; LIBPROTOBUF_EXPORT extern EnumDefaultTypeInternal _Enum_default_instance_; @@ -50,31 +77,22 @@ LIBPROTOBUF_EXPORT extern FieldDefaultTypeInternal _Field_default_instance_; class Option; class OptionDefaultTypeInternal; LIBPROTOBUF_EXPORT extern OptionDefaultTypeInternal _Option_default_instance_; -class SourceContext; -class SourceContextDefaultTypeInternal; -LIBPROTOBUF_EXPORT extern SourceContextDefaultTypeInternal _SourceContext_default_instance_; class Type; class TypeDefaultTypeInternal; LIBPROTOBUF_EXPORT extern TypeDefaultTypeInternal _Type_default_instance_; } // namespace protobuf } // namespace google - namespace google { namespace protobuf { - -namespace protobuf_google_2fprotobuf_2ftype_2eproto { -// Internal implementation detail -- do not call these. -struct LIBPROTOBUF_EXPORT TableStruct { - static const ::google::protobuf::internal::ParseTableField entries[]; - static const ::google::protobuf::internal::AuxillaryParseTableField aux[]; - static const ::google::protobuf::internal::ParseTable schema[]; - static const ::google::protobuf::uint32 offsets[]; - static void InitDefaultsImpl(); - static void Shutdown(); -}; -void LIBPROTOBUF_EXPORT AddDescriptors(); -void LIBPROTOBUF_EXPORT InitDefaults(); -} // namespace protobuf_google_2fprotobuf_2ftype_2eproto +template<> LIBPROTOBUF_EXPORT ::google::protobuf::Enum* Arena::CreateMessage< ::google::protobuf::Enum>(Arena*); +template<> LIBPROTOBUF_EXPORT ::google::protobuf::EnumValue* Arena::CreateMessage< ::google::protobuf::EnumValue>(Arena*); +template<> LIBPROTOBUF_EXPORT ::google::protobuf::Field* Arena::CreateMessage< ::google::protobuf::Field>(Arena*); +template<> LIBPROTOBUF_EXPORT ::google::protobuf::Option* Arena::CreateMessage< ::google::protobuf::Option>(Arena*); +template<> LIBPROTOBUF_EXPORT ::google::protobuf::Type* Arena::CreateMessage< ::google::protobuf::Type>(Arena*); +} // namespace protobuf +} // namespace google +namespace google { +namespace protobuf { enum Field_Kind { Field_Kind_TYPE_UNKNOWN = 0, @@ -171,7 +189,21 @@ class LIBPROTOBUF_EXPORT Type : public ::google::protobuf::Message /* @@protoc_i CopyFrom(from); return *this; } + #if LANG_CXX11 + Type(Type&& from) noexcept + : Type() { + *this = ::std::move(from); + } + inline Type& operator=(Type&& from) noexcept { + if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + #endif inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { return GetArenaNoVirtual(); } @@ -181,6 +213,7 @@ class LIBPROTOBUF_EXPORT Type : public ::google::protobuf::Message /* @@protoc_i static const ::google::protobuf::Descriptor* descriptor(); static const Type& default_instance(); + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY static inline const Type* internal_default_instance() { return reinterpret_cast<const Type*>( &_Type_default_instance_); @@ -190,12 +223,19 @@ class LIBPROTOBUF_EXPORT Type : public ::google::protobuf::Message /* @@protoc_i void UnsafeArenaSwap(Type* other); void Swap(Type* other); + friend void swap(Type& a, Type& b) { + a.Swap(&b); + } // implements Message ---------------------------------------------- - inline Type* New() const PROTOBUF_FINAL { return New(NULL); } + inline Type* New() const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<Type>(NULL); + } - Type* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + Type* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<Type>(arena); + } void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const Type& from); @@ -240,11 +280,11 @@ class LIBPROTOBUF_EXPORT Type : public ::google::protobuf::Message /* @@protoc_i int fields_size() const; void clear_fields(); static const int kFieldsFieldNumber = 2; - const ::google::protobuf::Field& fields(int index) const; ::google::protobuf::Field* mutable_fields(int index); - ::google::protobuf::Field* add_fields(); ::google::protobuf::RepeatedPtrField< ::google::protobuf::Field >* mutable_fields(); + const ::google::protobuf::Field& fields(int index) const; + ::google::protobuf::Field* add_fields(); const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Field >& fields() const; @@ -274,11 +314,11 @@ class LIBPROTOBUF_EXPORT Type : public ::google::protobuf::Message /* @@protoc_i int options_size() const; void clear_options(); static const int kOptionsFieldNumber = 4; - const ::google::protobuf::Option& options(int index) const; ::google::protobuf::Option* mutable_options(int index); - ::google::protobuf::Option* add_options(); ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >* mutable_options(); + const ::google::protobuf::Option& options(int index) const; + ::google::protobuf::Option* add_options(); const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >& options() const; @@ -287,12 +327,21 @@ class LIBPROTOBUF_EXPORT Type : public ::google::protobuf::Message /* @@protoc_i static const int kNameFieldNumber = 1; const ::std::string& name() const; void set_name(const ::std::string& value); + #if LANG_CXX11 + void set_name(::std::string&& value); + #endif void set_name(const char* value); void set_name(const char* value, size_t size); ::std::string* mutable_name(); ::std::string* release_name(); void set_allocated_name(::std::string* name); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") ::std::string* unsafe_arena_release_name(); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") void unsafe_arena_set_allocated_name( ::std::string* name); @@ -300,17 +349,13 @@ class LIBPROTOBUF_EXPORT Type : public ::google::protobuf::Message /* @@protoc_i bool has_source_context() const; void clear_source_context(); static const int kSourceContextFieldNumber = 5; - private: - void _slow_mutable_source_context(); - ::google::protobuf::SourceContext* _slow_release_source_context(); - public: const ::google::protobuf::SourceContext& source_context() const; - ::google::protobuf::SourceContext* mutable_source_context(); ::google::protobuf::SourceContext* release_source_context(); + ::google::protobuf::SourceContext* mutable_source_context(); void set_allocated_source_context(::google::protobuf::SourceContext* source_context); - ::google::protobuf::SourceContext* unsafe_arena_release_source_context(); void unsafe_arena_set_allocated_source_context( ::google::protobuf::SourceContext* source_context); + ::google::protobuf::SourceContext* unsafe_arena_release_source_context(); // .google.protobuf.Syntax syntax = 6; void clear_syntax(); @@ -322,7 +367,7 @@ class LIBPROTOBUF_EXPORT Type : public ::google::protobuf::Message /* @@protoc_i private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - friend class ::google::protobuf::Arena; + template <typename T> friend class ::google::protobuf::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::Field > fields_; @@ -332,7 +377,8 @@ class LIBPROTOBUF_EXPORT Type : public ::google::protobuf::Message /* @@protoc_i ::google::protobuf::SourceContext* source_context_; int syntax_; mutable int _cached_size_; - friend struct protobuf_google_2fprotobuf_2ftype_2eproto::TableStruct; + friend struct ::protobuf_google_2fprotobuf_2ftype_2eproto::TableStruct; + friend void ::protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaultsTypeImpl(); }; // ------------------------------------------------------------------- @@ -347,7 +393,21 @@ class LIBPROTOBUF_EXPORT Field : public ::google::protobuf::Message /* @@protoc_ CopyFrom(from); return *this; } + #if LANG_CXX11 + Field(Field&& from) noexcept + : Field() { + *this = ::std::move(from); + } + inline Field& operator=(Field&& from) noexcept { + if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + #endif inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { return GetArenaNoVirtual(); } @@ -357,6 +417,7 @@ class LIBPROTOBUF_EXPORT Field : public ::google::protobuf::Message /* @@protoc_ static const ::google::protobuf::Descriptor* descriptor(); static const Field& default_instance(); + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY static inline const Field* internal_default_instance() { return reinterpret_cast<const Field*>( &_Field_default_instance_); @@ -366,12 +427,19 @@ class LIBPROTOBUF_EXPORT Field : public ::google::protobuf::Message /* @@protoc_ void UnsafeArenaSwap(Field* other); void Swap(Field* other); + friend void swap(Field& a, Field& b) { + a.Swap(&b); + } // implements Message ---------------------------------------------- - inline Field* New() const PROTOBUF_FINAL { return New(NULL); } + inline Field* New() const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<Field>(NULL); + } - Field* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + Field* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<Field>(arena); + } void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const Field& from); @@ -506,11 +574,11 @@ class LIBPROTOBUF_EXPORT Field : public ::google::protobuf::Message /* @@protoc_ int options_size() const; void clear_options(); static const int kOptionsFieldNumber = 9; - const ::google::protobuf::Option& options(int index) const; ::google::protobuf::Option* mutable_options(int index); - ::google::protobuf::Option* add_options(); ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >* mutable_options(); + const ::google::protobuf::Option& options(int index) const; + ::google::protobuf::Option* add_options(); const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >& options() const; @@ -519,12 +587,21 @@ class LIBPROTOBUF_EXPORT Field : public ::google::protobuf::Message /* @@protoc_ static const int kNameFieldNumber = 4; const ::std::string& name() const; void set_name(const ::std::string& value); + #if LANG_CXX11 + void set_name(::std::string&& value); + #endif void set_name(const char* value); void set_name(const char* value, size_t size); ::std::string* mutable_name(); ::std::string* release_name(); void set_allocated_name(::std::string* name); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") ::std::string* unsafe_arena_release_name(); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") void unsafe_arena_set_allocated_name( ::std::string* name); @@ -533,12 +610,21 @@ class LIBPROTOBUF_EXPORT Field : public ::google::protobuf::Message /* @@protoc_ static const int kTypeUrlFieldNumber = 6; const ::std::string& type_url() const; void set_type_url(const ::std::string& value); + #if LANG_CXX11 + void set_type_url(::std::string&& value); + #endif void set_type_url(const char* value); void set_type_url(const char* value, size_t size); ::std::string* mutable_type_url(); ::std::string* release_type_url(); void set_allocated_type_url(::std::string* type_url); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") ::std::string* unsafe_arena_release_type_url(); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") void unsafe_arena_set_allocated_type_url( ::std::string* type_url); @@ -547,12 +633,21 @@ class LIBPROTOBUF_EXPORT Field : public ::google::protobuf::Message /* @@protoc_ static const int kJsonNameFieldNumber = 10; const ::std::string& json_name() const; void set_json_name(const ::std::string& value); + #if LANG_CXX11 + void set_json_name(::std::string&& value); + #endif void set_json_name(const char* value); void set_json_name(const char* value, size_t size); ::std::string* mutable_json_name(); ::std::string* release_json_name(); void set_allocated_json_name(::std::string* json_name); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") ::std::string* unsafe_arena_release_json_name(); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") void unsafe_arena_set_allocated_json_name( ::std::string* json_name); @@ -561,12 +656,21 @@ class LIBPROTOBUF_EXPORT Field : public ::google::protobuf::Message /* @@protoc_ static const int kDefaultValueFieldNumber = 11; const ::std::string& default_value() const; void set_default_value(const ::std::string& value); + #if LANG_CXX11 + void set_default_value(::std::string&& value); + #endif void set_default_value(const char* value); void set_default_value(const char* value, size_t size); ::std::string* mutable_default_value(); ::std::string* release_default_value(); void set_allocated_default_value(::std::string* default_value); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") ::std::string* unsafe_arena_release_default_value(); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") void unsafe_arena_set_allocated_default_value( ::std::string* default_value); @@ -604,7 +708,7 @@ class LIBPROTOBUF_EXPORT Field : public ::google::protobuf::Message /* @@protoc_ private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - friend class ::google::protobuf::Arena; + template <typename T> friend class ::google::protobuf::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option > options_; @@ -618,7 +722,8 @@ class LIBPROTOBUF_EXPORT Field : public ::google::protobuf::Message /* @@protoc_ ::google::protobuf::int32 oneof_index_; bool packed_; mutable int _cached_size_; - friend struct protobuf_google_2fprotobuf_2ftype_2eproto::TableStruct; + friend struct ::protobuf_google_2fprotobuf_2ftype_2eproto::TableStruct; + friend void ::protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaultsFieldImpl(); }; // ------------------------------------------------------------------- @@ -633,7 +738,21 @@ class LIBPROTOBUF_EXPORT Enum : public ::google::protobuf::Message /* @@protoc_i CopyFrom(from); return *this; } + #if LANG_CXX11 + Enum(Enum&& from) noexcept + : Enum() { + *this = ::std::move(from); + } + inline Enum& operator=(Enum&& from) noexcept { + if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + #endif inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { return GetArenaNoVirtual(); } @@ -643,6 +762,7 @@ class LIBPROTOBUF_EXPORT Enum : public ::google::protobuf::Message /* @@protoc_i static const ::google::protobuf::Descriptor* descriptor(); static const Enum& default_instance(); + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY static inline const Enum* internal_default_instance() { return reinterpret_cast<const Enum*>( &_Enum_default_instance_); @@ -652,12 +772,19 @@ class LIBPROTOBUF_EXPORT Enum : public ::google::protobuf::Message /* @@protoc_i void UnsafeArenaSwap(Enum* other); void Swap(Enum* other); + friend void swap(Enum& a, Enum& b) { + a.Swap(&b); + } // implements Message ---------------------------------------------- - inline Enum* New() const PROTOBUF_FINAL { return New(NULL); } + inline Enum* New() const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<Enum>(NULL); + } - Enum* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + Enum* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<Enum>(arena); + } void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const Enum& from); @@ -702,11 +829,11 @@ class LIBPROTOBUF_EXPORT Enum : public ::google::protobuf::Message /* @@protoc_i int enumvalue_size() const; void clear_enumvalue(); static const int kEnumvalueFieldNumber = 2; - const ::google::protobuf::EnumValue& enumvalue(int index) const; ::google::protobuf::EnumValue* mutable_enumvalue(int index); - ::google::protobuf::EnumValue* add_enumvalue(); ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumValue >* mutable_enumvalue(); + const ::google::protobuf::EnumValue& enumvalue(int index) const; + ::google::protobuf::EnumValue* add_enumvalue(); const ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumValue >& enumvalue() const; @@ -714,11 +841,11 @@ class LIBPROTOBUF_EXPORT Enum : public ::google::protobuf::Message /* @@protoc_i int options_size() const; void clear_options(); static const int kOptionsFieldNumber = 3; - const ::google::protobuf::Option& options(int index) const; ::google::protobuf::Option* mutable_options(int index); - ::google::protobuf::Option* add_options(); ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >* mutable_options(); + const ::google::protobuf::Option& options(int index) const; + ::google::protobuf::Option* add_options(); const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >& options() const; @@ -727,12 +854,21 @@ class LIBPROTOBUF_EXPORT Enum : public ::google::protobuf::Message /* @@protoc_i static const int kNameFieldNumber = 1; const ::std::string& name() const; void set_name(const ::std::string& value); + #if LANG_CXX11 + void set_name(::std::string&& value); + #endif void set_name(const char* value); void set_name(const char* value, size_t size); ::std::string* mutable_name(); ::std::string* release_name(); void set_allocated_name(::std::string* name); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") ::std::string* unsafe_arena_release_name(); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") void unsafe_arena_set_allocated_name( ::std::string* name); @@ -740,17 +876,13 @@ class LIBPROTOBUF_EXPORT Enum : public ::google::protobuf::Message /* @@protoc_i bool has_source_context() const; void clear_source_context(); static const int kSourceContextFieldNumber = 4; - private: - void _slow_mutable_source_context(); - ::google::protobuf::SourceContext* _slow_release_source_context(); - public: const ::google::protobuf::SourceContext& source_context() const; - ::google::protobuf::SourceContext* mutable_source_context(); ::google::protobuf::SourceContext* release_source_context(); + ::google::protobuf::SourceContext* mutable_source_context(); void set_allocated_source_context(::google::protobuf::SourceContext* source_context); - ::google::protobuf::SourceContext* unsafe_arena_release_source_context(); void unsafe_arena_set_allocated_source_context( ::google::protobuf::SourceContext* source_context); + ::google::protobuf::SourceContext* unsafe_arena_release_source_context(); // .google.protobuf.Syntax syntax = 5; void clear_syntax(); @@ -762,7 +894,7 @@ class LIBPROTOBUF_EXPORT Enum : public ::google::protobuf::Message /* @@protoc_i private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - friend class ::google::protobuf::Arena; + template <typename T> friend class ::google::protobuf::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumValue > enumvalue_; @@ -771,7 +903,8 @@ class LIBPROTOBUF_EXPORT Enum : public ::google::protobuf::Message /* @@protoc_i ::google::protobuf::SourceContext* source_context_; int syntax_; mutable int _cached_size_; - friend struct protobuf_google_2fprotobuf_2ftype_2eproto::TableStruct; + friend struct ::protobuf_google_2fprotobuf_2ftype_2eproto::TableStruct; + friend void ::protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaultsEnumImpl(); }; // ------------------------------------------------------------------- @@ -786,7 +919,21 @@ class LIBPROTOBUF_EXPORT EnumValue : public ::google::protobuf::Message /* @@pro CopyFrom(from); return *this; } + #if LANG_CXX11 + EnumValue(EnumValue&& from) noexcept + : EnumValue() { + *this = ::std::move(from); + } + inline EnumValue& operator=(EnumValue&& from) noexcept { + if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + #endif inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { return GetArenaNoVirtual(); } @@ -796,6 +943,7 @@ class LIBPROTOBUF_EXPORT EnumValue : public ::google::protobuf::Message /* @@pro static const ::google::protobuf::Descriptor* descriptor(); static const EnumValue& default_instance(); + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY static inline const EnumValue* internal_default_instance() { return reinterpret_cast<const EnumValue*>( &_EnumValue_default_instance_); @@ -805,12 +953,19 @@ class LIBPROTOBUF_EXPORT EnumValue : public ::google::protobuf::Message /* @@pro void UnsafeArenaSwap(EnumValue* other); void Swap(EnumValue* other); + friend void swap(EnumValue& a, EnumValue& b) { + a.Swap(&b); + } // implements Message ---------------------------------------------- - inline EnumValue* New() const PROTOBUF_FINAL { return New(NULL); } + inline EnumValue* New() const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<EnumValue>(NULL); + } - EnumValue* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + EnumValue* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<EnumValue>(arena); + } void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const EnumValue& from); @@ -855,11 +1010,11 @@ class LIBPROTOBUF_EXPORT EnumValue : public ::google::protobuf::Message /* @@pro int options_size() const; void clear_options(); static const int kOptionsFieldNumber = 3; - const ::google::protobuf::Option& options(int index) const; ::google::protobuf::Option* mutable_options(int index); - ::google::protobuf::Option* add_options(); ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >* mutable_options(); + const ::google::protobuf::Option& options(int index) const; + ::google::protobuf::Option* add_options(); const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >& options() const; @@ -868,12 +1023,21 @@ class LIBPROTOBUF_EXPORT EnumValue : public ::google::protobuf::Message /* @@pro static const int kNameFieldNumber = 1; const ::std::string& name() const; void set_name(const ::std::string& value); + #if LANG_CXX11 + void set_name(::std::string&& value); + #endif void set_name(const char* value); void set_name(const char* value, size_t size); ::std::string* mutable_name(); ::std::string* release_name(); void set_allocated_name(::std::string* name); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") ::std::string* unsafe_arena_release_name(); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") void unsafe_arena_set_allocated_name( ::std::string* name); @@ -887,14 +1051,15 @@ class LIBPROTOBUF_EXPORT EnumValue : public ::google::protobuf::Message /* @@pro private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - friend class ::google::protobuf::Arena; + template <typename T> friend class ::google::protobuf::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option > options_; ::google::protobuf::internal::ArenaStringPtr name_; ::google::protobuf::int32 number_; mutable int _cached_size_; - friend struct protobuf_google_2fprotobuf_2ftype_2eproto::TableStruct; + friend struct ::protobuf_google_2fprotobuf_2ftype_2eproto::TableStruct; + friend void ::protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaultsEnumValueImpl(); }; // ------------------------------------------------------------------- @@ -909,7 +1074,21 @@ class LIBPROTOBUF_EXPORT Option : public ::google::protobuf::Message /* @@protoc CopyFrom(from); return *this; } + #if LANG_CXX11 + Option(Option&& from) noexcept + : Option() { + *this = ::std::move(from); + } + inline Option& operator=(Option&& from) noexcept { + if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + #endif inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { return GetArenaNoVirtual(); } @@ -919,6 +1098,7 @@ class LIBPROTOBUF_EXPORT Option : public ::google::protobuf::Message /* @@protoc static const ::google::protobuf::Descriptor* descriptor(); static const Option& default_instance(); + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY static inline const Option* internal_default_instance() { return reinterpret_cast<const Option*>( &_Option_default_instance_); @@ -928,12 +1108,19 @@ class LIBPROTOBUF_EXPORT Option : public ::google::protobuf::Message /* @@protoc void UnsafeArenaSwap(Option* other); void Swap(Option* other); + friend void swap(Option& a, Option& b) { + a.Swap(&b); + } // implements Message ---------------------------------------------- - inline Option* New() const PROTOBUF_FINAL { return New(NULL); } + inline Option* New() const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<Option>(NULL); + } - Option* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + Option* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<Option>(arena); + } void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const Option& from); @@ -979,12 +1166,21 @@ class LIBPROTOBUF_EXPORT Option : public ::google::protobuf::Message /* @@protoc static const int kNameFieldNumber = 1; const ::std::string& name() const; void set_name(const ::std::string& value); + #if LANG_CXX11 + void set_name(::std::string&& value); + #endif void set_name(const char* value); void set_name(const char* value, size_t size); ::std::string* mutable_name(); ::std::string* release_name(); void set_allocated_name(::std::string* name); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") ::std::string* unsafe_arena_release_name(); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") void unsafe_arena_set_allocated_name( ::std::string* name); @@ -992,36 +1188,36 @@ class LIBPROTOBUF_EXPORT Option : public ::google::protobuf::Message /* @@protoc bool has_value() const; void clear_value(); static const int kValueFieldNumber = 2; - private: - void _slow_mutable_value(); - ::google::protobuf::Any* _slow_release_value(); - public: const ::google::protobuf::Any& value() const; - ::google::protobuf::Any* mutable_value(); ::google::protobuf::Any* release_value(); + ::google::protobuf::Any* mutable_value(); void set_allocated_value(::google::protobuf::Any* value); - ::google::protobuf::Any* unsafe_arena_release_value(); void unsafe_arena_set_allocated_value( ::google::protobuf::Any* value); + ::google::protobuf::Any* unsafe_arena_release_value(); // @@protoc_insertion_point(class_scope:google.protobuf.Option) private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - friend class ::google::protobuf::Arena; + template <typename T> friend class ::google::protobuf::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; ::google::protobuf::internal::ArenaStringPtr name_; ::google::protobuf::Any* value_; mutable int _cached_size_; - friend struct protobuf_google_2fprotobuf_2ftype_2eproto::TableStruct; + friend struct ::protobuf_google_2fprotobuf_2ftype_2eproto::TableStruct; + friend void ::protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaultsOptionImpl(); }; // =================================================================== // =================================================================== -#if !PROTOBUF_INLINE_NOT_IN_HEADERS +#ifdef __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif // __GNUC__ // Type // string name = 1; @@ -1037,6 +1233,14 @@ inline void Type::set_name(const ::std::string& value) { name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.Type.name) } +#if LANG_CXX11 +inline void Type::set_name(::std::string&& value) { + + name_.Set( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Type.name) +} +#endif inline void Type::set_name(const char* value) { GOOGLE_DCHECK(value != NULL); @@ -1061,13 +1265,6 @@ inline ::std::string* Type::release_name() { return name_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } -inline ::std::string* Type::unsafe_arena_release_name() { - // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Type.name) - GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); - - return name_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); -} inline void Type::set_allocated_name(::std::string* name) { if (name != NULL) { @@ -1078,6 +1275,13 @@ inline void Type::set_allocated_name(::std::string* name) { GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.Type.name) } +inline ::std::string* Type::unsafe_arena_release_name() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Type.name) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + + return name_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); +} inline void Type::unsafe_arena_set_allocated_name( ::std::string* name) { GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); @@ -1098,23 +1302,23 @@ inline int Type::fields_size() const { inline void Type::clear_fields() { fields_.Clear(); } -inline const ::google::protobuf::Field& Type::fields(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.Type.fields) - return fields_.Get(index); -} inline ::google::protobuf::Field* Type::mutable_fields(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.Type.fields) return fields_.Mutable(index); } -inline ::google::protobuf::Field* Type::add_fields() { - // @@protoc_insertion_point(field_add:google.protobuf.Type.fields) - return fields_.Add(); -} inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::Field >* Type::mutable_fields() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.Type.fields) return &fields_; } +inline const ::google::protobuf::Field& Type::fields(int index) const { + // @@protoc_insertion_point(field_get:google.protobuf.Type.fields) + return fields_.Get(index); +} +inline ::google::protobuf::Field* Type::add_fields() { + // @@protoc_insertion_point(field_add:google.protobuf.Type.fields) + return fields_.Add(); +} inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Field >& Type::fields() const { // @@protoc_insertion_point(field_list:google.protobuf.Type.fields) @@ -1197,23 +1401,23 @@ inline int Type::options_size() const { inline void Type::clear_options() { options_.Clear(); } -inline const ::google::protobuf::Option& Type::options(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.Type.options) - return options_.Get(index); -} inline ::google::protobuf::Option* Type::mutable_options(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.Type.options) return options_.Mutable(index); } -inline ::google::protobuf::Option* Type::add_options() { - // @@protoc_insertion_point(field_add:google.protobuf.Type.options) - return options_.Add(); -} inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >* Type::mutable_options() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.Type.options) return &options_; } +inline const ::google::protobuf::Option& Type::options(int index) const { + // @@protoc_insertion_point(field_get:google.protobuf.Type.options) + return options_.Get(index); +} +inline ::google::protobuf::Option* Type::add_options() { + // @@protoc_insertion_point(field_add:google.protobuf.Type.options) + return options_.Add(); +} inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >& Type::options() const { // @@protoc_insertion_point(field_list:google.protobuf.Type.options) @@ -1224,50 +1428,54 @@ Type::options() const { inline bool Type::has_source_context() const { return this != internal_default_instance() && source_context_ != NULL; } -inline void Type::clear_source_context() { - if (GetArenaNoVirtual() == NULL && source_context_ != NULL) delete source_context_; - source_context_ = NULL; -} inline const ::google::protobuf::SourceContext& Type::source_context() const { + const ::google::protobuf::SourceContext* p = source_context_; // @@protoc_insertion_point(field_get:google.protobuf.Type.source_context) - return source_context_ != NULL ? *source_context_ - : *::google::protobuf::SourceContext::internal_default_instance(); + return p != NULL ? *p : *reinterpret_cast<const ::google::protobuf::SourceContext*>( + &::google::protobuf::_SourceContext_default_instance_); +} +inline ::google::protobuf::SourceContext* Type::release_source_context() { + // @@protoc_insertion_point(field_release:google.protobuf.Type.source_context) + + ::google::protobuf::SourceContext* temp = source_context_; + if (GetArenaNoVirtual() != NULL) { + temp = ::google::protobuf::internal::DuplicateIfNonNull(temp, NULL); + } + source_context_ = NULL; + return temp; +} +inline ::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; } inline ::google::protobuf::SourceContext* Type::mutable_source_context() { if (source_context_ == NULL) { - _slow_mutable_source_context(); + source_context_ = ::google::protobuf::Arena::Create< ::google::protobuf::SourceContext >( + GetArenaNoVirtual()); } // @@protoc_insertion_point(field_mutable:google.protobuf.Type.source_context) return source_context_; } -inline ::google::protobuf::SourceContext* Type::release_source_context() { - // @@protoc_insertion_point(field_release:google.protobuf.Type.source_context) - - if (GetArenaNoVirtual() != NULL) { - return _slow_release_source_context(); - } else { - ::google::protobuf::SourceContext* temp = source_context_; - source_context_ = NULL; - return temp; - } -} -inline void Type::set_allocated_source_context(::google::protobuf::SourceContext* source_context) { +inline void Type::set_allocated_source_context(::google::protobuf::SourceContext* source_context) { ::google::protobuf::Arena* message_arena = GetArenaNoVirtual(); if (message_arena == NULL) { - delete source_context_; + delete reinterpret_cast< ::google::protobuf::MessageLite*>(source_context_); } - if (source_context != NULL) { - if (message_arena != NULL) { - message_arena->Own(source_context); - } - } - source_context_ = source_context; if (source_context) { + ::google::protobuf::Arena* submessage_arena = NULL; + if (message_arena != submessage_arena) { + source_context = ::google::protobuf::internal::GetOwnedMessage( + message_arena, source_context, submessage_arena); + } } else { } + source_context_ = source_context; // @@protoc_insertion_point(field_set_allocated:google.protobuf.Type.source_context) } @@ -1344,6 +1552,14 @@ inline void Field::set_name(const ::std::string& value) { name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.Field.name) } +#if LANG_CXX11 +inline void Field::set_name(::std::string&& value) { + + name_.Set( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Field.name) +} +#endif inline void Field::set_name(const char* value) { GOOGLE_DCHECK(value != NULL); @@ -1368,13 +1584,6 @@ inline ::std::string* Field::release_name() { return name_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } -inline ::std::string* Field::unsafe_arena_release_name() { - // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Field.name) - GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); - - return name_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); -} inline void Field::set_allocated_name(::std::string* name) { if (name != NULL) { @@ -1385,6 +1594,13 @@ inline void Field::set_allocated_name(::std::string* name) { GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.Field.name) } +inline ::std::string* Field::unsafe_arena_release_name() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Field.name) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + + return name_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); +} inline void Field::unsafe_arena_set_allocated_name( ::std::string* name) { GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); @@ -1411,6 +1627,14 @@ inline void Field::set_type_url(const ::std::string& value) { type_url_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.Field.type_url) } +#if LANG_CXX11 +inline void Field::set_type_url(::std::string&& value) { + + type_url_.Set( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Field.type_url) +} +#endif inline void Field::set_type_url(const char* value) { GOOGLE_DCHECK(value != NULL); @@ -1435,13 +1659,6 @@ inline ::std::string* Field::release_type_url() { return type_url_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } -inline ::std::string* Field::unsafe_arena_release_type_url() { - // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Field.type_url) - GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); - - return type_url_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); -} inline void Field::set_allocated_type_url(::std::string* type_url) { if (type_url != NULL) { @@ -1452,6 +1669,13 @@ inline void Field::set_allocated_type_url(::std::string* type_url) { GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.Field.type_url) } +inline ::std::string* Field::unsafe_arena_release_type_url() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Field.type_url) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + + return type_url_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); +} inline void Field::unsafe_arena_set_allocated_type_url( ::std::string* type_url) { GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); @@ -1500,23 +1724,23 @@ inline int Field::options_size() const { inline void Field::clear_options() { options_.Clear(); } -inline const ::google::protobuf::Option& Field::options(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.Field.options) - return options_.Get(index); -} inline ::google::protobuf::Option* Field::mutable_options(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.Field.options) return options_.Mutable(index); } -inline ::google::protobuf::Option* Field::add_options() { - // @@protoc_insertion_point(field_add:google.protobuf.Field.options) - return options_.Add(); -} inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >* Field::mutable_options() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.Field.options) return &options_; } +inline const ::google::protobuf::Option& Field::options(int index) const { + // @@protoc_insertion_point(field_get:google.protobuf.Field.options) + return options_.Get(index); +} +inline ::google::protobuf::Option* Field::add_options() { + // @@protoc_insertion_point(field_add:google.protobuf.Field.options) + return options_.Add(); +} inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >& Field::options() const { // @@protoc_insertion_point(field_list:google.protobuf.Field.options) @@ -1536,6 +1760,14 @@ inline void Field::set_json_name(const ::std::string& value) { json_name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.Field.json_name) } +#if LANG_CXX11 +inline void Field::set_json_name(::std::string&& value) { + + json_name_.Set( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Field.json_name) +} +#endif inline void Field::set_json_name(const char* value) { GOOGLE_DCHECK(value != NULL); @@ -1560,13 +1792,6 @@ inline ::std::string* Field::release_json_name() { return json_name_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } -inline ::std::string* Field::unsafe_arena_release_json_name() { - // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Field.json_name) - GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); - - return json_name_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); -} inline void Field::set_allocated_json_name(::std::string* json_name) { if (json_name != NULL) { @@ -1577,6 +1802,13 @@ inline void Field::set_allocated_json_name(::std::string* json_name) { GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.Field.json_name) } +inline ::std::string* Field::unsafe_arena_release_json_name() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Field.json_name) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + + return json_name_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); +} inline void Field::unsafe_arena_set_allocated_json_name( ::std::string* json_name) { GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); @@ -1603,6 +1835,14 @@ inline void Field::set_default_value(const ::std::string& value) { default_value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.Field.default_value) } +#if LANG_CXX11 +inline void Field::set_default_value(::std::string&& value) { + + default_value_.Set( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Field.default_value) +} +#endif inline void Field::set_default_value(const char* value) { GOOGLE_DCHECK(value != NULL); @@ -1627,13 +1867,6 @@ inline ::std::string* Field::release_default_value() { return default_value_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } -inline ::std::string* Field::unsafe_arena_release_default_value() { - // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Field.default_value) - GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); - - return default_value_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); -} inline void Field::set_allocated_default_value(::std::string* default_value) { if (default_value != NULL) { @@ -1644,6 +1877,13 @@ inline void Field::set_allocated_default_value(::std::string* default_value) { GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.Field.default_value) } +inline ::std::string* Field::unsafe_arena_release_default_value() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Field.default_value) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + + return default_value_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); +} inline void Field::unsafe_arena_set_allocated_default_value( ::std::string* default_value) { GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); @@ -1674,6 +1914,14 @@ inline void Enum::set_name(const ::std::string& value) { name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.Enum.name) } +#if LANG_CXX11 +inline void Enum::set_name(::std::string&& value) { + + name_.Set( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Enum.name) +} +#endif inline void Enum::set_name(const char* value) { GOOGLE_DCHECK(value != NULL); @@ -1698,13 +1946,6 @@ inline ::std::string* Enum::release_name() { return name_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } -inline ::std::string* Enum::unsafe_arena_release_name() { - // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Enum.name) - GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); - - return name_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); -} inline void Enum::set_allocated_name(::std::string* name) { if (name != NULL) { @@ -1715,6 +1956,13 @@ inline void Enum::set_allocated_name(::std::string* name) { GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.Enum.name) } +inline ::std::string* Enum::unsafe_arena_release_name() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Enum.name) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + + return name_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); +} inline void Enum::unsafe_arena_set_allocated_name( ::std::string* name) { GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); @@ -1735,23 +1983,23 @@ inline int Enum::enumvalue_size() const { inline void Enum::clear_enumvalue() { enumvalue_.Clear(); } -inline const ::google::protobuf::EnumValue& Enum::enumvalue(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.Enum.enumvalue) - return enumvalue_.Get(index); -} inline ::google::protobuf::EnumValue* Enum::mutable_enumvalue(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.Enum.enumvalue) return enumvalue_.Mutable(index); } -inline ::google::protobuf::EnumValue* Enum::add_enumvalue() { - // @@protoc_insertion_point(field_add:google.protobuf.Enum.enumvalue) - return enumvalue_.Add(); -} inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumValue >* Enum::mutable_enumvalue() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.Enum.enumvalue) return &enumvalue_; } +inline const ::google::protobuf::EnumValue& Enum::enumvalue(int index) const { + // @@protoc_insertion_point(field_get:google.protobuf.Enum.enumvalue) + return enumvalue_.Get(index); +} +inline ::google::protobuf::EnumValue* Enum::add_enumvalue() { + // @@protoc_insertion_point(field_add:google.protobuf.Enum.enumvalue) + return enumvalue_.Add(); +} inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumValue >& Enum::enumvalue() const { // @@protoc_insertion_point(field_list:google.protobuf.Enum.enumvalue) @@ -1765,23 +2013,23 @@ inline int Enum::options_size() const { inline void Enum::clear_options() { options_.Clear(); } -inline const ::google::protobuf::Option& Enum::options(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.Enum.options) - return options_.Get(index); -} inline ::google::protobuf::Option* Enum::mutable_options(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.Enum.options) return options_.Mutable(index); } -inline ::google::protobuf::Option* Enum::add_options() { - // @@protoc_insertion_point(field_add:google.protobuf.Enum.options) - return options_.Add(); -} inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >* Enum::mutable_options() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.Enum.options) return &options_; } +inline const ::google::protobuf::Option& Enum::options(int index) const { + // @@protoc_insertion_point(field_get:google.protobuf.Enum.options) + return options_.Get(index); +} +inline ::google::protobuf::Option* Enum::add_options() { + // @@protoc_insertion_point(field_add:google.protobuf.Enum.options) + return options_.Add(); +} inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >& Enum::options() const { // @@protoc_insertion_point(field_list:google.protobuf.Enum.options) @@ -1792,50 +2040,54 @@ Enum::options() const { inline bool Enum::has_source_context() const { return this != internal_default_instance() && source_context_ != NULL; } -inline void Enum::clear_source_context() { - if (GetArenaNoVirtual() == NULL && source_context_ != NULL) delete source_context_; - source_context_ = NULL; -} inline const ::google::protobuf::SourceContext& Enum::source_context() const { + const ::google::protobuf::SourceContext* p = source_context_; // @@protoc_insertion_point(field_get:google.protobuf.Enum.source_context) - return source_context_ != NULL ? *source_context_ - : *::google::protobuf::SourceContext::internal_default_instance(); + return p != NULL ? *p : *reinterpret_cast<const ::google::protobuf::SourceContext*>( + &::google::protobuf::_SourceContext_default_instance_); +} +inline ::google::protobuf::SourceContext* Enum::release_source_context() { + // @@protoc_insertion_point(field_release:google.protobuf.Enum.source_context) + + ::google::protobuf::SourceContext* temp = source_context_; + if (GetArenaNoVirtual() != NULL) { + temp = ::google::protobuf::internal::DuplicateIfNonNull(temp, NULL); + } + source_context_ = NULL; + return temp; +} +inline ::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; } inline ::google::protobuf::SourceContext* Enum::mutable_source_context() { if (source_context_ == NULL) { - _slow_mutable_source_context(); + source_context_ = ::google::protobuf::Arena::Create< ::google::protobuf::SourceContext >( + GetArenaNoVirtual()); } // @@protoc_insertion_point(field_mutable:google.protobuf.Enum.source_context) return source_context_; } -inline ::google::protobuf::SourceContext* Enum::release_source_context() { - // @@protoc_insertion_point(field_release:google.protobuf.Enum.source_context) - - if (GetArenaNoVirtual() != NULL) { - return _slow_release_source_context(); - } else { - ::google::protobuf::SourceContext* temp = source_context_; - source_context_ = NULL; - return temp; - } -} -inline void Enum::set_allocated_source_context(::google::protobuf::SourceContext* source_context) { +inline void Enum::set_allocated_source_context(::google::protobuf::SourceContext* source_context) { ::google::protobuf::Arena* message_arena = GetArenaNoVirtual(); if (message_arena == NULL) { - delete source_context_; + delete reinterpret_cast< ::google::protobuf::MessageLite*>(source_context_); } - if (source_context != NULL) { - if (message_arena != NULL) { - message_arena->Own(source_context); - } - } - source_context_ = source_context; if (source_context) { + ::google::protobuf::Arena* submessage_arena = NULL; + if (message_arena != submessage_arena) { + source_context = ::google::protobuf::internal::GetOwnedMessage( + message_arena, source_context, submessage_arena); + } } else { } + source_context_ = source_context; // @@protoc_insertion_point(field_set_allocated:google.protobuf.Enum.source_context) } @@ -1870,6 +2122,14 @@ inline void EnumValue::set_name(const ::std::string& value) { name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.EnumValue.name) } +#if LANG_CXX11 +inline void EnumValue::set_name(::std::string&& value) { + + name_.Set( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.EnumValue.name) +} +#endif inline void EnumValue::set_name(const char* value) { GOOGLE_DCHECK(value != NULL); @@ -1894,13 +2154,6 @@ inline ::std::string* EnumValue::release_name() { return name_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } -inline ::std::string* EnumValue::unsafe_arena_release_name() { - // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.EnumValue.name) - GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); - - return name_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); -} inline void EnumValue::set_allocated_name(::std::string* name) { if (name != NULL) { @@ -1911,6 +2164,13 @@ inline void EnumValue::set_allocated_name(::std::string* name) { GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.EnumValue.name) } +inline ::std::string* EnumValue::unsafe_arena_release_name() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.EnumValue.name) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + + return name_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); +} inline void EnumValue::unsafe_arena_set_allocated_name( ::std::string* name) { GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); @@ -1945,23 +2205,23 @@ inline int EnumValue::options_size() const { inline void EnumValue::clear_options() { options_.Clear(); } -inline const ::google::protobuf::Option& EnumValue::options(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.EnumValue.options) - return options_.Get(index); -} inline ::google::protobuf::Option* EnumValue::mutable_options(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.EnumValue.options) return options_.Mutable(index); } -inline ::google::protobuf::Option* EnumValue::add_options() { - // @@protoc_insertion_point(field_add:google.protobuf.EnumValue.options) - return options_.Add(); -} inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >* EnumValue::mutable_options() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.EnumValue.options) return &options_; } +inline const ::google::protobuf::Option& EnumValue::options(int index) const { + // @@protoc_insertion_point(field_get:google.protobuf.EnumValue.options) + return options_.Get(index); +} +inline ::google::protobuf::Option* EnumValue::add_options() { + // @@protoc_insertion_point(field_add:google.protobuf.EnumValue.options) + return options_.Add(); +} inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >& EnumValue::options() const { // @@protoc_insertion_point(field_list:google.protobuf.EnumValue.options) @@ -1985,6 +2245,14 @@ inline void Option::set_name(const ::std::string& value) { name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.Option.name) } +#if LANG_CXX11 +inline void Option::set_name(::std::string&& value) { + + name_.Set( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Option.name) +} +#endif inline void Option::set_name(const char* value) { GOOGLE_DCHECK(value != NULL); @@ -2009,13 +2277,6 @@ inline ::std::string* Option::release_name() { return name_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } -inline ::std::string* Option::unsafe_arena_release_name() { - // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Option.name) - GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); - - return name_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); -} inline void Option::set_allocated_name(::std::string* name) { if (name != NULL) { @@ -2026,6 +2287,13 @@ inline void Option::set_allocated_name(::std::string* name) { GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.Option.name) } +inline ::std::string* Option::unsafe_arena_release_name() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Option.name) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + + return name_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); +} inline void Option::unsafe_arena_set_allocated_name( ::std::string* name) { GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); @@ -2043,54 +2311,60 @@ inline void Option::unsafe_arena_set_allocated_name( inline bool Option::has_value() const { return this != internal_default_instance() && value_ != NULL; } -inline void Option::clear_value() { - if (GetArenaNoVirtual() == NULL && value_ != NULL) delete value_; - value_ = NULL; -} inline const ::google::protobuf::Any& Option::value() const { + const ::google::protobuf::Any* p = value_; // @@protoc_insertion_point(field_get:google.protobuf.Option.value) - return value_ != NULL ? *value_ - : *::google::protobuf::Any::internal_default_instance(); + return p != NULL ? *p : *reinterpret_cast<const ::google::protobuf::Any*>( + &::google::protobuf::_Any_default_instance_); +} +inline ::google::protobuf::Any* Option::release_value() { + // @@protoc_insertion_point(field_release:google.protobuf.Option.value) + + ::google::protobuf::Any* temp = value_; + if (GetArenaNoVirtual() != NULL) { + temp = ::google::protobuf::internal::DuplicateIfNonNull(temp, NULL); + } + value_ = NULL; + return temp; +} +inline ::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; } inline ::google::protobuf::Any* Option::mutable_value() { if (value_ == NULL) { - _slow_mutable_value(); + value_ = ::google::protobuf::Arena::Create< ::google::protobuf::Any >( + GetArenaNoVirtual()); } // @@protoc_insertion_point(field_mutable:google.protobuf.Option.value) return value_; } -inline ::google::protobuf::Any* Option::release_value() { - // @@protoc_insertion_point(field_release:google.protobuf.Option.value) - - if (GetArenaNoVirtual() != NULL) { - return _slow_release_value(); - } else { - ::google::protobuf::Any* temp = value_; - value_ = NULL; - return temp; - } -} -inline void Option::set_allocated_value(::google::protobuf::Any* value) { +inline void Option::set_allocated_value(::google::protobuf::Any* value) { ::google::protobuf::Arena* message_arena = GetArenaNoVirtual(); if (message_arena == NULL) { - delete value_; + delete reinterpret_cast< ::google::protobuf::MessageLite*>(value_); } - if (value != NULL) { - if (message_arena != NULL) { - message_arena->Own(value); - } - } - value_ = value; if (value) { + ::google::protobuf::Arena* submessage_arena = NULL; + if (message_arena != submessage_arena) { + value = ::google::protobuf::internal::GetOwnedMessage( + message_arena, value, submessage_arena); + } } else { } + value_ = value; // @@protoc_insertion_point(field_set_allocated:google.protobuf.Option.value) } -#endif // !PROTOBUF_INLINE_NOT_IN_HEADERS +#ifdef __GNUC__ + #pragma GCC diagnostic pop +#endif // __GNUC__ // ------------------------------------------------------------------- // ------------------------------------------------------------------- @@ -2102,11 +2376,9 @@ inline void Option::set_allocated_value(::google::protobuf::Any* value) { // @@protoc_insertion_point(namespace_scope) - } // namespace protobuf } // namespace google -#ifndef SWIG namespace google { namespace protobuf { @@ -2128,8 +2400,7 @@ inline const EnumDescriptor* GetEnumDescriptor< ::google::protobuf::Syntax>() { } // namespace protobuf } // namespace google -#endif // SWIG // @@protoc_insertion_point(global_scope) -#endif // PROTOBUF_google_2fprotobuf_2ftype_2eproto__INCLUDED +#endif // PROTOBUF_google_2fprotobuf_2ftype_2eproto_INCLUDED diff --git a/src/google/protobuf/unittest.proto b/src/google/protobuf/unittest.proto index 2040487e..2a288daa 100644 --- a/src/google/protobuf/unittest.proto +++ b/src/google/protobuf/unittest.proto @@ -189,6 +189,9 @@ message NestedTestAllTypes { message TestDeprecatedFields { optional int32 deprecated_int32 = 1 [deprecated=true]; + oneof oneof_fields { + int32 deprecated_int32_in_oneof = 2 [deprecated=true]; + } } message TestDeprecatedMessage { @@ -397,6 +400,12 @@ message TestRequiredForeign { optional int32 dummy = 3; } +message TestRequiredMessage { + optional TestRequired optional_message = 1; + repeated TestRequired repeated_message = 2; + required TestRequired required_message = 3; +} + // Test that we can use NestedMessage from outside TestAllTypes. message TestForeignNested { optional TestAllTypes.NestedMessage foreign_nested = 1; diff --git a/src/google/protobuf/unittest_lite.proto b/src/google/protobuf/unittest_lite.proto index c39ac6b0..9a15bdaa 100644 --- a/src/google/protobuf/unittest_lite.proto +++ b/src/google/protobuf/unittest_lite.proto @@ -439,3 +439,18 @@ message TestHugeFieldNumbersLite { extend TestHugeFieldNumbersLite { optional TestAllTypesLite test_all_types_lite = 536860000; } + +message TestOneofParsingLite { + oneof oneof_field { + int32 oneof_int32 = 1; + TestAllTypesLite oneof_submessage = 2; + string oneof_string = 3; + bytes oneof_bytes = 4 [default = "default bytes"]; + string oneof_string_cord = 5 [ctype = CORD, default = "default Cord"]; + bytes oneof_bytes_cord = 6 [ctype = CORD]; + string oneof_string_string_piece = 7 [ctype = STRING_PIECE]; + bytes oneof_bytes_string_piece = 8 + [ctype = STRING_PIECE, default = "default StringPiece"]; + V2EnumLite oneof_enum = 9; + } +} diff --git a/src/google/protobuf/unittest_lite_imports_nonlite.proto b/src/google/protobuf/unittest_lite_imports_nonlite.proto index 132d6a82..8a470160 100644 --- a/src/google/protobuf/unittest_lite_imports_nonlite.proto +++ b/src/google/protobuf/unittest_lite_imports_nonlite.proto @@ -41,4 +41,7 @@ option optimize_for = LITE_RUNTIME; message TestLiteImportsNonlite { optional TestAllTypes message = 1; + + // Verifies that transitive required fields generates valid code. + optional TestRequired message_with_required = 2; } diff --git a/src/google/protobuf/unittest_proto3.proto b/src/google/protobuf/unittest_proto3.proto index a27b1b26..84815d42 100644 --- a/src/google/protobuf/unittest_proto3.proto +++ b/src/google/protobuf/unittest_proto3.proto @@ -28,35 +28,13 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. -// -// A proto file we will use for unit testing. - syntax = "proto3"; -// Some generic_services option(s) added automatically. -// See: http://go/proto2-generic-services-default -option cc_generic_services = true; // auto-added -option java_generic_services = true; // auto-added -option py_generic_services = true; // auto-added -option cc_enable_arenas = true; -option csharp_namespace = "Google.Protobuf.TestProtos"; - -import "google/protobuf/unittest_import_proto3.proto"; - -// We don't put this in a package within proto2 because we need to make sure -// that the generated code doesn't depend on being in the proto2 namespace. -// In test_util.h we do "using namespace unittest = protobuf_unittest". -package protobuf_unittest; - -// Protos optimized for SPEED use a strict superset of the generated code -// of equivalent ones optimized for CODE_SIZE, so we should optimize all our -// tests for speed unless explicitly testing code size optimization. option optimize_for = SPEED; -option java_outer_classname = "UnittestProto"; +import "google/protobuf/unittest_import.proto"; + +package proto3_unittest; // This proto includes every type of field in both singular and repeated // forms. @@ -69,7 +47,7 @@ message TestAllTypes { } enum NestedEnum { - NESTED_ENUM_UNSPECIFIED = 0; + ZERO = 0; FOO = 1; BAR = 2; BAZ = 3; @@ -77,33 +55,49 @@ message TestAllTypes { } // Singular - int32 single_int32 = 1; - int64 single_int64 = 2; - uint32 single_uint32 = 3; - uint64 single_uint64 = 4; - sint32 single_sint32 = 5; - sint64 single_sint64 = 6; - fixed32 single_fixed32 = 7; - fixed64 single_fixed64 = 8; - sfixed32 single_sfixed32 = 9; - sfixed64 single_sfixed64 = 10; - float single_float = 11; - double single_double = 12; - bool single_bool = 13; - string single_string = 14; - bytes single_bytes = 15; - - NestedMessage single_nested_message = 18; - ForeignMessage single_foreign_message = 19; - protobuf_unittest_import.ImportMessage single_import_message = 20; - - NestedEnum single_nested_enum = 21; - ForeignEnum single_foreign_enum = 22; - protobuf_unittest_import.ImportEnum single_import_enum = 23; + int32 optional_int32 = 1; + int64 optional_int64 = 2; + uint32 optional_uint32 = 3; + uint64 optional_uint64 = 4; + sint32 optional_sint32 = 5; + sint64 optional_sint64 = 6; + fixed32 optional_fixed32 = 7; + fixed64 optional_fixed64 = 8; + sfixed32 optional_sfixed32 = 9; + sfixed64 optional_sfixed64 = 10; + float optional_float = 11; + double optional_double = 12; + bool optional_bool = 13; + string optional_string = 14; + bytes optional_bytes = 15; + + // Groups are not allowed in proto3. + // optional group OptionalGroup = 16 { + // optional int32 a = 17; + // } + + NestedMessage optional_nested_message = 18; + ForeignMessage optional_foreign_message = 19; + protobuf_unittest_import.ImportMessage optional_import_message = 20; + + NestedEnum optional_nested_enum = 21; + ForeignEnum optional_foreign_enum = 22; + + // Omitted (compared to unittest.proto) because proto2 enums are not allowed + // inside proto2 messages. + // + // optional protobuf_unittest_import.ImportEnum optional_import_enum = 23; + + string optional_string_piece = 24 [ctype=STRING_PIECE]; + string optional_cord = 25 [ctype=CORD]; // Defined in unittest_import_public.proto protobuf_unittest_import.PublicImportMessage - single_public_import_message = 26; + optional_public_import_message = 26; + + NestedMessage optional_lazy_message = 27 [lazy=true]; + protobuf_unittest_import.ImportMessage optional_lazy_import_message = 115 + [lazy = true]; // Repeated repeated int32 repeated_int32 = 31; @@ -122,18 +116,28 @@ message TestAllTypes { repeated string repeated_string = 44; repeated bytes repeated_bytes = 45; + // Groups are not allowed in proto3. + // repeated group RepeatedGroup = 46 { + // optional int32 a = 47; + // } + repeated NestedMessage repeated_nested_message = 48; repeated ForeignMessage repeated_foreign_message = 49; repeated protobuf_unittest_import.ImportMessage repeated_import_message = 50; repeated NestedEnum repeated_nested_enum = 51; repeated ForeignEnum repeated_foreign_enum = 52; - repeated protobuf_unittest_import.ImportEnum repeated_import_enum = 53; - // Defined in unittest_import_public.proto - repeated protobuf_unittest_import.PublicImportMessage - repeated_public_import_message = 54; - // For oneof test + // Omitted (compared to unittest.proto) because proto2 enums are not allowed + // inside proto2 messages. + // + // repeated protobuf_unittest_import.ImportEnum repeated_import_enum = 53; + + repeated string repeated_string_piece = 54 [ctype=STRING_PIECE]; + repeated string repeated_cord = 55 [ctype=CORD]; + + repeated NestedMessage repeated_lazy_message = 57 [lazy=true]; + oneof oneof_field { uint32 oneof_uint32 = 111; NestedMessage oneof_nested_message = 112; @@ -142,176 +146,6 @@ message TestAllTypes { } } -// This proto includes a recusively nested message. -message NestedTestAllTypes { - NestedTestAllTypes child = 1; - TestAllTypes payload = 2; - repeated NestedTestAllTypes repeated_child = 3; -} - -message TestDeprecatedFields { - int32 deprecated_int32 = 1 [deprecated=true]; -} - -// Define these after TestAllTypes to make sure the compiler can handle -// that. -message ForeignMessage { - int32 c = 1; -} - -enum ForeignEnum { - FOREIGN_UNSPECIFIED = 0; - FOREIGN_FOO = 4; - FOREIGN_BAR = 5; - FOREIGN_BAZ = 6; -} - -message TestReservedFields { - reserved 2, 15, 9 to 11; - reserved "bar", "baz"; -} - - -// Test that we can use NestedMessage from outside TestAllTypes. -message TestForeignNested { - TestAllTypes.NestedMessage foreign_nested = 1; -} - -// Test that really large tag numbers don't break anything. -message TestReallyLargeTagNumber { - // The largest possible tag number is 2^28 - 1, since the wire format uses - // three bits to communicate wire type. - int32 a = 1; - int32 bb = 268435455; -} - -message TestRecursiveMessage { - TestRecursiveMessage a = 1; - int32 i = 2; -} - -// Test that mutual recursion works. -message TestMutualRecursionA { - TestMutualRecursionB bb = 1; -} - -message TestMutualRecursionB { - TestMutualRecursionA a = 1; - int32 optional_int32 = 2; -} - -message TestEnumAllowAlias { - TestEnumWithDupValue value = 1; -} - -// Test an enum that has multiple values with the same number. -enum TestEnumWithDupValue { - TEST_ENUM_WITH_DUP_VALUE_UNSPECIFIED = 0; - option allow_alias = true; - - FOO1 = 1; - BAR1 = 2; - BAZ = 3; - FOO2 = 1; - BAR2 = 2; -} - -// Test an enum with large, unordered values. -enum TestSparseEnum { - TEST_SPARSE_ENUM_UNSPECIFIED = 0; - SPARSE_A = 123; - SPARSE_B = 62374; - SPARSE_C = 12589234; - SPARSE_D = -15; - SPARSE_E = -53452; - // In proto3, value 0 must be the first one specified - // SPARSE_F = 0; - SPARSE_G = 2; -} - -// Test message with CamelCase field names. This violates Protocol Buffer -// standard style. -message TestCamelCaseFieldNames { - int32 PrimitiveField = 1; - string StringField = 2; - ForeignEnum EnumField = 3; - ForeignMessage MessageField = 4; - - repeated int32 RepeatedPrimitiveField = 7; - repeated string RepeatedStringField = 8; - repeated ForeignEnum RepeatedEnumField = 9; - repeated ForeignMessage RepeatedMessageField = 10; -} - - -// We list fields out of order, to ensure that we're using field number and not -// field index to determine serialization order. -message TestFieldOrderings { - string my_string = 11; - int64 my_int = 1; - float my_float = 101; - message NestedMessage { - int64 oo = 2; - // The field name "b" fails to compile in proto1 because it conflicts with - // a local variable named "b" in one of the generated methods. Doh. - // This file needs to compile in proto1 to test backwards-compatibility. - int32 bb = 1; - } - - NestedMessage single_nested_message = 200; -} - -message SparseEnumMessage { - TestSparseEnum sparse_enum = 1; -} - -// Test String and Bytes: string is for valid UTF-8 strings -message OneString { - string data = 1; -} - -message MoreString { - repeated string data = 1; -} - -message OneBytes { - bytes data = 1; -} - -message MoreBytes { - bytes data = 1; -} - -// Test int32, uint32, int64, uint64, and bool are all compatible -message Int32Message { - int32 data = 1; -} - -message Uint32Message { - uint32 data = 1; -} - -message Int64Message { - int64 data = 1; -} - -message Uint64Message { - uint64 data = 1; -} - -message BoolMessage { - bool data = 1; -} - -// Test oneofs. -message TestOneof { - oneof foo { - int32 foo_int = 1; - string foo_string = 2; - TestAllTypes foo_message = 3; - } -} - // Test messages for packed fields message TestPackedTypes { @@ -331,61 +165,44 @@ message TestPackedTypes { repeated ForeignEnum packed_enum = 103 [packed = true]; } -// A message with the same fields as TestPackedTypes, but without packing. Used -// to test packed <-> unpacked wire compatibility. +// Explicitly set packed to false message TestUnpackedTypes { - repeated int32 unpacked_int32 = 90 [packed = false]; - repeated int64 unpacked_int64 = 91 [packed = false]; - repeated uint32 unpacked_uint32 = 92 [packed = false]; - repeated uint64 unpacked_uint64 = 93 [packed = false]; - repeated sint32 unpacked_sint32 = 94 [packed = false]; - repeated sint64 unpacked_sint64 = 95 [packed = false]; - repeated fixed32 unpacked_fixed32 = 96 [packed = false]; - repeated fixed64 unpacked_fixed64 = 97 [packed = false]; - repeated sfixed32 unpacked_sfixed32 = 98 [packed = false]; - repeated sfixed64 unpacked_sfixed64 = 99 [packed = false]; - repeated float unpacked_float = 100 [packed = false]; - repeated double unpacked_double = 101 [packed = false]; - repeated bool unpacked_bool = 102 [packed = false]; - repeated ForeignEnum unpacked_enum = 103 [packed = false]; + repeated int32 repeated_int32 = 1 [packed = false]; + repeated int64 repeated_int64 = 2 [packed = false]; + repeated uint32 repeated_uint32 = 3 [packed = false]; + repeated uint64 repeated_uint64 = 4 [packed = false]; + repeated sint32 repeated_sint32 = 5 [packed = false]; + repeated sint64 repeated_sint64 = 6 [packed = false]; + repeated fixed32 repeated_fixed32 = 7 [packed = false]; + repeated fixed64 repeated_fixed64 = 8 [packed = false]; + repeated sfixed32 repeated_sfixed32 = 9 [packed = false]; + repeated sfixed64 repeated_sfixed64 = 10 [packed = false]; + repeated float repeated_float = 11 [packed = false]; + repeated double repeated_double = 12 [packed = false]; + repeated bool repeated_bool = 13 [packed = false]; + repeated TestAllTypes.NestedEnum repeated_nested_enum = 14 [packed = false]; } -message TestRepeatedScalarDifferentTagSizes { - // Parsing repeated fixed size values used to fail. This message needs to be - // used in order to get a tag of the right size; all of the repeated fields - // in TestAllTypes didn't trigger the check. - repeated fixed32 repeated_fixed32 = 12; - // Check for a varint type, just for good measure. - repeated int32 repeated_int32 = 13; - - // These have two-byte tags. - repeated fixed64 repeated_fixed64 = 2046; - repeated int64 repeated_int64 = 2047; - - // Three byte tags. - repeated float repeated_float = 262142; - repeated uint64 repeated_uint64 = 262143; +// This proto includes a recusively nested message. +message NestedTestAllTypes { + NestedTestAllTypes child = 1; + TestAllTypes payload = 2; } -message TestCommentInjectionMessage { - // */ <- This should not close the generated doc comment - string a = 1; +// Define these after TestAllTypes to make sure the compiler can handle +// that. +message ForeignMessage { + int32 c = 1; } - -// Test that RPC services work. -message FooRequest {} -message FooResponse {} - -message FooClientMessage {} -message FooServerMessage{} - -service TestService { - rpc Foo(FooRequest) returns (FooResponse); - rpc Bar(BarRequest) returns (BarResponse); +enum ForeignEnum { + FOREIGN_ZERO = 0; + FOREIGN_FOO = 4; + FOREIGN_BAR = 5; + FOREIGN_BAZ = 6; } - -message BarRequest {} -message BarResponse {} +// TestEmptyMessage is used to test behavior of unknown fields. +message TestEmptyMessage { +} diff --git a/src/google/protobuf/unittest_proto3_arena.proto b/src/google/protobuf/unittest_proto3_arena.proto index 9375d85a..ea88ec90 100644 --- a/src/google/protobuf/unittest_proto3_arena.proto +++ b/src/google/protobuf/unittest_proto3_arena.proto @@ -187,6 +187,7 @@ message TestUnpackedTypes { message NestedTestAllTypes { NestedTestAllTypes child = 1; TestAllTypes payload = 2; + repeated NestedTestAllTypes repeated_child = 3; } // Define these after TestAllTypes to make sure the compiler can handle @@ -205,4 +206,3 @@ enum ForeignEnum { // TestEmptyMessage is used to test behavior of unknown fields. message TestEmptyMessage { } - diff --git a/src/google/protobuf/unknown_field_set.h b/src/google/protobuf/unknown_field_set.h index 002ea8e8..619855ed 100644 --- a/src/google/protobuf/unknown_field_set.h +++ b/src/google/protobuf/unknown_field_set.h @@ -43,7 +43,7 @@ #include <vector> #include <google/protobuf/stubs/common.h> #include <google/protobuf/stubs/logging.h> -#include <google/protobuf/generated_message_util.h> +#include <google/protobuf/message_lite.h> namespace google { namespace protobuf { @@ -282,10 +282,10 @@ inline int UnknownFieldSet::field_count() const { } inline const UnknownField& UnknownFieldSet::field(int index) const { GOOGLE_DCHECK(fields_ != NULL); - return (*fields_)[index]; + return (*fields_)[static_cast<size_t>(index)]; } inline UnknownField* UnknownFieldSet::mutable_field(int index) { - return &(*fields_)[index]; + return &(*fields_)[static_cast<size_t>(index)]; } inline void UnknownFieldSet::AddLengthDelimited( @@ -296,7 +296,7 @@ inline void UnknownFieldSet::AddLengthDelimited( -inline int UnknownField::number() const { return number_; } +inline int UnknownField::number() const { return static_cast<int>(number_); } inline UnknownField::Type UnknownField::type() const { return static_cast<Type>(type_); } diff --git a/src/google/protobuf/util/delimited_message_util.cc b/src/google/protobuf/util/delimited_message_util.cc index 16378782..3ba930e7 100644 --- a/src/google/protobuf/util/delimited_message_util.cc +++ b/src/google/protobuf/util/delimited_message_util.cc @@ -12,7 +12,7 @@ bool SerializeDelimitedToFileDescriptor(const MessageLite& message, int file_des return SerializeDelimitedToZeroCopyStream(message, &output); } -bool SerializeDelimitedToOstream(const MessageLite& message, ostream* output) { +bool SerializeDelimitedToOstream(const MessageLite& message, std::ostream* output) { { io::OstreamOutputStream zero_copy_output(output); if (!SerializeDelimitedToZeroCopyStream(message, &zero_copy_output)) return false; diff --git a/src/google/protobuf/util/delimited_message_util.h b/src/google/protobuf/util/delimited_message_util.h index 302d4781..e8a7204a 100644 --- a/src/google/protobuf/util/delimited_message_util.h +++ b/src/google/protobuf/util/delimited_message_util.h @@ -32,7 +32,7 @@ namespace util { // underlying source, so instead you must keep using the same stream object. bool LIBPROTOBUF_EXPORT SerializeDelimitedToFileDescriptor(const MessageLite& message, int file_descriptor); -bool LIBPROTOBUF_EXPORT SerializeDelimitedToOstream(const MessageLite& message, ostream* output); +bool LIBPROTOBUF_EXPORT SerializeDelimitedToOstream(const MessageLite& message, std::ostream* output); // Read a single size-delimited message from the given stream. Delimited // format allows a single file or stream to contain multiple messages, diff --git a/src/google/protobuf/util/field_comparator.cc b/src/google/protobuf/util/field_comparator.cc index a1a56ee6..86ddf06a 100644 --- a/src/google/protobuf/util/field_comparator.cc +++ b/src/google/protobuf/util/field_comparator.cc @@ -36,6 +36,7 @@ #include <google/protobuf/descriptor.h> #include <google/protobuf/message.h> +#include <google/protobuf/util/message_differencer.h> #include <google/protobuf/stubs/map_util.h> #include <google/protobuf/stubs/mathlimits.h> #include <google/protobuf/stubs/mathutil.h> @@ -130,6 +131,15 @@ FieldComparator::ComparisonResult DefaultFieldComparator::Compare( } } +bool DefaultFieldComparator::Compare( + MessageDifferencer* differencer, + const Message& message1, + const Message& message2, + const google::protobuf::util::FieldContext* field_context) { + return differencer->Compare( + message1, message2, field_context->parent_fields()); +} + void DefaultFieldComparator::SetDefaultFractionAndMargin(double fraction, double margin) { default_tolerance_ = Tolerance(fraction, margin); diff --git a/src/google/protobuf/util/field_comparator.h b/src/google/protobuf/util/field_comparator.h index ad560ebc..27ef4c77 100644 --- a/src/google/protobuf/util/field_comparator.h +++ b/src/google/protobuf/util/field_comparator.h @@ -35,6 +35,7 @@ #include <map> #include <string> +#include <vector> #include <google/protobuf/stubs/common.h> @@ -48,6 +49,7 @@ class FieldDescriptor; namespace util { class FieldContext; +class MessageDifferencer; // Base class specifying the interface for comparing protocol buffer fields. // Regular users should consider using or subclassing DefaultFieldComparator @@ -153,6 +155,15 @@ class LIBPROTOBUF_EXPORT DefaultFieldComparator : public FieldComparator { // REQUIRES: float_comparison_ == APPROXIMATE void SetDefaultFractionAndMargin(double fraction, double margin); + protected: + // Compare using the provided message_differencer. For example, a subclass can + // use this method to compare some field in a certain way using the same + // message_differencer instance and the field context. + bool Compare(MessageDifferencer* differencer, + const google::protobuf::Message& message1, + const google::protobuf::Message& message2, + const google::protobuf::util::FieldContext* field_context); + private: // Defines the tolerance for floating point comparison (fraction and margin). struct Tolerance { @@ -237,7 +248,7 @@ class LIBPROTOBUF_EXPORT DefaultFieldComparator : public FieldComparator { // True iff default_tolerance_ has been explicitly set. // - // If false, then the default tolerance for flaots and doubles is that which + // If false, then the default tolerance for floats and doubles is that which // is used by MathUtil::AlmostEquals(). bool has_default_tolerance_; diff --git a/src/google/protobuf/util/field_mask_util.cc b/src/google/protobuf/util/field_mask_util.cc index 85cecec5..8a413498 100644 --- a/src/google/protobuf/util/field_mask_util.cc +++ b/src/google/protobuf/util/field_mask_util.cc @@ -192,6 +192,13 @@ class FieldMaskTree { // children removed because the path matches all the node's children. void AddPath(const string& path); + // Remove a path from the tree. + // If the path is a sub-path of an existing field path in the tree, it means + // we need remove the existing fied path and add all sub-paths except + // specified path. If the path matches an existing node in the tree, this node + // will be moved. + void RemovePath(const string& path, const Descriptor* descriptor); + // Calculate the intersection part of a field path with this tree and add // the intersection field path into out. void IntersectPath(const string& path, FieldMaskTree* out); @@ -207,6 +214,18 @@ class FieldMaskTree { MergeMessage(&root_, source, options, destination); } + // Add required field path of the message to this tree based on current tree + // structure. If a message is present in the tree, add the path of its + // required field to the tree. This is to make sure that after trimming a + // message with required fields are set, check IsInitialized() will not fail. + void AddRequiredFieldPath(const Descriptor* descriptor) { + // Do nothing if the tree is empty. + if (root_.children.empty()) { + return; + } + AddRequiredFieldPath(&root_, descriptor); + } + // Trims all fields not specified by this tree from the given message. void TrimMessage(Message* message) { // Do nothing if the tree is empty. @@ -249,6 +268,12 @@ class FieldMaskTree { const FieldMaskUtil::MergeOptions& options, Message* destination); + // Add required field path of the message to this tree based on current tree + // structure. If a message is present in the tree, add the path of its + // required field to the tree. This is to make sure that after trimming a + // message with required fields are set, check IsInitialized() will not fail. + void AddRequiredFieldPath(Node* node, const Descriptor* descriptor); + // Trims all fields not specified by this sub-tree from the given message. void TrimMessage(const Node* node, Message* message); @@ -315,6 +340,59 @@ void FieldMaskTree::AddPath(const string& path) { } } +void FieldMaskTree::RemovePath(const string& path, + const Descriptor* descriptor) { + std::vector<string> parts = Split(path, "."); + if (parts.empty()) { + return; + } + std::vector<Node*> nodes(parts.size()); + Node* node = &root_; + const Descriptor* current_descriptor = descriptor; + Node* new_branch_node = NULL; + for (int i = 0; i < parts.size(); ++i) { + nodes[i] = node; + const FieldDescriptor* field_descriptor = + current_descriptor->FindFieldByName(parts[i]); + if (field_descriptor == NULL || + (field_descriptor->cpp_type() != FieldDescriptor::CPPTYPE_MESSAGE && + i != parts.size() - 1)) { + // Invalid path. + if (new_branch_node != NULL) { + // If add any new nodes, cleanup. + new_branch_node->ClearChildren(); + } + return; + } + + if (node->children.empty()) { + if (new_branch_node == NULL) { + new_branch_node = node; + } + for (int i = 0; i < current_descriptor->field_count(); ++i) { + node->children[current_descriptor->field(i)->name()] = new Node(); + } + } + if (ContainsKey(node->children, parts[i])) { + node = node->children[parts[i]]; + if (field_descriptor->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { + current_descriptor = field_descriptor->message_type(); + } + } else { + // Path does not exist. + return; + } + } + // Remove path. + for (int i = parts.size() - 1; i >= 0; i--) { + delete nodes[i]->children[parts[i]]; + nodes[i]->children.erase(parts[i]); + if (!nodes[i]->children.empty()) { + break; + } + } +} + void FieldMaskTree::IntersectPath(const string& path, FieldMaskTree* out) { std::vector<string> parts = Split(path, "."); if (parts.empty()) { @@ -456,6 +534,41 @@ void FieldMaskTree::MergeMessage(const Node* node, const Message& source, } } +void FieldMaskTree::AddRequiredFieldPath( + Node* node, const Descriptor* descriptor) { + const int32 field_count = descriptor->field_count(); + for (int index = 0; index < field_count; ++index) { + const FieldDescriptor* field = descriptor->field(index); + if (field->is_required()) { + const string& node_name = field->name(); + Node*& child = node->children[node_name]; + if (child == NULL) { + // Add required field path to the tree + child = new Node(); + } else if (child->children.empty()){ + // If the required field is in the tree and does not have any children, + // do nothing. + continue; + } + // Add required field in the children to the tree if the field is message. + if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { + AddRequiredFieldPath(child, field->message_type()); + } + } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { + std::map<string, Node*>::const_iterator it = + node->children.find(field->name()); + if (it != node->children.end()) { + // Add required fields in the children to the + // tree if the field is a message and present in the tree. + Node* child = it->second; + if (!child->children.empty()) { + AddRequiredFieldPath(child, field->message_type()); + } + } + } + } +} + void FieldMaskTree::TrimMessage(const Node* node, Message* message) { GOOGLE_DCHECK(!node->children.empty()); const Reflection* reflection = message->GetReflection(); @@ -470,7 +583,7 @@ void FieldMaskTree::TrimMessage(const Node* node, Message* message) { } else { if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { Node* child = it->second; - if (!child->children.empty()) { + if (!child->children.empty() && reflection->HasField(*message, field)) { TrimMessage(child, reflection->MutableMessage(message, field)); } } @@ -507,6 +620,22 @@ void FieldMaskUtil::Intersect(const FieldMask& mask1, const FieldMask& mask2, intersection.MergeToFieldMask(out); } +void FieldMaskUtil::InternalSubtract(const Descriptor* descriptor, + const FieldMask& mask1, + const FieldMask& mask2, FieldMask* out) { + if (mask1.paths().empty()) { + out->Clear(); + return; + } + FieldMaskTree tree; + tree.MergeFromFieldMask(mask1); + for (int i = 0; i < mask2.paths_size(); ++i) { + tree.RemovePath(mask2.paths(i), descriptor); + } + out->Clear(); + tree.MergeToFieldMask(out); +} + bool FieldMaskUtil::IsPathInFieldMask(StringPiece path, const FieldMask& mask) { for (int i = 0; i < mask.paths_size(); ++i) { const string& mask_path = mask.paths(i); @@ -542,6 +671,20 @@ void FieldMaskUtil::TrimMessage(const FieldMask& mask, Message* destination) { tree.TrimMessage(GOOGLE_CHECK_NOTNULL(destination)); } +void FieldMaskUtil::TrimMessage(const FieldMask& mask, Message* destination, + const TrimOptions& options) { + // Build a FieldMaskTree and walk through the tree to merge all specified + // fields. + FieldMaskTree tree; + tree.MergeFromFieldMask(mask); + // If keep_required_fields is true, implicitely add required fields of + // a message present in the tree to prevent from trimming. + if (options.keep_required_fields()) { + tree.AddRequiredFieldPath(GOOGLE_CHECK_NOTNULL(destination->GetDescriptor())); + } + tree.TrimMessage(GOOGLE_CHECK_NOTNULL(destination)); +} + } // namespace util } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/util/field_mask_util.h b/src/google/protobuf/util/field_mask_util.h index ab1f2e94..91787bd5 100644 --- a/src/google/protobuf/util/field_mask_util.h +++ b/src/google/protobuf/util/field_mask_util.h @@ -94,6 +94,13 @@ class LIBPROTOBUF_EXPORT FieldMaskUtil { // Creates a FieldMask with all fields of type T. This FieldMask only // contains fields of T but not any sub-message fields. template <typename T> + static FieldMask GetFieldMaskForAllFields() { + FieldMask out; + InternalGetFieldMaskForAllFields(T::descriptor(), &out); + return out; + } + template <typename T> + PROTOBUF_RUNTIME_DEPRECATED("Use *out = GetFieldMaskForAllFields() instead") static void GetFieldMaskForAllFields(FieldMask* out) { InternalGetFieldMaskForAllFields(T::descriptor(), out); } @@ -113,8 +120,17 @@ class LIBPROTOBUF_EXPORT FieldMaskUtil { static void Intersect(const FieldMask& mask1, const FieldMask& mask2, FieldMask* out); + // Subtracts mask2 from mask1 base of type T. + template <typename T> + static void Subtract(const FieldMask& mask1, const FieldMask& mask2, + FieldMask* out) { + InternalSubtract(T::descriptor(), mask1, mask2, out); + } + // Returns true if path is covered by the given FieldMask. Note that path // "foo.bar" covers all paths like "foo.bar.baz", "foo.bar.quz.x", etc. + // Also note that parent paths are not covered by explicit child path, i.e. + // "foo.bar" does NOT cover "foo", even if "bar" is the only child. static bool IsPathInFieldMask(StringPiece path, const FieldMask& mask); class MergeOptions; @@ -124,10 +140,17 @@ class LIBPROTOBUF_EXPORT FieldMaskUtil { static void MergeMessageTo(const Message& source, const FieldMask& mask, const MergeOptions& options, Message* destination); + class TrimOptions; // Removes from 'message' any field that is not represented in the given // FieldMask. If the FieldMask is empty, does nothing. static void TrimMessage(const FieldMask& mask, Message* message); + // Removes from 'message' any field that is not represented in the given + // FieldMask with customized TrimOptions. + // If the FieldMask is empty, does nothing. + static void TrimMessage(const FieldMask& mask, Message* message, + const TrimOptions& options); + private: friend class SnakeCaseCamelCaseTest; // Converts a field name from snake_case to camelCase: @@ -160,6 +183,10 @@ class LIBPROTOBUF_EXPORT FieldMaskUtil { static void InternalGetFieldMaskForAllFields(const Descriptor* descriptor, FieldMask* out); + + static void InternalSubtract(const Descriptor* descriptor, + const FieldMask& mask1, const FieldMask& mask2, + FieldMask* out); }; // Note that for compatibility with the defined behaviour for FieldMask in @@ -194,6 +221,23 @@ class LIBPROTOBUF_EXPORT FieldMaskUtil::MergeOptions { bool replace_repeated_fields_; }; +class LIBPROTOBUF_EXPORT FieldMaskUtil::TrimOptions { + public: + TrimOptions() + : keep_required_fields_(false) {} + // When trimming message fields, the default behavior is to trim required + // fields of the present message if they are not specified in the field mask. + // If you instead want to keep required fields of the present message even + // they are not speicifed in the field mask, set this flag to true. + void set_keep_required_fields(bool value) { + keep_required_fields_ = value; + } + bool keep_required_fields() const { return keep_required_fields_; } + + private: + bool keep_required_fields_; +}; + } // namespace util } // namespace protobuf diff --git a/src/google/protobuf/util/field_mask_util_test.cc b/src/google/protobuf/util/field_mask_util_test.cc index f952786f..0664d9e5 100644 --- a/src/google/protobuf/util/field_mask_util_test.cc +++ b/src/google/protobuf/util/field_mask_util_test.cc @@ -114,6 +114,8 @@ TEST_F(SnakeCaseCamelCaseTest, RoundTripTest) { } using protobuf_unittest::TestAllTypes; +using protobuf_unittest::TestRequired; +using protobuf_unittest::TestRequiredMessage; using protobuf_unittest::NestedTestAllTypes; using google::protobuf::FieldMask; @@ -204,12 +206,12 @@ TEST(FieldMaskUtilTest, TestIsValidFieldMask) { TEST(FieldMaskUtilTest, TestGetFieldMaskForAllFields) { FieldMask mask; - FieldMaskUtil::GetFieldMaskForAllFields<TestAllTypes::NestedMessage>(&mask); + mask = FieldMaskUtil::GetFieldMaskForAllFields<TestAllTypes::NestedMessage>(); EXPECT_EQ(1, mask.paths_size()); EXPECT_TRUE(FieldMaskUtil::IsPathInFieldMask("bb", mask)); - FieldMaskUtil::GetFieldMaskForAllFields<TestAllTypes>(&mask); - EXPECT_EQ(76, mask.paths_size()); + mask = FieldMaskUtil::GetFieldMaskForAllFields<TestAllTypes>(); + EXPECT_EQ(75, mask.paths_size()); EXPECT_TRUE(FieldMaskUtil::IsPathInFieldMask("optional_int32", mask)); EXPECT_TRUE(FieldMaskUtil::IsPathInFieldMask("optional_int64", mask)); EXPECT_TRUE(FieldMaskUtil::IsPathInFieldMask("optional_uint32", mask)); @@ -346,6 +348,46 @@ TEST(FieldMaskUtilTest, TestIntersect) { EXPECT_EQ("foo.bar.baz", FieldMaskUtil::ToString(out)); } +TEST(FieldMaskUtilTest, TestSubtract) { + FieldMask mask1, mask2, out; + // Normal case. + FieldMaskUtil::FromString( + "optional_int32,optional_uint64,optional_nested_message,optional_foreign_" + "message,repeated_int32,repeated_foreign_message,repeated_nested_message." + "bb", + &mask1); + + FieldMaskUtil::FromString( + "optional_int32,optional_nested_message.bb,optional_foreign_message.c," + "repeated_int32,repeated_nested_message.bb,repeated_foreign_message.f," + "repeated_foreign_message.d,repeated_nested_message.bb,repeated_uint32", + &mask2); + + FieldMaskUtil::Subtract<TestAllTypes>(mask1, mask2, &out); + EXPECT_EQ( + "optional_foreign_message.d,optional_uint64,repeated_foreign_message.c", + FieldMaskUtil::ToString(out)); + + // mask1 is empty. + FieldMaskUtil::FromString("", &mask1); + FieldMaskUtil::Subtract<TestAllTypes>(mask1, mask2, &out); + EXPECT_EQ("", FieldMaskUtil::ToString(out)); + + // mask1 is "optional_nested_message" and mask2 is + // "optional_nested_message.nonexist_field". + FieldMaskUtil::FromString("optional_nested_message", &mask1); + FieldMaskUtil::FromString("optional_nested_message.nonexist_field", &mask2); + FieldMaskUtil::Subtract<TestAllTypes>(mask1, mask2, &out); + EXPECT_EQ("optional_nested_message", FieldMaskUtil::ToString(out)); + + // mask1 is "optional_nested_message" and mask2 is + // "optional_nested_message". + FieldMaskUtil::FromString("optional_nested_message", &mask1); + FieldMaskUtil::FromString("optional_nested_message", &mask2); + FieldMaskUtil::Subtract<TestAllTypes>(mask1, mask2, &out); + EXPECT_EQ("", FieldMaskUtil::ToString(out)); +} + TEST(FieldMaskUtilTest, TestIspathInFieldMask) { FieldMask mask; FieldMaskUtil::FromString("foo.bar", &mask); @@ -618,6 +660,84 @@ TEST(FieldMaskUtilTest, TrimMessage) { FieldMask empty_mask; FieldMaskUtil::TrimMessage(empty_mask, &trimmed_all_types); EXPECT_EQ(trimmed_all_types.DebugString(), all_types_msg.DebugString()); + + // Test trim required fields with keep_required_fields is set true. + FieldMaskUtil::TrimOptions options; + TestRequired required_msg_1; + required_msg_1.set_a(1234); + required_msg_1.set_b(3456); + required_msg_1.set_c(5678); + TestRequired trimmed_required_msg_1(required_msg_1); + FieldMaskUtil::FromString("dummy2", &mask); + options.set_keep_required_fields(true); + FieldMaskUtil::TrimMessage(mask, &trimmed_required_msg_1, options); + EXPECT_EQ(trimmed_required_msg_1.DebugString(), required_msg_1.DebugString()); + + // Test trim required fields with keep_required_fields is set false. + required_msg_1.clear_a(); + required_msg_1.clear_b(); + required_msg_1.clear_c(); + options.set_keep_required_fields(false); + FieldMaskUtil::TrimMessage(mask, &trimmed_required_msg_1, options); + EXPECT_EQ(trimmed_required_msg_1.DebugString(), required_msg_1.DebugString()); + + // Test trim required message with keep_required_fields is set true. + TestRequiredMessage required_msg_2; + required_msg_2.mutable_optional_message()->set_a(1234); + required_msg_2.mutable_optional_message()->set_b(3456); + required_msg_2.mutable_optional_message()->set_c(5678); + required_msg_2.mutable_required_message()->set_a(1234); + required_msg_2.mutable_required_message()->set_b(3456); + required_msg_2.mutable_required_message()->set_c(5678); + required_msg_2.mutable_required_message()->set_dummy2(7890); + TestRequired* repeated_msg = required_msg_2.add_repeated_message(); + repeated_msg->set_a(1234); + repeated_msg->set_b(3456); + repeated_msg->set_c(5678); + TestRequiredMessage trimmed_required_msg_2(required_msg_2); + FieldMaskUtil::FromString("optional_message.dummy2", &mask); + options.set_keep_required_fields(true); + required_msg_2.clear_repeated_message(); + required_msg_2.mutable_required_message()->clear_dummy2(); + FieldMaskUtil::TrimMessage(mask, &trimmed_required_msg_2, options); + EXPECT_EQ(trimmed_required_msg_2.DebugString(), + required_msg_2.DebugString()); + + FieldMaskUtil::FromString("required_message", &mask); + required_msg_2.mutable_required_message()->set_dummy2(7890); + trimmed_required_msg_2.mutable_required_message()->set_dummy2(7890); + required_msg_2.clear_optional_message(); + FieldMaskUtil::TrimMessage(mask, &trimmed_required_msg_2, options); + EXPECT_EQ(trimmed_required_msg_2.DebugString(), + required_msg_2.DebugString()); + + // Test trim required message with keep_required_fields is set false. + FieldMaskUtil::FromString("required_message.dummy2", &mask); + required_msg_2.mutable_required_message()->clear_a(); + required_msg_2.mutable_required_message()->clear_b(); + required_msg_2.mutable_required_message()->clear_c(); + options.set_keep_required_fields(false); + FieldMaskUtil::TrimMessage(mask, &trimmed_required_msg_2, options); + EXPECT_EQ(trimmed_required_msg_2.DebugString(), + required_msg_2.DebugString()); + + // Verify that trimming an empty message has no effect. In particular, fields + // mentioned in the field mask should not be created or changed. + TestAllTypes empty_msg; + FieldMaskUtil::FromString( + "optional_int32,optional_bytes,optional_nested_message.bb", &mask); + FieldMaskUtil::TrimMessage(mask, &empty_msg); + EXPECT_FALSE(empty_msg.has_optional_int32()); + EXPECT_FALSE(empty_msg.has_optional_bytes()); + EXPECT_FALSE(empty_msg.has_optional_nested_message()); + + // Verify trimming of oneof fields. This should work as expected even if + // multiple elements of the same oneof are included in the FieldMask. + TestAllTypes oneof_msg; + oneof_msg.set_oneof_uint32(11); + FieldMaskUtil::FromString("oneof_uint32,oneof_nested_message.bb", &mask); + FieldMaskUtil::TrimMessage(mask, &oneof_msg); + EXPECT_EQ(11, oneof_msg.oneof_uint32()); } diff --git a/src/google/protobuf/util/internal/default_value_objectwriter.cc b/src/google/protobuf/util/internal/default_value_objectwriter.cc index 5763d0c6..95b3a17d 100644 --- a/src/google/protobuf/util/internal/default_value_objectwriter.cc +++ b/src/google/protobuf/util/internal/default_value_objectwriter.cc @@ -637,6 +637,7 @@ void DefaultValueObjectWriter::RenderDataPiece(StringPiece name, current_->AddChild(node.release()); } else { child->set_data(data); + child->set_is_placeholder(false); } } diff --git a/src/google/protobuf/util/internal/default_value_objectwriter.h b/src/google/protobuf/util/internal/default_value_objectwriter.h index ef2cc981..09c6d23f 100644 --- a/src/google/protobuf/util/internal/default_value_objectwriter.h +++ b/src/google/protobuf/util/internal/default_value_objectwriter.h @@ -172,7 +172,7 @@ class LIBPROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter { // If this node is a leaf (has data), writes the current node to the // ObjectWriter; if not, then recursively writes the children to the // ObjectWriter. - void WriteTo(ObjectWriter* ow); + virtual void WriteTo(ObjectWriter* ow); // Accessors const string& name() const { return name_; } @@ -262,6 +262,10 @@ class LIBPROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter { static DataPiece CreateDefaultDataPieceForField( const google::protobuf::Field& field, const TypeInfo* typeinfo); + protected: + // Returns a pointer to current Node in tree. + Node* current() { return current_; } + private: // Populates children of "node" if it is an "any" Node and its real type has // been given. diff --git a/src/google/protobuf/util/internal/json_escaping.cc b/src/google/protobuf/util/internal/json_escaping.cc index 18b7f923..06b9a7f2 100644 --- a/src/google/protobuf/util/internal/json_escaping.cc +++ b/src/google/protobuf/util/internal/json_escaping.cc @@ -207,7 +207,7 @@ StringPiece ToHex(uint16 cp, char* buffer) { buffer[3] = kHex[cp & 0x0f]; cp >>= 4; buffer[2] = kHex[cp & 0x0f]; - return StringPiece(buffer).substr(0, 6); + return StringPiece(buffer, 6); } // Stores the 32-bit unicode code point as its hexadecimal digits in buffer diff --git a/src/google/protobuf/util/internal/json_escaping.h b/src/google/protobuf/util/internal/json_escaping.h index e3e329fc..5495c57f 100644 --- a/src/google/protobuf/util/internal/json_escaping.h +++ b/src/google/protobuf/util/internal/json_escaping.h @@ -28,8 +28,8 @@ // (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 NET_PROTO2_UTIL_CONVERTER_STRINGS_JSON_ESCAPING_H_ -#define NET_PROTO2_UTIL_CONVERTER_STRINGS_JSON_ESCAPING_H_ +#ifndef GOOGLE_PROTOBUF_UTIL_INTERNAL__JSON_ESCAPING_H__ +#define GOOGLE_PROTOBUF_UTIL_INTERNAL__JSON_ESCAPING_H__ #include <google/protobuf/stubs/common.h> #include <google/protobuf/stubs/bytestream.h> @@ -87,5 +87,5 @@ class JsonEscaping { } // namespace util } // namespace protobuf -#endif // NET_PROTO2_UTIL_CONVERTER_STRINGS_JSON_ESCAPING_H_ } // namespace google +#endif // GOOGLE_PROTOBUF_UTIL_INTERNAL__JSON_ESCAPING_H__ diff --git a/src/google/protobuf/util/internal/json_objectwriter.cc b/src/google/protobuf/util/internal/json_objectwriter.cc index 6e4edd88..a431177a 100644 --- a/src/google/protobuf/util/internal/json_objectwriter.cc +++ b/src/google/protobuf/util/internal/json_objectwriter.cc @@ -57,7 +57,7 @@ JsonObjectWriter::~JsonObjectWriter() { JsonObjectWriter* JsonObjectWriter::StartObject(StringPiece name) { WritePrefix(name); WriteChar('{'); - Push(); + PushObject(); return this; } @@ -71,7 +71,7 @@ JsonObjectWriter* JsonObjectWriter::EndObject() { JsonObjectWriter* JsonObjectWriter::StartList(StringPiece name) { WritePrefix(name); WriteChar('['); - Push(); + PushArray(); return this; } @@ -172,8 +172,7 @@ void JsonObjectWriter::WritePrefix(StringPiece name) { bool not_first = !element()->is_first(); if (not_first) WriteChar(','); if (not_first || !element()->is_root()) NewLine(); - bool empty_key_ok = GetAndResetEmptyKeyOk(); - if (!name.empty() || empty_key_ok) { + if (!name.empty() || element()->is_json_object()) { WriteChar('"'); if (!name.empty()) { ArrayByteSource source(name); @@ -184,12 +183,6 @@ void JsonObjectWriter::WritePrefix(StringPiece name) { } } -bool JsonObjectWriter::GetAndResetEmptyKeyOk() { - bool retval = empty_name_ok_for_next_key_; - empty_name_ok_for_next_key_ = false; - return retval; -} - } // namespace converter } // namespace util } // namespace protobuf diff --git a/src/google/protobuf/util/internal/json_objectwriter.h b/src/google/protobuf/util/internal/json_objectwriter.h index 31edc292..81da0500 100644 --- a/src/google/protobuf/util/internal/json_objectwriter.h +++ b/src/google/protobuf/util/internal/json_objectwriter.h @@ -89,12 +89,11 @@ class LIBPROTOBUF_EXPORT JsonObjectWriter : public StructuredObjectWriter { public: JsonObjectWriter(StringPiece indent_string, google::protobuf::io::CodedOutputStream* out) - : element_(new Element(NULL)), + : element_(new Element(/*parent=*/NULL, /*is_json_object=*/false)), stream_(out), sink_(out), indent_string_(indent_string.ToString()), - use_websafe_base64_for_bytes_(false), - empty_name_ok_for_next_key_(false) {} + use_websafe_base64_for_bytes_(false) {} virtual ~JsonObjectWriter(); // ObjectWriter methods. @@ -118,17 +117,13 @@ class LIBPROTOBUF_EXPORT JsonObjectWriter : public StructuredObjectWriter { use_websafe_base64_for_bytes_ = value; } - // Whether empty strings should be rendered for the next JSON key. This - // setting is only valid until the next key is rendered, after which it gets - // reset to false. - virtual void empty_name_ok_for_next_key() { - empty_name_ok_for_next_key_ = true; - } - protected: class LIBPROTOBUF_EXPORT Element : public BaseElement { public: - explicit Element(Element* parent) : BaseElement(parent), is_first_(true) {} + Element(Element* parent, bool is_json_object) + : BaseElement(parent), + is_first_(true), + is_json_object_(is_json_object) {} // Called before each field of the Element is to be processed. // Returns true if this is the first call (processing the first field). @@ -140,8 +135,13 @@ class LIBPROTOBUF_EXPORT JsonObjectWriter : public StructuredObjectWriter { return false; } + // Whether we are currently renderring inside a JSON object (i.e., between + // StartObject() and EndObject()). + bool is_json_object() const { return is_json_object_; } + private: bool is_first_; + bool is_json_object_; GOOGLE_DISALLOW_IMPLICIT_CONSTRUCTORS(Element); }; @@ -175,8 +175,15 @@ class LIBPROTOBUF_EXPORT JsonObjectWriter : public StructuredObjectWriter { return this; } - // Pushes a new element to the stack. - void Push() { element_.reset(new Element(element_.release())); } + // Pushes a new JSON array element to the stack. + void PushArray() { + element_.reset(new Element(element_.release(), /*is_json_object=*/false)); + } + + // Pushes a new JSON object element to the stack. + void PushObject() { + element_.reset(new Element(element_.release(), /*is_json_object=*/true)); + } // Pops an element off of the stack and deletes the popped element. void Pop() { @@ -204,10 +211,6 @@ class LIBPROTOBUF_EXPORT JsonObjectWriter : public StructuredObjectWriter { // Writes an individual character to the output. void WriteChar(const char c) { stream_->WriteRaw(&c, sizeof(c)); } - // Returns the current value of empty_name_ok_for_next_key_ and resets it to - // false. - bool GetAndResetEmptyKeyOk(); - google::protobuf::scoped_ptr<Element> element_; google::protobuf::io::CodedOutputStream* stream_; ByteSinkWrapper sink_; @@ -217,11 +220,6 @@ class LIBPROTOBUF_EXPORT JsonObjectWriter : public StructuredObjectWriter { // to regular base64 encoding. bool use_websafe_base64_for_bytes_; - // Whether empty strings should be rendered for the next JSON key. This - // setting is only valid until the next key is rendered, after which it gets - // reset to false. - bool empty_name_ok_for_next_key_; - GOOGLE_DISALLOW_IMPLICIT_CONSTRUCTORS(JsonObjectWriter); }; diff --git a/src/google/protobuf/util/internal/json_objectwriter_test.cc b/src/google/protobuf/util/internal/json_objectwriter_test.cc index bbd9d78a..8cc588a6 100644 --- a/src/google/protobuf/util/internal/json_objectwriter_test.cc +++ b/src/google/protobuf/util/internal/json_objectwriter_test.cc @@ -95,6 +95,12 @@ TEST_F(JsonObjectWriterTest, EmptyList) { output_.substr(0, out_stream_->ByteCount())); } +TEST_F(JsonObjectWriterTest, EmptyObjectKey) { + ow_ = new JsonObjectWriter("", out_stream_); + ow_->StartObject("")->RenderString("", "value")->EndObject(); + EXPECT_EQ("{\"\":\"value\"}", output_.substr(0, out_stream_->ByteCount())); +} + TEST_F(JsonObjectWriterTest, ObjectInObject) { ow_ = new JsonObjectWriter("", out_stream_); ow_->StartObject("") diff --git a/src/google/protobuf/util/internal/json_stream_parser.cc b/src/google/protobuf/util/internal/json_stream_parser.cc index 047c14e1..2ada3583 100644 --- a/src/google/protobuf/util/internal/json_stream_parser.cc +++ b/src/google/protobuf/util/internal/json_stream_parser.cc @@ -498,6 +498,19 @@ util::Status JsonStreamParser::ParseNumber() { return result; } +util::Status JsonStreamParser::ParseDoubleHelper( + const string& number, NumberResult* result) { + if (!safe_strtod(number, &result->double_val)) { + return ReportFailure("Unable to parse number."); + } + if (!loose_float_number_conversion_ && + !MathLimits<double>::IsFinite(result->double_val)) { + return ReportFailure("Number exceeds the range of double."); + } + result->type = NumberResult::DOUBLE; + return util::Status(); +} + util::Status JsonStreamParser::ParseNumberHelper(NumberResult* result) { const char* data = p_.data(); int length = p_.length(); @@ -533,16 +546,11 @@ util::Status JsonStreamParser::ParseNumberHelper(NumberResult* result) { // Floating point number, parse as a double. if (floating) { - if (!safe_strtod(number, &result->double_val)) { - return ReportFailure("Unable to parse number."); + util::Status status = ParseDoubleHelper(number, result); + if (status.ok()) { + p_.remove_prefix(index); } - if (!loose_float_number_conversion_ && - !MathLimits<double>::IsFinite(result->double_val)) { - return ReportFailure("Number exceeds the range of double."); - } - result->type = NumberResult::DOUBLE; - p_.remove_prefix(index); - return util::Status(); + return status; } // Positive non-floating point number, parse as a uint64. @@ -551,12 +559,18 @@ util::Status JsonStreamParser::ParseNumberHelper(NumberResult* result) { if (number.length() >= 2 && number[0] == '0') { return ReportFailure("Octal/hex numbers are not valid JSON values."); } - if (!safe_strtou64(number, &result->uint_val)) { - return ReportFailure("Unable to parse number."); + if (safe_strtou64(number, &result->uint_val)) { + result->type = NumberResult::UINT; + p_.remove_prefix(index); + return util::Status(); + } else { + // If the value is too large, parse it as double. + util::Status status = ParseDoubleHelper(number, result); + if (status.ok()) { + p_.remove_prefix(index); + } + return status; } - result->type = NumberResult::UINT; - p_.remove_prefix(index); - return util::Status(); } // Octal/Hex numbers are not valid JSON values. @@ -564,12 +578,18 @@ util::Status JsonStreamParser::ParseNumberHelper(NumberResult* result) { return ReportFailure("Octal/hex numbers are not valid JSON values."); } // Negative non-floating point number, parse as an int64. - if (!safe_strto64(number, &result->int_val)) { - return ReportFailure("Unable to parse number."); + if (safe_strto64(number, &result->int_val)) { + result->type = NumberResult::INT; + p_.remove_prefix(index); + return util::Status(); + } else { + // If the value is too large, parse it as double. + util::Status status = ParseDoubleHelper(number, result); + if (status.ok()) { + p_.remove_prefix(index); + } + return status; } - result->type = NumberResult::INT; - p_.remove_prefix(index); - return util::Status(); } util::Status JsonStreamParser::HandleBeginObject() { diff --git a/src/google/protobuf/util/internal/json_stream_parser.h b/src/google/protobuf/util/internal/json_stream_parser.h index 6b9d46ee..31933b67 100644 --- a/src/google/protobuf/util/internal/json_stream_parser.h +++ b/src/google/protobuf/util/internal/json_stream_parser.h @@ -154,6 +154,9 @@ class LIBPROTOBUF_EXPORT JsonStreamParser { // component. util::Status ParseNumberHelper(NumberResult* result); + // Parse a number as double into a NumberResult. + util::Status ParseDoubleHelper(const string& number, NumberResult* result); + // Handles a { during parsing of a value. util::Status HandleBeginObject(); diff --git a/src/google/protobuf/util/internal/json_stream_parser_test.cc b/src/google/protobuf/util/internal/json_stream_parser_test.cc index ca71ff24..a11e9be0 100644 --- a/src/google/protobuf/util/internal/json_stream_parser_test.cc +++ b/src/google/protobuf/util/internal/json_stream_parser_test.cc @@ -694,20 +694,19 @@ TEST_F(JsonStreamParserTest, ExtraCharactersAfterObject) { } } -// numbers too large -TEST_F(JsonStreamParserTest, PositiveNumberTooBig) { - StringPiece str = "[18446744073709551616]"; // 2^64 +TEST_F(JsonStreamParserTest, PositiveNumberTooBigIsDouble) { + StringPiece str = "18446744073709551616"; // 2^64 for (int i = 0; i <= str.length(); ++i) { - ow_.StartList(""); - DoErrorTest(str, i, "Unable to parse number."); + ow_.RenderDouble("", 18446744073709552000.0); + DoTest(str, i); } } -TEST_F(JsonStreamParserTest, NegativeNumberTooBig) { - StringPiece str = "[-18446744073709551616]"; +TEST_F(JsonStreamParserTest, NegativeNumberTooBigIsDouble) { + StringPiece str = "-18446744073709551616"; for (int i = 0; i <= str.length(); ++i) { - ow_.StartList(""); - DoErrorTest(str, i, "Unable to parse number."); + ow_.RenderDouble("", -18446744073709551616.0); + DoTest(str, i); } } diff --git a/src/google/protobuf/util/internal/object_writer.h b/src/google/protobuf/util/internal/object_writer.h index b6fbd19b..5781aa1e 100644 --- a/src/google/protobuf/util/internal/object_writer.h +++ b/src/google/protobuf/util/internal/object_writer.h @@ -119,13 +119,6 @@ class LIBPROTOBUF_EXPORT ObjectWriter { return use_strict_base64_decoding_; } - // Whether empty strings should be rendered for the next name for Start/Render - // calls. This setting is only valid until the next key is rendered, after - // which it gets reset. - // It is up to the derived classes to interpret this and render accordingly. - // Default implementation ignores this setting. - virtual void empty_name_ok_for_next_key() {} - protected: ObjectWriter() : use_strict_base64_decoding_(true) {} diff --git a/src/google/protobuf/util/internal/protostream_objectsource.cc b/src/google/protobuf/util/internal/protostream_objectsource.cc index 025fbd40..72ad5a7a 100644 --- a/src/google/protobuf/util/internal/protostream_objectsource.cc +++ b/src/google/protobuf/util/internal/protostream_objectsource.cc @@ -125,6 +125,7 @@ ProtoStreamObjectSource::ProtoStreamObjectSource( recursion_depth_(0), max_recursion_depth_(kDefaultMaxRecursionDepth), render_unknown_fields_(false), + render_unknown_enum_values_(true), add_trailing_zeros_for_timestamp_and_duration_(false) { GOOGLE_LOG_IF(DFATAL, stream == NULL) << "Input stream is NULL."; } @@ -142,6 +143,7 @@ ProtoStreamObjectSource::ProtoStreamObjectSource( recursion_depth_(0), max_recursion_depth_(kDefaultMaxRecursionDepth), render_unknown_fields_(false), + render_unknown_enum_values_(true), add_trailing_zeros_for_timestamp_and_duration_(false) { GOOGLE_LOG_IF(DFATAL, stream == NULL) << "Input stream is NULL."; } @@ -298,8 +300,6 @@ StatusOr<uint32> ProtoStreamObjectSource::RenderMap( return Status(util::error::INTERNAL, "Invalid map entry."); } ASSIGN_OR_RETURN(map_key, MapKeyDefaultValueAsString(*key_field)); - // Key is empty, force it to render as empty (for string values). - ow->empty_name_ok_for_next_key(); } RETURN_IF_ERROR(RenderField(field, map_key, ow)); } else { @@ -866,12 +866,6 @@ Status ProtoStreamObjectSource::RenderNonMessageField( break; } - // No need to lookup enum type if we need to render int. - if (use_ints_for_enums_) { - ow->RenderInt32(field_name, buffer32); - break; - } - // Get the nested enum type for this field. // TODO(skarvaje): Avoid string manipulation. Find ways to speed this // up. @@ -883,14 +877,17 @@ Status ProtoStreamObjectSource::RenderNonMessageField( const google::protobuf::EnumValue* enum_value = FindEnumValueByNumber(*en, buffer32); if (enum_value != NULL) { - if (use_lower_camel_for_enums_) + if (use_ints_for_enums_) { + ow->RenderInt32(field_name, buffer32); + } else if (use_lower_camel_for_enums_) { ow->RenderString(field_name, ToCamelCase(enum_value->name())); - else + } else { ow->RenderString(field_name, enum_value->name()); - } else { + } + } else if (render_unknown_enum_values_) { ow->RenderInt32(field_name, buffer32); } - } else { + } else if (render_unknown_enum_values_) { ow->RenderInt32(field_name, buffer32); } break; diff --git a/src/google/protobuf/util/internal/protostream_objectsource.h b/src/google/protobuf/util/internal/protostream_objectsource.h index 58d77c2c..b56efdf4 100644 --- a/src/google/protobuf/util/internal/protostream_objectsource.h +++ b/src/google/protobuf/util/internal/protostream_objectsource.h @@ -309,6 +309,9 @@ class LIBPROTOBUF_EXPORT ProtoStreamObjectSource : public ObjectSource { // Whether to render unknown fields. bool render_unknown_fields_; + // Whether to render unknown enum values. + bool render_unknown_enum_values_; + // Whether to add trailing zeros for timestamp and duration. bool add_trailing_zeros_for_timestamp_and_duration_; diff --git a/src/google/protobuf/util/internal/protostream_objectsource_test.cc b/src/google/protobuf/util/internal/protostream_objectsource_test.cc index 06c9bb6d..36bb1ba9 100644 --- a/src/google/protobuf/util/internal/protostream_objectsource_test.cc +++ b/src/google/protobuf/util/internal/protostream_objectsource_test.cc @@ -103,7 +103,8 @@ class ProtostreamObjectSourceTest ow_(&mock_), use_lower_camel_for_enums_(false), use_ints_for_enums_(false), - add_trailing_zeros_(false) { + add_trailing_zeros_(false), + render_unknown_enum_values_(true) { helper_.ResetTypeInfo(Book::descriptor(), Proto3Message::descriptor()); } @@ -276,6 +277,10 @@ class ProtostreamObjectSourceTest void AddTrailingZeros() { add_trailing_zeros_ = true; } + void SetRenderUnknownEnumValues(bool value) { + render_unknown_enum_values_ = value; + } + testing::TypeInfoTestHelper helper_; ::testing::NiceMock<MockObjectWriter> mock_; @@ -283,6 +288,7 @@ class ProtostreamObjectSourceTest bool use_lower_camel_for_enums_; bool use_ints_for_enums_; bool add_trailing_zeros_; + bool render_unknown_enum_values_; }; INSTANTIATE_TEST_CASE_P(DifferentTypeInfoSourceTest, @@ -513,12 +519,27 @@ TEST_P(ProtostreamObjectSourceTest, UseIntsForEnumsTest) { DoTest(book, Book::descriptor()); } -TEST_P(ProtostreamObjectSourceTest, UnknownEnum) { +TEST_P(ProtostreamObjectSourceTest, + UnknownEnumAreDroppedWhenRenderUnknownEnumValuesIsUnset) { Proto3Message message; message.set_enum_value(static_cast<Proto3Message::NestedEnum>(1234)); - ow_.StartObject("") - ->RenderInt32("enumValue", 1234) - ->EndObject(); + + SetRenderUnknownEnumValues(false); + + // Unknown enum values are not output. + ow_.StartObject("")->EndObject(); + DoTest(message, Proto3Message::descriptor()); +} + +TEST_P(ProtostreamObjectSourceTest, + UnknownEnumAreOutputWhenRenderUnknownEnumValuesIsSet) { + Proto3Message message; + message.set_enum_value(static_cast<Proto3Message::NestedEnum>(1234)); + + SetRenderUnknownEnumValues(true); + + // Unknown enum values are output. + ow_.StartObject("")->RenderInt32("enumValue", 1234)->EndObject(); DoTest(message, Proto3Message::descriptor()); } diff --git a/src/google/protobuf/util/internal/protostream_objectwriter.cc b/src/google/protobuf/util/internal/protostream_objectwriter.cc index d4e15bca..97f96819 100644 --- a/src/google/protobuf/util/internal/protostream_objectwriter.cc +++ b/src/google/protobuf/util/internal/protostream_objectwriter.cc @@ -962,7 +962,7 @@ Status ProtoStreamObjectWriter::RenderFieldMask(ProtoStreamObjectWriter* ow, // conversions as much as possible. Because ToSnakeCase sometimes returns the // wrong value. google::protobuf::scoped_ptr<ResultCallback1<util::Status, StringPiece> > callback( - NewPermanentCallback(&RenderOneFieldPath, ow)); + ::google::protobuf::NewPermanentCallback(&RenderOneFieldPath, ow)); return DecodeCompactFieldMaskPaths(data.str(), callback.get()); } diff --git a/src/google/protobuf/util/internal/utility.cc b/src/google/protobuf/util/internal/utility.cc index 8cf42e49..b1007765 100644 --- a/src/google/protobuf/util/internal/utility.cc +++ b/src/google/protobuf/util/internal/utility.cc @@ -124,7 +124,10 @@ const StringPiece GetTypeWithoutUrl(StringPiece type_url) { return type_url.substr(kTypeUrlSize + 1); } else { size_t idx = type_url.rfind('/'); - return type_url.substr(idx + 1); + if (idx != type_url.npos) { + type_url.remove_prefix(idx + 1); + } + return type_url; } } @@ -350,8 +353,6 @@ bool IsMap(const google::protobuf::Field& field, google::protobuf::Field_Cardinality_CARDINALITY_REPEATED && (GetBoolOptionOrDefault(type.options(), "map_entry", false) || GetBoolOptionOrDefault(type.options(), - "google.protobuf.MessageOptions.map_entry", false) || - GetBoolOptionOrDefault(type.options(), "google.protobuf.MessageOptions.map_entry", false)); } @@ -359,9 +360,6 @@ bool IsMap(const google::protobuf::Field& field, bool IsMessageSetWireFormat(const google::protobuf::Type& type) { return GetBoolOptionOrDefault(type.options(), "message_set_wire_format", false) || - GetBoolOptionOrDefault(type.options(), - "google.protobuf.MessageOptions.message_set_wire_format", - false) || GetBoolOptionOrDefault( type.options(), "google.protobuf.MessageOptions.message_set_wire_format", false); diff --git a/src/google/protobuf/util/json_util.cc b/src/google/protobuf/util/json_util.cc index c85f1899..25e78a65 100644 --- a/src/google/protobuf/util/json_util.cc +++ b/src/google/protobuf/util/json_util.cc @@ -50,7 +50,9 @@ namespace util { namespace internal { ZeroCopyStreamByteSink::~ZeroCopyStreamByteSink() { - stream_->BackUp(buffer_size_); + if (buffer_size_ > 0) { + stream_->BackUp(buffer_size_); + } } void ZeroCopyStreamByteSink::Append(const char* bytes, size_t len) { @@ -61,9 +63,11 @@ void ZeroCopyStreamByteSink::Append(const char* bytes, size_t len) { buffer_size_ -= len; return; } - memcpy(buffer_, bytes, buffer_size_); - bytes += buffer_size_; - len -= buffer_size_; + if (buffer_size_ > 0) { + memcpy(buffer_, bytes, buffer_size_); + bytes += buffer_size_; + len -= buffer_size_; + } if (!stream_->Next(&buffer_, &buffer_size_)) { // There isn't a way for ByteSink to report errors. buffer_size_ = 0; diff --git a/src/google/protobuf/util/json_util.h b/src/google/protobuf/util/json_util.h index f4f4380a..b1c69813 100644 --- a/src/google/protobuf/util/json_util.h +++ b/src/google/protobuf/util/json_util.h @@ -56,10 +56,10 @@ struct JsonPrintOptions { // Whether to add spaces, line breaks and indentation to make the JSON output // easy to read. bool add_whitespace; - // Whether to always print primitive fields. By default primitive fields with - // default values will be omitted in JSON joutput. For example, an int32 field - // set to 0 will be omitted. Set this flag to true will override the default - // behavior and print primitive fields regardless of their values. + // Whether to always print primitive fields. By default proto3 primitive + // fields with default values will be omitted in JSON output. For example, an + // int32 field set to 0 will be omitted. Set this flag to true will override + // the default behavior and print primitive fields regardless of their values. bool always_print_primitive_fields; // Whether to always print enums as ints. By default they are rendered as // strings. @@ -179,7 +179,7 @@ namespace internal { class LIBPROTOBUF_EXPORT ZeroCopyStreamByteSink : public strings::ByteSink { public: explicit ZeroCopyStreamByteSink(io::ZeroCopyOutputStream* stream) - : stream_(stream), buffer_size_(0) {} + : stream_(stream), buffer_(NULL), buffer_size_(0) {} ~ZeroCopyStreamByteSink(); virtual void Append(const char* bytes, size_t len); diff --git a/src/google/protobuf/util/json_util_test.cc b/src/google/protobuf/util/json_util_test.cc index 25c7e96c..5b714bb1 100644 --- a/src/google/protobuf/util/json_util_test.cc +++ b/src/google/protobuf/util/json_util_test.cc @@ -40,6 +40,7 @@ #include <google/protobuf/util/json_format_proto3.pb.h> #include <google/protobuf/util/type_resolver.h> #include <google/protobuf/util/type_resolver_util.h> +#include <google/protobuf/io/zero_copy_stream_impl.h> #include <gtest/gtest.h> namespace google { @@ -457,6 +458,29 @@ TEST(ZeroCopyStreamByteSinkTest, TestAllInputOutputPatterns) { } } +TEST_F(JsonUtilTest, TestWrongJsonInput) { + using namespace google::protobuf; + const char json[] = "{\"unknown_field\":\"some_value\"}"; + io::ArrayInputStream input_stream(json, strlen(json)); + char proto_buffer[10000]; + io::ArrayOutputStream output_stream(proto_buffer, sizeof(proto_buffer)); + std::string message_type = "type.googleapis.com/proto3.TestMessage"; + TypeResolver* resolver = NewTypeResolverForDescriptorPool( + "type.googleapis.com", + DescriptorPool::generated_pool()); + + util::Status result_status = util::JsonToBinaryStream(resolver, + message_type, + &input_stream, + &output_stream); + + delete resolver; + + EXPECT_FALSE(result_status.ok()); + EXPECT_EQ(result_status.error_code(), + google::protobuf::util::error::INVALID_ARGUMENT); +} + } // namespace } // namespace util } // namespace protobuf diff --git a/src/google/protobuf/util/message_differencer.cc b/src/google/protobuf/util/message_differencer.cc index 830850be..c32e941c 100644 --- a/src/google/protobuf/util/message_differencer.cc +++ b/src/google/protobuf/util/message_differencer.cc @@ -53,6 +53,7 @@ #include <google/protobuf/io/printer.h> #include <google/protobuf/io/zero_copy_stream.h> #include <google/protobuf/io/zero_copy_stream_impl.h> +#include <google/protobuf/descriptor.pb.h> #include <google/protobuf/dynamic_message.h> #include <google/protobuf/text_format.h> #include <google/protobuf/util/field_comparator.h> @@ -150,6 +151,32 @@ class MessageDifferencer::MultipleFieldsMapKeyComparator GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MultipleFieldsMapKeyComparator); }; +MessageDifferencer::MapEntryKeyComparator::MapEntryKeyComparator( + MessageDifferencer* message_differencer) + : message_differencer_(message_differencer) {} + +bool MessageDifferencer::MapEntryKeyComparator::IsMatch( + const Message& message1, const Message& message2, + const std::vector<SpecificField>& parent_fields) const { + // Map entry has its key in the field with tag 1. See the comment for + // map_entry in MessageOptions. + const FieldDescriptor* key = message1.GetDescriptor()->FindFieldByNumber(1); + // If key is not present in message1 and we're doing partial comparison or if + // map key is explicitly ignored treat the field as set instead, + const bool treat_as_set = + (message_differencer_->scope() == PARTIAL && + !message1.GetReflection()->HasField(message1, key)) || + message_differencer_->IsIgnored(message1, message2, key, parent_fields); + + std::vector<SpecificField> current_parent_fields(parent_fields); + if (treat_as_set) { + return message_differencer_->Compare(message1, message2, + ¤t_parent_fields); + } + return message_differencer_->CompareFieldValueUsingParentFields( + message1, message2, key, -1, -1, ¤t_parent_fields); +} + bool MessageDifferencer::Equals(const Message& message1, const Message& message2) { MessageDifferencer differencer; @@ -191,8 +218,10 @@ MessageDifferencer::MessageDifferencer() message_field_comparison_(EQUAL), scope_(FULL), repeated_field_comparison_(AS_LIST), + map_entry_key_comparator_(this), report_matches_(false), - output_string_(NULL) { } + report_moves_(true), + output_string_(NULL) {} MessageDifferencer::~MessageDifferencer() { for (int i = 0; i < owned_key_comparators_.size(); ++i) { @@ -334,9 +363,6 @@ void MessageDifferencer::TreatAsMapUsingKeyComparator( const MapKeyComparator* key_comparator) { GOOGLE_CHECK(field->is_repeated()) << "Field must be repeated: " << field->full_name(); - GOOGLE_CHECK_EQ(FieldDescriptor::CPPTYPE_MESSAGE, field->cpp_type()) - << "Field has to be message type. Field name is: " - << field->full_name(); GOOGLE_CHECK(set_fields_.find(field) == set_fields_.end()) << "Cannot treat this repeated field as both Map and Set for " << "comparison."; @@ -484,8 +510,22 @@ bool MessageDifferencer::Compare( std::vector<const FieldDescriptor*> message2_fields; message2_fields.reserve(1 + message2.GetDescriptor()->field_count()); - reflection1->ListFields(message1, &message1_fields); - reflection2->ListFields(message2, &message2_fields); + if (descriptor1->options().map_entry()) { + if (scope_ == PARTIAL) { + reflection1->ListFields(message1, &message1_fields); + } else { + // Map entry fields are always considered present. + for (int i = 0; i < descriptor1->field_count(); i++) { + message1_fields.push_back(descriptor1->field(i)); + } + } + for (int i = 0; i < descriptor1->field_count(); i++) { + message2_fields.push_back(descriptor1->field(i)); + } + } else { + reflection1->ListFields(message1, &message1_fields); + reflection2->ListFields(message2, &message2_fields); + } // Add sentinel values to deal with the // case where the number of the fields in @@ -783,6 +823,8 @@ bool MessageDifferencer::IsMatch( reflection2->GetRepeatedMessage(*message2, repeated_field, index2); SpecificField specific_field; specific_field.field = repeated_field; + specific_field.index = index1; + specific_field.new_index = index2; current_parent_fields.push_back(specific_field); match = key_comparator->IsMatch(m1, m2, current_parent_fields); } @@ -854,7 +896,7 @@ bool MessageDifferencer::CompareRepeatedField( fieldDifferent = true; } else if (reporter_ != NULL && specific_field.index != specific_field.new_index && - !specific_field.field->is_map()) { + !specific_field.field->is_map() && report_moves_) { parent_fields->push_back(specific_field); reporter_->ReportMoved(message1, message2, *parent_fields); parent_fields->pop_back(); @@ -945,6 +987,8 @@ bool MessageDifferencer::CompareFieldValueUsingParentFields( bool MessageDifferencer::CheckPathChanged( const std::vector<SpecificField>& field_path) { for (int i = 0; i < field_path.size(); ++i) { + // Don't check indexes for map entries -- maps are unordered. + if (field_path[i].field != NULL && field_path[i].field->is_map()) continue; if (field_path[i].index != field_path[i].new_index) return true; } return false; @@ -952,7 +996,6 @@ bool MessageDifferencer::CheckPathChanged( bool MessageDifferencer::IsTreatedAsSet(const FieldDescriptor* field) { if (!field->is_repeated()) return false; - if (field->is_map()) return true; if (repeated_field_comparison_ == AS_SET) return list_fields_.find(field) == list_fields_.end(); return (set_fields_.find(field) != set_fields_.end()); @@ -993,12 +1036,18 @@ bool MessageDifferencer::IsUnknownFieldIgnored( return false; } -const MessageDifferencer::MapKeyComparator* MessageDifferencer - ::GetMapKeyComparator(const FieldDescriptor* field) { +const MessageDifferencer::MapKeyComparator* +MessageDifferencer ::GetMapKeyComparator(const FieldDescriptor* field) const { if (!field->is_repeated()) return NULL; - if (map_field_key_comparator_.find(field) != - map_field_key_comparator_.end()) { - return map_field_key_comparator_[field]; + FieldKeyComparatorMap::const_iterator it = + map_field_key_comparator_.find(field); + if (it != map_field_key_comparator_.end()) { + return it->second; + } + if (field->is_map()) { + // field cannot already be treated as list or set since TreatAsList() and + // TreatAsSet() call GetMapKeyComparator() and fail if it returns non-NULL. + return &map_entry_key_comparator_; } return NULL; } @@ -1388,9 +1437,6 @@ bool MessageDifferencer::MatchRepeatedFieldIndices( match_list1->assign(count1, -1); match_list2->assign(count2, -1); - SpecificField specific_field; - specific_field.field = repeated_field; - bool success = true; // Find potential match if this is a special repeated field. if (key_comparator != NULL || IsTreatedAsSet(repeated_field)) { @@ -1400,7 +1446,7 @@ bool MessageDifferencer::MatchRepeatedFieldIndices( // algorithm will fail to find a maximum matching. // Here we use the argumenting path algorithm. MaximumMatcher::NodeMatchCallback* callback = - NewPermanentCallback( + ::google::protobuf::NewPermanentCallback( this, &MessageDifferencer::IsMatch, repeated_field, key_comparator, &message1, &message2, parent_fields); @@ -1417,20 +1463,15 @@ bool MessageDifferencer::MatchRepeatedFieldIndices( // Indicates any matched elements for this repeated field. bool match = false; - specific_field.index = i; - specific_field.new_index = i; - for (int j = 0; j < count2; j++) { if (match_list2->at(j) != -1) continue; - specific_field.index = i; - specific_field.new_index = j; match = IsMatch(repeated_field, key_comparator, &message1, &message2, parent_fields, i, j); if (match) { - match_list1->at(specific_field.index) = specific_field.new_index; - match_list2->at(specific_field.new_index) = specific_field.index; + match_list1->at(i) = j; + match_list2->at(j) = i; break; } } @@ -1524,6 +1565,12 @@ void MessageDifferencer::StreamReporter::PrintPath( } } +void MessageDifferencer::StreamReporter::PrintPath( + const std::vector<SpecificField>& field_path, bool left_side, + const Message& message) { + PrintPath(field_path, left_side); +} + void MessageDifferencer:: StreamReporter::PrintValue(const Message& message, const std::vector<SpecificField>& field_path, @@ -1601,7 +1648,7 @@ void MessageDifferencer::StreamReporter::ReportAdded( const Message& message2, const std::vector<SpecificField>& field_path) { printer_->Print("added: "); - PrintPath(field_path, false); + PrintPath(field_path, false, message2); printer_->Print(": "); PrintValue(message2, field_path, false); printer_->Print("\n"); // Print for newlines. @@ -1612,7 +1659,7 @@ void MessageDifferencer::StreamReporter::ReportDeleted( const Message& message2, const std::vector<SpecificField>& field_path) { printer_->Print("deleted: "); - PrintPath(field_path, true); + PrintPath(field_path, true, message1); printer_->Print(": "); PrintValue(message1, field_path, true); printer_->Print("\n"); // Print for newlines @@ -1636,10 +1683,10 @@ void MessageDifferencer::StreamReporter::ReportModified( } printer_->Print("modified: "); - PrintPath(field_path, true); + PrintPath(field_path, true, message1); if (CheckPathChanged(field_path)) { printer_->Print(" -> "); - PrintPath(field_path, false); + PrintPath(field_path, false, message2); } printer_->Print(": "); PrintValue(message1, field_path, true); @@ -1653,9 +1700,9 @@ void MessageDifferencer::StreamReporter::ReportMoved( const Message& message2, const std::vector<SpecificField>& field_path) { printer_->Print("moved: "); - PrintPath(field_path, true); + PrintPath(field_path, true, message1); printer_->Print(" -> "); - PrintPath(field_path, false); + PrintPath(field_path, false, message2); printer_->Print(" : "); PrintValue(message1, field_path, true); printer_->Print("\n"); // Print for newlines. @@ -1666,10 +1713,10 @@ void MessageDifferencer::StreamReporter::ReportMatched( const Message& message2, const std::vector<SpecificField>& field_path) { printer_->Print("matched: "); - PrintPath(field_path, true); + PrintPath(field_path, true, message1); if (CheckPathChanged(field_path)) { printer_->Print(" -> "); - PrintPath(field_path, false); + PrintPath(field_path, false, message2); } printer_->Print(" : "); PrintValue(message1, field_path, true); @@ -1681,10 +1728,10 @@ void MessageDifferencer::StreamReporter::ReportIgnored( const Message& message2, const std::vector<SpecificField>& field_path) { printer_->Print("ignored: "); - PrintPath(field_path, true); + PrintPath(field_path, true, message1); if (CheckPathChanged(field_path)) { printer_->Print(" -> "); - PrintPath(field_path, false); + PrintPath(field_path, false, message2); } printer_->Print("\n"); // Print for newlines. } @@ -1693,14 +1740,21 @@ void MessageDifferencer::StreamReporter::ReportUnknownFieldIgnored( const Message& message1, const Message& message2, const std::vector<SpecificField>& field_path) { printer_->Print("ignored: "); - PrintPath(field_path, true); + PrintPath(field_path, true, message1); if (CheckPathChanged(field_path)) { printer_->Print(" -> "); - PrintPath(field_path, false); + PrintPath(field_path, false, message2); } printer_->Print("\n"); // Print for newlines. } +MessageDifferencer::MapKeyComparator* +MessageDifferencer::CreateMultipleFieldsMapKeyComparator( + const std::vector<std::vector<const FieldDescriptor*> >& key_field_paths) { + return new MultipleFieldsMapKeyComparator(this, key_field_paths); +} + + } // namespace util } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/util/message_differencer.h b/src/google/protobuf/util/message_differencer.h index 192266b6..11d6cc03 100644 --- a/src/google/protobuf/util/message_differencer.h +++ b/src/google/protobuf/util/message_differencer.h @@ -64,6 +64,7 @@ class Printer; namespace util { +class DefaultFieldComparator; class FieldContext; // declared below MessageDifferencer // A basic differencer that can be used to determine @@ -372,7 +373,7 @@ class LIBPROTOBUF_EXPORT MessageDifferencer { // repeated fields have different numbers of elements, the // unpaired elements are reported using ReportAdded() or // ReportDeleted(). - AS_SET, // Treat all the repeated fields as sets by default. + AS_SET, // Treat all the repeated fields as sets. // See TreatAsSet(), as below. }; @@ -386,6 +387,11 @@ class LIBPROTOBUF_EXPORT MessageDifferencer { // the only differences between the compared messages is that some fields // have been moved, then the comparison returns true. // + // Note that despite the name of this method, this is really + // comparison as multisets: if one side of the comparison has a duplicate + // in the repeated field but the other side doesn't, this will count as + // a mismatch. + // // If the scope of comparison is set to PARTIAL, then in addition to what's // above, extra values added to repeated fields of the second message will // not cause the comparison to fail. @@ -470,6 +476,10 @@ class LIBPROTOBUF_EXPORT MessageDifferencer { const FieldDescriptor* field, const MapKeyComparator* key_comparator); + // Initiates and returns a new instance of MultipleFieldsMapKeyComparator. + MapKeyComparator* CreateMultipleFieldsMapKeyComparator( + const std::vector<std::vector<const FieldDescriptor*> >& key_field_paths); + // Add a custom ignore criteria that is evaluated in addition to the // ignored fields added with IgnoreField. // Takes ownership of ignore_criteria. @@ -518,6 +528,13 @@ class LIBPROTOBUF_EXPORT MessageDifferencer { report_matches_ = report_matches; } + // Tells the differencer whether or not to report moves (in a set or map + // repeated field). This method must be called before Compare. The default for + // a new differencer is true. + void set_report_moves(bool report_moves) { + report_moves_ = report_moves; + } + // Sets the scope of the comparison (as defined in the Scope enumeration // above) that is used by this differencer when determining which fields to // compare between the messages. @@ -620,6 +637,11 @@ class LIBPROTOBUF_EXPORT MessageDifferencer { const std::vector<SpecificField>& field_path); protected: + // Prints the specified path of fields to the buffer. message is used to + // print map keys. + virtual void PrintPath(const std::vector<SpecificField>& field_path, + bool left_side, const Message& message); + // Prints the specified path of fields to the buffer. virtual void PrintPath(const std::vector<SpecificField>& field_path, bool left_side); @@ -648,11 +670,25 @@ class LIBPROTOBUF_EXPORT MessageDifferencer { }; private: + friend class DefaultFieldComparator; + // A MapKeyComparator to be used in TreatAsMapUsingKeyComparator. // Implementation of this class needs to do field value comparison which // relies on some private methods of MessageDifferencer. That's why this // class is declared as a nested class of MessageDifferencer. class MultipleFieldsMapKeyComparator; + + // A MapKeyComparator for use with map_entries. + class LIBPROTOBUF_EXPORT MapEntryKeyComparator : public MapKeyComparator { + public: + explicit MapEntryKeyComparator(MessageDifferencer* message_differencer); + virtual bool IsMatch(const Message& message1, const Message& message2, + const std::vector<SpecificField>& parent_fields) const; + + private: + MessageDifferencer* message_differencer_; + }; + // Returns true if field1's number() is less than field2's. static bool FieldBefore(const FieldDescriptor* field1, const FieldDescriptor* field2); @@ -765,9 +801,10 @@ class LIBPROTOBUF_EXPORT MessageDifferencer { const SpecificField& field, const std::vector<SpecificField>& parent_fields); - // Returns MapKeyComparator* when this field has been configured to - // be treated as a map. If not, returns NULL. - const MapKeyComparator* GetMapKeyComparator(const FieldDescriptor* field); + // Returns MapKeyComparator* when this field has been configured to be treated + // as a map or its is_map() return true. If not, returns NULL. + const MapKeyComparator* GetMapKeyComparator( + const FieldDescriptor* field) const; // Attempts to match indices of a repeated field, so that the contained values // match. Clears output vectors and sets their values to indices of paired @@ -817,11 +854,13 @@ class LIBPROTOBUF_EXPORT MessageDifferencer { // MapKeyComparator is created for comparison purpose. std::vector<MapKeyComparator*> owned_key_comparators_; FieldKeyComparatorMap map_field_key_comparator_; + MapEntryKeyComparator map_entry_key_comparator_; std::vector<IgnoreCriteria*> ignore_criteria_; FieldSet ignored_fields_; bool report_matches_; + bool report_moves_; string* output_string_; diff --git a/src/google/protobuf/util/message_differencer_unittest.cc b/src/google/protobuf/util/message_differencer_unittest.cc index 850b3977..75cffd9f 100755 --- a/src/google/protobuf/util/message_differencer_unittest.cc +++ b/src/google/protobuf/util/message_differencer_unittest.cc @@ -1558,6 +1558,43 @@ TEST(MessageDifferencerTest, RepeatedFieldMapTest_CustomMapKeyComparator) { EXPECT_EQ("ignored: item[0].ra\n", output); } +// Compares fields by their index offset by one, so index 0 matches with 1, etc. +class OffsetByOneMapKeyComparator + : public util::MessageDifferencer::MapKeyComparator { + public: + typedef util::MessageDifferencer::SpecificField SpecificField; + virtual bool IsMatch(const Message& message1, const Message& message2, + const std::vector<SpecificField>& parent_fields) const { + return parent_fields.back().index + 1 == parent_fields.back().new_index; + } +}; + +TEST(MessageDifferencerTest, RepeatedFieldMapTest_CustomIndexMapKeyComparator) { + protobuf_unittest::TestDiffMessage msg1; + protobuf_unittest::TestDiffMessage msg2; + // Treat "item" as Map, using custom key comparator to determine if two + // elements have the same key. + protobuf_unittest::TestDiffMessage::Item* item = msg1.add_item(); + item->set_b("one"); + item = msg2.add_item(); + item->set_b("zero"); + item = msg2.add_item(); + item->set_b("one"); + util::MessageDifferencer differencer; + OffsetByOneMapKeyComparator key_comparator; + differencer.TreatAsMapUsingKeyComparator(GetFieldDescriptor(msg1, "item"), + &key_comparator); + string output; + differencer.ReportDifferencesToString(&output); + // With the offset by one comparator msg1.item[0] should be compared to + // msg2.item[1] and thus be moved, msg2.item[0] should be marked as added. + EXPECT_FALSE(differencer.Compare(msg1, msg2)); + EXPECT_EQ( + "moved: item[0] -> item[1] : { b: \"one\" }\n" + "added: item[0]: { b: \"zero\" }\n", + output); +} + TEST(MessageDifferencerTest, RepeatedFieldSetTest_Subset) { protobuf_unittest::TestDiffMessage msg1; protobuf_unittest::TestDiffMessage msg2; @@ -2806,21 +2843,130 @@ TEST_F(ComparisonTest, EquivalentIgnoresUnknown) { } TEST_F(ComparisonTest, MapTest) { - repeated_field_as_set(); + Map<string, string>& map1 = *map_proto1_.mutable_map_string_string(); + map1["key1"] = "1"; + map1["key2"] = "2"; + map1["key3"] = "3"; + Map<string, string>& map2 = *map_proto2_.mutable_map_string_string(); + map2["key3"] = "0"; + map2["key2"] = "2"; + map2["key1"] = "1"; + + EXPECT_EQ("modified: map_string_string.value: \"3\" -> \"0\"\n", + Run(map_proto1_, map_proto2_)); +} +TEST_F(ComparisonTest, MapIgnoreKeyTest) { Map<string, string>& map1 = *map_proto1_.mutable_map_string_string(); - map1["1"] = "1"; - map1["2"] = "2"; - map1["3"] = "3"; + map1["key1"] = "1"; + map1["key2"] = "2"; + map1["key3"] = "3"; Map<string, string>& map2 = *map_proto2_.mutable_map_string_string(); - map2["3"] = "0"; - map2["2"] = "2"; - map2["1"] = "1"; + map2["key4"] = "2"; + map2["key5"] = "3"; + map2["key6"] = "1"; - EXPECT_EQ( - "added: map_string_string: { key: \"3\" value: \"0\" }\n" - "deleted: map_string_string: { key: \"3\" value: \"3\" }\n", - Run(map_proto1_, map_proto2_)); + util::MessageDifferencer differencer; + differencer.IgnoreField( + GetFieldDescriptor(map_proto1_, "map_string_string.key")); + EXPECT_TRUE(differencer.Compare(map_proto1_, map_proto2_)); +} + +TEST_F(ComparisonTest, MapRoundTripSyncTest) { + google::protobuf::TextFormat::Parser parser; + unittest::TestMap map_reflection1; + + // By setting via reflection, data exists in repeated field. + ASSERT_TRUE(parser.ParseFromString( + "map_int32_foreign_message { key: 1 }", &map_reflection1)); + + // During copy, data is synced from repeated field to map. + unittest::TestMap map_reflection2 = map_reflection1; + + // During comparison, data is synced from map to repeated field. + EXPECT_TRUE( + util::MessageDifferencer::Equals(map_reflection1, map_reflection2)); +} + +TEST_F(ComparisonTest, MapEntryPartialTest) { + google::protobuf::TextFormat::Parser parser; + unittest::TestMap map1; + unittest::TestMap map2; + + string output; + util::MessageDifferencer differencer; + differencer.set_scope(util::MessageDifferencer::PARTIAL); + differencer.ReportDifferencesToString(&output); + + ASSERT_TRUE(parser.ParseFromString( + "map_int32_foreign_message { key: 1 value { c: 1 } }", &map1)); + ASSERT_TRUE(parser.ParseFromString( + "map_int32_foreign_message { key: 1 value { c: 2 }}", &map2)); + EXPECT_FALSE(differencer.Compare(map1, map2)); + EXPECT_EQ("modified: map_int32_foreign_message.value.c: 1 -> 2\n", output); + + ASSERT_TRUE( + parser.ParseFromString("map_int32_foreign_message { key: 1 }", &map1)); + EXPECT_TRUE(differencer.Compare(map1, map2)); +} + +TEST_F(ComparisonTest, MapEntryPartialEmptyKeyTest) { + google::protobuf::TextFormat::Parser parser; + unittest::TestMap map1; + unittest::TestMap map2; + ASSERT_TRUE(parser.ParseFromString("map_int32_foreign_message {}", &map1)); + ASSERT_TRUE( + parser.ParseFromString("map_int32_foreign_message { key: 1 }", &map2)); + + util::MessageDifferencer differencer; + differencer.set_scope(util::MessageDifferencer::PARTIAL); + EXPECT_TRUE(differencer.Compare(map1, map2)); +} + +// Considers strings keys as equal if they have equal lengths. +class LengthMapKeyComparator + : public util::MessageDifferencer::MapKeyComparator { + public: + typedef util::MessageDifferencer::SpecificField SpecificField; + virtual bool IsMatch(const Message& message1, const Message& message2, + const std::vector<SpecificField>& parent_fields) const { + const Reflection* reflection1 = message1.GetReflection(); + const Reflection* reflection2 = message2.GetReflection(); + const FieldDescriptor* key_field = + message1.GetDescriptor()->FindFieldByName("key"); + return reflection1->GetString(message1, key_field).size() == + reflection2->GetString(message2, key_field).size(); + } +}; + +TEST_F(ComparisonTest, MapEntryCustomMapKeyComparator) { + google::protobuf::TextFormat::Parser parser; + protobuf_unittest::TestMap msg1; + protobuf_unittest::TestMap msg2; + + ASSERT_TRUE(parser.ParseFromString( + "map_string_foreign_message { key: 'key1' value { c: 1 }}", &msg1)); + ASSERT_TRUE(parser.ParseFromString( + "map_string_foreign_message { key: 'key2' value { c: 1 }}", &msg2)); + + util::MessageDifferencer differencer; + LengthMapKeyComparator key_comparator; + differencer.TreatAsMapUsingKeyComparator( + GetFieldDescriptor(msg1, "map_string_foreign_message"), &key_comparator); + string output; + differencer.ReportDifferencesToString(&output); + // Though the above two messages have different keys for their map entries, + // they are considered the same by key_comparator because their lengths are + // equal. However, in value comparison, all fields of the message are taken + // into consideration, so they are reported as different. + EXPECT_FALSE(differencer.Compare(msg1, msg2)); + EXPECT_EQ("modified: map_string_foreign_message.key: \"key1\" -> \"key2\"\n", + output); + differencer.IgnoreField( + GetFieldDescriptor(msg1, "map_string_foreign_message.key")); + output.clear(); + EXPECT_TRUE(differencer.Compare(msg1, msg2)); + EXPECT_EQ("ignored: map_string_foreign_message.key\n", output); } class MatchingTest : public testing::Test { diff --git a/src/google/protobuf/wire_format.h b/src/google/protobuf/wire_format.h index 5e9aca52..d602d214 100644 --- a/src/google/protobuf/wire_format.h +++ b/src/google/protobuf/wire_format.h @@ -41,16 +41,10 @@ #include <string> #include <google/protobuf/stubs/common.h> -#include <google/protobuf/descriptor.pb.h> #include <google/protobuf/descriptor.h> #include <google/protobuf/message.h> #include <google/protobuf/wire_format_lite.h> -// Do UTF-8 validation on string type in Debug build only -#ifndef NDEBUG -#define GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED -#endif - namespace google { namespace protobuf { namespace io { diff --git a/src/google/protobuf/wire_format_lite.cc b/src/google/protobuf/wire_format_lite.cc index 7987f7c4..1d8cda5a 100644 --- a/src/google/protobuf/wire_format_lite.cc +++ b/src/google/protobuf/wire_format_lite.cc @@ -34,9 +34,6 @@ #include <google/protobuf/wire_format_lite_inl.h> -#ifdef __SSE_4_1__ -#include <immintrin.h> -#endif #include <stack> #include <string> #include <vector> @@ -47,8 +44,8 @@ #include <google/protobuf/io/zero_copy_stream.h> #include <google/protobuf/io/zero_copy_stream_impl_lite.h> -namespace google { +namespace google { namespace protobuf { namespace internal { @@ -586,7 +583,7 @@ void WireFormatLite::WriteMessageMaybeToArray(int field_number, } } -GOOGLE_ATTRIBUTE_ALWAYS_INLINE static bool ReadBytesToString( +GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE static bool ReadBytesToString( io::CodedInputStream* input, string* value); inline static bool ReadBytesToString(io::CodedInputStream* input, string* value) { @@ -635,12 +632,12 @@ bool WireFormatLite::VerifyUtf8String(const char* data, return true; } -#ifdef __SSE_4_1__ -template<typename T, bool ZigZag, bool SignExtended> -static size_t VarintSize( - const T* data, const int n, - const internal::enable_if<sizeof(T) == 4>::type* = NULL) { +// this code is deliberately written such that clang makes it into really +// efficient SSE code. +template<bool ZigZag, bool SignExtended, typename T> +static size_t VarintSize(const T* data, const int n) { #if __cplusplus >= 201103L + static_assert(sizeof(T) == 4, "This routine only works for 32 bit integers"); // is_unsigned<T> => !ZigZag static_assert((std::is_unsigned<T>::value ^ ZigZag) || std::is_signed<T>::value, @@ -649,101 +646,83 @@ static size_t VarintSize( static_assert((std::is_unsigned<T>::value ^ SignExtended) || std::is_signed<T>::value, "Cannot SignExtended unsigned types"); + static_assert(!(SignExtended && ZigZag), + "Cannot SignExtended and ZigZag on the same type"); #endif - - union vus32 { - uint32 u[4]; - int32 s[4]; - __m128i v; - }; - - static const vus32 ones = {{1, 1, 1, 1}}; - - // CodedOutputStream::VarintSize32SignExtended returns 10 for negative - // numbers. We can apply the UInt32Size algorithm, and simultaneously logical - // shift the MSB into the LSB to determine if it is negative. - static const vus32 fives = {{5, 5, 5, 5}}; - - // sum is the vectorized-output of calling CodedOutputStream::VarintSize32 on - // the processed elements. - // - // msb_sum is the count of set most-significant bits. When computing the - // vectorized CodedOutputStream::VarintSize32SignExtended, negative values - // have the most significant bit set. VarintSize32SignExtended returns 10 and - // VarintSize32 returns 5. msb_sum allows us to compute: - // VarintSize32SignExtended = msb_sum * 5 + VarintSize32 - vus32 sum, v, msb_sum; - sum.v = _mm_setzero_si128(); - msb_sum.v = _mm_setzero_si128(); - - int rounded = n & ~(3); - int i; - for (i = 0; i < rounded; i += 4) { - v.v = _mm_loadu_si128(reinterpret_cast<const __m128i*>(&data[i])); - + uint32 sum = n; + uint32 msb_sum = 0; + for (int i = 0; i < n; i++) { + uint32 x = data[i]; if (ZigZag) { - // Note: the right-shift must be arithmetic - v.v = _mm_xor_si128(_mm_slli_epi32(v.v, 1), _mm_srai_epi32(v.v, 31)); - } - - sum.v = _mm_add_epi32(sum.v, ones.v); - if (SignExtended) { - msb_sum.v = _mm_add_epi32(msb_sum.v, _mm_srli_epi32(v.v, 31)); - } - - v.v = _mm_srli_epi32(v.v, 7); - - for (int j = 0; j < 4; j++) { - __m128i min = _mm_min_epi32(v.v, ones.v); - - sum.v = _mm_add_epi32(sum.v, min); - v.v = _mm_srli_epi32(v.v, 7); + x = WireFormatLite::ZigZagEncode32(x); + } else if (SignExtended) { + msb_sum += x >> 31; } + // clang is so smart that it produces optimal SSE sequence unrolling + // the loop 8 ints at a time. With a sequence of 4 + // cmpres = cmpgt x, sizeclass ( -1 or 0) + // sum = sum - cmpres + if (x > 0x7F) sum++; + if (x > 0x3FFF) sum++; + if (x > 0x1FFFFF) sum++; + if (x > 0xFFFFFFF) sum++; } + if (SignExtended) sum += msb_sum * 5; + return sum; +} - if (SignExtended) { - vus32 extensions; - extensions.v = _mm_mullo_epi32(msb_sum.v, fives.v); - - sum.v = _mm_add_epi32(sum.v, extensions.v); - } - - // TODO(ckennelly): Can we avoid the sign conversion? - size_t out = _mm_cvtsi128_si32( - _mm_hadd_epi32(_mm_hadd_epi32(sum.v, ones.v), ones.v)); - - // Finish tail. - for (; i < n; i++) { +template<bool ZigZag, typename T> +static size_t VarintSize64(const T* data, const int n) { +#if __cplusplus >= 201103L + static_assert(sizeof(T) == 8, "This routine only works for 64 bit integers"); + // is_unsigned<T> => !ZigZag + static_assert(!ZigZag || !std::is_unsigned<T>::value, + "Cannot ZigZag encode unsigned types"); +#endif + uint64 sum = n; + for (int i = 0; i < n; i++) { + uint64 x = data[i]; if (ZigZag) { - out += WireFormatLite::SInt32Size(data[i]); - } else if (SignExtended) { - out += WireFormatLite::Int32Size(data[i]); - } else { - out += WireFormatLite::UInt32Size(data[i]); + x = WireFormatLite::ZigZagEncode64(x); } + // First step is a binary search, we can't branch in sse so we use the + // result of the compare to adjust sum and appropriately. This code is + // written to make clang recognize the vectorization. + uint64 tmp = x >= (static_cast<uint64>(1) << 35) ? -1 : 0; + sum += 5 & tmp; + x >>= 35 & tmp; + if (x > 0x7F) sum++; + if (x > 0x3FFF) sum++; + if (x > 0x1FFFFF) sum++; + if (x > 0xFFFFFFF) sum++; } - - return out; + return sum; } +// GCC does not recognize the vectorization opportunity +// and other platforms are untested, in those cases using the optimized +// varint size routine for each element is faster. +// Hence we enable it only for clang +#if defined(__SSE__) && defined(__clang__) size_t WireFormatLite::Int32Size(const RepeatedField<int32>& value) { - return VarintSize<int32, false, true>(value.data(), value.size()); + return VarintSize<false, true>(value.data(), value.size()); } size_t WireFormatLite::UInt32Size(const RepeatedField<uint32>& value) { - return VarintSize<uint32, false, false>(value.data(), value.size()); + return VarintSize<false, false>(value.data(), value.size()); } size_t WireFormatLite::SInt32Size(const RepeatedField<int32>& value) { - return VarintSize<int32, true, true>(value.data(), value.size()); + return VarintSize<true, false>(value.data(), value.size()); } size_t WireFormatLite::EnumSize(const RepeatedField<int>& value) { // On ILP64, sizeof(int) == 8, which would require a different template. - return VarintSize<int, false, true>(value.data(), value.size()); + return VarintSize<false, true>(value.data(), value.size()); } -#else // !__SSE_4_1__ +#else // !(defined(__SSE4_1__) && defined(__clang__)) + size_t WireFormatLite::Int32Size(const RepeatedField<int32>& value) { size_t out = 0; const int n = value.size(); @@ -779,6 +758,56 @@ size_t WireFormatLite::EnumSize(const RepeatedField<int>& value) { } return out; } + +#endif + +// Micro benchmarks show that the SSE improved loop only starts beating +// the normal loop on Haswell platforms and then only for >32 ints. We +// disable this for now. Some specialized users might find it worthwhile to +// enable this. +#define USE_SSE_FOR_64_BIT_INTEGER_ARRAYS 0 +#if USE_SSE_FOR_64_BIT_INTEGER_ARRAYS +size_t WireFormatLite::Int64Size (const RepeatedField< int64>& value) { + return VarintSize64<false>(value.data(), value.size()); +} + +size_t WireFormatLite::UInt64Size(const RepeatedField<uint64>& value) { + return VarintSize64<false>(value.data(), value.size()); +} + +size_t WireFormatLite::SInt64Size(const RepeatedField< int64>& value) { + return VarintSize64<true>(value.data(), value.size()); +} + +#else + +size_t WireFormatLite::Int64Size (const RepeatedField< int64>& value) { + size_t out = 0; + const int n = value.size(); + for (int i = 0; i < n; i++) { + out += Int64Size(value.Get(i)); + } + return out; +} + +size_t WireFormatLite::UInt64Size(const RepeatedField<uint64>& value) { + size_t out = 0; + const int n = value.size(); + for (int i = 0; i < n; i++) { + out += UInt64Size(value.Get(i)); + } + return out; +} + +size_t WireFormatLite::SInt64Size(const RepeatedField< int64>& value) { + size_t out = 0; + const int n = value.size(); + for (int i = 0; i < n; i++) { + out += SInt64Size(value.Get(i)); + } + return out; +} + #endif } // namespace internal diff --git a/src/google/protobuf/wire_format_lite.h b/src/google/protobuf/wire_format_lite.h index ce55f266..76275518 100644 --- a/src/google/protobuf/wire_format_lite.h +++ b/src/google/protobuf/wire_format_lite.h @@ -41,10 +41,17 @@ #define GOOGLE_PROTOBUF_WIRE_FORMAT_LITE_H__ #include <string> + #include <google/protobuf/stubs/common.h> -#include <google/protobuf/repeated_field.h> +#include <google/protobuf/io/coded_stream.h> #include <google/protobuf/message_lite.h> -#include <google/protobuf/io/coded_stream.h> // for CodedOutputStream::Varint32Size +#include <google/protobuf/stubs/port.h> +#include <google/protobuf/repeated_field.h> + +// Do UTF-8 validation on string type in Debug build only +#ifndef NDEBUG +#define GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED +#endif // Avoid conflict with iOS where <ConditionalMacros.h> #defines TYPE_BOOL. // @@ -144,7 +151,7 @@ class LIBPROTOBUF_EXPORT WireFormatLite { // Helper method to get the CppType for a particular Type. static CppType FieldTypeToCppType(FieldType type); - // Given a FieldSescriptor::Type return its WireType + // Given a FieldDescriptor::Type return its WireType static inline WireFormatLite::WireType WireTypeForFieldType( WireFormatLite::FieldType type) { return kWireTypeForFieldType[type]; @@ -251,7 +258,7 @@ class LIBPROTOBUF_EXPORT WireFormatLite { // that file to use these. #ifdef NDEBUG -#define INL GOOGLE_ATTRIBUTE_ALWAYS_INLINE +#define INL GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE #else // Avoid excessive inlining in non-optimized builds. Without other optimizations // the inlining is not going to provide benefits anyway and the huge resulting @@ -329,7 +336,6 @@ class LIBPROTOBUF_EXPORT WireFormatLite { static bool ReadBytes(io::CodedInputStream* input, string* value); static bool ReadBytes(io::CodedInputStream* input, string** p); - enum Operation { PARSE = 0, SERIALIZE = 1, @@ -668,13 +674,13 @@ class LIBPROTOBUF_EXPORT WireFormatLite { static inline size_t SInt64Size ( int64 value); static inline size_t EnumSize ( int value); - static size_t Int32Size (const RepeatedField< int32>& value); - static inline size_t Int64Size (const RepeatedField< int64>& value); - static size_t UInt32Size(const RepeatedField<uint32>& value); - static inline size_t UInt64Size(const RepeatedField<uint64>& value); - static size_t SInt32Size(const RepeatedField< int32>& value); - static inline size_t SInt64Size(const RepeatedField< int64>& value); - static size_t EnumSize (const RepeatedField< int>& value); + static size_t Int32Size (const RepeatedField< int32>& value); + static size_t Int64Size (const RepeatedField< int64>& value); + static size_t UInt32Size(const RepeatedField<uint32>& value); + static size_t UInt64Size(const RepeatedField<uint64>& value); + static size_t SInt32Size(const RepeatedField< int32>& value); + static size_t SInt64Size(const RepeatedField< int64>& value); + static size_t EnumSize (const RepeatedField< int>& value); // These types always have the same size. static const size_t kFixed32Size = 4; @@ -707,7 +713,8 @@ class LIBPROTOBUF_EXPORT WireFormatLite { // A helper method for the repeated primitive reader. This method has // optimizations for primitive types that have fixed size on the wire, and // can be read using potentially faster paths. - template <typename CType, enum FieldType DeclaredType> GOOGLE_ATTRIBUTE_ALWAYS_INLINE + template <typename CType, enum FieldType DeclaredType> + GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE static bool ReadRepeatedFixedSizePrimitive( int tag_size, uint32 tag, @@ -716,7 +723,8 @@ class LIBPROTOBUF_EXPORT WireFormatLite { // Like ReadRepeatedFixedSizePrimitive but for packed primitive fields. template <typename CType, enum FieldType DeclaredType> - GOOGLE_ATTRIBUTE_ALWAYS_INLINE static bool ReadPackedFixedSizePrimitive( + GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE + static bool ReadPackedFixedSizePrimitive( google::protobuf::io::CodedInputStream* input, RepeatedField<CType>* value); static const CppType kFieldTypeToCppTypeMap[]; @@ -787,7 +795,7 @@ inline int WireFormatLite::GetTagFieldNumber(uint32 tag) { inline size_t WireFormatLite::TagSize(int field_number, WireFormatLite::FieldType type) { size_t result = io::CodedOutputStream::VarintSize32( - field_number << kTagTypeBits); + static_cast<uint32>(field_number << kTagTypeBits)); if (type == TYPE_GROUP) { // Groups have both a start and an end tag. return result * 2; @@ -846,20 +854,24 @@ inline double WireFormatLite::DecodeDouble(uint64 value) { inline uint32 WireFormatLite::ZigZagEncode32(int32 n) { // Note: the right-shift must be arithmetic - return (static_cast<uint32>(n) << 1) ^ (n >> 31); + // Note: left shift must be unsigned because of overflow + return (static_cast<uint32>(n) << 1) ^ static_cast<uint32>(n >> 31); } inline int32 WireFormatLite::ZigZagDecode32(uint32 n) { - return (n >> 1) ^ -static_cast<int32>(n & 1); + // Note: Using unsigned types prevent undefined behavior + return static_cast<int32>((n >> 1) ^ (~(n & 1) + 1)); } inline uint64 WireFormatLite::ZigZagEncode64(int64 n) { // Note: the right-shift must be arithmetic - return (static_cast<uint64>(n) << 1) ^ (n >> 63); + // Note: left shift must be unsigned because of overflow + return (static_cast<uint64>(n) << 1) ^ static_cast<uint64>(n >> 63); } inline int64 WireFormatLite::ZigZagDecode64(uint64 n) { - return (n >> 1) ^ -static_cast<int64>(n & 1); + // Note: Using unsigned types prevent undefined behavior + return static_cast<int64>((n >> 1) ^ (~(n & 1) + 1)); } // String is for UTF-8 text only, but, even so, ReadString() can simply diff --git a/src/google/protobuf/wire_format_lite_inl.h b/src/google/protobuf/wire_format_lite_inl.h index 05049017..82fb62ae 100644 --- a/src/google/protobuf/wire_format_lite_inl.h +++ b/src/google/protobuf/wire_format_lite_inl.h @@ -268,7 +268,7 @@ inline bool WireFormatLite::ReadRepeatedFixedSizePrimitive( if (size > 0) { const uint8* buffer = reinterpret_cast<const uint8*>(void_pointer); // The number of bytes each type occupies on the wire. - const int per_value_size = tag_size + sizeof(value); + const int per_value_size = tag_size + static_cast<int>(sizeof(value)); // parentheses around (std::min) prevents macro expansion of min(...) int elements_available = @@ -344,8 +344,8 @@ inline bool WireFormatLite::ReadPackedFixedSizePrimitive( int length; if (!input->ReadVarintSizeAsInt(&length)) return false; const int old_entries = values->size(); - const int new_entries = length / sizeof(CType); - const int new_bytes = new_entries * sizeof(CType); + const int new_entries = length / static_cast<int>(sizeof(CType)); + const int new_bytes = new_entries * static_cast<int>(sizeof(CType)); if (new_bytes != length) return false; // We would *like* to pre-allocate the buffer to write into (for // speed), but *must* avoid performing a very large allocation due @@ -426,7 +426,6 @@ bool WireFormatLite::ReadPackedPrimitiveNoInline(io::CodedInputStream* input, } - inline bool WireFormatLite::ReadGroup(int field_number, io::CodedInputStream* input, MessageLite* value) { @@ -695,8 +694,8 @@ inline uint8* WireFormatLite::WriteFixedNoTagToArray( GOOGLE_DCHECK_GT(n, 0); const T* ii = value.unsafe_data(); - const int bytes = n * sizeof(ii[0]); - memcpy(target, ii, bytes); + const int bytes = n * static_cast<int>(sizeof(ii[0])); + memcpy(target, ii, static_cast<size_t>(bytes)); return target + bytes; #else return WritePrimitiveNoTagToArray(value, Writer, target); @@ -954,7 +953,7 @@ inline uint8* WireFormatLite::InternalWriteMessageToArray( uint8* target) { target = WriteTagToArray(field_number, WIRETYPE_LENGTH_DELIMITED, target); target = io::CodedOutputStream::WriteVarint32ToArray( - value.GetCachedSize(), target); + static_cast<uint32>(value.GetCachedSize()), target); return value.InternalSerializeWithCachedSizesToArray(deterministic, target); } @@ -975,7 +974,9 @@ inline uint8* WireFormatLite::InternalWriteMessageNoVirtualToArray( bool deterministic, uint8* target) { target = WriteTagToArray(field_number, WIRETYPE_LENGTH_DELIMITED, target); target = io::CodedOutputStream::WriteVarint32ToArray( - value.MessageType_WorkAroundCppLookupDefect::GetCachedSize(), target); + static_cast<uint32>( + value.MessageType_WorkAroundCppLookupDefect::GetCachedSize()), + target); return value.MessageType_WorkAroundCppLookupDefect:: InternalSerializeWithCachedSizesToArray(deterministic, target); } @@ -1042,33 +1043,6 @@ inline size_t WireFormatLite::LengthDelimitedSize(size_t length) { static_cast<uint32>(length)); } -size_t WireFormatLite::Int64Size (const RepeatedField< int64>& value) { - size_t out = 0; - const int n = value.size(); - for (int i = 0; i < n; i++) { - out += Int64Size(value.Get(i)); - } - return out; -} - -size_t WireFormatLite::UInt64Size(const RepeatedField<uint64>& value) { - size_t out = 0; - const int n = value.size(); - for (int i = 0; i < n; i++) { - out += UInt64Size(value.Get(i)); - } - return out; -} - -size_t WireFormatLite::SInt64Size(const RepeatedField< int64>& value) { - size_t out = 0; - const int n = value.size(); - for (int i = 0; i < n; i++) { - out += SInt64Size(value.Get(i)); - } - return out; -} - } // namespace internal } // namespace protobuf diff --git a/src/google/protobuf/wire_format_unittest.cc b/src/google/protobuf/wire_format_unittest.cc index cafe9a48..736a1282 100644 --- a/src/google/protobuf/wire_format_unittest.cc +++ b/src/google/protobuf/wire_format_unittest.cc @@ -1436,6 +1436,7 @@ TEST(RepeatedVarint, Enum) { EXPECT_EQ(expected, WireFormatLite::EnumSize(v)); } + } // namespace } // namespace internal } // namespace protobuf diff --git a/src/google/protobuf/wrappers.pb.cc b/src/google/protobuf/wrappers.pb.cc index 12c04fd5..34c6fed1 100644 --- a/src/google/protobuf/wrappers.pb.cc +++ b/src/google/protobuf/wrappers.pb.cc @@ -1,7 +1,6 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/protobuf/wrappers.proto -#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION #include <google/protobuf/wrappers.pb.h> #include <algorithm> @@ -15,143 +14,332 @@ #include <google/protobuf/generated_message_reflection.h> #include <google/protobuf/reflection_ops.h> #include <google/protobuf/wire_format.h> +// This is a temporary google only hack +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS +#include "third_party/protobuf/version.h" +#endif // @@protoc_insertion_point(includes) - namespace google { namespace protobuf { -class DoubleValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<DoubleValue> { +class DoubleValueDefaultTypeInternal { + public: + ::google::protobuf::internal::ExplicitlyConstructed<DoubleValue> + _instance; } _DoubleValue_default_instance_; -class FloatValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<FloatValue> { +class FloatValueDefaultTypeInternal { + public: + ::google::protobuf::internal::ExplicitlyConstructed<FloatValue> + _instance; } _FloatValue_default_instance_; -class Int64ValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Int64Value> { +class Int64ValueDefaultTypeInternal { + public: + ::google::protobuf::internal::ExplicitlyConstructed<Int64Value> + _instance; } _Int64Value_default_instance_; -class UInt64ValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<UInt64Value> { +class UInt64ValueDefaultTypeInternal { + public: + ::google::protobuf::internal::ExplicitlyConstructed<UInt64Value> + _instance; } _UInt64Value_default_instance_; -class Int32ValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Int32Value> { +class Int32ValueDefaultTypeInternal { + public: + ::google::protobuf::internal::ExplicitlyConstructed<Int32Value> + _instance; } _Int32Value_default_instance_; -class UInt32ValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<UInt32Value> { +class UInt32ValueDefaultTypeInternal { + public: + ::google::protobuf::internal::ExplicitlyConstructed<UInt32Value> + _instance; } _UInt32Value_default_instance_; -class BoolValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<BoolValue> { +class BoolValueDefaultTypeInternal { + public: + ::google::protobuf::internal::ExplicitlyConstructed<BoolValue> + _instance; } _BoolValue_default_instance_; -class StringValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<StringValue> { +class StringValueDefaultTypeInternal { + public: + ::google::protobuf::internal::ExplicitlyConstructed<StringValue> + _instance; } _StringValue_default_instance_; -class BytesValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<BytesValue> { +class BytesValueDefaultTypeInternal { + public: + ::google::protobuf::internal::ExplicitlyConstructed<BytesValue> + _instance; } _BytesValue_default_instance_; - +} // namespace protobuf +} // namespace google namespace protobuf_google_2fprotobuf_2fwrappers_2eproto { +void InitDefaultsDoubleValueImpl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); +#else + ::google::protobuf::internal::InitProtobufDefaults(); +#endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + { + void* ptr = &::google::protobuf::_DoubleValue_default_instance_; + new (ptr) ::google::protobuf::DoubleValue(); + ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); + } + ::google::protobuf::DoubleValue::InitAsDefaultInstance(); +} -namespace { +void InitDefaultsDoubleValue() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsDoubleValueImpl); +} -::google::protobuf::Metadata file_level_metadata[9]; +void InitDefaultsFloatValueImpl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; -} // namespace +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); +#else + ::google::protobuf::internal::InitProtobufDefaults(); +#endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + { + void* ptr = &::google::protobuf::_FloatValue_default_instance_; + new (ptr) ::google::protobuf::FloatValue(); + ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); + } + ::google::protobuf::FloatValue::InitAsDefaultInstance(); +} -PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::ParseTableField - const TableStruct::entries[] = { - {0, 0, 0, ::google::protobuf::internal::kInvalidMask, 0, 0}, -}; +void InitDefaultsFloatValue() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsFloatValueImpl); +} -PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::AuxillaryParseTableField - const TableStruct::aux[] = { - ::google::protobuf::internal::AuxillaryParseTableField(), -}; -PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::ParseTable const - TableStruct::schema[] = { - { NULL, NULL, 0, -1, -1, false }, - { NULL, NULL, 0, -1, -1, false }, - { NULL, NULL, 0, -1, -1, false }, - { NULL, NULL, 0, -1, -1, false }, - { NULL, NULL, 0, -1, -1, false }, - { NULL, NULL, 0, -1, -1, false }, - { NULL, NULL, 0, -1, -1, false }, - { NULL, NULL, 0, -1, -1, false }, - { NULL, NULL, 0, -1, -1, false }, -}; +void InitDefaultsInt64ValueImpl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); +#else + ::google::protobuf::internal::InitProtobufDefaults(); +#endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + { + void* ptr = &::google::protobuf::_Int64Value_default_instance_; + new (ptr) ::google::protobuf::Int64Value(); + ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); + } + ::google::protobuf::Int64Value::InitAsDefaultInstance(); +} + +void InitDefaultsInt64Value() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsInt64ValueImpl); +} + +void InitDefaultsUInt64ValueImpl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); +#else + ::google::protobuf::internal::InitProtobufDefaults(); +#endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + { + void* ptr = &::google::protobuf::_UInt64Value_default_instance_; + new (ptr) ::google::protobuf::UInt64Value(); + ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); + } + ::google::protobuf::UInt64Value::InitAsDefaultInstance(); +} -const ::google::protobuf::uint32 TableStruct::offsets[] = { +void InitDefaultsUInt64Value() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsUInt64ValueImpl); +} + +void InitDefaultsInt32ValueImpl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); +#else + ::google::protobuf::internal::InitProtobufDefaults(); +#endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + { + void* ptr = &::google::protobuf::_Int32Value_default_instance_; + new (ptr) ::google::protobuf::Int32Value(); + ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); + } + ::google::protobuf::Int32Value::InitAsDefaultInstance(); +} + +void InitDefaultsInt32Value() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsInt32ValueImpl); +} + +void InitDefaultsUInt32ValueImpl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); +#else + ::google::protobuf::internal::InitProtobufDefaults(); +#endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + { + void* ptr = &::google::protobuf::_UInt32Value_default_instance_; + new (ptr) ::google::protobuf::UInt32Value(); + ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); + } + ::google::protobuf::UInt32Value::InitAsDefaultInstance(); +} + +void InitDefaultsUInt32Value() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsUInt32ValueImpl); +} + +void InitDefaultsBoolValueImpl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); +#else + ::google::protobuf::internal::InitProtobufDefaults(); +#endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + { + void* ptr = &::google::protobuf::_BoolValue_default_instance_; + new (ptr) ::google::protobuf::BoolValue(); + ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); + } + ::google::protobuf::BoolValue::InitAsDefaultInstance(); +} + +void InitDefaultsBoolValue() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsBoolValueImpl); +} + +void InitDefaultsStringValueImpl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); +#else + ::google::protobuf::internal::InitProtobufDefaults(); +#endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + { + void* ptr = &::google::protobuf::_StringValue_default_instance_; + new (ptr) ::google::protobuf::StringValue(); + ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); + } + ::google::protobuf::StringValue::InitAsDefaultInstance(); +} + +void InitDefaultsStringValue() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsStringValueImpl); +} + +void InitDefaultsBytesValueImpl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + +#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); +#else + ::google::protobuf::internal::InitProtobufDefaults(); +#endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS + { + void* ptr = &::google::protobuf::_BytesValue_default_instance_; + new (ptr) ::google::protobuf::BytesValue(); + ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); + } + ::google::protobuf::BytesValue::InitAsDefaultInstance(); +} + +void InitDefaultsBytesValue() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsBytesValueImpl); +} + +::google::protobuf::Metadata file_level_metadata[9]; + +const ::google::protobuf::uint32 TableStruct::offsets[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { ~0u, // no _has_bits_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DoubleValue, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::DoubleValue, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DoubleValue, value_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::DoubleValue, value_), ~0u, // no _has_bits_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FloatValue, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FloatValue, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FloatValue, value_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FloatValue, value_), ~0u, // no _has_bits_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Int64Value, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Int64Value, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Int64Value, value_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Int64Value, value_), ~0u, // no _has_bits_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UInt64Value, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::UInt64Value, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UInt64Value, value_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::UInt64Value, value_), ~0u, // no _has_bits_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Int32Value, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Int32Value, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Int32Value, value_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Int32Value, value_), ~0u, // no _has_bits_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UInt32Value, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::UInt32Value, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UInt32Value, value_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::UInt32Value, value_), ~0u, // no _has_bits_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BoolValue, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::BoolValue, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BoolValue, value_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::BoolValue, value_), ~0u, // no _has_bits_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(StringValue, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::StringValue, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(StringValue, value_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::StringValue, value_), ~0u, // no _has_bits_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BytesValue, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::BytesValue, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BytesValue, value_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::BytesValue, value_), }; - -static const ::google::protobuf::internal::MigrationSchema schemas[] = { - { 0, -1, sizeof(DoubleValue)}, - { 6, -1, sizeof(FloatValue)}, - { 12, -1, sizeof(Int64Value)}, - { 18, -1, sizeof(UInt64Value)}, - { 24, -1, sizeof(Int32Value)}, - { 30, -1, sizeof(UInt32Value)}, - { 36, -1, sizeof(BoolValue)}, - { 42, -1, sizeof(StringValue)}, - { 48, -1, sizeof(BytesValue)}, +static const ::google::protobuf::internal::MigrationSchema schemas[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { + { 0, -1, sizeof(::google::protobuf::DoubleValue)}, + { 6, -1, sizeof(::google::protobuf::FloatValue)}, + { 12, -1, sizeof(::google::protobuf::Int64Value)}, + { 18, -1, sizeof(::google::protobuf::UInt64Value)}, + { 24, -1, sizeof(::google::protobuf::Int32Value)}, + { 30, -1, sizeof(::google::protobuf::UInt32Value)}, + { 36, -1, sizeof(::google::protobuf::BoolValue)}, + { 42, -1, sizeof(::google::protobuf::StringValue)}, + { 48, -1, sizeof(::google::protobuf::BytesValue)}, }; static ::google::protobuf::Message const * const file_default_instances[] = { - reinterpret_cast<const ::google::protobuf::Message*>(&_DoubleValue_default_instance_), - reinterpret_cast<const ::google::protobuf::Message*>(&_FloatValue_default_instance_), - reinterpret_cast<const ::google::protobuf::Message*>(&_Int64Value_default_instance_), - reinterpret_cast<const ::google::protobuf::Message*>(&_UInt64Value_default_instance_), - reinterpret_cast<const ::google::protobuf::Message*>(&_Int32Value_default_instance_), - reinterpret_cast<const ::google::protobuf::Message*>(&_UInt32Value_default_instance_), - reinterpret_cast<const ::google::protobuf::Message*>(&_BoolValue_default_instance_), - reinterpret_cast<const ::google::protobuf::Message*>(&_StringValue_default_instance_), - reinterpret_cast<const ::google::protobuf::Message*>(&_BytesValue_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_DoubleValue_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_FloatValue_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_Int64Value_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_UInt64Value_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_Int32Value_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_UInt32Value_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_BoolValue_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_StringValue_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_BytesValue_default_instance_), }; -namespace { - void protobuf_AssignDescriptors() { AddDescriptors(); ::google::protobuf::MessageFactory* factory = NULL; @@ -165,57 +353,15 @@ void protobuf_AssignDescriptorsOnce() { ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors); } -void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; +void protobuf_RegisterTypes(const ::std::string&) GOOGLE_PROTOBUF_ATTRIBUTE_COLD; void protobuf_RegisterTypes(const ::std::string&) { protobuf_AssignDescriptorsOnce(); ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 9); } -} // namespace - -void TableStruct::Shutdown() { - _DoubleValue_default_instance_.Shutdown(); - delete file_level_metadata[0].reflection; - _FloatValue_default_instance_.Shutdown(); - delete file_level_metadata[1].reflection; - _Int64Value_default_instance_.Shutdown(); - delete file_level_metadata[2].reflection; - _UInt64Value_default_instance_.Shutdown(); - delete file_level_metadata[3].reflection; - _Int32Value_default_instance_.Shutdown(); - delete file_level_metadata[4].reflection; - _UInt32Value_default_instance_.Shutdown(); - delete file_level_metadata[5].reflection; - _BoolValue_default_instance_.Shutdown(); - delete file_level_metadata[6].reflection; - _StringValue_default_instance_.Shutdown(); - delete file_level_metadata[7].reflection; - _BytesValue_default_instance_.Shutdown(); - delete file_level_metadata[8].reflection; -} - -void TableStruct::InitDefaultsImpl() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - ::google::protobuf::internal::InitProtobufDefaults(); - _DoubleValue_default_instance_.DefaultConstruct(); - _FloatValue_default_instance_.DefaultConstruct(); - _Int64Value_default_instance_.DefaultConstruct(); - _UInt64Value_default_instance_.DefaultConstruct(); - _Int32Value_default_instance_.DefaultConstruct(); - _UInt32Value_default_instance_.DefaultConstruct(); - _BoolValue_default_instance_.DefaultConstruct(); - _StringValue_default_instance_.DefaultConstruct(); - _BytesValue_default_instance_.DefaultConstruct(); -} - -void InitDefaults() { - static GOOGLE_PROTOBUF_DECLARE_ONCE(once); - ::google::protobuf::GoogleOnceInit(&once, &TableStruct::InitDefaultsImpl); -} void AddDescriptorsImpl() { InitDefaults(); - static const char descriptor[] = { + static const char descriptor[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { "\n\036google/protobuf/wrappers.proto\022\017google" ".protobuf\"\034\n\013DoubleValue\022\r\n\005value\030\001 \001(\001\"" "\033\n\nFloatValue\022\r\n\005value\030\001 \001(\002\"\033\n\nInt64Val" @@ -233,25 +379,26 @@ void AddDescriptorsImpl() { descriptor, 447); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/wrappers.proto", &protobuf_RegisterTypes); - ::google::protobuf::internal::OnShutdown(&TableStruct::Shutdown); } void AddDescriptors() { static GOOGLE_PROTOBUF_DECLARE_ONCE(once); ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl); } -// Force AddDescriptors() to be called at static initialization time. +// Force AddDescriptors() to be called at dynamic initialization time. struct StaticDescriptorInitializer { StaticDescriptorInitializer() { AddDescriptors(); } } static_descriptor_initializer; - } // namespace protobuf_google_2fprotobuf_2fwrappers_2eproto - +namespace google { +namespace protobuf { // =================================================================== +void DoubleValue::InitAsDefaultInstance() { +} #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int DoubleValue::kValueFieldNumber; #endif // !defined(_MSC_VER) || _MSC_VER >= 1900 @@ -259,7 +406,7 @@ const int DoubleValue::kValueFieldNumber; DoubleValue::DoubleValue() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { - protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaultsDoubleValue(); } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.DoubleValue) @@ -267,9 +414,7 @@ DoubleValue::DoubleValue() DoubleValue::DoubleValue(::google::protobuf::Arena* arena) : ::google::protobuf::Message(), _internal_metadata_(arena) { -#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER - protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults(); -#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + ::protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaultsDoubleValue(); SharedCtor(); RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.DoubleValue) @@ -294,11 +439,7 @@ DoubleValue::~DoubleValue() { } void DoubleValue::SharedDtor() { - ::google::protobuf::Arena* arena = GetArenaNoVirtual(); - if (arena != NULL) { - return; - } - + GOOGLE_DCHECK(GetArenaNoVirtual() == NULL); } void DoubleValue::ArenaDtor(void* object) { @@ -313,22 +454,24 @@ void DoubleValue::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* DoubleValue::descriptor() { - protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; + ::protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce(); + return ::protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const DoubleValue& DoubleValue::default_instance() { - protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaultsDoubleValue(); return *internal_default_instance(); } -DoubleValue* DoubleValue::New(::google::protobuf::Arena* arena) const { - return ::google::protobuf::Arena::CreateMessage<DoubleValue>(arena); -} void DoubleValue::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.DoubleValue) + ::google::protobuf::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + value_ = 0; + _internal_metadata_.Clear(); } bool DoubleValue::MergePartialFromCodedStream( @@ -344,7 +487,7 @@ bool DoubleValue::MergePartialFromCodedStream( // double value = 1; case 1: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(9u)) { + static_cast< ::google::protobuf::uint8>(9u /* 9 & 0xFF */)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< double, ::google::protobuf::internal::WireFormatLite::TYPE_DOUBLE>( @@ -357,12 +500,11 @@ bool DoubleValue::MergePartialFromCodedStream( default: { handle_unusual: - if (tag == 0 || - ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + if (tag == 0) { goto success; } - DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag)); + DO_(::google::protobuf::internal::WireFormat::SkipField( + input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } @@ -387,11 +529,16 @@ void DoubleValue::SerializeWithCachedSizes( ::google::protobuf::internal::WireFormatLite::WriteDouble(1, this->value(), output); } + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + ::google::protobuf::internal::WireFormat::SerializeUnknownFields( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), output); + } // @@protoc_insertion_point(serialize_end:google.protobuf.DoubleValue) } ::google::protobuf::uint8* DoubleValue::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.DoubleValue) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -401,6 +548,10 @@ void DoubleValue::SerializeWithCachedSizes( target = ::google::protobuf::internal::WireFormatLite::WriteDoubleToArray(1, this->value(), target); } + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), target); + } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.DoubleValue) return target; } @@ -409,6 +560,11 @@ size_t DoubleValue::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.DoubleValue) size_t total_size = 0; + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance())); + } // double value = 1; if (this->value() != 0) { total_size += 1 + 8; @@ -486,36 +642,22 @@ void DoubleValue::UnsafeArenaSwap(DoubleValue* other) { InternalSwap(other); } void DoubleValue::InternalSwap(DoubleValue* other) { - std::swap(value_, other->value_); - std::swap(_cached_size_, other->_cached_size_); + using std::swap; + swap(value_, other->value_); + _internal_metadata_.Swap(&other->_internal_metadata_); + swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata DoubleValue::GetMetadata() const { protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[kIndexInFileMessages]; + return ::protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[kIndexInFileMessages]; } -#if PROTOBUF_INLINE_NOT_IN_HEADERS -// DoubleValue - -// double value = 1; -void DoubleValue::clear_value() { - value_ = 0; -} -double DoubleValue::value() const { - // @@protoc_insertion_point(field_get:google.protobuf.DoubleValue.value) - return value_; -} -void DoubleValue::set_value(double value) { - - value_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.DoubleValue.value) -} - -#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== +void FloatValue::InitAsDefaultInstance() { +} #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int FloatValue::kValueFieldNumber; #endif // !defined(_MSC_VER) || _MSC_VER >= 1900 @@ -523,7 +665,7 @@ const int FloatValue::kValueFieldNumber; FloatValue::FloatValue() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { - protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaultsFloatValue(); } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.FloatValue) @@ -531,9 +673,7 @@ FloatValue::FloatValue() FloatValue::FloatValue(::google::protobuf::Arena* arena) : ::google::protobuf::Message(), _internal_metadata_(arena) { -#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER - protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults(); -#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + ::protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaultsFloatValue(); SharedCtor(); RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.FloatValue) @@ -558,11 +698,7 @@ FloatValue::~FloatValue() { } void FloatValue::SharedDtor() { - ::google::protobuf::Arena* arena = GetArenaNoVirtual(); - if (arena != NULL) { - return; - } - + GOOGLE_DCHECK(GetArenaNoVirtual() == NULL); } void FloatValue::ArenaDtor(void* object) { @@ -577,22 +713,24 @@ void FloatValue::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* FloatValue::descriptor() { - protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; + ::protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce(); + return ::protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const FloatValue& FloatValue::default_instance() { - protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaultsFloatValue(); return *internal_default_instance(); } -FloatValue* FloatValue::New(::google::protobuf::Arena* arena) const { - return ::google::protobuf::Arena::CreateMessage<FloatValue>(arena); -} void FloatValue::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.FloatValue) + ::google::protobuf::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + value_ = 0; + _internal_metadata_.Clear(); } bool FloatValue::MergePartialFromCodedStream( @@ -608,7 +746,7 @@ bool FloatValue::MergePartialFromCodedStream( // float value = 1; case 1: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(13u)) { + static_cast< ::google::protobuf::uint8>(13u /* 13 & 0xFF */)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( @@ -621,12 +759,11 @@ bool FloatValue::MergePartialFromCodedStream( default: { handle_unusual: - if (tag == 0 || - ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + if (tag == 0) { goto success; } - DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag)); + DO_(::google::protobuf::internal::WireFormat::SkipField( + input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } @@ -651,11 +788,16 @@ void FloatValue::SerializeWithCachedSizes( ::google::protobuf::internal::WireFormatLite::WriteFloat(1, this->value(), output); } + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + ::google::protobuf::internal::WireFormat::SerializeUnknownFields( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), output); + } // @@protoc_insertion_point(serialize_end:google.protobuf.FloatValue) } ::google::protobuf::uint8* FloatValue::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.FloatValue) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -665,6 +807,10 @@ void FloatValue::SerializeWithCachedSizes( target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(1, this->value(), target); } + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), target); + } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.FloatValue) return target; } @@ -673,6 +819,11 @@ size_t FloatValue::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.FloatValue) size_t total_size = 0; + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance())); + } // float value = 1; if (this->value() != 0) { total_size += 1 + 4; @@ -750,36 +901,22 @@ void FloatValue::UnsafeArenaSwap(FloatValue* other) { InternalSwap(other); } void FloatValue::InternalSwap(FloatValue* other) { - std::swap(value_, other->value_); - std::swap(_cached_size_, other->_cached_size_); + using std::swap; + swap(value_, other->value_); + _internal_metadata_.Swap(&other->_internal_metadata_); + swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata FloatValue::GetMetadata() const { protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[kIndexInFileMessages]; -} - -#if PROTOBUF_INLINE_NOT_IN_HEADERS -// FloatValue - -// float value = 1; -void FloatValue::clear_value() { - value_ = 0; -} -float FloatValue::value() const { - // @@protoc_insertion_point(field_get:google.protobuf.FloatValue.value) - return value_; -} -void FloatValue::set_value(float value) { - - value_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.FloatValue.value) + return ::protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[kIndexInFileMessages]; } -#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== +void Int64Value::InitAsDefaultInstance() { +} #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int Int64Value::kValueFieldNumber; #endif // !defined(_MSC_VER) || _MSC_VER >= 1900 @@ -787,7 +924,7 @@ const int Int64Value::kValueFieldNumber; Int64Value::Int64Value() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { - protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaultsInt64Value(); } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Int64Value) @@ -795,9 +932,7 @@ Int64Value::Int64Value() Int64Value::Int64Value(::google::protobuf::Arena* arena) : ::google::protobuf::Message(), _internal_metadata_(arena) { -#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER - protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults(); -#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + ::protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaultsInt64Value(); SharedCtor(); RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.Int64Value) @@ -822,11 +957,7 @@ Int64Value::~Int64Value() { } void Int64Value::SharedDtor() { - ::google::protobuf::Arena* arena = GetArenaNoVirtual(); - if (arena != NULL) { - return; - } - + GOOGLE_DCHECK(GetArenaNoVirtual() == NULL); } void Int64Value::ArenaDtor(void* object) { @@ -841,22 +972,24 @@ void Int64Value::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* Int64Value::descriptor() { - protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; + ::protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce(); + return ::protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const Int64Value& Int64Value::default_instance() { - protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaultsInt64Value(); return *internal_default_instance(); } -Int64Value* Int64Value::New(::google::protobuf::Arena* arena) const { - return ::google::protobuf::Arena::CreateMessage<Int64Value>(arena); -} void Int64Value::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.Int64Value) + ::google::protobuf::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + value_ = GOOGLE_LONGLONG(0); + _internal_metadata_.Clear(); } bool Int64Value::MergePartialFromCodedStream( @@ -872,7 +1005,7 @@ bool Int64Value::MergePartialFromCodedStream( // int64 value = 1; case 1: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(8u)) { + static_cast< ::google::protobuf::uint8>(8u /* 8 & 0xFF */)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>( @@ -885,12 +1018,11 @@ bool Int64Value::MergePartialFromCodedStream( default: { handle_unusual: - if (tag == 0 || - ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + if (tag == 0) { goto success; } - DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag)); + DO_(::google::protobuf::internal::WireFormat::SkipField( + input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } @@ -915,11 +1047,16 @@ void Int64Value::SerializeWithCachedSizes( ::google::protobuf::internal::WireFormatLite::WriteInt64(1, this->value(), output); } + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + ::google::protobuf::internal::WireFormat::SerializeUnknownFields( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), output); + } // @@protoc_insertion_point(serialize_end:google.protobuf.Int64Value) } ::google::protobuf::uint8* Int64Value::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Int64Value) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -929,6 +1066,10 @@ void Int64Value::SerializeWithCachedSizes( target = ::google::protobuf::internal::WireFormatLite::WriteInt64ToArray(1, this->value(), target); } + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), target); + } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Int64Value) return target; } @@ -937,6 +1078,11 @@ size_t Int64Value::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Int64Value) size_t total_size = 0; + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance())); + } // int64 value = 1; if (this->value() != 0) { total_size += 1 + @@ -1016,36 +1162,22 @@ void Int64Value::UnsafeArenaSwap(Int64Value* other) { InternalSwap(other); } void Int64Value::InternalSwap(Int64Value* other) { - std::swap(value_, other->value_); - std::swap(_cached_size_, other->_cached_size_); + using std::swap; + swap(value_, other->value_); + _internal_metadata_.Swap(&other->_internal_metadata_); + swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata Int64Value::GetMetadata() const { protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[kIndexInFileMessages]; + return ::protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[kIndexInFileMessages]; } -#if PROTOBUF_INLINE_NOT_IN_HEADERS -// Int64Value - -// int64 value = 1; -void Int64Value::clear_value() { - value_ = GOOGLE_LONGLONG(0); -} -::google::protobuf::int64 Int64Value::value() const { - // @@protoc_insertion_point(field_get:google.protobuf.Int64Value.value) - return value_; -} -void Int64Value::set_value(::google::protobuf::int64 value) { - - value_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.Int64Value.value) -} - -#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== +void UInt64Value::InitAsDefaultInstance() { +} #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int UInt64Value::kValueFieldNumber; #endif // !defined(_MSC_VER) || _MSC_VER >= 1900 @@ -1053,7 +1185,7 @@ const int UInt64Value::kValueFieldNumber; UInt64Value::UInt64Value() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { - protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaultsUInt64Value(); } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.UInt64Value) @@ -1061,9 +1193,7 @@ UInt64Value::UInt64Value() UInt64Value::UInt64Value(::google::protobuf::Arena* arena) : ::google::protobuf::Message(), _internal_metadata_(arena) { -#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER - protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults(); -#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + ::protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaultsUInt64Value(); SharedCtor(); RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.UInt64Value) @@ -1088,11 +1218,7 @@ UInt64Value::~UInt64Value() { } void UInt64Value::SharedDtor() { - ::google::protobuf::Arena* arena = GetArenaNoVirtual(); - if (arena != NULL) { - return; - } - + GOOGLE_DCHECK(GetArenaNoVirtual() == NULL); } void UInt64Value::ArenaDtor(void* object) { @@ -1107,22 +1233,24 @@ void UInt64Value::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* UInt64Value::descriptor() { - protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; + ::protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce(); + return ::protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const UInt64Value& UInt64Value::default_instance() { - protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaultsUInt64Value(); return *internal_default_instance(); } -UInt64Value* UInt64Value::New(::google::protobuf::Arena* arena) const { - return ::google::protobuf::Arena::CreateMessage<UInt64Value>(arena); -} void UInt64Value::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.UInt64Value) + ::google::protobuf::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + value_ = GOOGLE_ULONGLONG(0); + _internal_metadata_.Clear(); } bool UInt64Value::MergePartialFromCodedStream( @@ -1138,7 +1266,7 @@ bool UInt64Value::MergePartialFromCodedStream( // uint64 value = 1; case 1: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(8u)) { + static_cast< ::google::protobuf::uint8>(8u /* 8 & 0xFF */)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint64, ::google::protobuf::internal::WireFormatLite::TYPE_UINT64>( @@ -1151,12 +1279,11 @@ bool UInt64Value::MergePartialFromCodedStream( default: { handle_unusual: - if (tag == 0 || - ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + if (tag == 0) { goto success; } - DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag)); + DO_(::google::protobuf::internal::WireFormat::SkipField( + input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } @@ -1181,11 +1308,16 @@ void UInt64Value::SerializeWithCachedSizes( ::google::protobuf::internal::WireFormatLite::WriteUInt64(1, this->value(), output); } + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + ::google::protobuf::internal::WireFormat::SerializeUnknownFields( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), output); + } // @@protoc_insertion_point(serialize_end:google.protobuf.UInt64Value) } ::google::protobuf::uint8* UInt64Value::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.UInt64Value) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -1195,6 +1327,10 @@ void UInt64Value::SerializeWithCachedSizes( target = ::google::protobuf::internal::WireFormatLite::WriteUInt64ToArray(1, this->value(), target); } + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), target); + } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.UInt64Value) return target; } @@ -1203,6 +1339,11 @@ size_t UInt64Value::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.UInt64Value) size_t total_size = 0; + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance())); + } // uint64 value = 1; if (this->value() != 0) { total_size += 1 + @@ -1282,36 +1423,22 @@ void UInt64Value::UnsafeArenaSwap(UInt64Value* other) { InternalSwap(other); } void UInt64Value::InternalSwap(UInt64Value* other) { - std::swap(value_, other->value_); - std::swap(_cached_size_, other->_cached_size_); + using std::swap; + swap(value_, other->value_); + _internal_metadata_.Swap(&other->_internal_metadata_); + swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata UInt64Value::GetMetadata() const { protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[kIndexInFileMessages]; + return ::protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[kIndexInFileMessages]; } -#if PROTOBUF_INLINE_NOT_IN_HEADERS -// UInt64Value - -// uint64 value = 1; -void UInt64Value::clear_value() { - value_ = GOOGLE_ULONGLONG(0); -} -::google::protobuf::uint64 UInt64Value::value() const { - // @@protoc_insertion_point(field_get:google.protobuf.UInt64Value.value) - return value_; -} -void UInt64Value::set_value(::google::protobuf::uint64 value) { - - value_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.UInt64Value.value) -} - -#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== +void Int32Value::InitAsDefaultInstance() { +} #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int Int32Value::kValueFieldNumber; #endif // !defined(_MSC_VER) || _MSC_VER >= 1900 @@ -1319,7 +1446,7 @@ const int Int32Value::kValueFieldNumber; Int32Value::Int32Value() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { - protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaultsInt32Value(); } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Int32Value) @@ -1327,9 +1454,7 @@ Int32Value::Int32Value() Int32Value::Int32Value(::google::protobuf::Arena* arena) : ::google::protobuf::Message(), _internal_metadata_(arena) { -#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER - protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults(); -#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + ::protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaultsInt32Value(); SharedCtor(); RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.Int32Value) @@ -1354,11 +1479,7 @@ Int32Value::~Int32Value() { } void Int32Value::SharedDtor() { - ::google::protobuf::Arena* arena = GetArenaNoVirtual(); - if (arena != NULL) { - return; - } - + GOOGLE_DCHECK(GetArenaNoVirtual() == NULL); } void Int32Value::ArenaDtor(void* object) { @@ -1373,22 +1494,24 @@ void Int32Value::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* Int32Value::descriptor() { - protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; + ::protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce(); + return ::protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const Int32Value& Int32Value::default_instance() { - protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaultsInt32Value(); return *internal_default_instance(); } -Int32Value* Int32Value::New(::google::protobuf::Arena* arena) const { - return ::google::protobuf::Arena::CreateMessage<Int32Value>(arena); -} void Int32Value::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.Int32Value) + ::google::protobuf::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + value_ = 0; + _internal_metadata_.Clear(); } bool Int32Value::MergePartialFromCodedStream( @@ -1404,7 +1527,7 @@ bool Int32Value::MergePartialFromCodedStream( // int32 value = 1; case 1: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(8u)) { + static_cast< ::google::protobuf::uint8>(8u /* 8 & 0xFF */)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -1417,12 +1540,11 @@ bool Int32Value::MergePartialFromCodedStream( default: { handle_unusual: - if (tag == 0 || - ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + if (tag == 0) { goto success; } - DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag)); + DO_(::google::protobuf::internal::WireFormat::SkipField( + input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } @@ -1447,11 +1569,16 @@ void Int32Value::SerializeWithCachedSizes( ::google::protobuf::internal::WireFormatLite::WriteInt32(1, this->value(), output); } + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + ::google::protobuf::internal::WireFormat::SerializeUnknownFields( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), output); + } // @@protoc_insertion_point(serialize_end:google.protobuf.Int32Value) } ::google::protobuf::uint8* Int32Value::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Int32Value) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -1461,6 +1588,10 @@ void Int32Value::SerializeWithCachedSizes( target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(1, this->value(), target); } + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), target); + } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Int32Value) return target; } @@ -1469,6 +1600,11 @@ size_t Int32Value::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Int32Value) size_t total_size = 0; + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance())); + } // int32 value = 1; if (this->value() != 0) { total_size += 1 + @@ -1548,36 +1684,22 @@ void Int32Value::UnsafeArenaSwap(Int32Value* other) { InternalSwap(other); } void Int32Value::InternalSwap(Int32Value* other) { - std::swap(value_, other->value_); - std::swap(_cached_size_, other->_cached_size_); + using std::swap; + swap(value_, other->value_); + _internal_metadata_.Swap(&other->_internal_metadata_); + swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata Int32Value::GetMetadata() const { protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[kIndexInFileMessages]; + return ::protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[kIndexInFileMessages]; } -#if PROTOBUF_INLINE_NOT_IN_HEADERS -// Int32Value - -// int32 value = 1; -void Int32Value::clear_value() { - value_ = 0; -} -::google::protobuf::int32 Int32Value::value() const { - // @@protoc_insertion_point(field_get:google.protobuf.Int32Value.value) - return value_; -} -void Int32Value::set_value(::google::protobuf::int32 value) { - - value_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.Int32Value.value) -} - -#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== +void UInt32Value::InitAsDefaultInstance() { +} #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int UInt32Value::kValueFieldNumber; #endif // !defined(_MSC_VER) || _MSC_VER >= 1900 @@ -1585,7 +1707,7 @@ const int UInt32Value::kValueFieldNumber; UInt32Value::UInt32Value() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { - protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaultsUInt32Value(); } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.UInt32Value) @@ -1593,9 +1715,7 @@ UInt32Value::UInt32Value() UInt32Value::UInt32Value(::google::protobuf::Arena* arena) : ::google::protobuf::Message(), _internal_metadata_(arena) { -#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER - protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults(); -#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + ::protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaultsUInt32Value(); SharedCtor(); RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.UInt32Value) @@ -1620,11 +1740,7 @@ UInt32Value::~UInt32Value() { } void UInt32Value::SharedDtor() { - ::google::protobuf::Arena* arena = GetArenaNoVirtual(); - if (arena != NULL) { - return; - } - + GOOGLE_DCHECK(GetArenaNoVirtual() == NULL); } void UInt32Value::ArenaDtor(void* object) { @@ -1639,22 +1755,24 @@ void UInt32Value::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* UInt32Value::descriptor() { - protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; + ::protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce(); + return ::protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const UInt32Value& UInt32Value::default_instance() { - protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaultsUInt32Value(); return *internal_default_instance(); } -UInt32Value* UInt32Value::New(::google::protobuf::Arena* arena) const { - return ::google::protobuf::Arena::CreateMessage<UInt32Value>(arena); -} void UInt32Value::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.UInt32Value) + ::google::protobuf::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + value_ = 0u; + _internal_metadata_.Clear(); } bool UInt32Value::MergePartialFromCodedStream( @@ -1670,7 +1788,7 @@ bool UInt32Value::MergePartialFromCodedStream( // uint32 value = 1; case 1: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(8u)) { + static_cast< ::google::protobuf::uint8>(8u /* 8 & 0xFF */)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( @@ -1683,12 +1801,11 @@ bool UInt32Value::MergePartialFromCodedStream( default: { handle_unusual: - if (tag == 0 || - ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + if (tag == 0) { goto success; } - DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag)); + DO_(::google::protobuf::internal::WireFormat::SkipField( + input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } @@ -1713,11 +1830,16 @@ void UInt32Value::SerializeWithCachedSizes( ::google::protobuf::internal::WireFormatLite::WriteUInt32(1, this->value(), output); } + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + ::google::protobuf::internal::WireFormat::SerializeUnknownFields( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), output); + } // @@protoc_insertion_point(serialize_end:google.protobuf.UInt32Value) } ::google::protobuf::uint8* UInt32Value::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.UInt32Value) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -1727,6 +1849,10 @@ void UInt32Value::SerializeWithCachedSizes( target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(1, this->value(), target); } + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), target); + } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.UInt32Value) return target; } @@ -1735,6 +1861,11 @@ size_t UInt32Value::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.UInt32Value) size_t total_size = 0; + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance())); + } // uint32 value = 1; if (this->value() != 0) { total_size += 1 + @@ -1814,36 +1945,22 @@ void UInt32Value::UnsafeArenaSwap(UInt32Value* other) { InternalSwap(other); } void UInt32Value::InternalSwap(UInt32Value* other) { - std::swap(value_, other->value_); - std::swap(_cached_size_, other->_cached_size_); + using std::swap; + swap(value_, other->value_); + _internal_metadata_.Swap(&other->_internal_metadata_); + swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata UInt32Value::GetMetadata() const { protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[kIndexInFileMessages]; + return ::protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[kIndexInFileMessages]; } -#if PROTOBUF_INLINE_NOT_IN_HEADERS -// UInt32Value - -// uint32 value = 1; -void UInt32Value::clear_value() { - value_ = 0u; -} -::google::protobuf::uint32 UInt32Value::value() const { - // @@protoc_insertion_point(field_get:google.protobuf.UInt32Value.value) - return value_; -} -void UInt32Value::set_value(::google::protobuf::uint32 value) { - - value_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.UInt32Value.value) -} - -#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== +void BoolValue::InitAsDefaultInstance() { +} #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int BoolValue::kValueFieldNumber; #endif // !defined(_MSC_VER) || _MSC_VER >= 1900 @@ -1851,7 +1968,7 @@ const int BoolValue::kValueFieldNumber; BoolValue::BoolValue() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { - protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaultsBoolValue(); } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.BoolValue) @@ -1859,9 +1976,7 @@ BoolValue::BoolValue() BoolValue::BoolValue(::google::protobuf::Arena* arena) : ::google::protobuf::Message(), _internal_metadata_(arena) { -#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER - protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults(); -#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + ::protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaultsBoolValue(); SharedCtor(); RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.BoolValue) @@ -1886,11 +2001,7 @@ BoolValue::~BoolValue() { } void BoolValue::SharedDtor() { - ::google::protobuf::Arena* arena = GetArenaNoVirtual(); - if (arena != NULL) { - return; - } - + GOOGLE_DCHECK(GetArenaNoVirtual() == NULL); } void BoolValue::ArenaDtor(void* object) { @@ -1905,22 +2016,24 @@ void BoolValue::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* BoolValue::descriptor() { - protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; + ::protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce(); + return ::protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const BoolValue& BoolValue::default_instance() { - protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaultsBoolValue(); return *internal_default_instance(); } -BoolValue* BoolValue::New(::google::protobuf::Arena* arena) const { - return ::google::protobuf::Arena::CreateMessage<BoolValue>(arena); -} void BoolValue::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.BoolValue) + ::google::protobuf::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + value_ = false; + _internal_metadata_.Clear(); } bool BoolValue::MergePartialFromCodedStream( @@ -1936,7 +2049,7 @@ bool BoolValue::MergePartialFromCodedStream( // bool value = 1; case 1: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(8u)) { + static_cast< ::google::protobuf::uint8>(8u /* 8 & 0xFF */)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -1949,12 +2062,11 @@ bool BoolValue::MergePartialFromCodedStream( default: { handle_unusual: - if (tag == 0 || - ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + if (tag == 0) { goto success; } - DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag)); + DO_(::google::protobuf::internal::WireFormat::SkipField( + input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } @@ -1979,11 +2091,16 @@ void BoolValue::SerializeWithCachedSizes( ::google::protobuf::internal::WireFormatLite::WriteBool(1, this->value(), output); } + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + ::google::protobuf::internal::WireFormat::SerializeUnknownFields( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), output); + } // @@protoc_insertion_point(serialize_end:google.protobuf.BoolValue) } ::google::protobuf::uint8* BoolValue::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.BoolValue) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -1993,6 +2110,10 @@ void BoolValue::SerializeWithCachedSizes( target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(1, this->value(), target); } + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), target); + } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.BoolValue) return target; } @@ -2001,6 +2122,11 @@ size_t BoolValue::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.BoolValue) size_t total_size = 0; + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance())); + } // bool value = 1; if (this->value() != 0) { total_size += 1 + 1; @@ -2078,36 +2204,22 @@ void BoolValue::UnsafeArenaSwap(BoolValue* other) { InternalSwap(other); } void BoolValue::InternalSwap(BoolValue* other) { - std::swap(value_, other->value_); - std::swap(_cached_size_, other->_cached_size_); + using std::swap; + swap(value_, other->value_); + _internal_metadata_.Swap(&other->_internal_metadata_); + swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata BoolValue::GetMetadata() const { protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[kIndexInFileMessages]; + return ::protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[kIndexInFileMessages]; } -#if PROTOBUF_INLINE_NOT_IN_HEADERS -// BoolValue - -// bool value = 1; -void BoolValue::clear_value() { - value_ = false; -} -bool BoolValue::value() const { - // @@protoc_insertion_point(field_get:google.protobuf.BoolValue.value) - return value_; -} -void BoolValue::set_value(bool value) { - - value_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.BoolValue.value) -} - -#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== +void StringValue::InitAsDefaultInstance() { +} #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int StringValue::kValueFieldNumber; #endif // !defined(_MSC_VER) || _MSC_VER >= 1900 @@ -2115,7 +2227,7 @@ const int StringValue::kValueFieldNumber; StringValue::StringValue() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { - protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaultsStringValue(); } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.StringValue) @@ -2123,9 +2235,7 @@ StringValue::StringValue() StringValue::StringValue(::google::protobuf::Arena* arena) : ::google::protobuf::Message(), _internal_metadata_(arena) { -#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER - protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults(); -#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + ::protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaultsStringValue(); SharedCtor(); RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.StringValue) @@ -2154,12 +2264,8 @@ StringValue::~StringValue() { } void StringValue::SharedDtor() { - ::google::protobuf::Arena* arena = GetArenaNoVirtual(); - if (arena != NULL) { - return; - } - - value_.Destroy(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), arena); + GOOGLE_DCHECK(GetArenaNoVirtual() == NULL); + value_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } void StringValue::ArenaDtor(void* object) { @@ -2174,22 +2280,24 @@ void StringValue::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* StringValue::descriptor() { - protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; + ::protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce(); + return ::protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const StringValue& StringValue::default_instance() { - protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaultsStringValue(); return *internal_default_instance(); } -StringValue* StringValue::New(::google::protobuf::Arena* arena) const { - return ::google::protobuf::Arena::CreateMessage<StringValue>(arena); -} void StringValue::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.StringValue) + ::google::protobuf::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + value_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + _internal_metadata_.Clear(); } bool StringValue::MergePartialFromCodedStream( @@ -2205,11 +2313,11 @@ bool StringValue::MergePartialFromCodedStream( // string value = 1; case 1: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(10u)) { + static_cast< ::google::protobuf::uint8>(10u /* 10 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_value())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( - this->value().data(), this->value().length(), + this->value().data(), static_cast<int>(this->value().length()), ::google::protobuf::internal::WireFormatLite::PARSE, "google.protobuf.StringValue.value")); } else { @@ -2220,12 +2328,11 @@ bool StringValue::MergePartialFromCodedStream( default: { handle_unusual: - if (tag == 0 || - ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + if (tag == 0) { goto success; } - DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag)); + DO_(::google::protobuf::internal::WireFormat::SkipField( + input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } @@ -2248,18 +2355,23 @@ void StringValue::SerializeWithCachedSizes( // string value = 1; if (this->value().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( - this->value().data(), this->value().length(), + this->value().data(), static_cast<int>(this->value().length()), ::google::protobuf::internal::WireFormatLite::SERIALIZE, "google.protobuf.StringValue.value"); ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( 1, this->value(), output); } + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + ::google::protobuf::internal::WireFormat::SerializeUnknownFields( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), output); + } // @@protoc_insertion_point(serialize_end:google.protobuf.StringValue) } ::google::protobuf::uint8* StringValue::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.StringValue) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -2267,7 +2379,7 @@ void StringValue::SerializeWithCachedSizes( // string value = 1; if (this->value().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( - this->value().data(), this->value().length(), + this->value().data(), static_cast<int>(this->value().length()), ::google::protobuf::internal::WireFormatLite::SERIALIZE, "google.protobuf.StringValue.value"); target = @@ -2275,6 +2387,10 @@ void StringValue::SerializeWithCachedSizes( 1, this->value(), target); } + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), target); + } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.StringValue) return target; } @@ -2283,6 +2399,11 @@ size_t StringValue::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.StringValue) size_t total_size = 0; + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance())); + } // string value = 1; if (this->value().size() > 0) { total_size += 1 + @@ -2362,89 +2483,22 @@ void StringValue::UnsafeArenaSwap(StringValue* other) { InternalSwap(other); } void StringValue::InternalSwap(StringValue* other) { + using std::swap; value_.Swap(&other->value_); - std::swap(_cached_size_, other->_cached_size_); + _internal_metadata_.Swap(&other->_internal_metadata_); + swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata StringValue::GetMetadata() const { protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[kIndexInFileMessages]; + return ::protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[kIndexInFileMessages]; } -#if PROTOBUF_INLINE_NOT_IN_HEADERS -// StringValue - -// string value = 1; -void StringValue::clear_value() { - value_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); -} -const ::std::string& StringValue::value() const { - // @@protoc_insertion_point(field_get:google.protobuf.StringValue.value) - return value_.Get(); -} -void StringValue::set_value(const ::std::string& value) { - - value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); - // @@protoc_insertion_point(field_set:google.protobuf.StringValue.value) -} -void StringValue::set_value(const char* value) { - GOOGLE_DCHECK(value != NULL); - - value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), - GetArenaNoVirtual()); - // @@protoc_insertion_point(field_set_char:google.protobuf.StringValue.value) -} -void StringValue::set_value(const char* value, - size_t size) { - - value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( - reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.StringValue.value) -} -::std::string* StringValue::mutable_value() { - - // @@protoc_insertion_point(field_mutable:google.protobuf.StringValue.value) - return value_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); -} -::std::string* StringValue::release_value() { - // @@protoc_insertion_point(field_release:google.protobuf.StringValue.value) - - return value_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); -} -::std::string* StringValue::unsafe_arena_release_value() { - // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.StringValue.value) - GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); - - return value_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); -} -void StringValue::set_allocated_value(::std::string* value) { - if (value != NULL) { - - } else { - - } - value_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, - GetArenaNoVirtual()); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.StringValue.value) -} -void StringValue::unsafe_arena_set_allocated_value( - ::std::string* value) { - GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); - if (value != NULL) { - - } else { - - } - value_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - value, GetArenaNoVirtual()); - // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.StringValue.value) -} - -#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== +void BytesValue::InitAsDefaultInstance() { +} #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int BytesValue::kValueFieldNumber; #endif // !defined(_MSC_VER) || _MSC_VER >= 1900 @@ -2452,7 +2506,7 @@ const int BytesValue::kValueFieldNumber; BytesValue::BytesValue() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { - protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaultsBytesValue(); } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.BytesValue) @@ -2460,9 +2514,7 @@ BytesValue::BytesValue() BytesValue::BytesValue(::google::protobuf::Arena* arena) : ::google::protobuf::Message(), _internal_metadata_(arena) { -#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER - protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults(); -#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + ::protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaultsBytesValue(); SharedCtor(); RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.BytesValue) @@ -2491,12 +2543,8 @@ BytesValue::~BytesValue() { } void BytesValue::SharedDtor() { - ::google::protobuf::Arena* arena = GetArenaNoVirtual(); - if (arena != NULL) { - return; - } - - value_.Destroy(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), arena); + GOOGLE_DCHECK(GetArenaNoVirtual() == NULL); + value_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } void BytesValue::ArenaDtor(void* object) { @@ -2511,22 +2559,24 @@ void BytesValue::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* BytesValue::descriptor() { - protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; + ::protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce(); + return ::protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const BytesValue& BytesValue::default_instance() { - protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults(); + ::protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaultsBytesValue(); return *internal_default_instance(); } -BytesValue* BytesValue::New(::google::protobuf::Arena* arena) const { - return ::google::protobuf::Arena::CreateMessage<BytesValue>(arena); -} void BytesValue::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.BytesValue) + ::google::protobuf::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + value_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + _internal_metadata_.Clear(); } bool BytesValue::MergePartialFromCodedStream( @@ -2542,7 +2592,7 @@ bool BytesValue::MergePartialFromCodedStream( // bytes value = 1; case 1: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(10u)) { + static_cast< ::google::protobuf::uint8>(10u /* 10 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadBytes( input, this->mutable_value())); } else { @@ -2553,12 +2603,11 @@ bool BytesValue::MergePartialFromCodedStream( default: { handle_unusual: - if (tag == 0 || - ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + if (tag == 0) { goto success; } - DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag)); + DO_(::google::protobuf::internal::WireFormat::SkipField( + input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } @@ -2584,11 +2633,16 @@ void BytesValue::SerializeWithCachedSizes( 1, this->value(), output); } + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + ::google::protobuf::internal::WireFormat::SerializeUnknownFields( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), output); + } // @@protoc_insertion_point(serialize_end:google.protobuf.BytesValue) } ::google::protobuf::uint8* BytesValue::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.BytesValue) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -2600,6 +2654,10 @@ void BytesValue::SerializeWithCachedSizes( 1, this->value(), target); } + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), target); + } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.BytesValue) return target; } @@ -2608,6 +2666,11 @@ size_t BytesValue::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.BytesValue) size_t total_size = 0; + if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance())); + } // bytes value = 1; if (this->value().size() > 0) { total_size += 1 + @@ -2687,89 +2750,50 @@ void BytesValue::UnsafeArenaSwap(BytesValue* other) { InternalSwap(other); } void BytesValue::InternalSwap(BytesValue* other) { + using std::swap; value_.Swap(&other->value_); - std::swap(_cached_size_, other->_cached_size_); + _internal_metadata_.Swap(&other->_internal_metadata_); + swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata BytesValue::GetMetadata() const { protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[kIndexInFileMessages]; + return ::protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[kIndexInFileMessages]; } -#if PROTOBUF_INLINE_NOT_IN_HEADERS -// BytesValue -// bytes value = 1; -void BytesValue::clear_value() { - value_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); +// @@protoc_insertion_point(namespace_scope) +} // namespace protobuf +} // namespace google +namespace google { +namespace protobuf { +template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::DoubleValue* Arena::CreateMessage< ::google::protobuf::DoubleValue >(Arena* arena) { + return Arena::CreateMessageInternal< ::google::protobuf::DoubleValue >(arena); } -const ::std::string& BytesValue::value() const { - // @@protoc_insertion_point(field_get:google.protobuf.BytesValue.value) - return value_.Get(); -} -void BytesValue::set_value(const ::std::string& value) { - - value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); - // @@protoc_insertion_point(field_set:google.protobuf.BytesValue.value) -} -void BytesValue::set_value(const char* value) { - GOOGLE_DCHECK(value != NULL); - - value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), - GetArenaNoVirtual()); - // @@protoc_insertion_point(field_set_char:google.protobuf.BytesValue.value) -} -void BytesValue::set_value(const void* value, - size_t size) { - - value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( - reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.BytesValue.value) -} -::std::string* BytesValue::mutable_value() { - - // @@protoc_insertion_point(field_mutable:google.protobuf.BytesValue.value) - return value_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); -} -::std::string* BytesValue::release_value() { - // @@protoc_insertion_point(field_release:google.protobuf.BytesValue.value) - - return value_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); -} -::std::string* BytesValue::unsafe_arena_release_value() { - // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.BytesValue.value) - GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); - - return value_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); +template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::FloatValue* Arena::CreateMessage< ::google::protobuf::FloatValue >(Arena* arena) { + return Arena::CreateMessageInternal< ::google::protobuf::FloatValue >(arena); } -void BytesValue::set_allocated_value(::std::string* value) { - if (value != NULL) { - - } else { - - } - value_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, - GetArenaNoVirtual()); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.BytesValue.value) +template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::Int64Value* Arena::CreateMessage< ::google::protobuf::Int64Value >(Arena* arena) { + return Arena::CreateMessageInternal< ::google::protobuf::Int64Value >(arena); } -void BytesValue::unsafe_arena_set_allocated_value( - ::std::string* value) { - GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); - if (value != NULL) { - - } else { - - } - value_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - value, GetArenaNoVirtual()); - // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.BytesValue.value) +template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::UInt64Value* Arena::CreateMessage< ::google::protobuf::UInt64Value >(Arena* arena) { + return Arena::CreateMessageInternal< ::google::protobuf::UInt64Value >(arena); +} +template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::Int32Value* Arena::CreateMessage< ::google::protobuf::Int32Value >(Arena* arena) { + return Arena::CreateMessageInternal< ::google::protobuf::Int32Value >(arena); +} +template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::UInt32Value* Arena::CreateMessage< ::google::protobuf::UInt32Value >(Arena* arena) { + return Arena::CreateMessageInternal< ::google::protobuf::UInt32Value >(arena); +} +template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::BoolValue* Arena::CreateMessage< ::google::protobuf::BoolValue >(Arena* arena) { + return Arena::CreateMessageInternal< ::google::protobuf::BoolValue >(arena); +} +template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::StringValue* Arena::CreateMessage< ::google::protobuf::StringValue >(Arena* arena) { + return Arena::CreateMessageInternal< ::google::protobuf::StringValue >(arena); +} +template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::BytesValue* Arena::CreateMessage< ::google::protobuf::BytesValue >(Arena* arena) { + return Arena::CreateMessageInternal< ::google::protobuf::BytesValue >(arena); } - -#endif // PROTOBUF_INLINE_NOT_IN_HEADERS - -// @@protoc_insertion_point(namespace_scope) - } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/wrappers.pb.h b/src/google/protobuf/wrappers.pb.h index 4202541b..876bf39b 100644 --- a/src/google/protobuf/wrappers.pb.h +++ b/src/google/protobuf/wrappers.pb.h @@ -1,19 +1,19 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/protobuf/wrappers.proto -#ifndef PROTOBUF_google_2fprotobuf_2fwrappers_2eproto__INCLUDED -#define PROTOBUF_google_2fprotobuf_2fwrappers_2eproto__INCLUDED +#ifndef PROTOBUF_google_2fprotobuf_2fwrappers_2eproto_INCLUDED +#define PROTOBUF_google_2fprotobuf_2fwrappers_2eproto_INCLUDED #include <string> #include <google/protobuf/stubs/common.h> -#if GOOGLE_PROTOBUF_VERSION < 3003000 +#if GOOGLE_PROTOBUF_VERSION < 3005000 #error This file was generated by a newer version of protoc which is #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3003000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION +#if 3005001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. @@ -30,6 +30,48 @@ #include <google/protobuf/extension_set.h> // IWYU pragma: export #include <google/protobuf/unknown_field_set.h> // @@protoc_insertion_point(includes) + +namespace protobuf_google_2fprotobuf_2fwrappers_2eproto { +// Internal implementation detail -- do not use these members. +struct LIBPROTOBUF_EXPORT TableStruct { + static const ::google::protobuf::internal::ParseTableField entries[]; + static const ::google::protobuf::internal::AuxillaryParseTableField aux[]; + static const ::google::protobuf::internal::ParseTable schema[9]; + static const ::google::protobuf::internal::FieldMetadata field_metadata[]; + static const ::google::protobuf::internal::SerializationTable serialization_table[]; + static const ::google::protobuf::uint32 offsets[]; +}; +void LIBPROTOBUF_EXPORT AddDescriptors(); +void LIBPROTOBUF_EXPORT InitDefaultsDoubleValueImpl(); +void LIBPROTOBUF_EXPORT InitDefaultsDoubleValue(); +void LIBPROTOBUF_EXPORT InitDefaultsFloatValueImpl(); +void LIBPROTOBUF_EXPORT InitDefaultsFloatValue(); +void LIBPROTOBUF_EXPORT InitDefaultsInt64ValueImpl(); +void LIBPROTOBUF_EXPORT InitDefaultsInt64Value(); +void LIBPROTOBUF_EXPORT InitDefaultsUInt64ValueImpl(); +void LIBPROTOBUF_EXPORT InitDefaultsUInt64Value(); +void LIBPROTOBUF_EXPORT InitDefaultsInt32ValueImpl(); +void LIBPROTOBUF_EXPORT InitDefaultsInt32Value(); +void LIBPROTOBUF_EXPORT InitDefaultsUInt32ValueImpl(); +void LIBPROTOBUF_EXPORT InitDefaultsUInt32Value(); +void LIBPROTOBUF_EXPORT InitDefaultsBoolValueImpl(); +void LIBPROTOBUF_EXPORT InitDefaultsBoolValue(); +void LIBPROTOBUF_EXPORT InitDefaultsStringValueImpl(); +void LIBPROTOBUF_EXPORT InitDefaultsStringValue(); +void LIBPROTOBUF_EXPORT InitDefaultsBytesValueImpl(); +void LIBPROTOBUF_EXPORT InitDefaultsBytesValue(); +inline void LIBPROTOBUF_EXPORT InitDefaults() { + InitDefaultsDoubleValue(); + InitDefaultsFloatValue(); + InitDefaultsInt64Value(); + InitDefaultsUInt64Value(); + InitDefaultsInt32Value(); + InitDefaultsUInt32Value(); + InitDefaultsBoolValue(); + InitDefaultsStringValue(); + InitDefaultsBytesValue(); +} +} // namespace protobuf_google_2fprotobuf_2fwrappers_2eproto namespace google { namespace protobuf { class BoolValue; @@ -61,23 +103,21 @@ class UInt64ValueDefaultTypeInternal; LIBPROTOBUF_EXPORT extern UInt64ValueDefaultTypeInternal _UInt64Value_default_instance_; } // namespace protobuf } // namespace google - namespace google { namespace protobuf { - -namespace protobuf_google_2fprotobuf_2fwrappers_2eproto { -// Internal implementation detail -- do not call these. -struct LIBPROTOBUF_EXPORT TableStruct { - static const ::google::protobuf::internal::ParseTableField entries[]; - static const ::google::protobuf::internal::AuxillaryParseTableField aux[]; - static const ::google::protobuf::internal::ParseTable schema[]; - static const ::google::protobuf::uint32 offsets[]; - static void InitDefaultsImpl(); - static void Shutdown(); -}; -void LIBPROTOBUF_EXPORT AddDescriptors(); -void LIBPROTOBUF_EXPORT InitDefaults(); -} // namespace protobuf_google_2fprotobuf_2fwrappers_2eproto +template<> LIBPROTOBUF_EXPORT ::google::protobuf::BoolValue* Arena::CreateMessage< ::google::protobuf::BoolValue>(Arena*); +template<> LIBPROTOBUF_EXPORT ::google::protobuf::BytesValue* Arena::CreateMessage< ::google::protobuf::BytesValue>(Arena*); +template<> LIBPROTOBUF_EXPORT ::google::protobuf::DoubleValue* Arena::CreateMessage< ::google::protobuf::DoubleValue>(Arena*); +template<> LIBPROTOBUF_EXPORT ::google::protobuf::FloatValue* Arena::CreateMessage< ::google::protobuf::FloatValue>(Arena*); +template<> LIBPROTOBUF_EXPORT ::google::protobuf::Int32Value* Arena::CreateMessage< ::google::protobuf::Int32Value>(Arena*); +template<> LIBPROTOBUF_EXPORT ::google::protobuf::Int64Value* Arena::CreateMessage< ::google::protobuf::Int64Value>(Arena*); +template<> LIBPROTOBUF_EXPORT ::google::protobuf::StringValue* Arena::CreateMessage< ::google::protobuf::StringValue>(Arena*); +template<> LIBPROTOBUF_EXPORT ::google::protobuf::UInt32Value* Arena::CreateMessage< ::google::protobuf::UInt32Value>(Arena*); +template<> LIBPROTOBUF_EXPORT ::google::protobuf::UInt64Value* Arena::CreateMessage< ::google::protobuf::UInt64Value>(Arena*); +} // namespace protobuf +} // namespace google +namespace google { +namespace protobuf { // =================================================================== @@ -92,7 +132,21 @@ class LIBPROTOBUF_EXPORT DoubleValue : public ::google::protobuf::Message /* @@p CopyFrom(from); return *this; } + #if LANG_CXX11 + DoubleValue(DoubleValue&& from) noexcept + : DoubleValue() { + *this = ::std::move(from); + } + inline DoubleValue& operator=(DoubleValue&& from) noexcept { + if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + #endif inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { return GetArenaNoVirtual(); } @@ -102,6 +156,7 @@ class LIBPROTOBUF_EXPORT DoubleValue : public ::google::protobuf::Message /* @@p static const ::google::protobuf::Descriptor* descriptor(); static const DoubleValue& default_instance(); + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY static inline const DoubleValue* internal_default_instance() { return reinterpret_cast<const DoubleValue*>( &_DoubleValue_default_instance_); @@ -111,12 +166,19 @@ class LIBPROTOBUF_EXPORT DoubleValue : public ::google::protobuf::Message /* @@p void UnsafeArenaSwap(DoubleValue* other); void Swap(DoubleValue* other); + friend void swap(DoubleValue& a, DoubleValue& b) { + a.Swap(&b); + } // implements Message ---------------------------------------------- - inline DoubleValue* New() const PROTOBUF_FINAL { return New(NULL); } + inline DoubleValue* New() const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<DoubleValue>(NULL); + } - DoubleValue* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + DoubleValue* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<DoubleValue>(arena); + } void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const DoubleValue& from); @@ -167,12 +229,13 @@ class LIBPROTOBUF_EXPORT DoubleValue : public ::google::protobuf::Message /* @@p private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - friend class ::google::protobuf::Arena; + template <typename T> friend class ::google::protobuf::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; double value_; mutable int _cached_size_; - friend struct protobuf_google_2fprotobuf_2fwrappers_2eproto::TableStruct; + friend struct ::protobuf_google_2fprotobuf_2fwrappers_2eproto::TableStruct; + friend void ::protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaultsDoubleValueImpl(); }; // ------------------------------------------------------------------- @@ -187,7 +250,21 @@ class LIBPROTOBUF_EXPORT FloatValue : public ::google::protobuf::Message /* @@pr CopyFrom(from); return *this; } + #if LANG_CXX11 + FloatValue(FloatValue&& from) noexcept + : FloatValue() { + *this = ::std::move(from); + } + inline FloatValue& operator=(FloatValue&& from) noexcept { + if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + #endif inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { return GetArenaNoVirtual(); } @@ -197,6 +274,7 @@ class LIBPROTOBUF_EXPORT FloatValue : public ::google::protobuf::Message /* @@pr static const ::google::protobuf::Descriptor* descriptor(); static const FloatValue& default_instance(); + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY static inline const FloatValue* internal_default_instance() { return reinterpret_cast<const FloatValue*>( &_FloatValue_default_instance_); @@ -206,12 +284,19 @@ class LIBPROTOBUF_EXPORT FloatValue : public ::google::protobuf::Message /* @@pr void UnsafeArenaSwap(FloatValue* other); void Swap(FloatValue* other); + friend void swap(FloatValue& a, FloatValue& b) { + a.Swap(&b); + } // implements Message ---------------------------------------------- - inline FloatValue* New() const PROTOBUF_FINAL { return New(NULL); } + inline FloatValue* New() const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<FloatValue>(NULL); + } - FloatValue* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + FloatValue* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<FloatValue>(arena); + } void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const FloatValue& from); @@ -262,12 +347,13 @@ class LIBPROTOBUF_EXPORT FloatValue : public ::google::protobuf::Message /* @@pr private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - friend class ::google::protobuf::Arena; + template <typename T> friend class ::google::protobuf::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; float value_; mutable int _cached_size_; - friend struct protobuf_google_2fprotobuf_2fwrappers_2eproto::TableStruct; + friend struct ::protobuf_google_2fprotobuf_2fwrappers_2eproto::TableStruct; + friend void ::protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaultsFloatValueImpl(); }; // ------------------------------------------------------------------- @@ -282,7 +368,21 @@ class LIBPROTOBUF_EXPORT Int64Value : public ::google::protobuf::Message /* @@pr CopyFrom(from); return *this; } + #if LANG_CXX11 + Int64Value(Int64Value&& from) noexcept + : Int64Value() { + *this = ::std::move(from); + } + inline Int64Value& operator=(Int64Value&& from) noexcept { + if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + #endif inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { return GetArenaNoVirtual(); } @@ -292,6 +392,7 @@ class LIBPROTOBUF_EXPORT Int64Value : public ::google::protobuf::Message /* @@pr static const ::google::protobuf::Descriptor* descriptor(); static const Int64Value& default_instance(); + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY static inline const Int64Value* internal_default_instance() { return reinterpret_cast<const Int64Value*>( &_Int64Value_default_instance_); @@ -301,12 +402,19 @@ class LIBPROTOBUF_EXPORT Int64Value : public ::google::protobuf::Message /* @@pr void UnsafeArenaSwap(Int64Value* other); void Swap(Int64Value* other); + friend void swap(Int64Value& a, Int64Value& b) { + a.Swap(&b); + } // implements Message ---------------------------------------------- - inline Int64Value* New() const PROTOBUF_FINAL { return New(NULL); } + inline Int64Value* New() const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<Int64Value>(NULL); + } - Int64Value* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + Int64Value* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<Int64Value>(arena); + } void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const Int64Value& from); @@ -357,12 +465,13 @@ class LIBPROTOBUF_EXPORT Int64Value : public ::google::protobuf::Message /* @@pr private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - friend class ::google::protobuf::Arena; + template <typename T> friend class ::google::protobuf::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; ::google::protobuf::int64 value_; mutable int _cached_size_; - friend struct protobuf_google_2fprotobuf_2fwrappers_2eproto::TableStruct; + friend struct ::protobuf_google_2fprotobuf_2fwrappers_2eproto::TableStruct; + friend void ::protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaultsInt64ValueImpl(); }; // ------------------------------------------------------------------- @@ -377,7 +486,21 @@ class LIBPROTOBUF_EXPORT UInt64Value : public ::google::protobuf::Message /* @@p CopyFrom(from); return *this; } + #if LANG_CXX11 + UInt64Value(UInt64Value&& from) noexcept + : UInt64Value() { + *this = ::std::move(from); + } + inline UInt64Value& operator=(UInt64Value&& from) noexcept { + if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + #endif inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { return GetArenaNoVirtual(); } @@ -387,6 +510,7 @@ class LIBPROTOBUF_EXPORT UInt64Value : public ::google::protobuf::Message /* @@p static const ::google::protobuf::Descriptor* descriptor(); static const UInt64Value& default_instance(); + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY static inline const UInt64Value* internal_default_instance() { return reinterpret_cast<const UInt64Value*>( &_UInt64Value_default_instance_); @@ -396,12 +520,19 @@ class LIBPROTOBUF_EXPORT UInt64Value : public ::google::protobuf::Message /* @@p void UnsafeArenaSwap(UInt64Value* other); void Swap(UInt64Value* other); + friend void swap(UInt64Value& a, UInt64Value& b) { + a.Swap(&b); + } // implements Message ---------------------------------------------- - inline UInt64Value* New() const PROTOBUF_FINAL { return New(NULL); } + inline UInt64Value* New() const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<UInt64Value>(NULL); + } - UInt64Value* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + UInt64Value* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<UInt64Value>(arena); + } void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const UInt64Value& from); @@ -452,12 +583,13 @@ class LIBPROTOBUF_EXPORT UInt64Value : public ::google::protobuf::Message /* @@p private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - friend class ::google::protobuf::Arena; + template <typename T> friend class ::google::protobuf::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; ::google::protobuf::uint64 value_; mutable int _cached_size_; - friend struct protobuf_google_2fprotobuf_2fwrappers_2eproto::TableStruct; + friend struct ::protobuf_google_2fprotobuf_2fwrappers_2eproto::TableStruct; + friend void ::protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaultsUInt64ValueImpl(); }; // ------------------------------------------------------------------- @@ -472,7 +604,21 @@ class LIBPROTOBUF_EXPORT Int32Value : public ::google::protobuf::Message /* @@pr CopyFrom(from); return *this; } + #if LANG_CXX11 + Int32Value(Int32Value&& from) noexcept + : Int32Value() { + *this = ::std::move(from); + } + inline Int32Value& operator=(Int32Value&& from) noexcept { + if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + #endif inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { return GetArenaNoVirtual(); } @@ -482,6 +628,7 @@ class LIBPROTOBUF_EXPORT Int32Value : public ::google::protobuf::Message /* @@pr static const ::google::protobuf::Descriptor* descriptor(); static const Int32Value& default_instance(); + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY static inline const Int32Value* internal_default_instance() { return reinterpret_cast<const Int32Value*>( &_Int32Value_default_instance_); @@ -491,12 +638,19 @@ class LIBPROTOBUF_EXPORT Int32Value : public ::google::protobuf::Message /* @@pr void UnsafeArenaSwap(Int32Value* other); void Swap(Int32Value* other); + friend void swap(Int32Value& a, Int32Value& b) { + a.Swap(&b); + } // implements Message ---------------------------------------------- - inline Int32Value* New() const PROTOBUF_FINAL { return New(NULL); } + inline Int32Value* New() const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<Int32Value>(NULL); + } - Int32Value* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + Int32Value* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<Int32Value>(arena); + } void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const Int32Value& from); @@ -547,12 +701,13 @@ class LIBPROTOBUF_EXPORT Int32Value : public ::google::protobuf::Message /* @@pr private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - friend class ::google::protobuf::Arena; + template <typename T> friend class ::google::protobuf::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; ::google::protobuf::int32 value_; mutable int _cached_size_; - friend struct protobuf_google_2fprotobuf_2fwrappers_2eproto::TableStruct; + friend struct ::protobuf_google_2fprotobuf_2fwrappers_2eproto::TableStruct; + friend void ::protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaultsInt32ValueImpl(); }; // ------------------------------------------------------------------- @@ -567,7 +722,21 @@ class LIBPROTOBUF_EXPORT UInt32Value : public ::google::protobuf::Message /* @@p CopyFrom(from); return *this; } + #if LANG_CXX11 + UInt32Value(UInt32Value&& from) noexcept + : UInt32Value() { + *this = ::std::move(from); + } + inline UInt32Value& operator=(UInt32Value&& from) noexcept { + if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + #endif inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { return GetArenaNoVirtual(); } @@ -577,6 +746,7 @@ class LIBPROTOBUF_EXPORT UInt32Value : public ::google::protobuf::Message /* @@p static const ::google::protobuf::Descriptor* descriptor(); static const UInt32Value& default_instance(); + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY static inline const UInt32Value* internal_default_instance() { return reinterpret_cast<const UInt32Value*>( &_UInt32Value_default_instance_); @@ -586,12 +756,19 @@ class LIBPROTOBUF_EXPORT UInt32Value : public ::google::protobuf::Message /* @@p void UnsafeArenaSwap(UInt32Value* other); void Swap(UInt32Value* other); + friend void swap(UInt32Value& a, UInt32Value& b) { + a.Swap(&b); + } // implements Message ---------------------------------------------- - inline UInt32Value* New() const PROTOBUF_FINAL { return New(NULL); } + inline UInt32Value* New() const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<UInt32Value>(NULL); + } - UInt32Value* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + UInt32Value* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<UInt32Value>(arena); + } void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const UInt32Value& from); @@ -642,12 +819,13 @@ class LIBPROTOBUF_EXPORT UInt32Value : public ::google::protobuf::Message /* @@p private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - friend class ::google::protobuf::Arena; + template <typename T> friend class ::google::protobuf::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; ::google::protobuf::uint32 value_; mutable int _cached_size_; - friend struct protobuf_google_2fprotobuf_2fwrappers_2eproto::TableStruct; + friend struct ::protobuf_google_2fprotobuf_2fwrappers_2eproto::TableStruct; + friend void ::protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaultsUInt32ValueImpl(); }; // ------------------------------------------------------------------- @@ -662,7 +840,21 @@ class LIBPROTOBUF_EXPORT BoolValue : public ::google::protobuf::Message /* @@pro CopyFrom(from); return *this; } + #if LANG_CXX11 + BoolValue(BoolValue&& from) noexcept + : BoolValue() { + *this = ::std::move(from); + } + inline BoolValue& operator=(BoolValue&& from) noexcept { + if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + #endif inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { return GetArenaNoVirtual(); } @@ -672,6 +864,7 @@ class LIBPROTOBUF_EXPORT BoolValue : public ::google::protobuf::Message /* @@pro static const ::google::protobuf::Descriptor* descriptor(); static const BoolValue& default_instance(); + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY static inline const BoolValue* internal_default_instance() { return reinterpret_cast<const BoolValue*>( &_BoolValue_default_instance_); @@ -681,12 +874,19 @@ class LIBPROTOBUF_EXPORT BoolValue : public ::google::protobuf::Message /* @@pro void UnsafeArenaSwap(BoolValue* other); void Swap(BoolValue* other); + friend void swap(BoolValue& a, BoolValue& b) { + a.Swap(&b); + } // implements Message ---------------------------------------------- - inline BoolValue* New() const PROTOBUF_FINAL { return New(NULL); } + inline BoolValue* New() const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<BoolValue>(NULL); + } - BoolValue* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + BoolValue* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<BoolValue>(arena); + } void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const BoolValue& from); @@ -737,12 +937,13 @@ class LIBPROTOBUF_EXPORT BoolValue : public ::google::protobuf::Message /* @@pro private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - friend class ::google::protobuf::Arena; + template <typename T> friend class ::google::protobuf::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; bool value_; mutable int _cached_size_; - friend struct protobuf_google_2fprotobuf_2fwrappers_2eproto::TableStruct; + friend struct ::protobuf_google_2fprotobuf_2fwrappers_2eproto::TableStruct; + friend void ::protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaultsBoolValueImpl(); }; // ------------------------------------------------------------------- @@ -757,7 +958,21 @@ class LIBPROTOBUF_EXPORT StringValue : public ::google::protobuf::Message /* @@p CopyFrom(from); return *this; } + #if LANG_CXX11 + StringValue(StringValue&& from) noexcept + : StringValue() { + *this = ::std::move(from); + } + inline StringValue& operator=(StringValue&& from) noexcept { + if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + #endif inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { return GetArenaNoVirtual(); } @@ -767,6 +982,7 @@ class LIBPROTOBUF_EXPORT StringValue : public ::google::protobuf::Message /* @@p static const ::google::protobuf::Descriptor* descriptor(); static const StringValue& default_instance(); + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY static inline const StringValue* internal_default_instance() { return reinterpret_cast<const StringValue*>( &_StringValue_default_instance_); @@ -776,12 +992,19 @@ class LIBPROTOBUF_EXPORT StringValue : public ::google::protobuf::Message /* @@p void UnsafeArenaSwap(StringValue* other); void Swap(StringValue* other); + friend void swap(StringValue& a, StringValue& b) { + a.Swap(&b); + } // implements Message ---------------------------------------------- - inline StringValue* New() const PROTOBUF_FINAL { return New(NULL); } + inline StringValue* New() const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<StringValue>(NULL); + } - StringValue* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + StringValue* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<StringValue>(arena); + } void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const StringValue& from); @@ -827,12 +1050,21 @@ class LIBPROTOBUF_EXPORT StringValue : public ::google::protobuf::Message /* @@p static const int kValueFieldNumber = 1; const ::std::string& value() const; void set_value(const ::std::string& value); + #if LANG_CXX11 + void set_value(::std::string&& value); + #endif void set_value(const char* value); void set_value(const char* value, size_t size); ::std::string* mutable_value(); ::std::string* release_value(); void set_allocated_value(::std::string* value); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") ::std::string* unsafe_arena_release_value(); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") void unsafe_arena_set_allocated_value( ::std::string* value); @@ -840,12 +1072,13 @@ class LIBPROTOBUF_EXPORT StringValue : public ::google::protobuf::Message /* @@p private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - friend class ::google::protobuf::Arena; + template <typename T> friend class ::google::protobuf::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; ::google::protobuf::internal::ArenaStringPtr value_; mutable int _cached_size_; - friend struct protobuf_google_2fprotobuf_2fwrappers_2eproto::TableStruct; + friend struct ::protobuf_google_2fprotobuf_2fwrappers_2eproto::TableStruct; + friend void ::protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaultsStringValueImpl(); }; // ------------------------------------------------------------------- @@ -860,7 +1093,21 @@ class LIBPROTOBUF_EXPORT BytesValue : public ::google::protobuf::Message /* @@pr CopyFrom(from); return *this; } + #if LANG_CXX11 + BytesValue(BytesValue&& from) noexcept + : BytesValue() { + *this = ::std::move(from); + } + inline BytesValue& operator=(BytesValue&& from) noexcept { + if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + #endif inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { return GetArenaNoVirtual(); } @@ -870,6 +1117,7 @@ class LIBPROTOBUF_EXPORT BytesValue : public ::google::protobuf::Message /* @@pr static const ::google::protobuf::Descriptor* descriptor(); static const BytesValue& default_instance(); + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY static inline const BytesValue* internal_default_instance() { return reinterpret_cast<const BytesValue*>( &_BytesValue_default_instance_); @@ -879,12 +1127,19 @@ class LIBPROTOBUF_EXPORT BytesValue : public ::google::protobuf::Message /* @@pr void UnsafeArenaSwap(BytesValue* other); void Swap(BytesValue* other); + friend void swap(BytesValue& a, BytesValue& b) { + a.Swap(&b); + } // implements Message ---------------------------------------------- - inline BytesValue* New() const PROTOBUF_FINAL { return New(NULL); } + inline BytesValue* New() const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<BytesValue>(NULL); + } - BytesValue* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + BytesValue* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL { + return ::google::protobuf::Arena::CreateMessage<BytesValue>(arena); + } void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const BytesValue& from); @@ -930,12 +1185,21 @@ class LIBPROTOBUF_EXPORT BytesValue : public ::google::protobuf::Message /* @@pr static const int kValueFieldNumber = 1; const ::std::string& value() const; void set_value(const ::std::string& value); + #if LANG_CXX11 + void set_value(::std::string&& value); + #endif void set_value(const char* value); void set_value(const void* value, size_t size); ::std::string* mutable_value(); ::std::string* release_value(); void set_allocated_value(::std::string* value); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") ::std::string* unsafe_arena_release_value(); + PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") void unsafe_arena_set_allocated_value( ::std::string* value); @@ -943,19 +1207,23 @@ class LIBPROTOBUF_EXPORT BytesValue : public ::google::protobuf::Message /* @@pr private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - friend class ::google::protobuf::Arena; + template <typename T> friend class ::google::protobuf::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; ::google::protobuf::internal::ArenaStringPtr value_; mutable int _cached_size_; - friend struct protobuf_google_2fprotobuf_2fwrappers_2eproto::TableStruct; + friend struct ::protobuf_google_2fprotobuf_2fwrappers_2eproto::TableStruct; + friend void ::protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaultsBytesValueImpl(); }; // =================================================================== // =================================================================== -#if !PROTOBUF_INLINE_NOT_IN_HEADERS +#ifdef __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif // __GNUC__ // DoubleValue // double value = 1; @@ -1097,6 +1365,14 @@ inline void StringValue::set_value(const ::std::string& value) { value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.StringValue.value) } +#if LANG_CXX11 +inline void StringValue::set_value(::std::string&& value) { + + value_.Set( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.StringValue.value) +} +#endif inline void StringValue::set_value(const char* value) { GOOGLE_DCHECK(value != NULL); @@ -1121,13 +1397,6 @@ inline ::std::string* StringValue::release_value() { return value_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } -inline ::std::string* StringValue::unsafe_arena_release_value() { - // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.StringValue.value) - GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); - - return value_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); -} inline void StringValue::set_allocated_value(::std::string* value) { if (value != NULL) { @@ -1138,6 +1407,13 @@ inline void StringValue::set_allocated_value(::std::string* value) { GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.StringValue.value) } +inline ::std::string* StringValue::unsafe_arena_release_value() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.StringValue.value) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + + return value_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); +} inline void StringValue::unsafe_arena_set_allocated_value( ::std::string* value) { GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); @@ -1168,6 +1444,14 @@ inline void BytesValue::set_value(const ::std::string& value) { value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.BytesValue.value) } +#if LANG_CXX11 +inline void BytesValue::set_value(::std::string&& value) { + + value_.Set( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual()); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.BytesValue.value) +} +#endif inline void BytesValue::set_value(const char* value) { GOOGLE_DCHECK(value != NULL); @@ -1192,13 +1476,6 @@ inline ::std::string* BytesValue::release_value() { return value_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } -inline ::std::string* BytesValue::unsafe_arena_release_value() { - // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.BytesValue.value) - GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); - - return value_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - GetArenaNoVirtual()); -} inline void BytesValue::set_allocated_value(::std::string* value) { if (value != NULL) { @@ -1209,6 +1486,13 @@ inline void BytesValue::set_allocated_value(::std::string* value) { GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.BytesValue.value) } +inline ::std::string* BytesValue::unsafe_arena_release_value() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.BytesValue.value) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + + return value_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); +} inline void BytesValue::unsafe_arena_set_allocated_value( ::std::string* value) { GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); @@ -1222,7 +1506,9 @@ inline void BytesValue::unsafe_arena_set_allocated_value( // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.BytesValue.value) } -#endif // !PROTOBUF_INLINE_NOT_IN_HEADERS +#ifdef __GNUC__ + #pragma GCC diagnostic pop +#endif // __GNUC__ // ------------------------------------------------------------------- // ------------------------------------------------------------------- @@ -1242,10 +1528,9 @@ inline void BytesValue::unsafe_arena_set_allocated_value( // @@protoc_insertion_point(namespace_scope) - } // namespace protobuf } // namespace google // @@protoc_insertion_point(global_scope) -#endif // PROTOBUF_google_2fprotobuf_2fwrappers_2eproto__INCLUDED +#endif // PROTOBUF_google_2fprotobuf_2fwrappers_2eproto_INCLUDED |