diff options
Diffstat (limited to 'src')
45 files changed, 1085 insertions, 317 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index ab9eb31b..8c25a10a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -783,6 +783,7 @@ protobuf_test_SOURCES = \ google/protobuf/compiler/objectivec/objectivec_helpers_unittest.cc \ google/protobuf/compiler/python/python_plugin_unittest.cc \ google/protobuf/compiler/ruby/ruby_generator_unittest.cc \ + google/protobuf/compiler/csharp/csharp_bootstrap_unittest.cc \ google/protobuf/compiler/csharp/csharp_generator_unittest.cc \ google/protobuf/util/field_comparator_test.cc \ google/protobuf/util/field_mask_util_test.cc \ diff --git a/src/google/protobuf/any.pb.cc b/src/google/protobuf/any.pb.cc index 1c30c62d..94c9539f 100644 --- a/src/google/protobuf/any.pb.cc +++ b/src/google/protobuf/any.pb.cc @@ -220,7 +220,8 @@ bool Any::MergePartialFromCodedStream( switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // string type_url = 1; case 1: { - if (tag == 10u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(10u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_type_url())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -235,7 +236,8 @@ bool Any::MergePartialFromCodedStream( // bytes value = 2; case 2: { - if (tag == 18u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(18u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadBytes( input, this->mutable_value())); } else { diff --git a/src/google/protobuf/api.pb.cc b/src/google/protobuf/api.pb.cc index 24275722..6518e518 100644 --- a/src/google/protobuf/api.pb.cc +++ b/src/google/protobuf/api.pb.cc @@ -288,7 +288,8 @@ bool Api::MergePartialFromCodedStream( switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // string name = 1; case 1: { - if (tag == 10u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(10u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -303,7 +304,8 @@ bool Api::MergePartialFromCodedStream( // repeated .google.protobuf.Method methods = 2; case 2: { - if (tag == 18u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(18u)) { DO_(input->IncrementRecursionDepth()); DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_methods())); @@ -316,7 +318,8 @@ bool Api::MergePartialFromCodedStream( // repeated .google.protobuf.Option options = 3; case 3: { - if (tag == 26u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(26u)) { DO_(input->IncrementRecursionDepth()); DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_options())); @@ -329,7 +332,8 @@ bool Api::MergePartialFromCodedStream( // string version = 4; case 4: { - if (tag == 34u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(34u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_version())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -344,7 +348,8 @@ bool Api::MergePartialFromCodedStream( // .google.protobuf.SourceContext source_context = 5; case 5: { - if (tag == 42u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(42u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_source_context())); } else { @@ -355,7 +360,8 @@ bool Api::MergePartialFromCodedStream( // repeated .google.protobuf.Mixin mixins = 6; case 6: { - if (tag == 50u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(50u)) { DO_(input->IncrementRecursionDepth()); DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_mixins())); @@ -368,7 +374,8 @@ bool Api::MergePartialFromCodedStream( // .google.protobuf.Syntax syntax = 7; case 7: { - if (tag == 56u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(56u)) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -1029,7 +1036,8 @@ bool Method::MergePartialFromCodedStream( switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // string name = 1; case 1: { - if (tag == 10u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(10u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -1044,7 +1052,8 @@ bool Method::MergePartialFromCodedStream( // string request_type_url = 2; case 2: { - if (tag == 18u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(18u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_request_type_url())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -1059,7 +1068,8 @@ bool Method::MergePartialFromCodedStream( // bool request_streaming = 3; case 3: { - if (tag == 24u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(24u)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -1072,7 +1082,8 @@ bool Method::MergePartialFromCodedStream( // string response_type_url = 4; case 4: { - if (tag == 34u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(34u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_response_type_url())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -1087,7 +1098,8 @@ bool Method::MergePartialFromCodedStream( // bool response_streaming = 5; case 5: { - if (tag == 40u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(40u)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -1100,7 +1112,8 @@ bool Method::MergePartialFromCodedStream( // repeated .google.protobuf.Option options = 6; case 6: { - if (tag == 50u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(50u)) { DO_(input->IncrementRecursionDepth()); DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_options())); @@ -1113,7 +1126,8 @@ bool Method::MergePartialFromCodedStream( // .google.protobuf.Syntax syntax = 7; case 7: { - if (tag == 56u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(56u)) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -1729,7 +1743,8 @@ bool Mixin::MergePartialFromCodedStream( switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // string name = 1; case 1: { - if (tag == 10u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(10u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -1744,7 +1759,8 @@ bool Mixin::MergePartialFromCodedStream( // string root = 2; case 2: { - if (tag == 18u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(18u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_root())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( diff --git a/src/google/protobuf/arena.h b/src/google/protobuf/arena.h index 879fd0d3..05e05ebc 100644 --- a/src/google/protobuf/arena.h +++ b/src/google/protobuf/arena.h @@ -322,6 +322,17 @@ class LIBPROTOBUF_EXPORT Arena { arg); } } +#if LANG_CXX11 + template <typename T, typename Arg> GOOGLE_ATTRIBUTE_ALWAYS_INLINE + static T* Create(::google::protobuf::Arena* arena, Arg&& arg) { + if (arena == NULL) { + return new T(std::move(arg)); + } else { + return arena->CreateInternal<T>(google::protobuf::internal::has_trivial_destructor<T>::value, + std::move(arg)); + } + } +#endif // Version of the above with two constructor arguments for the created object. template <typename T, typename Arg1, typename Arg2> GOOGLE_ATTRIBUTE_ALWAYS_INLINE @@ -662,6 +673,18 @@ class LIBPROTOBUF_EXPORT Arena { return t; } +#if LANG_CXX11 + template <typename T, typename Arg> GOOGLE_ATTRIBUTE_ALWAYS_INLINE + T* CreateInternal(bool skip_explicit_ownership, Arg&& arg) { + T* t = new (AllocateAligned(RTTI_TYPE_ID(T), sizeof(T))) T( + std::move(arg)); + if (!skip_explicit_ownership) { + AddListNode(t, &internal::arena_destruct_object<T>); + } + return t; + } +#endif + template <typename T, typename Arg1, typename Arg2> GOOGLE_ATTRIBUTE_ALWAYS_INLINE T* CreateInternal( bool skip_explicit_ownership, const Arg1& arg1, const Arg2& arg2) { diff --git a/src/google/protobuf/compiler/command_line_interface.cc b/src/google/protobuf/compiler/command_line_interface.cc index 725ac823..1914fc48 100644 --- a/src/google/protobuf/compiler/command_line_interface.cc +++ b/src/google/protobuf/compiler/command_line_interface.cc @@ -1031,16 +1031,34 @@ CommandLineInterface::ParseArguments(int argc, const char* const argv[]) { } // Make sure each plugin option has a matching plugin output. + bool foundUnknownPluginOption = false; for (map<string, string>::const_iterator i = plugin_parameters_.begin(); i != plugin_parameters_.end(); ++i) { - if (plugins_.find(i->first) == plugins_.end()) { + if (plugins_.find(i->first) != plugins_.end()) { + continue; + } + bool foundImplicitPlugin = false; + for (std::vector<OutputDirective>::const_iterator j = output_directives_.begin(); + j != output_directives_.end(); ++j) { + if (j->generator == NULL) { + string plugin_name = PluginName(plugin_prefix_ , j->name); + if (plugin_name == i->first) { + foundImplicitPlugin = true; + break; + } + } + } + if (!foundImplicitPlugin) { std::cerr << "Unknown flag: " // strip prefix + "gen-" and add back "_opt" << "--" + i->first.substr(plugin_prefix_.size() + 4) + "_opt" << std::endl; - return PARSE_ARGUMENT_FAIL; + foundUnknownPluginOption = true; } } + if (foundUnknownPluginOption) { + return PARSE_ARGUMENT_FAIL; + } // If no --proto_path was given, use the current working directory. if (proto_path_.empty()) { diff --git a/src/google/protobuf/compiler/command_line_interface_unittest.cc b/src/google/protobuf/compiler/command_line_interface_unittest.cc index e43d287f..cce1018a 100644 --- a/src/google/protobuf/compiler/command_line_interface_unittest.cc +++ b/src/google/protobuf/compiler/command_line_interface_unittest.cc @@ -689,10 +689,36 @@ TEST_F(CommandLineInterfaceTest, UnrecognizedExtraParameters) { "message Foo {}\n"); Run("protocol_compiler --plug_out=TestParameter:$tmpdir " + "--unknown_plug_a_opt=Foo " + "--unknown_plug_b_opt=Bar " + "--proto_path=$tmpdir foo.proto"); + + ExpectErrorSubstring("Unknown flag: --unknown_plug_a_opt"); + ExpectErrorSubstring("Unknown flag: --unknown_plug_b_opt"); +} + +TEST_F(CommandLineInterfaceTest, ExtraPluginParametersForOutParameters) { + // This doesn't rely on the plugin having been registred and instead that + // the existence of --[name]_out is enough to make the --[name]_opt valid. + // However, running out of process plugins found via the search path (i.e. - + // not pre registered with --plugin) isn't support in this test suite, so we + // list the options pre/post the _out directive, and then include _opt that + // will be unknown, and confirm the failure output is about the expected + // unknown directive, which means the other were accepted. + // NOTE: UnrecognizedExtraParameters confirms that if two unknown _opt + // directives appear, they both are reported. + + CreateTempFile("foo.proto", + "syntax = \"proto2\";\n" + "message Foo {}\n"); + + Run("protocol_compiler --plug_out=TestParameter:$tmpdir " + "--xyz_opt=foo=bar --xyz_out=$tmpdir " + "--abc_out=$tmpdir --abc_opt=foo=bar " "--unknown_plug_opt=Foo " "--proto_path=$tmpdir foo.proto"); - ExpectErrorSubstring("Unknown flag: --unknown_plug_opt"); + ExpectErrorText("Unknown flag: --unknown_plug_opt\n"); } TEST_F(CommandLineInterfaceTest, Insert) { diff --git a/src/google/protobuf/compiler/cpp/cpp_enum_field.cc b/src/google/protobuf/compiler/cpp/cpp_enum_field.cc index 44a86fc8..e4b17a98 100644 --- a/src/google/protobuf/compiler/cpp/cpp_enum_field.cc +++ b/src/google/protobuf/compiler/cpp/cpp_enum_field.cc @@ -436,7 +436,7 @@ GenerateSerializeWithCachedSizes(io::Printer* printer) const { "}\n"); } printer->Print(variables_, - "for (int i = 0; i < this->$name$_size(); i++) {\n"); + "for (int i = 0, n = this->$name$_size(); i < n; i++) {\n"); if (descriptor_->is_packed()) { printer->Print(variables_, " ::google::protobuf::internal::WireFormatLite::WriteEnumNoTag(\n" @@ -464,7 +464,7 @@ GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const { "}\n"); } printer->Print(variables_, - "for (int i = 0; i < this->$name$_size(); i++) {\n"); + "for (int i = 0, n = this->$name$_size(); i < n; i++) {\n"); if (descriptor_->is_packed()) { printer->Print(variables_, " target = ::google::protobuf::internal::WireFormatLite::WriteEnumNoTagToArray(\n" diff --git a/src/google/protobuf/compiler/cpp/cpp_message.cc b/src/google/protobuf/compiler/cpp/cpp_message.cc index 32f05f25..6274ba29 100644 --- a/src/google/protobuf/compiler/cpp/cpp_message.cc +++ b/src/google/protobuf/compiler/cpp/cpp_message.cc @@ -3028,7 +3028,8 @@ GenerateMergeFromCodedStream(io::Printer* printer) { const FieldGenerator& field_generator = field_generators_.get(field); // Emit code to parse the common, expected case. - printer->Print("if (tag == $commontag$u) {\n", + printer->Print("if (static_cast< ::google::protobuf::uint8>(tag) ==\n" + " static_cast< ::google::protobuf::uint8>($commontag$u)) {\n", "commontag", SimpleItoa(WireFormat::MakeTag(field))); if (loops) { @@ -3047,7 +3048,8 @@ GenerateMergeFromCodedStream(io::Printer* printer) { if (field->is_packed()) { internal::WireFormatLite::WireType wiretype = WireFormat::WireTypeForFieldType(field->type()); - printer->Print("} else if (tag == $uncommontag$u) {\n", + printer->Print("} else if (static_cast< ::google::protobuf::uint8>(tag) ==\n" + " static_cast< ::google::protobuf::uint8>($uncommontag$u)) {\n", "uncommontag", SimpleItoa( internal::WireFormatLite::MakeTag( field->number(), wiretype))); @@ -3057,7 +3059,8 @@ GenerateMergeFromCodedStream(io::Printer* printer) { } else if (field->is_packable() && !field->is_packed()) { internal::WireFormatLite::WireType wiretype = internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED; - printer->Print("} else if (tag == $uncommontag$u) {\n", + printer->Print("} else if (static_cast< ::google::protobuf::uint8>(tag) ==\n" + " static_cast< ::google::protobuf::uint8>($uncommontag$u)) {\n", "uncommontag", SimpleItoa( internal::WireFormatLite::MakeTag( field->number(), wiretype))); diff --git a/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc b/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc index a68891a3..4a0a23f6 100644 --- a/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc +++ b/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc @@ -394,7 +394,7 @@ GenerateSerializeWithCachedSizes(io::Printer* printer) const { } if (!array_written) { printer->Print(variables_, - "for (int i = 0; i < this->$name$_size(); i++) {\n"); + "for (int i = 0, n = this->$name$_size(); i < n; i++) {\n"); if (descriptor_->is_packed()) { printer->Print(variables_, " ::google::protobuf::internal::WireFormatLite::Write$declared_type$NoTag(\n" @@ -423,7 +423,7 @@ GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const { "}\n"); } printer->Print(variables_, - "for (int i = 0; i < this->$name$_size(); i++) {\n"); + "for (int i = 0, n = this->$name$_size(); i < n; i++) {\n"); if (descriptor_->is_packed()) { printer->Print(variables_, " target = ::google::protobuf::internal::WireFormatLite::\n" diff --git a/src/google/protobuf/compiler/cpp/cpp_string_field.cc b/src/google/protobuf/compiler/cpp/cpp_string_field.cc index 359e5e26..664a2779 100644 --- a/src/google/protobuf/compiler/cpp/cpp_string_field.cc +++ b/src/google/protobuf/compiler/cpp/cpp_string_field.cc @@ -830,12 +830,18 @@ GenerateAccessorDeclarations(io::Printer* printer) const { "$deprecated_attr$const ::std::string& $name$(int index) const;\n" "$deprecated_attr$::std::string* mutable_$name$(int index);\n" "$deprecated_attr$void set_$name$(int index, const ::std::string& value);\n" + "#if LANG_CXX11\n" + "$deprecated_attr$void set_$name$(int index, ::std::string&& value);\n" + "#endif\n" "$deprecated_attr$void set_$name$(int index, const char* value);\n" "" "$deprecated_attr$void set_$name$(" "int index, const $pointer_type$* value, size_t size);\n" "$deprecated_attr$::std::string* add_$name$();\n" "$deprecated_attr$void add_$name$(const ::std::string& value);\n" + "#if LANG_CXX11\n" + "$deprecated_attr$void add_$name$(::std::string&& value);\n" + "#endif\n" "$deprecated_attr$void add_$name$(const char* value);\n" "$deprecated_attr$void add_$name$(const $pointer_type$* value, size_t size)" ";\n" @@ -869,6 +875,12 @@ GenerateInlineAccessorDefinitions(io::Printer* printer, " // @@protoc_insertion_point(field_set:$full_name$)\n" " $name$_.Mutable(index)->assign(value);\n" "}\n" + "#if LANG_CXX11\n" + "$inline$void $classname$::set_$name$(int index, ::std::string&& value) {\n" + " // @@protoc_insertion_point(field_set:$full_name$)\n" + " $name$_.Mutable(index)->assign(std::move(value));\n" + "}\n" + "#endif\n" "$inline$void $classname$::set_$name$(int index, const char* value) {\n" " $name$_.Mutable(index)->assign(value);\n" " // @@protoc_insertion_point(field_set_char:$full_name$)\n" @@ -888,6 +900,12 @@ GenerateInlineAccessorDefinitions(io::Printer* printer, " $name$_.Add()->assign(value);\n" " // @@protoc_insertion_point(field_add:$full_name$)\n" "}\n" + "#if LANG_CXX11\n" + "$inline$void $classname$::add_$name$(::std::string&& value) {\n" + " $name$_.Add()->assign(std::move(value));\n" + " // @@protoc_insertion_point(field_add:$full_name$)\n" + "}\n" + "#endif\n" "$inline$void $classname$::add_$name$(const char* value) {\n" " $name$_.Add()->assign(value);\n" " // @@protoc_insertion_point(field_add_char:$full_name$)\n" @@ -951,7 +969,7 @@ GenerateMergeFromCodedStream(io::Printer* printer) const { void RepeatedStringFieldGenerator:: GenerateSerializeWithCachedSizes(io::Printer* printer) const { printer->Print(variables_, - "for (int i = 0; i < this->$name$_size(); i++) {\n"); + "for (int i = 0, n = this->$name$_size(); i < n; i++) {\n"); printer->Indent(); if (descriptor_->type() == FieldDescriptor::TYPE_STRING) { GenerateUtf8CheckCodeForString( @@ -968,7 +986,7 @@ GenerateSerializeWithCachedSizes(io::Printer* printer) const { void RepeatedStringFieldGenerator:: GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const { printer->Print(variables_, - "for (int i = 0; i < this->$name$_size(); i++) {\n"); + "for (int i = 0, n = this->$name$_size(); i < n; i++) {\n"); printer->Indent(); if (descriptor_->type() == FieldDescriptor::TYPE_STRING) { GenerateUtf8CheckCodeForString( @@ -987,7 +1005,7 @@ GenerateByteSize(io::Printer* printer) const { printer->Print(variables_, "total_size += $tag_size$ *\n" " ::google::protobuf::internal::FromIntSize(this->$name$_size());\n" - "for (int i = 0; i < this->$name$_size(); i++) {\n" + "for (int i = 0, n = this->$name$_size(); i < n; i++) {\n" " total_size += ::google::protobuf::internal::WireFormatLite::$declared_type$Size(\n" " this->$name$(i));\n" "}\n"); diff --git a/src/google/protobuf/compiler/cpp/cpp_unittest.cc b/src/google/protobuf/compiler/cpp/cpp_unittest.cc index 686c70a9..6d68ec35 100644 --- a/src/google/protobuf/compiler/cpp/cpp_unittest.cc +++ b/src/google/protobuf/compiler/cpp/cpp_unittest.cc @@ -463,6 +463,26 @@ TEST(GeneratedMessageTest, StringMove) { EXPECT_EQ(old_data, new_data); EXPECT_EQ(string(32, 'b'), message.oneof_string()); } + + // Verify that we trigger the move behavior on a repeated setter. + { + string tmp(32, 'a'); + + const char* old_data = tmp.data(); + message.add_repeated_string(std::move(tmp)); + const char* new_data = message.repeated_string(0).data(); + + EXPECT_EQ(old_data, new_data); + EXPECT_EQ(string(32, 'a'), message.repeated_string(0)); + + string tmp2(32, 'b'); + old_data = tmp2.data(); + message.set_repeated_string(0, std::move(tmp2)); + new_data = message.repeated_string(0).data(); + + EXPECT_EQ(old_data, new_data); + EXPECT_EQ(string(32, 'b'), message.repeated_string(0)); + } } #endif diff --git a/src/google/protobuf/compiler/csharp/csharp_bootstrap_unittest.cc b/src/google/protobuf/compiler/csharp/csharp_bootstrap_unittest.cc new file mode 100644 index 00000000..c1f90e41 --- /dev/null +++ b/src/google/protobuf/compiler/csharp/csharp_bootstrap_unittest.cc @@ -0,0 +1,142 @@ +// 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 test insures that +// csharp/src/Google.Protobuf/Reflection/Descriptor.cs match exactly +// what would be generated by the protocol compiler. The file is not +// generated automatically at build time. +// +// If this test fails, run the script +// "generate_descriptor_proto.sh" and add +// csharp/src/Google.Protobuf/Reflection/Descriptor.cs to your changelist. + +#include <map> + +#include <google/protobuf/compiler/csharp/csharp_generator.h> +#include <google/protobuf/compiler/importer.h> +#include <google/protobuf/descriptor.h> +#include <google/protobuf/io/zero_copy_stream_impl.h> +#include <google/protobuf/stubs/map_util.h> +#include <google/protobuf/stubs/stl_util.h> +#include <google/protobuf/stubs/strutil.h> +#include <google/protobuf/stubs/substitute.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 csharp { + +namespace { + +class MockErrorCollector : public MultiFileErrorCollector { + public: + MockErrorCollector() {} + ~MockErrorCollector() {} + + string text_; + + // implements ErrorCollector --------------------------------------- + void AddError(const string& filename, int line, int column, + const string& message) { + strings::SubstituteAndAppend(&text_, "$0:$1:$2: $3\n", + filename, line, column, message); + } +}; + +class MockGeneratorContext : public GeneratorContext { + public: + MockGeneratorContext() {} + ~MockGeneratorContext() { + STLDeleteValues(&files_); + } + + void ExpectFileMatches(const string& virtual_filename, + const string& physical_filename) { + string* expected_contents = FindPtrOrNull(files_, virtual_filename); + ASSERT_TRUE(expected_contents != NULL) + << "Generator failed to generate file: " << virtual_filename; + + string actual_contents; + GOOGLE_CHECK_OK( + File::GetContents(TestSourceDir() + "/" + physical_filename, + &actual_contents, true)); + EXPECT_TRUE(actual_contents == *expected_contents) + << physical_filename << " needs to be regenerated. Please run " + "generate_descriptor_proto.sh. Then add this file " + "to your CL."; + } + + // implements GeneratorContext -------------------------------------- + + virtual io::ZeroCopyOutputStream* Open(const string& filename) { + string** map_slot = &files_[filename]; + delete *map_slot; + *map_slot = new string; + + return new io::StringOutputStream(*map_slot); + } + + private: + std::map<string, string*> files_; +}; + +TEST(CsharpBootstrapTest, GeneratedCsharpDescriptorMatches) { + MockErrorCollector error_collector; + DiskSourceTree source_tree; + source_tree.MapPath("", TestSourceDir()); + Importer importer(&source_tree, &error_collector); + const FileDescriptor* proto_file = + importer.Import("google/protobuf/descriptor.proto"); + EXPECT_EQ("", error_collector.text_); + ASSERT_TRUE(proto_file != NULL); + + Generator generator; + MockGeneratorContext context; + string error; + string parameter = "base_namespace=Google.Protobuf"; + ASSERT_TRUE(generator.Generate(proto_file, parameter, + &context, &error)); + + context.ExpectFileMatches( + "Reflection/Descriptor.cs", + "../csharp/src/Google.Protobuf/Reflection/Descriptor.cs"); +} + +} // namespace + +} // namespace csharp +} // namespace compiler +} // namespace protobuf +} // namespace google diff --git a/src/google/protobuf/compiler/csharp/csharp_enum.cc b/src/google/protobuf/compiler/csharp/csharp_enum.cc index 9e4da1ed..9759e3ef 100644 --- a/src/google/protobuf/compiler/csharp/csharp_enum.cc +++ b/src/google/protobuf/compiler/csharp/csharp_enum.cc @@ -65,6 +65,7 @@ void EnumGenerator::Generate(io::Printer* printer) { "name", descriptor_->name()); printer->Indent(); std::set<string> used_names; + std::set<int> used_number; for (int i = 0; i < descriptor_->value_count(); i++) { WriteEnumValueDocComment(printer, descriptor_->value(i)); string original_name = descriptor_->value(i)->name(); @@ -76,10 +77,18 @@ void EnumGenerator::Generate(io::Printer* printer) { << ") in " << descriptor_->name() << "; adding underscore to distinguish"; name += "_"; } - printer->Print("[pbr::OriginalName(\"$original_name$\")] $name$ = $number$,\n", - "original_name", original_name, - "name", name, - "number", SimpleItoa(descriptor_->value(i)->number())); + int number = descriptor_->value(i)->number(); + if (!used_number.insert(number).second) { + printer->Print("[pbr::OriginalName(\"$original_name$\", PreferredAlias = false)] $name$ = $number$,\n", + "original_name", original_name, + "name", name, + "number", SimpleItoa(number)); + } else { + printer->Print("[pbr::OriginalName(\"$original_name$\")] $name$ = $number$,\n", + "original_name", original_name, + "name", name, + "number", SimpleItoa(number)); + } } printer->Outdent(); printer->Print("}\n"); diff --git a/src/google/protobuf/compiler/csharp/csharp_generator.h b/src/google/protobuf/compiler/csharp/csharp_generator.h index fd41d852..c8b19529 100644 --- a/src/google/protobuf/compiler/csharp/csharp_generator.h +++ b/src/google/protobuf/compiler/csharp/csharp_generator.h @@ -48,6 +48,7 @@ namespace csharp { // CodeGenerator with the CommandLineInterface in your main() function. class LIBPROTOC_EXPORT Generator : public google::protobuf::compiler::CodeGenerator { +public: virtual bool Generate( const FileDescriptor* file, const string& parameter, @@ -61,4 +62,3 @@ class LIBPROTOC_EXPORT Generator } // namespace google #endif // GOOGLE_PROTOBUF_COMPILER_CSHARP_GENERATOR_H__ - diff --git a/src/google/protobuf/compiler/java/java_file.cc b/src/google/protobuf/compiler/java/java_file.cc index cb4503f6..86719f70 100644 --- a/src/google/protobuf/compiler/java/java_file.cc +++ b/src/google/protobuf/compiler/java/java_file.cc @@ -65,7 +65,7 @@ namespace java { namespace { struct FieldDescriptorCompare { - bool operator ()(const FieldDescriptor* f1, const FieldDescriptor* f2) { + bool operator ()(const FieldDescriptor* f1, const FieldDescriptor* f2) const { if(f1 == NULL) { return false; } diff --git a/src/google/protobuf/compiler/plugin.pb.cc b/src/google/protobuf/compiler/plugin.pb.cc index ac27c412..4310ff1e 100644 --- a/src/google/protobuf/compiler/plugin.pb.cc +++ b/src/google/protobuf/compiler/plugin.pb.cc @@ -287,7 +287,8 @@ bool Version::MergePartialFromCodedStream( switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional int32 major = 1; case 1: { - if (tag == 8u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(8u)) { set_has_major(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -300,7 +301,8 @@ bool Version::MergePartialFromCodedStream( // optional int32 minor = 2; case 2: { - if (tag == 16u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(16u)) { set_has_minor(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -313,7 +315,8 @@ bool Version::MergePartialFromCodedStream( // optional int32 patch = 3; case 3: { - if (tag == 24u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(24u)) { set_has_patch(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -326,7 +329,8 @@ bool Version::MergePartialFromCodedStream( // optional string suffix = 4; case 4: { - if (tag == 34u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(34u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_suffix())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -800,7 +804,8 @@ bool CodeGeneratorRequest::MergePartialFromCodedStream( switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // repeated string file_to_generate = 1; case 1: { - if (tag == 10u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(10u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->add_file_to_generate())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -816,7 +821,8 @@ bool CodeGeneratorRequest::MergePartialFromCodedStream( // optional string parameter = 2; case 2: { - if (tag == 18u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(18u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_parameter())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -831,7 +837,8 @@ bool CodeGeneratorRequest::MergePartialFromCodedStream( // optional .google.protobuf.compiler.Version compiler_version = 3; case 3: { - if (tag == 26u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(26u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_compiler_version())); } else { @@ -842,7 +849,8 @@ bool CodeGeneratorRequest::MergePartialFromCodedStream( // repeated .google.protobuf.FileDescriptorProto proto_file = 15; case 15: { - if (tag == 122u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(122u)) { DO_(input->IncrementRecursionDepth()); DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_proto_file())); @@ -879,7 +887,7 @@ void CodeGeneratorRequest::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:google.protobuf.compiler.CodeGeneratorRequest) // repeated string file_to_generate = 1; - for (int i = 0; i < this->file_to_generate_size(); i++) { + for (int i = 0, n = this->file_to_generate_size(); i < n; i++) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->file_to_generate(i).data(), this->file_to_generate(i).length(), ::google::protobuf::internal::WireFormat::SERIALIZE, @@ -922,7 +930,7 @@ void CodeGeneratorRequest::SerializeWithCachedSizes( (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.compiler.CodeGeneratorRequest) // repeated string file_to_generate = 1; - for (int i = 0; i < this->file_to_generate_size(); i++) { + for (int i = 0, n = this->file_to_generate_size(); i < n; i++) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->file_to_generate(i).data(), this->file_to_generate(i).length(), ::google::protobuf::internal::WireFormat::SERIALIZE, @@ -976,7 +984,7 @@ size_t CodeGeneratorRequest::ByteSizeLong() const { // repeated string file_to_generate = 1; total_size += 1 * ::google::protobuf::internal::FromIntSize(this->file_to_generate_size()); - for (int i = 0; i < this->file_to_generate_size(); i++) { + for (int i = 0, n = this->file_to_generate_size(); i < n; i++) { total_size += ::google::protobuf::internal::WireFormatLite::StringSize( this->file_to_generate(i)); } @@ -1107,6 +1115,12 @@ void CodeGeneratorRequest::set_file_to_generate(int index, const ::std::string& // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) file_to_generate_.Mutable(index)->assign(value); } +#if LANG_CXX11 +void CodeGeneratorRequest::set_file_to_generate(int index, ::std::string&& value) { + // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) + file_to_generate_.Mutable(index)->assign(std::move(value)); +} +#endif void CodeGeneratorRequest::set_file_to_generate(int index, const char* value) { file_to_generate_.Mutable(index)->assign(value); // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) @@ -1124,6 +1138,12 @@ void CodeGeneratorRequest::add_file_to_generate(const ::std::string& value) { file_to_generate_.Add()->assign(value); // @@protoc_insertion_point(field_add:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) } +#if LANG_CXX11 +void CodeGeneratorRequest::add_file_to_generate(::std::string&& value) { + file_to_generate_.Add()->assign(std::move(value)); + // @@protoc_insertion_point(field_add:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) +} +#endif void CodeGeneratorRequest::add_file_to_generate(const char* value) { file_to_generate_.Add()->assign(value); // @@protoc_insertion_point(field_add_char:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) @@ -1392,7 +1412,8 @@ bool CodeGeneratorResponse_File::MergePartialFromCodedStream( switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional string name = 1; case 1: { - if (tag == 10u) { + 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( @@ -1407,7 +1428,8 @@ bool CodeGeneratorResponse_File::MergePartialFromCodedStream( // optional string insertion_point = 2; case 2: { - if (tag == 18u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(18u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_insertion_point())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -1422,7 +1444,8 @@ bool CodeGeneratorResponse_File::MergePartialFromCodedStream( // optional string content = 15; case 15: { - if (tag == 122u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(122u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_content())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -1932,7 +1955,8 @@ bool CodeGeneratorResponse::MergePartialFromCodedStream( switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional string error = 1; case 1: { - if (tag == 10u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(10u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_error())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -1947,7 +1971,8 @@ bool CodeGeneratorResponse::MergePartialFromCodedStream( // repeated .google.protobuf.compiler.CodeGeneratorResponse.File file = 15; case 15: { - if (tag == 122u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(122u)) { DO_(input->IncrementRecursionDepth()); DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_file())); diff --git a/src/google/protobuf/compiler/plugin.pb.h b/src/google/protobuf/compiler/plugin.pb.h index 8465f0bd..1b91daca 100644 --- a/src/google/protobuf/compiler/plugin.pb.h +++ b/src/google/protobuf/compiler/plugin.pb.h @@ -356,10 +356,16 @@ class LIBPROTOC_EXPORT CodeGeneratorRequest : public ::google::protobuf::Message const ::std::string& file_to_generate(int index) const; ::std::string* mutable_file_to_generate(int index); void set_file_to_generate(int index, const ::std::string& value); + #if LANG_CXX11 + void set_file_to_generate(int index, ::std::string&& value); + #endif void set_file_to_generate(int index, const char* value); void set_file_to_generate(int index, const char* value, size_t size); ::std::string* add_file_to_generate(); void add_file_to_generate(const ::std::string& value); + #if LANG_CXX11 + void add_file_to_generate(::std::string&& value); + #endif void add_file_to_generate(const char* value); void add_file_to_generate(const char* value, size_t size); const ::google::protobuf::RepeatedPtrField< ::std::string>& file_to_generate() const; @@ -839,6 +845,12 @@ inline void CodeGeneratorRequest::set_file_to_generate(int index, const ::std::s // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) file_to_generate_.Mutable(index)->assign(value); } +#if LANG_CXX11 +inline void CodeGeneratorRequest::set_file_to_generate(int index, ::std::string&& value) { + // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) + file_to_generate_.Mutable(index)->assign(std::move(value)); +} +#endif inline void CodeGeneratorRequest::set_file_to_generate(int index, const char* value) { file_to_generate_.Mutable(index)->assign(value); // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) @@ -856,6 +868,12 @@ inline void CodeGeneratorRequest::add_file_to_generate(const ::std::string& valu file_to_generate_.Add()->assign(value); // @@protoc_insertion_point(field_add:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) } +#if LANG_CXX11 +inline void CodeGeneratorRequest::add_file_to_generate(::std::string&& value) { + file_to_generate_.Add()->assign(std::move(value)); + // @@protoc_insertion_point(field_add:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) +} +#endif inline void CodeGeneratorRequest::add_file_to_generate(const char* value) { file_to_generate_.Add()->assign(value); // @@protoc_insertion_point(field_add_char:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) diff --git a/src/google/protobuf/descriptor.pb.cc b/src/google/protobuf/descriptor.pb.cc index 9715fc1b..2a270d65 100644 --- a/src/google/protobuf/descriptor.pb.cc +++ b/src/google/protobuf/descriptor.pb.cc @@ -1004,7 +1004,8 @@ bool FileDescriptorSet::MergePartialFromCodedStream( switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // repeated .google.protobuf.FileDescriptorProto file = 1; case 1: { - if (tag == 10u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(10u)) { DO_(input->IncrementRecursionDepth()); DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_file())); @@ -1350,7 +1351,8 @@ bool FileDescriptorProto::MergePartialFromCodedStream( switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional string name = 1; case 1: { - if (tag == 10u) { + 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( @@ -1365,7 +1367,8 @@ bool FileDescriptorProto::MergePartialFromCodedStream( // optional string package = 2; case 2: { - if (tag == 18u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(18u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_package())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -1380,7 +1383,8 @@ bool FileDescriptorProto::MergePartialFromCodedStream( // repeated string dependency = 3; case 3: { - if (tag == 26u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(26u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->add_dependency())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -1396,7 +1400,8 @@ bool FileDescriptorProto::MergePartialFromCodedStream( // repeated .google.protobuf.DescriptorProto message_type = 4; case 4: { - if (tag == 34u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(34u)) { DO_(input->IncrementRecursionDepth()); DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_message_type())); @@ -1409,7 +1414,8 @@ bool FileDescriptorProto::MergePartialFromCodedStream( // repeated .google.protobuf.EnumDescriptorProto enum_type = 5; case 5: { - if (tag == 42u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(42u)) { DO_(input->IncrementRecursionDepth()); DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_enum_type())); @@ -1422,7 +1428,8 @@ bool FileDescriptorProto::MergePartialFromCodedStream( // repeated .google.protobuf.ServiceDescriptorProto service = 6; case 6: { - if (tag == 50u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(50u)) { DO_(input->IncrementRecursionDepth()); DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_service())); @@ -1435,7 +1442,8 @@ bool FileDescriptorProto::MergePartialFromCodedStream( // repeated .google.protobuf.FieldDescriptorProto extension = 7; case 7: { - if (tag == 58u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(58u)) { DO_(input->IncrementRecursionDepth()); DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_extension())); @@ -1448,7 +1456,8 @@ bool FileDescriptorProto::MergePartialFromCodedStream( // optional .google.protobuf.FileOptions options = 8; case 8: { - if (tag == 66u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(66u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_options())); } else { @@ -1459,7 +1468,8 @@ bool FileDescriptorProto::MergePartialFromCodedStream( // optional .google.protobuf.SourceCodeInfo source_code_info = 9; case 9: { - if (tag == 74u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(74u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_source_code_info())); } else { @@ -1470,11 +1480,13 @@ bool FileDescriptorProto::MergePartialFromCodedStream( // repeated int32 public_dependency = 10; case 10: { - if (tag == 80u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(80u)) { DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( 1, 80u, input, this->mutable_public_dependency()))); - } else if (tag == 82u) { + } else if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(82u)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, this->mutable_public_dependency()))); @@ -1486,11 +1498,13 @@ bool FileDescriptorProto::MergePartialFromCodedStream( // repeated int32 weak_dependency = 11; case 11: { - if (tag == 88u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(88u)) { DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( 1, 88u, input, this->mutable_weak_dependency()))); - } else if (tag == 90u) { + } else if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(90u)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, this->mutable_weak_dependency()))); @@ -1502,7 +1516,8 @@ bool FileDescriptorProto::MergePartialFromCodedStream( // optional string syntax = 12; case 12: { - if (tag == 98u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(98u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_syntax())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -1561,7 +1576,7 @@ void FileDescriptorProto::SerializeWithCachedSizes( } // repeated string dependency = 3; - for (int i = 0; i < this->dependency_size(); i++) { + for (int i = 0, n = this->dependency_size(); i < n; i++) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->dependency(i).data(), this->dependency(i).length(), ::google::protobuf::internal::WireFormat::SERIALIZE, @@ -1607,13 +1622,13 @@ void FileDescriptorProto::SerializeWithCachedSizes( } // repeated int32 public_dependency = 10; - for (int i = 0; i < this->public_dependency_size(); i++) { + for (int i = 0, n = this->public_dependency_size(); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteInt32( 10, this->public_dependency(i), output); } // repeated int32 weak_dependency = 11; - for (int i = 0; i < this->weak_dependency_size(); i++) { + for (int i = 0, n = this->weak_dependency_size(); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteInt32( 11, this->weak_dependency(i), output); } @@ -1662,7 +1677,7 @@ void FileDescriptorProto::SerializeWithCachedSizes( } // repeated string dependency = 3; - for (int i = 0; i < this->dependency_size(); i++) { + for (int i = 0, n = this->dependency_size(); i < n; i++) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->dependency(i).data(), this->dependency(i).length(), ::google::protobuf::internal::WireFormat::SERIALIZE, @@ -1714,13 +1729,13 @@ void FileDescriptorProto::SerializeWithCachedSizes( } // repeated int32 public_dependency = 10; - for (int i = 0; i < this->public_dependency_size(); i++) { + for (int i = 0, n = this->public_dependency_size(); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: WriteInt32ToArray(10, this->public_dependency(i), target); } // repeated int32 weak_dependency = 11; - for (int i = 0; i < this->weak_dependency_size(); i++) { + for (int i = 0, n = this->weak_dependency_size(); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: WriteInt32ToArray(11, this->weak_dependency(i), target); } @@ -1756,7 +1771,7 @@ size_t FileDescriptorProto::ByteSizeLong() const { // repeated string dependency = 3; total_size += 1 * ::google::protobuf::internal::FromIntSize(this->dependency_size()); - for (int i = 0; i < this->dependency_size(); i++) { + for (int i = 0, n = this->dependency_size(); i < n; i++) { total_size += ::google::protobuf::internal::WireFormatLite::StringSize( this->dependency(i)); } @@ -2113,6 +2128,12 @@ void FileDescriptorProto::set_dependency(int index, const ::std::string& value) // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.dependency) dependency_.Mutable(index)->assign(value); } +#if LANG_CXX11 +void FileDescriptorProto::set_dependency(int index, ::std::string&& value) { + // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.dependency) + dependency_.Mutable(index)->assign(std::move(value)); +} +#endif void FileDescriptorProto::set_dependency(int index, const char* value) { dependency_.Mutable(index)->assign(value); // @@protoc_insertion_point(field_set_char:google.protobuf.FileDescriptorProto.dependency) @@ -2130,6 +2151,12 @@ void FileDescriptorProto::add_dependency(const ::std::string& value) { dependency_.Add()->assign(value); // @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.dependency) } +#if LANG_CXX11 +void FileDescriptorProto::add_dependency(::std::string&& value) { + dependency_.Add()->assign(std::move(value)); + // @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.dependency) +} +#endif void FileDescriptorProto::add_dependency(const char* value) { dependency_.Add()->assign(value); // @@protoc_insertion_point(field_add_char:google.protobuf.FileDescriptorProto.dependency) @@ -2569,7 +2596,8 @@ bool DescriptorProto_ExtensionRange::MergePartialFromCodedStream( switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional int32 start = 1; case 1: { - if (tag == 8u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(8u)) { set_has_start(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -2582,7 +2610,8 @@ bool DescriptorProto_ExtensionRange::MergePartialFromCodedStream( // optional int32 end = 2; case 2: { - if (tag == 16u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(16u)) { set_has_end(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -2892,7 +2921,8 @@ bool DescriptorProto_ReservedRange::MergePartialFromCodedStream( switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional int32 start = 1; case 1: { - if (tag == 8u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(8u)) { set_has_start(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -2905,7 +2935,8 @@ bool DescriptorProto_ReservedRange::MergePartialFromCodedStream( // optional int32 end = 2; case 2: { - if (tag == 16u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(16u)) { set_has_end(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -3255,7 +3286,8 @@ bool DescriptorProto::MergePartialFromCodedStream( switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional string name = 1; case 1: { - if (tag == 10u) { + 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( @@ -3270,7 +3302,8 @@ bool DescriptorProto::MergePartialFromCodedStream( // repeated .google.protobuf.FieldDescriptorProto field = 2; case 2: { - if (tag == 18u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(18u)) { DO_(input->IncrementRecursionDepth()); DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_field())); @@ -3283,7 +3316,8 @@ bool DescriptorProto::MergePartialFromCodedStream( // repeated .google.protobuf.DescriptorProto nested_type = 3; case 3: { - if (tag == 26u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(26u)) { DO_(input->IncrementRecursionDepth()); DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_nested_type())); @@ -3296,7 +3330,8 @@ bool DescriptorProto::MergePartialFromCodedStream( // repeated .google.protobuf.EnumDescriptorProto enum_type = 4; case 4: { - if (tag == 34u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(34u)) { DO_(input->IncrementRecursionDepth()); DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_enum_type())); @@ -3309,7 +3344,8 @@ bool DescriptorProto::MergePartialFromCodedStream( // repeated .google.protobuf.DescriptorProto.ExtensionRange extension_range = 5; case 5: { - if (tag == 42u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(42u)) { DO_(input->IncrementRecursionDepth()); DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_extension_range())); @@ -3322,7 +3358,8 @@ bool DescriptorProto::MergePartialFromCodedStream( // repeated .google.protobuf.FieldDescriptorProto extension = 6; case 6: { - if (tag == 50u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(50u)) { DO_(input->IncrementRecursionDepth()); DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_extension())); @@ -3335,7 +3372,8 @@ bool DescriptorProto::MergePartialFromCodedStream( // optional .google.protobuf.MessageOptions options = 7; case 7: { - if (tag == 58u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(58u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_options())); } else { @@ -3346,7 +3384,8 @@ bool DescriptorProto::MergePartialFromCodedStream( // repeated .google.protobuf.OneofDescriptorProto oneof_decl = 8; case 8: { - if (tag == 66u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(66u)) { DO_(input->IncrementRecursionDepth()); DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_oneof_decl())); @@ -3359,7 +3398,8 @@ bool DescriptorProto::MergePartialFromCodedStream( // repeated .google.protobuf.DescriptorProto.ReservedRange reserved_range = 9; case 9: { - if (tag == 74u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(74u)) { DO_(input->IncrementRecursionDepth()); DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_reserved_range())); @@ -3372,7 +3412,8 @@ bool DescriptorProto::MergePartialFromCodedStream( // repeated string reserved_name = 10; case 10: { - if (tag == 82u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(82u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->add_reserved_name())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -3470,7 +3511,7 @@ void DescriptorProto::SerializeWithCachedSizes( } // repeated string reserved_name = 10; - for (int i = 0; i < this->reserved_name_size(); i++) { + for (int i = 0, n = this->reserved_name_size(); i < n; i++) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->reserved_name(i).data(), this->reserved_name(i).length(), ::google::protobuf::internal::WireFormat::SERIALIZE, @@ -3558,7 +3599,7 @@ void DescriptorProto::SerializeWithCachedSizes( } // repeated string reserved_name = 10; - for (int i = 0; i < this->reserved_name_size(); i++) { + for (int i = 0, n = this->reserved_name_size(); i < n; i++) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->reserved_name(i).data(), this->reserved_name(i).length(), ::google::protobuf::internal::WireFormat::SERIALIZE, @@ -3664,7 +3705,7 @@ size_t DescriptorProto::ByteSizeLong() const { // repeated string reserved_name = 10; total_size += 1 * ::google::protobuf::internal::FromIntSize(this->reserved_name_size()); - for (int i = 0; i < this->reserved_name_size(); i++) { + for (int i = 0, n = this->reserved_name_size(); i < n; i++) { total_size += ::google::protobuf::internal::WireFormatLite::StringSize( this->reserved_name(i)); } @@ -4120,6 +4161,12 @@ void DescriptorProto::set_reserved_name(int index, const ::std::string& value) { // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.reserved_name) reserved_name_.Mutable(index)->assign(value); } +#if LANG_CXX11 +void DescriptorProto::set_reserved_name(int index, ::std::string&& value) { + // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.reserved_name) + reserved_name_.Mutable(index)->assign(std::move(value)); +} +#endif void DescriptorProto::set_reserved_name(int index, const char* value) { reserved_name_.Mutable(index)->assign(value); // @@protoc_insertion_point(field_set_char:google.protobuf.DescriptorProto.reserved_name) @@ -4137,6 +4184,12 @@ void DescriptorProto::add_reserved_name(const ::std::string& value) { reserved_name_.Add()->assign(value); // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.reserved_name) } +#if LANG_CXX11 +void DescriptorProto::add_reserved_name(::std::string&& value) { + reserved_name_.Add()->assign(std::move(value)); + // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.reserved_name) +} +#endif void DescriptorProto::add_reserved_name(const char* value) { reserved_name_.Add()->assign(value); // @@protoc_insertion_point(field_add_char:google.protobuf.DescriptorProto.reserved_name) @@ -4322,7 +4375,8 @@ bool FieldDescriptorProto::MergePartialFromCodedStream( switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional string name = 1; case 1: { - if (tag == 10u) { + 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( @@ -4337,7 +4391,8 @@ bool FieldDescriptorProto::MergePartialFromCodedStream( // optional string extendee = 2; case 2: { - if (tag == 18u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(18u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_extendee())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -4352,7 +4407,8 @@ bool FieldDescriptorProto::MergePartialFromCodedStream( // optional int32 number = 3; case 3: { - if (tag == 24u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(24u)) { set_has_number(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -4365,7 +4421,8 @@ bool FieldDescriptorProto::MergePartialFromCodedStream( // optional .google.protobuf.FieldDescriptorProto.Label label = 4; case 4: { - if (tag == 32u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(32u)) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -4383,7 +4440,8 @@ bool FieldDescriptorProto::MergePartialFromCodedStream( // optional .google.protobuf.FieldDescriptorProto.Type type = 5; case 5: { - if (tag == 40u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(40u)) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -4401,7 +4459,8 @@ bool FieldDescriptorProto::MergePartialFromCodedStream( // optional string type_name = 6; case 6: { - if (tag == 50u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(50u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_type_name())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -4416,7 +4475,8 @@ bool FieldDescriptorProto::MergePartialFromCodedStream( // optional string default_value = 7; case 7: { - if (tag == 58u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(58u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_default_value())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -4431,7 +4491,8 @@ bool FieldDescriptorProto::MergePartialFromCodedStream( // optional .google.protobuf.FieldOptions options = 8; case 8: { - if (tag == 66u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(66u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_options())); } else { @@ -4442,7 +4503,8 @@ bool FieldDescriptorProto::MergePartialFromCodedStream( // optional int32 oneof_index = 9; case 9: { - if (tag == 72u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(72u)) { set_has_oneof_index(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -4455,7 +4517,8 @@ bool FieldDescriptorProto::MergePartialFromCodedStream( // optional string json_name = 10; case 10: { - if (tag == 82u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(82u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_json_name())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -5428,7 +5491,8 @@ bool OneofDescriptorProto::MergePartialFromCodedStream( switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional string name = 1; case 1: { - if (tag == 10u) { + 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( @@ -5443,7 +5507,8 @@ bool OneofDescriptorProto::MergePartialFromCodedStream( // optional .google.protobuf.OneofOptions options = 2; case 2: { - if (tag == 18u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(18u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_options())); } else { @@ -5847,7 +5912,8 @@ bool EnumDescriptorProto::MergePartialFromCodedStream( switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional string name = 1; case 1: { - if (tag == 10u) { + 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( @@ -5862,7 +5928,8 @@ bool EnumDescriptorProto::MergePartialFromCodedStream( // repeated .google.protobuf.EnumValueDescriptorProto value = 2; case 2: { - if (tag == 18u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(18u)) { DO_(input->IncrementRecursionDepth()); DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_value())); @@ -5875,7 +5942,8 @@ bool EnumDescriptorProto::MergePartialFromCodedStream( // optional .google.protobuf.EnumOptions options = 3; case 3: { - if (tag == 26u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(26u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_options())); } else { @@ -6337,7 +6405,8 @@ bool EnumValueDescriptorProto::MergePartialFromCodedStream( switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional string name = 1; case 1: { - if (tag == 10u) { + 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( @@ -6352,7 +6421,8 @@ bool EnumValueDescriptorProto::MergePartialFromCodedStream( // optional int32 number = 2; case 2: { - if (tag == 16u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(16u)) { set_has_number(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -6365,7 +6435,8 @@ bool EnumValueDescriptorProto::MergePartialFromCodedStream( // optional .google.protobuf.EnumValueOptions options = 3; case 3: { - if (tag == 26u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(26u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_options())); } else { @@ -6814,7 +6885,8 @@ bool ServiceDescriptorProto::MergePartialFromCodedStream( switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional string name = 1; case 1: { - if (tag == 10u) { + 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( @@ -6829,7 +6901,8 @@ bool ServiceDescriptorProto::MergePartialFromCodedStream( // repeated .google.protobuf.MethodDescriptorProto method = 2; case 2: { - if (tag == 18u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(18u)) { DO_(input->IncrementRecursionDepth()); DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_method())); @@ -6842,7 +6915,8 @@ bool ServiceDescriptorProto::MergePartialFromCodedStream( // optional .google.protobuf.ServiceOptions options = 3; case 3: { - if (tag == 26u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(26u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_options())); } else { @@ -7332,7 +7406,8 @@ bool MethodDescriptorProto::MergePartialFromCodedStream( switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional string name = 1; case 1: { - if (tag == 10u) { + 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( @@ -7347,7 +7422,8 @@ bool MethodDescriptorProto::MergePartialFromCodedStream( // optional string input_type = 2; case 2: { - if (tag == 18u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(18u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_input_type())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -7362,7 +7438,8 @@ bool MethodDescriptorProto::MergePartialFromCodedStream( // optional string output_type = 3; case 3: { - if (tag == 26u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(26u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_output_type())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -7377,7 +7454,8 @@ bool MethodDescriptorProto::MergePartialFromCodedStream( // optional .google.protobuf.MethodOptions options = 4; case 4: { - if (tag == 34u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(34u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_options())); } else { @@ -7388,7 +7466,8 @@ bool MethodDescriptorProto::MergePartialFromCodedStream( // optional bool client_streaming = 5 [default = false]; case 5: { - if (tag == 40u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(40u)) { set_has_client_streaming(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -7401,7 +7480,8 @@ bool MethodDescriptorProto::MergePartialFromCodedStream( // optional bool server_streaming = 6 [default = false]; case 6: { - if (tag == 48u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(48u)) { set_has_server_streaming(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -8150,7 +8230,8 @@ bool FileOptions::MergePartialFromCodedStream( switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional string java_package = 1; case 1: { - if (tag == 10u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(10u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_java_package())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -8165,7 +8246,8 @@ bool FileOptions::MergePartialFromCodedStream( // optional string java_outer_classname = 8; case 8: { - if (tag == 66u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(66u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_java_outer_classname())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -8180,7 +8262,8 @@ bool FileOptions::MergePartialFromCodedStream( // optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED]; case 9: { - if (tag == 72u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(72u)) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -8198,7 +8281,8 @@ bool FileOptions::MergePartialFromCodedStream( // optional bool java_multiple_files = 10 [default = false]; case 10: { - if (tag == 80u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(80u)) { set_has_java_multiple_files(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -8211,7 +8295,8 @@ bool FileOptions::MergePartialFromCodedStream( // optional string go_package = 11; case 11: { - if (tag == 90u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(90u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_go_package())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -8226,7 +8311,8 @@ bool FileOptions::MergePartialFromCodedStream( // optional bool cc_generic_services = 16 [default = false]; case 16: { - if (tag == 128u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(128u)) { set_has_cc_generic_services(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -8239,7 +8325,8 @@ bool FileOptions::MergePartialFromCodedStream( // optional bool java_generic_services = 17 [default = false]; case 17: { - if (tag == 136u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(136u)) { set_has_java_generic_services(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -8252,7 +8339,8 @@ bool FileOptions::MergePartialFromCodedStream( // optional bool py_generic_services = 18 [default = false]; case 18: { - if (tag == 144u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(144u)) { set_has_py_generic_services(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -8265,7 +8353,8 @@ bool FileOptions::MergePartialFromCodedStream( // optional bool java_generate_equals_and_hash = 20 [deprecated = true]; case 20: { - if (tag == 160u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(160u)) { set_has_java_generate_equals_and_hash(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -8278,7 +8367,8 @@ bool FileOptions::MergePartialFromCodedStream( // optional bool deprecated = 23 [default = false]; case 23: { - if (tag == 184u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(184u)) { set_has_deprecated(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -8291,7 +8381,8 @@ bool FileOptions::MergePartialFromCodedStream( // optional bool java_string_check_utf8 = 27 [default = false]; case 27: { - if (tag == 216u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(216u)) { set_has_java_string_check_utf8(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -8304,7 +8395,8 @@ bool FileOptions::MergePartialFromCodedStream( // optional bool cc_enable_arenas = 31 [default = false]; case 31: { - if (tag == 248u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(248u)) { set_has_cc_enable_arenas(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -8317,7 +8409,8 @@ bool FileOptions::MergePartialFromCodedStream( // optional string objc_class_prefix = 36; case 36: { - if (tag == 290u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(290u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_objc_class_prefix())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -8332,7 +8425,8 @@ bool FileOptions::MergePartialFromCodedStream( // optional string csharp_namespace = 37; case 37: { - if (tag == 298u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(298u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_csharp_namespace())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -8347,7 +8441,8 @@ bool FileOptions::MergePartialFromCodedStream( // optional string swift_prefix = 39; case 39: { - if (tag == 314u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(314u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_swift_prefix())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -8362,7 +8457,8 @@ bool FileOptions::MergePartialFromCodedStream( // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; case 999: { - if (tag == 7994u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(7994u)) { DO_(input->IncrementRecursionDepth()); DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_uninterpreted_option())); @@ -9632,7 +9728,8 @@ bool MessageOptions::MergePartialFromCodedStream( switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional bool message_set_wire_format = 1 [default = false]; case 1: { - if (tag == 8u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(8u)) { set_has_message_set_wire_format(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -9645,7 +9742,8 @@ bool MessageOptions::MergePartialFromCodedStream( // optional bool no_standard_descriptor_accessor = 2 [default = false]; case 2: { - if (tag == 16u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(16u)) { set_has_no_standard_descriptor_accessor(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -9658,7 +9756,8 @@ bool MessageOptions::MergePartialFromCodedStream( // optional bool deprecated = 3 [default = false]; case 3: { - if (tag == 24u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(24u)) { set_has_deprecated(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -9671,7 +9770,8 @@ bool MessageOptions::MergePartialFromCodedStream( // optional bool map_entry = 7; case 7: { - if (tag == 56u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(56u)) { set_has_map_entry(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -9684,7 +9784,8 @@ bool MessageOptions::MergePartialFromCodedStream( // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; case 999: { - if (tag == 7994u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(7994u)) { DO_(input->IncrementRecursionDepth()); DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_uninterpreted_option())); @@ -10163,7 +10264,8 @@ bool FieldOptions::MergePartialFromCodedStream( switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING]; case 1: { - if (tag == 8u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(8u)) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -10181,7 +10283,8 @@ bool FieldOptions::MergePartialFromCodedStream( // optional bool packed = 2; case 2: { - if (tag == 16u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(16u)) { set_has_packed(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -10194,7 +10297,8 @@ bool FieldOptions::MergePartialFromCodedStream( // optional bool deprecated = 3 [default = false]; case 3: { - if (tag == 24u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(24u)) { set_has_deprecated(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -10207,7 +10311,8 @@ bool FieldOptions::MergePartialFromCodedStream( // optional bool lazy = 5 [default = false]; case 5: { - if (tag == 40u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(40u)) { set_has_lazy(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -10220,7 +10325,8 @@ bool FieldOptions::MergePartialFromCodedStream( // optional .google.protobuf.FieldOptions.JSType jstype = 6 [default = JS_NORMAL]; case 6: { - if (tag == 48u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(48u)) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -10238,7 +10344,8 @@ bool FieldOptions::MergePartialFromCodedStream( // optional bool weak = 10 [default = false]; case 10: { - if (tag == 80u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(80u)) { set_has_weak(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -10251,7 +10358,8 @@ bool FieldOptions::MergePartialFromCodedStream( // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; case 999: { - if (tag == 7994u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(7994u)) { DO_(input->IncrementRecursionDepth()); DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_uninterpreted_option())); @@ -10809,7 +10917,8 @@ bool OneofOptions::MergePartialFromCodedStream( switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; case 999: { - if (tag == 7994u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(7994u)) { DO_(input->IncrementRecursionDepth()); DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_uninterpreted_option())); @@ -11108,7 +11217,8 @@ bool EnumOptions::MergePartialFromCodedStream( switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional bool allow_alias = 2; case 2: { - if (tag == 16u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(16u)) { set_has_allow_alias(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -11121,7 +11231,8 @@ bool EnumOptions::MergePartialFromCodedStream( // optional bool deprecated = 3 [default = false]; case 3: { - if (tag == 24u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(24u)) { set_has_deprecated(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -11134,7 +11245,8 @@ bool EnumOptions::MergePartialFromCodedStream( // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; case 999: { - if (tag == 7994u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(7994u)) { DO_(input->IncrementRecursionDepth()); DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_uninterpreted_option())); @@ -11516,7 +11628,8 @@ bool EnumValueOptions::MergePartialFromCodedStream( switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional bool deprecated = 1 [default = false]; case 1: { - if (tag == 8u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(8u)) { set_has_deprecated(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -11529,7 +11642,8 @@ bool EnumValueOptions::MergePartialFromCodedStream( // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; case 999: { - if (tag == 7994u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(7994u)) { DO_(input->IncrementRecursionDepth()); DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_uninterpreted_option())); @@ -11864,7 +11978,8 @@ bool ServiceOptions::MergePartialFromCodedStream( switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional bool deprecated = 33 [default = false]; case 33: { - if (tag == 264u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(264u)) { set_has_deprecated(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -11877,7 +11992,8 @@ bool ServiceOptions::MergePartialFromCodedStream( // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; case 999: { - if (tag == 7994u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(7994u)) { DO_(input->IncrementRecursionDepth()); DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_uninterpreted_option())); @@ -12219,7 +12335,8 @@ bool MethodOptions::MergePartialFromCodedStream( switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional bool deprecated = 33 [default = false]; case 33: { - if (tag == 264u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(264u)) { set_has_deprecated(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -12232,7 +12349,8 @@ bool MethodOptions::MergePartialFromCodedStream( // optional .google.protobuf.MethodOptions.IdempotencyLevel idempotency_level = 34 [default = IDEMPOTENCY_UNKNOWN]; case 34: { - if (tag == 272u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(272u)) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -12250,7 +12368,8 @@ bool MethodOptions::MergePartialFromCodedStream( // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; case 999: { - if (tag == 7994u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(7994u)) { DO_(input->IncrementRecursionDepth()); DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_uninterpreted_option())); @@ -12642,7 +12761,8 @@ bool UninterpretedOption_NamePart::MergePartialFromCodedStream( switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // required string name_part = 1; case 1: { - if (tag == 10u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(10u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name_part())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -12657,7 +12777,8 @@ bool UninterpretedOption_NamePart::MergePartialFromCodedStream( // required bool is_extension = 2; case 2: { - if (tag == 16u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(16u)) { set_has_is_extension(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -13071,7 +13192,8 @@ bool UninterpretedOption::MergePartialFromCodedStream( switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // repeated .google.protobuf.UninterpretedOption.NamePart name = 2; case 2: { - if (tag == 18u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(18u)) { DO_(input->IncrementRecursionDepth()); DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_name())); @@ -13084,7 +13206,8 @@ bool UninterpretedOption::MergePartialFromCodedStream( // optional string identifier_value = 3; case 3: { - if (tag == 26u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(26u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_identifier_value())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -13099,7 +13222,8 @@ bool UninterpretedOption::MergePartialFromCodedStream( // optional uint64 positive_int_value = 4; case 4: { - if (tag == 32u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(32u)) { set_has_positive_int_value(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint64, ::google::protobuf::internal::WireFormatLite::TYPE_UINT64>( @@ -13112,7 +13236,8 @@ bool UninterpretedOption::MergePartialFromCodedStream( // optional int64 negative_int_value = 5; case 5: { - if (tag == 40u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(40u)) { set_has_negative_int_value(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>( @@ -13125,7 +13250,8 @@ bool UninterpretedOption::MergePartialFromCodedStream( // optional double double_value = 6; case 6: { - if (tag == 49u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(49u)) { set_has_double_value(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< double, ::google::protobuf::internal::WireFormatLite::TYPE_DOUBLE>( @@ -13138,7 +13264,8 @@ bool UninterpretedOption::MergePartialFromCodedStream( // optional bytes string_value = 7; case 7: { - if (tag == 58u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(58u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadBytes( input, this->mutable_string_value())); } else { @@ -13149,7 +13276,8 @@ bool UninterpretedOption::MergePartialFromCodedStream( // optional string aggregate_value = 8; case 8: { - if (tag == 66u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(66u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_aggregate_value())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -13860,11 +13988,13 @@ bool SourceCodeInfo_Location::MergePartialFromCodedStream( switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // repeated int32 path = 1 [packed = true]; case 1: { - if (tag == 10u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(10u)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, this->mutable_path()))); - } else if (tag == 8u) { + } else if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(8u)) { DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitiveNoInline< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( 1, 10u, input, this->mutable_path()))); @@ -13876,11 +14006,13 @@ bool SourceCodeInfo_Location::MergePartialFromCodedStream( // repeated int32 span = 2 [packed = true]; case 2: { - if (tag == 18u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(18u)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, this->mutable_span()))); - } else if (tag == 16u) { + } else if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(16u)) { DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitiveNoInline< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( 1, 18u, input, this->mutable_span()))); @@ -13892,7 +14024,8 @@ bool SourceCodeInfo_Location::MergePartialFromCodedStream( // optional string leading_comments = 3; case 3: { - if (tag == 26u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(26u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_leading_comments())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -13907,7 +14040,8 @@ bool SourceCodeInfo_Location::MergePartialFromCodedStream( // optional string trailing_comments = 4; case 4: { - if (tag == 34u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(34u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_trailing_comments())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -13922,7 +14056,8 @@ bool SourceCodeInfo_Location::MergePartialFromCodedStream( // repeated string leading_detached_comments = 6; case 6: { - if (tag == 50u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(50u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->add_leading_detached_comments())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -13966,7 +14101,7 @@ void SourceCodeInfo_Location::SerializeWithCachedSizes( ::google::protobuf::internal::WireFormatLite::WriteTag(1, ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED, output); output->WriteVarint32(_path_cached_byte_size_); } - for (int i = 0; i < this->path_size(); i++) { + for (int i = 0, n = this->path_size(); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteInt32NoTag( this->path(i), output); } @@ -13976,7 +14111,7 @@ void SourceCodeInfo_Location::SerializeWithCachedSizes( ::google::protobuf::internal::WireFormatLite::WriteTag(2, ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED, output); output->WriteVarint32(_span_cached_byte_size_); } - for (int i = 0; i < this->span_size(); i++) { + for (int i = 0, n = this->span_size(); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteInt32NoTag( this->span(i), output); } @@ -14002,7 +14137,7 @@ void SourceCodeInfo_Location::SerializeWithCachedSizes( } // repeated string leading_detached_comments = 6; - for (int i = 0; i < this->leading_detached_comments_size(); i++) { + for (int i = 0, n = this->leading_detached_comments_size(); i < n; i++) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->leading_detached_comments(i).data(), this->leading_detached_comments(i).length(), ::google::protobuf::internal::WireFormat::SERIALIZE, @@ -14031,7 +14166,7 @@ void SourceCodeInfo_Location::SerializeWithCachedSizes( target = ::google::protobuf::io::CodedOutputStream::WriteVarint32ToArray( _path_cached_byte_size_, target); } - for (int i = 0; i < this->path_size(); i++) { + for (int i = 0, n = this->path_size(); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: WriteInt32NoTagToArray(this->path(i), target); } @@ -14045,7 +14180,7 @@ void SourceCodeInfo_Location::SerializeWithCachedSizes( target = ::google::protobuf::io::CodedOutputStream::WriteVarint32ToArray( _span_cached_byte_size_, target); } - for (int i = 0; i < this->span_size(); i++) { + for (int i = 0, n = this->span_size(); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: WriteInt32NoTagToArray(this->span(i), target); } @@ -14073,7 +14208,7 @@ void SourceCodeInfo_Location::SerializeWithCachedSizes( } // repeated string leading_detached_comments = 6; - for (int i = 0; i < this->leading_detached_comments_size(); i++) { + for (int i = 0, n = this->leading_detached_comments_size(); i < n; i++) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->leading_detached_comments(i).data(), this->leading_detached_comments(i).length(), ::google::protobuf::internal::WireFormat::SERIALIZE, @@ -14132,7 +14267,7 @@ size_t SourceCodeInfo_Location::ByteSizeLong() const { // repeated string leading_detached_comments = 6; total_size += 1 * ::google::protobuf::internal::FromIntSize(this->leading_detached_comments_size()); - for (int i = 0; i < this->leading_detached_comments_size(); i++) { + for (int i = 0, n = this->leading_detached_comments_size(); i < n; i++) { total_size += ::google::protobuf::internal::WireFormatLite::StringSize( this->leading_detached_comments(i)); } @@ -14438,6 +14573,12 @@ void SourceCodeInfo_Location::set_leading_detached_comments(int index, const ::s // @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) leading_detached_comments_.Mutable(index)->assign(value); } +#if LANG_CXX11 +void SourceCodeInfo_Location::set_leading_detached_comments(int index, ::std::string&& value) { + // @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) + leading_detached_comments_.Mutable(index)->assign(std::move(value)); +} +#endif void SourceCodeInfo_Location::set_leading_detached_comments(int index, const char* value) { leading_detached_comments_.Mutable(index)->assign(value); // @@protoc_insertion_point(field_set_char:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) @@ -14455,6 +14596,12 @@ void SourceCodeInfo_Location::add_leading_detached_comments(const ::std::string& leading_detached_comments_.Add()->assign(value); // @@protoc_insertion_point(field_add:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) } +#if LANG_CXX11 +void SourceCodeInfo_Location::add_leading_detached_comments(::std::string&& value) { + leading_detached_comments_.Add()->assign(std::move(value)); + // @@protoc_insertion_point(field_add:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) +} +#endif void SourceCodeInfo_Location::add_leading_detached_comments(const char* value) { leading_detached_comments_.Add()->assign(value); // @@protoc_insertion_point(field_add_char:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) @@ -14554,7 +14701,8 @@ bool SourceCodeInfo::MergePartialFromCodedStream( switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // repeated .google.protobuf.SourceCodeInfo.Location location = 1; case 1: { - if (tag == 10u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(10u)) { DO_(input->IncrementRecursionDepth()); DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_location())); @@ -14840,11 +14988,13 @@ bool GeneratedCodeInfo_Annotation::MergePartialFromCodedStream( switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // repeated int32 path = 1 [packed = true]; case 1: { - if (tag == 10u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(10u)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, this->mutable_path()))); - } else if (tag == 8u) { + } else if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(8u)) { DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitiveNoInline< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( 1, 10u, input, this->mutable_path()))); @@ -14856,7 +15006,8 @@ bool GeneratedCodeInfo_Annotation::MergePartialFromCodedStream( // optional string source_file = 2; case 2: { - if (tag == 18u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(18u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_source_file())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -14871,7 +15022,8 @@ bool GeneratedCodeInfo_Annotation::MergePartialFromCodedStream( // optional int32 begin = 3; case 3: { - if (tag == 24u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(24u)) { set_has_begin(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -14884,7 +15036,8 @@ bool GeneratedCodeInfo_Annotation::MergePartialFromCodedStream( // optional int32 end = 4; case 4: { - if (tag == 32u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(32u)) { set_has_end(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -14925,7 +15078,7 @@ void GeneratedCodeInfo_Annotation::SerializeWithCachedSizes( ::google::protobuf::internal::WireFormatLite::WriteTag(1, ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED, output); output->WriteVarint32(_path_cached_byte_size_); } - for (int i = 0; i < this->path_size(); i++) { + for (int i = 0, n = this->path_size(); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteInt32NoTag( this->path(i), output); } @@ -14970,7 +15123,7 @@ void GeneratedCodeInfo_Annotation::SerializeWithCachedSizes( target = ::google::protobuf::io::CodedOutputStream::WriteVarint32ToArray( _path_cached_byte_size_, target); } - for (int i = 0; i < this->path_size(); i++) { + for (int i = 0, n = this->path_size(); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: WriteInt32NoTagToArray(this->path(i), target); } @@ -15352,7 +15505,8 @@ bool GeneratedCodeInfo::MergePartialFromCodedStream( switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // repeated .google.protobuf.GeneratedCodeInfo.Annotation annotation = 1; case 1: { - if (tag == 10u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(10u)) { DO_(input->IncrementRecursionDepth()); DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_annotation())); diff --git a/src/google/protobuf/descriptor.pb.h b/src/google/protobuf/descriptor.pb.h index fa8d0d6b..73b7a8dd 100644 --- a/src/google/protobuf/descriptor.pb.h +++ b/src/google/protobuf/descriptor.pb.h @@ -441,10 +441,16 @@ class LIBPROTOBUF_EXPORT FileDescriptorProto : public ::google::protobuf::Messag const ::std::string& dependency(int index) const; ::std::string* mutable_dependency(int index); void set_dependency(int index, const ::std::string& value); + #if LANG_CXX11 + void set_dependency(int index, ::std::string&& value); + #endif void set_dependency(int index, const char* value); void set_dependency(int index, const char* value, size_t size); ::std::string* add_dependency(); void add_dependency(const ::std::string& value); + #if LANG_CXX11 + void add_dependency(::std::string&& value); + #endif void add_dependency(const char* value); void add_dependency(const char* value, size_t size); const ::google::protobuf::RepeatedPtrField< ::std::string>& dependency() const; @@ -996,10 +1002,16 @@ class LIBPROTOBUF_EXPORT DescriptorProto : public ::google::protobuf::Message /* const ::std::string& reserved_name(int index) const; ::std::string* mutable_reserved_name(int index); void set_reserved_name(int index, const ::std::string& value); + #if LANG_CXX11 + void set_reserved_name(int index, ::std::string&& value); + #endif void set_reserved_name(int index, const char* value); void set_reserved_name(int index, const char* value, size_t size); ::std::string* add_reserved_name(); void add_reserved_name(const ::std::string& value); + #if LANG_CXX11 + void add_reserved_name(::std::string&& value); + #endif void add_reserved_name(const char* value); void add_reserved_name(const char* value, size_t size); const ::google::protobuf::RepeatedPtrField< ::std::string>& reserved_name() const; @@ -3717,10 +3729,16 @@ class LIBPROTOBUF_EXPORT SourceCodeInfo_Location : public ::google::protobuf::Me const ::std::string& leading_detached_comments(int index) const; ::std::string* mutable_leading_detached_comments(int index); void set_leading_detached_comments(int index, const ::std::string& value); + #if LANG_CXX11 + void set_leading_detached_comments(int index, ::std::string&& value); + #endif void set_leading_detached_comments(int index, const char* value); void set_leading_detached_comments(int index, const char* value, size_t size); ::std::string* add_leading_detached_comments(); void add_leading_detached_comments(const ::std::string& value); + #if LANG_CXX11 + void add_leading_detached_comments(::std::string&& value); + #endif void add_leading_detached_comments(const char* value); void add_leading_detached_comments(const char* value, size_t size); const ::google::protobuf::RepeatedPtrField< ::std::string>& leading_detached_comments() const; @@ -4297,6 +4315,12 @@ inline void FileDescriptorProto::set_dependency(int index, const ::std::string& // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.dependency) dependency_.Mutable(index)->assign(value); } +#if LANG_CXX11 +inline void FileDescriptorProto::set_dependency(int index, ::std::string&& value) { + // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.dependency) + dependency_.Mutable(index)->assign(std::move(value)); +} +#endif inline void FileDescriptorProto::set_dependency(int index, const char* value) { dependency_.Mutable(index)->assign(value); // @@protoc_insertion_point(field_set_char:google.protobuf.FileDescriptorProto.dependency) @@ -4314,6 +4338,12 @@ inline void FileDescriptorProto::add_dependency(const ::std::string& value) { dependency_.Add()->assign(value); // @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.dependency) } +#if LANG_CXX11 +inline void FileDescriptorProto::add_dependency(::std::string&& value) { + dependency_.Add()->assign(std::move(value)); + // @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.dependency) +} +#endif inline void FileDescriptorProto::add_dependency(const char* value) { dependency_.Add()->assign(value); // @@protoc_insertion_point(field_add_char:google.protobuf.FileDescriptorProto.dependency) @@ -5109,6 +5139,12 @@ inline void DescriptorProto::set_reserved_name(int index, const ::std::string& v // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.reserved_name) reserved_name_.Mutable(index)->assign(value); } +#if LANG_CXX11 +inline void DescriptorProto::set_reserved_name(int index, ::std::string&& value) { + // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.reserved_name) + reserved_name_.Mutable(index)->assign(std::move(value)); +} +#endif inline void DescriptorProto::set_reserved_name(int index, const char* value) { reserved_name_.Mutable(index)->assign(value); // @@protoc_insertion_point(field_set_char:google.protobuf.DescriptorProto.reserved_name) @@ -5126,6 +5162,12 @@ inline void DescriptorProto::add_reserved_name(const ::std::string& value) { reserved_name_.Add()->assign(value); // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.reserved_name) } +#if LANG_CXX11 +inline void DescriptorProto::add_reserved_name(::std::string&& value) { + reserved_name_.Add()->assign(std::move(value)); + // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.reserved_name) +} +#endif inline void DescriptorProto::add_reserved_name(const char* value) { reserved_name_.Add()->assign(value); // @@protoc_insertion_point(field_add_char:google.protobuf.DescriptorProto.reserved_name) @@ -8250,6 +8292,12 @@ inline void SourceCodeInfo_Location::set_leading_detached_comments(int index, co // @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) leading_detached_comments_.Mutable(index)->assign(value); } +#if LANG_CXX11 +inline void SourceCodeInfo_Location::set_leading_detached_comments(int index, ::std::string&& value) { + // @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) + leading_detached_comments_.Mutable(index)->assign(std::move(value)); +} +#endif inline void SourceCodeInfo_Location::set_leading_detached_comments(int index, const char* value) { leading_detached_comments_.Mutable(index)->assign(value); // @@protoc_insertion_point(field_set_char:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) @@ -8267,6 +8315,12 @@ inline void SourceCodeInfo_Location::add_leading_detached_comments(const ::std:: leading_detached_comments_.Add()->assign(value); // @@protoc_insertion_point(field_add:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) } +#if LANG_CXX11 +inline void SourceCodeInfo_Location::add_leading_detached_comments(::std::string&& value) { + leading_detached_comments_.Add()->assign(std::move(value)); + // @@protoc_insertion_point(field_add:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) +} +#endif inline void SourceCodeInfo_Location::add_leading_detached_comments(const char* value) { leading_detached_comments_.Add()->assign(value); // @@protoc_insertion_point(field_add_char:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) diff --git a/src/google/protobuf/duration.pb.cc b/src/google/protobuf/duration.pb.cc index 4242d079..e046cc5a 100644 --- a/src/google/protobuf/duration.pb.cc +++ b/src/google/protobuf/duration.pb.cc @@ -216,7 +216,8 @@ bool Duration::MergePartialFromCodedStream( switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // int64 seconds = 1; case 1: { - if (tag == 8u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(8u)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>( @@ -229,7 +230,8 @@ bool Duration::MergePartialFromCodedStream( // int32 nanos = 2; case 2: { - if (tag == 16u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(16u)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( diff --git a/src/google/protobuf/field_mask.pb.cc b/src/google/protobuf/field_mask.pb.cc index 7d80d211..b054dffd 100644 --- a/src/google/protobuf/field_mask.pb.cc +++ b/src/google/protobuf/field_mask.pb.cc @@ -192,7 +192,8 @@ bool FieldMask::MergePartialFromCodedStream( switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // repeated string paths = 1; case 1: { - if (tag == 10u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(10u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->add_paths())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -231,7 +232,7 @@ void FieldMask::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:google.protobuf.FieldMask) // repeated string paths = 1; - for (int i = 0; i < this->paths_size(); i++) { + for (int i = 0, n = this->paths_size(); i < n; i++) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->paths(i).data(), this->paths(i).length(), ::google::protobuf::internal::WireFormatLite::SERIALIZE, @@ -248,7 +249,7 @@ void FieldMask::SerializeWithCachedSizes( (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.FieldMask) // repeated string paths = 1; - for (int i = 0; i < this->paths_size(); i++) { + for (int i = 0, n = this->paths_size(); i < n; i++) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->paths(i).data(), this->paths(i).length(), ::google::protobuf::internal::WireFormatLite::SERIALIZE, @@ -268,7 +269,7 @@ size_t FieldMask::ByteSizeLong() const { // repeated string paths = 1; total_size += 1 * ::google::protobuf::internal::FromIntSize(this->paths_size()); - for (int i = 0; i < this->paths_size(); i++) { + for (int i = 0, n = this->paths_size(); i < n; i++) { total_size += ::google::protobuf::internal::WireFormatLite::StringSize( this->paths(i)); } @@ -356,6 +357,12 @@ void FieldMask::set_paths(int index, const ::std::string& value) { // @@protoc_insertion_point(field_set:google.protobuf.FieldMask.paths) paths_.Mutable(index)->assign(value); } +#if LANG_CXX11 +void FieldMask::set_paths(int index, ::std::string&& value) { + // @@protoc_insertion_point(field_set:google.protobuf.FieldMask.paths) + paths_.Mutable(index)->assign(std::move(value)); +} +#endif void FieldMask::set_paths(int index, const char* value) { paths_.Mutable(index)->assign(value); // @@protoc_insertion_point(field_set_char:google.protobuf.FieldMask.paths) @@ -373,6 +380,12 @@ void FieldMask::add_paths(const ::std::string& value) { paths_.Add()->assign(value); // @@protoc_insertion_point(field_add:google.protobuf.FieldMask.paths) } +#if LANG_CXX11 +void FieldMask::add_paths(::std::string&& value) { + paths_.Add()->assign(std::move(value)); + // @@protoc_insertion_point(field_add:google.protobuf.FieldMask.paths) +} +#endif void FieldMask::add_paths(const char* value) { paths_.Add()->assign(value); // @@protoc_insertion_point(field_add_char:google.protobuf.FieldMask.paths) diff --git a/src/google/protobuf/field_mask.pb.h b/src/google/protobuf/field_mask.pb.h index 6b2bc982..b609f235 100644 --- a/src/google/protobuf/field_mask.pb.h +++ b/src/google/protobuf/field_mask.pb.h @@ -127,10 +127,16 @@ class LIBPROTOBUF_EXPORT FieldMask : public ::google::protobuf::Message /* @@pro const ::std::string& paths(int index) const; ::std::string* mutable_paths(int index); void set_paths(int index, const ::std::string& value); + #if LANG_CXX11 + void set_paths(int index, ::std::string&& value); + #endif void set_paths(int index, const char* value); void set_paths(int index, const char* value, size_t size); ::std::string* add_paths(); void add_paths(const ::std::string& value); + #if LANG_CXX11 + void add_paths(::std::string&& value); + #endif void add_paths(const char* value); void add_paths(const char* value, size_t size); const ::google::protobuf::RepeatedPtrField< ::std::string>& paths() const; @@ -171,6 +177,12 @@ inline void FieldMask::set_paths(int index, const ::std::string& value) { // @@protoc_insertion_point(field_set:google.protobuf.FieldMask.paths) paths_.Mutable(index)->assign(value); } +#if LANG_CXX11 +inline void FieldMask::set_paths(int index, ::std::string&& value) { + // @@protoc_insertion_point(field_set:google.protobuf.FieldMask.paths) + paths_.Mutable(index)->assign(std::move(value)); +} +#endif inline void FieldMask::set_paths(int index, const char* value) { paths_.Mutable(index)->assign(value); // @@protoc_insertion_point(field_set_char:google.protobuf.FieldMask.paths) @@ -188,6 +200,12 @@ inline void FieldMask::add_paths(const ::std::string& value) { paths_.Add()->assign(value); // @@protoc_insertion_point(field_add:google.protobuf.FieldMask.paths) } +#if LANG_CXX11 +inline void FieldMask::add_paths(::std::string&& value) { + paths_.Add()->assign(std::move(value)); + // @@protoc_insertion_point(field_add:google.protobuf.FieldMask.paths) +} +#endif inline void FieldMask::add_paths(const char* value) { paths_.Add()->assign(value); // @@protoc_insertion_point(field_add_char:google.protobuf.FieldMask.paths) diff --git a/src/google/protobuf/generated_message_reflection.h b/src/google/protobuf/generated_message_reflection.h index 2e65787f..8b1362a2 100644 --- a/src/google/protobuf/generated_message_reflection.h +++ b/src/google/protobuf/generated_message_reflection.h @@ -674,6 +674,8 @@ class LIBPROTOBUF_EXPORT GeneratedMessageReflection PROTOBUF_FINAL template<typename To, typename From> inline To dynamic_cast_if_available(From from) { #if defined(GOOGLE_PROTOBUF_NO_RTTI) || (defined(_MSC_VER)&&!defined(_CPPRTTI)) + // Avoid the compiler warning about unused variables. + (void)from; return NULL; #else return dynamic_cast<To>(from); diff --git a/src/google/protobuf/io/coded_stream.cc b/src/google/protobuf/io/coded_stream.cc index 93748ee3..3c2e0fbd 100644 --- a/src/google/protobuf/io/coded_stream.cc +++ b/src/google/protobuf/io/coded_stream.cc @@ -816,25 +816,6 @@ bool CodedOutputStream::Refresh() { } } -size_t CodedOutputStream::VarintSize32Fallback(uint32 value) { - // This computes floor(log2(value)) / 7 + 1 - // Use an explicit multiplication to implement the divide of - // a number in the 1..31 range. - GOOGLE_DCHECK_NE(0, value); // This is enforced by our caller. - - uint32 log2value = Bits::Log2FloorNonZero(value); - return static_cast<size_t>((log2value * 9 + 73) / 64); -} - -size_t CodedOutputStream::VarintSize64(uint64 value) { - // This computes value == 0 ? 1 : floor(log2(value)) / 7 + 1 - // Use an explicit multiplication to implement the divide of - // a number in the 1..63 range. - // Explicit OR 0x1 to avoid calling clz(0), which is undefined. - uint32 log2value = Bits::Log2FloorNonZero64(value | 0x1); - return static_cast<size_t>((log2value * 9 + 73) / 64); -} - uint8* CodedOutputStream::WriteStringWithSizeToArray(const string& str, uint8* target) { GOOGLE_DCHECK_LE(str.size(), kuint32max); diff --git a/src/google/protobuf/io/coded_stream.h b/src/google/protobuf/io/coded_stream.h index 557312d3..b71b4a98 100644 --- a/src/google/protobuf/io/coded_stream.h +++ b/src/google/protobuf/io/coded_stream.h @@ -903,8 +903,6 @@ class LIBPROTOBUF_EXPORT CodedOutputStream { void WriteVarint32SlowPath(uint32 value); void WriteVarint64SlowPath(uint64 value); - static size_t VarintSize32Fallback(uint32 value); - // See above. Other projects may use "friend" to allow them to call this. // Requires: no protocol buffer serialization in progress. friend void ::google::protobuf::internal::MapTestForceDeterministic(); @@ -996,8 +994,7 @@ inline const uint8* CodedInputStream::ReadLittleEndian64FromArray( inline bool CodedInputStream::ReadLittleEndian32(uint32* value) { #if defined(PROTOBUF_LITTLE_ENDIAN) if (GOOGLE_PREDICT_TRUE(BufferSize() >= static_cast<int>(sizeof(*value)))) { - memcpy(value, buffer_, sizeof(*value)); - Advance(sizeof(*value)); + buffer_ = ReadLittleEndian32FromArray(buffer_, value); return true; } else { return ReadLittleEndian32Fallback(value); @@ -1010,8 +1007,7 @@ inline bool CodedInputStream::ReadLittleEndian32(uint32* value) { inline bool CodedInputStream::ReadLittleEndian64(uint64* value) { #if defined(PROTOBUF_LITTLE_ENDIAN) if (GOOGLE_PREDICT_TRUE(BufferSize() >= static_cast<int>(sizeof(*value)))) { - memcpy(value, buffer_, sizeof(*value)); - Advance(sizeof(*value)); + buffer_ = ReadLittleEndian64FromArray(buffer_, value); return true; } else { return ReadLittleEndian64Fallback(value); @@ -1292,11 +1288,23 @@ inline uint8* CodedOutputStream::WriteTagToArray( } inline size_t CodedOutputStream::VarintSize32(uint32 value) { - if (value < (1 << 7)) { - return 1; - } else { - return VarintSize32Fallback(value); - } + // This computes value == 0 ? 1 : floor(log2(value)) / 7 + 1 + // Use an explicit multiplication to implement the divide of + // a number in the 1..31 range. + // Explicit OR 0x1 to avoid calling Bits::Log2FloorNonZero(0), which is + // undefined. + uint32 log2value = Bits::Log2FloorNonZero(value | 0x1); + return static_cast<size_t>((log2value * 9 + 73) / 64); +} + +inline size_t CodedOutputStream::VarintSize64(uint64 value) { + // This computes value == 0 ? 1 : floor(log2(value)) / 7 + 1 + // Use an explicit multiplication to implement the divide of + // a number in the 1..63 range. + // Explicit OR 0x1 to avoid calling Bits::Log2FloorNonZero(0), which is + // undefined. + uint32 log2value = Bits::Log2FloorNonZero64(value | 0x1); + return static_cast<size_t>((log2value * 9 + 73) / 64); } inline size_t CodedOutputStream::VarintSize32SignExtended(int32 value) { diff --git a/src/google/protobuf/map.h b/src/google/protobuf/map.h index 6458714e..61a23897 100644 --- a/src/google/protobuf/map.h +++ b/src/google/protobuf/map.h @@ -592,7 +592,7 @@ class Map { MapAllocator(const MapAllocator<X>& allocator) : arena_(allocator.arena()) {} - pointer allocate(size_type n, const_pointer 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) { @@ -1726,12 +1726,19 @@ struct hash<google::protobuf::MapKey> { break; case google::protobuf::FieldDescriptor::CPPTYPE_STRING: return hash<string>()(map_key.GetStringValue()); +#if defined(GOOGLE_PROTOBUF_HAVE_64BIT_HASH) case google::protobuf::FieldDescriptor::CPPTYPE_INT64: return hash< ::google::protobuf::int64>()(map_key.GetInt64Value()); - case google::protobuf::FieldDescriptor::CPPTYPE_INT32: - return hash< ::google::protobuf::int32>()(map_key.GetInt32Value()); case google::protobuf::FieldDescriptor::CPPTYPE_UINT64: return hash< ::google::protobuf::uint64>()(map_key.GetUInt64Value()); +#else + case google::protobuf::FieldDescriptor::CPPTYPE_INT64: + case google::protobuf::FieldDescriptor::CPPTYPE_UINT64: + GOOGLE_LOG(FATAL) << "Unsupported on this platform."; + break; +#endif + case google::protobuf::FieldDescriptor::CPPTYPE_INT32: + return hash< ::google::protobuf::int32>()(map_key.GetInt32Value()); case google::protobuf::FieldDescriptor::CPPTYPE_UINT32: return hash< ::google::protobuf::uint32>()(map_key.GetUInt32Value()); case google::protobuf::FieldDescriptor::CPPTYPE_BOOL: diff --git a/src/google/protobuf/map_field_inl.h b/src/google/protobuf/map_field_inl.h index 01c9b89a..2d84b0a3 100644 --- a/src/google/protobuf/map_field_inl.h +++ b/src/google/protobuf/map_field_inl.h @@ -339,9 +339,9 @@ MapField<Key, T, kKeyFieldType, kValueFieldType, default_enum_value>::Swap( MapFieldLiteType* other) { MapField* down_other = down_cast<MapField*>(other); - std::swap(MapFieldBase::repeated_field_, down_other->repeated_field_); + std::swap(this->MapFieldBase::repeated_field_, down_other->repeated_field_); MapFieldLiteType::Swap(other); - std::swap(MapFieldBase::state_, down_other->state_); + std::swap(this->MapFieldBase::state_, down_other->state_); } template <typename Key, typename T, @@ -352,7 +352,7 @@ void MapField<Key, T, kKeyFieldType, kValueFieldType, default_enum_value>::SetEntryDescriptor( const Descriptor** descriptor) { - MapFieldBase::entry_descriptor_ = descriptor; + this->MapFieldBase::entry_descriptor_ = descriptor; } template <typename Key, typename T, @@ -362,7 +362,7 @@ template <typename Key, typename T, void MapField<Key, T, kKeyFieldType, kValueFieldType, default_enum_value>::SetAssignDescriptorCallback(void (*callback)()) { - MapFieldBase::assign_descriptor_callback_ = callback; + this->MapFieldBase::assign_descriptor_callback_ = callback; } template <typename Key, typename T, @@ -392,19 +392,19 @@ template <typename Key, typename T, void MapField<Key, T, kKeyFieldType, kValueFieldType, default_enum_value>::SyncRepeatedFieldWithMapNoLock() const { - if (MapFieldBase::repeated_field_ == NULL) { - if (MapFieldBase::arena_ == NULL) { - MapFieldBase::repeated_field_ = new RepeatedPtrField<Message>(); + if (this->MapFieldBase::repeated_field_ == NULL) { + if (this->MapFieldBase::arena_ == NULL) { + this->MapFieldBase::repeated_field_ = new RepeatedPtrField<Message>(); } else { - MapFieldBase::repeated_field_ = + this->MapFieldBase::repeated_field_ = Arena::CreateMessage<RepeatedPtrField<Message> >( - MapFieldBase::arena_); + this->MapFieldBase::arena_); } } const Map<Key, T>& map = GetInternalMap(); RepeatedPtrField<EntryType>* repeated_field = reinterpret_cast<RepeatedPtrField<EntryType>*>( - MapFieldBase::repeated_field_); + this->MapFieldBase::repeated_field_); repeated_field->Clear(); @@ -413,7 +413,7 @@ MapField<Key, T, kKeyFieldType, kValueFieldType, InitDefaultEntryOnce(); GOOGLE_CHECK(default_entry_ != NULL); EntryType* new_entry = - down_cast<EntryType*>(default_entry_->New(MapFieldBase::arena_)); + down_cast<EntryType*>(default_entry_->New(this->MapFieldBase::arena_)); repeated_field->AddAllocated(new_entry); (*new_entry->mutable_key()) = it->first; (*new_entry->mutable_value()) = it->second; @@ -430,8 +430,8 @@ MapField<Key, T, kKeyFieldType, kValueFieldType, Map<Key, T>* map = const_cast<MapField*>(this)->MutableInternalMap(); RepeatedPtrField<EntryType>* repeated_field = reinterpret_cast<RepeatedPtrField<EntryType>*>( - MapFieldBase::repeated_field_); - GOOGLE_CHECK(MapFieldBase::repeated_field_ != NULL); + this->MapFieldBase::repeated_field_); + GOOGLE_CHECK(this->MapFieldBase::repeated_field_ != NULL); map->clear(); for (typename RepeatedPtrField<EntryType>::iterator it = repeated_field->begin(); it != repeated_field->end(); ++it) { @@ -452,8 +452,8 @@ int MapField<Key, T, kKeyFieldType, kValueFieldType, default_enum_value>::SpaceUsedExcludingSelfNoLock() const { int size = 0; - if (MapFieldBase::repeated_field_ != NULL) { - size += MapFieldBase::repeated_field_->SpaceUsedExcludingSelf(); + if (this->MapFieldBase::repeated_field_ != NULL) { + size += this->MapFieldBase::repeated_field_->SpaceUsedExcludingSelf(); } Map<Key, T>* map = const_cast<MapField*>(this)->MutableInternalMap(); size += sizeof(*map); @@ -475,10 +475,10 @@ MapField<Key, T, kKeyFieldType, kValueFieldType, const { if (default_entry_ == NULL) { MapFieldBase::InitMetadataOnce(); - GOOGLE_CHECK(*MapFieldBase::entry_descriptor_ != NULL); + GOOGLE_CHECK(*this->MapFieldBase::entry_descriptor_ != NULL); default_entry_ = down_cast<const EntryType*>( MessageFactory::generated_factory()->GetPrototype( - *MapFieldBase::entry_descriptor_)); + *this->MapFieldBase::entry_descriptor_)); } } diff --git a/src/google/protobuf/message.cc b/src/google/protobuf/message.cc index b799dead..6800e4cd 100644 --- a/src/google/protobuf/message.cc +++ b/src/google/protobuf/message.cc @@ -451,8 +451,8 @@ struct ShutdownRepeatedFieldRegister { namespace internal { template<> -#if defined(_MSC_VER) && (_MSC_VER >= 1900) -// Note: force noinline to workaround MSVC 2015 compiler bug, issue #240 +#if defined(_MSC_VER) && (_MSC_VER >= 1800) +// Note: force noinline to workaround MSVC compiler bug with /Zc:inline, issue #240 GOOGLE_ATTRIBUTE_NOINLINE #endif Message* GenericTypeHandler<Message>::NewFromPrototype( @@ -460,8 +460,8 @@ Message* GenericTypeHandler<Message>::NewFromPrototype( return prototype->New(arena); } template<> -#if defined(_MSC_VER) && (_MSC_VER >= 1900) -// Note: force noinline to workaround MSVC 2015 compiler bug, issue #240 +#if defined(_MSC_VER) && (_MSC_VER >= 1800) +// Note: force noinline to workaround MSVC compiler bug with /Zc:inline, issue #240 GOOGLE_ATTRIBUTE_NOINLINE #endif google::protobuf::Arena* GenericTypeHandler<Message>::GetArena( @@ -469,8 +469,8 @@ google::protobuf::Arena* GenericTypeHandler<Message>::GetArena( return value->GetArena(); } template<> -#if defined(_MSC_VER) && (_MSC_VER >= 1900) -// Note: force noinline to workaround MSVC 2015 compiler bug, issue #240 +#if defined(_MSC_VER) && (_MSC_VER >= 1800) +// Note: force noinline to workaround MSVC compiler bug with /Zc:inline, issue #240 GOOGLE_ATTRIBUTE_NOINLINE #endif void* GenericTypeHandler<Message>::GetMaybeArenaPointer( diff --git a/src/google/protobuf/repeated_field.h b/src/google/protobuf/repeated_field.h index 9b87d94b..db5893b5 100644 --- a/src/google/protobuf/repeated_field.h +++ b/src/google/protobuf/repeated_field.h @@ -423,6 +423,11 @@ class LIBPROTOBUF_EXPORT RepeatedPtrFieldBase { void Delete(int index); template <typename TypeHandler> typename TypeHandler::Type* Add(typename TypeHandler::Type* prototype = NULL); +#if LANG_CXX11 + template <typename TypeHandler> + void Add(typename TypeHandler::Type&& value, + std::enable_if<TypeHandler::Moveable>* dummy = NULL); +#endif template <typename TypeHandler> void RemoveLast(); @@ -575,6 +580,9 @@ template <typename GenericType> class GenericTypeHandler { public: typedef GenericType Type; +#if LANG_CXX11 + static const bool Moveable = false; +#endif static inline GenericType* New(Arena* arena) { return ::google::protobuf::Arena::CreateMaybeMessage<Type>( arena, static_cast<GenericType*>(0)); @@ -690,10 +698,20 @@ inline const Message& GenericTypeHandler<Message>::default_instance() { class StringTypeHandler { public: typedef string Type; +#if LANG_CXX11 + static const bool Moveable = + std::is_move_constructible<Type>::value && + std::is_move_assignable<Type>::value; +#endif static inline string* New(Arena* arena) { return Arena::Create<string>(arena); } +#if LANG_CXX11 + static inline string* New(Arena* arena, std::string&& value) { + return Arena::Create<string>(arena, std::move(value)); + } +#endif static inline string* NewFromPrototype(const string*, ::google::protobuf::Arena* arena) { return New(arena); @@ -743,6 +761,9 @@ class RepeatedPtrField PROTOBUF_FINAL : public internal::RepeatedPtrFieldBase { const Element& Get(int index) const; Element* Mutable(int index); Element* Add(); +#if LANG_CXX11 + void Add(Element&& value); +#endif const Element& operator[](int index) const { return Get(index); } Element& operator[](int index) { return *Mutable(index); } @@ -1451,6 +1472,24 @@ inline typename TypeHandler::Type* RepeatedPtrFieldBase::Add( return result; } +#if LANG_CXX11 +template <typename TypeHandler> +inline void RepeatedPtrFieldBase::Add( + typename TypeHandler::Type&& value, + std::enable_if<TypeHandler::Moveable>*) { + if (rep_ != NULL && current_size_ < rep_->allocated_size) { + cast<TypeHandler>(rep_->elements[current_size_++]) = std::move(value); + } + if (!rep_ || rep_->allocated_size == total_size_) { + Reserve(total_size_ + 1); + } + ++rep_->allocated_size; + typename TypeHandler::Type* result = + TypeHandler::New(arena_, std::move(value)); + rep_->elements[current_size_++] = result; +} +#endif + template <typename TypeHandler> inline void RepeatedPtrFieldBase::RemoveLast() { GOOGLE_DCHECK_GT(current_size_, 0); @@ -1848,6 +1887,13 @@ inline Element* RepeatedPtrField<Element>::Add() { return RepeatedPtrFieldBase::Add<TypeHandler>(); } +#if LANG_CXX11 +template <typename Element> +inline void RepeatedPtrField<Element>::Add(Element&& value) { + RepeatedPtrFieldBase::Add<TypeHandler>(std::move(value)); +} +#endif + template <typename Element> inline void RepeatedPtrField<Element>::RemoveLast() { RepeatedPtrFieldBase::RemoveLast<TypeHandler>(); diff --git a/src/google/protobuf/source_context.pb.cc b/src/google/protobuf/source_context.pb.cc index 610a9317..50e17da1 100644 --- a/src/google/protobuf/source_context.pb.cc +++ b/src/google/protobuf/source_context.pb.cc @@ -198,7 +198,8 @@ bool SourceContext::MergePartialFromCodedStream( switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // string file_name = 1; case 1: { - if (tag == 10u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(10u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_file_name())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( diff --git a/src/google/protobuf/struct.pb.cc b/src/google/protobuf/struct.pb.cc index 332a8295..a1aa51ec 100644 --- a/src/google/protobuf/struct.pb.cc +++ b/src/google/protobuf/struct.pb.cc @@ -306,7 +306,8 @@ bool Struct::MergePartialFromCodedStream( switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // map<string, .google.protobuf.Value> fields = 1; case 1: { - if (tag == 10u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(10u)) { DO_(input->IncrementRecursionDepth()); Struct_FieldsEntry::Parser< ::google::protobuf::internal::MapField< ::std::string, ::google::protobuf::Value, @@ -769,7 +770,8 @@ bool Value::MergePartialFromCodedStream( switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // .google.protobuf.NullValue null_value = 1; case 1: { - if (tag == 8u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(8u)) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -783,7 +785,8 @@ bool Value::MergePartialFromCodedStream( // double number_value = 2; case 2: { - if (tag == 17u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(17u)) { clear_kind(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< double, ::google::protobuf::internal::WireFormatLite::TYPE_DOUBLE>( @@ -797,7 +800,8 @@ bool Value::MergePartialFromCodedStream( // string string_value = 3; case 3: { - if (tag == 26u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(26u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_string_value())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -812,7 +816,8 @@ bool Value::MergePartialFromCodedStream( // bool bool_value = 4; case 4: { - if (tag == 32u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(32u)) { clear_kind(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -826,7 +831,8 @@ bool Value::MergePartialFromCodedStream( // .google.protobuf.Struct struct_value = 5; case 5: { - if (tag == 42u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(42u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_struct_value())); } else { @@ -837,7 +843,8 @@ bool Value::MergePartialFromCodedStream( // .google.protobuf.ListValue list_value = 6; case 6: { - if (tag == 50u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(50u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_list_value())); } else { @@ -1590,7 +1597,8 @@ bool ListValue::MergePartialFromCodedStream( switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // repeated .google.protobuf.Value values = 1; case 1: { - if (tag == 10u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(10u)) { DO_(input->IncrementRecursionDepth()); DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_values())); diff --git a/src/google/protobuf/stubs/hash.h b/src/google/protobuf/stubs/hash.h index bf0b88b4..be998b29 100644 --- a/src/google/protobuf/stubs/hash.h +++ b/src/google/protobuf/stubs/hash.h @@ -40,6 +40,7 @@ #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) || \ @@ -92,6 +93,10 @@ # define GOOGLE_PROTOBUF_HASH_SET_CLASS hash_set # endif +# if __GNUC__ == 4 && __GNUC__MINOR__ <= 1 +# undef GOOGLE_PROTOBUF_HAVE_64BIT_HASH +# endif + // Version checks for MSC. // Apparently Microsoft decided to move hash_map *back* to the std namespace in // MSVC 2010: diff --git a/src/google/protobuf/stubs/port.h b/src/google/protobuf/stubs/port.h index d37e8130..6f0633c4 100644 --- a/src/google/protobuf/stubs/port.h +++ b/src/google/protobuf/stubs/port.h @@ -358,7 +358,7 @@ class Bits { #endif } - static uint64 Log2FloorNonZero64(uint64 n) { + static uint32 Log2FloorNonZero64(uint64 n) { #if defined(__GNUC__) return 63 ^ __builtin_clzll(n); #else diff --git a/src/google/protobuf/timestamp.pb.cc b/src/google/protobuf/timestamp.pb.cc index c7a1179a..c1865d93 100644 --- a/src/google/protobuf/timestamp.pb.cc +++ b/src/google/protobuf/timestamp.pb.cc @@ -216,7 +216,8 @@ bool Timestamp::MergePartialFromCodedStream( switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // int64 seconds = 1; case 1: { - if (tag == 8u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(8u)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>( @@ -229,7 +230,8 @@ bool Timestamp::MergePartialFromCodedStream( // int32 nanos = 2; case 2: { - if (tag == 16u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(16u)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( diff --git a/src/google/protobuf/type.pb.cc b/src/google/protobuf/type.pb.cc index 50d7be43..017392c9 100644 --- a/src/google/protobuf/type.pb.cc +++ b/src/google/protobuf/type.pb.cc @@ -486,7 +486,8 @@ bool Type::MergePartialFromCodedStream( switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // string name = 1; case 1: { - if (tag == 10u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(10u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -501,7 +502,8 @@ bool Type::MergePartialFromCodedStream( // repeated .google.protobuf.Field fields = 2; case 2: { - if (tag == 18u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(18u)) { DO_(input->IncrementRecursionDepth()); DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_fields())); @@ -514,7 +516,8 @@ bool Type::MergePartialFromCodedStream( // repeated string oneofs = 3; case 3: { - if (tag == 26u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(26u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->add_oneofs())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -530,7 +533,8 @@ bool Type::MergePartialFromCodedStream( // repeated .google.protobuf.Option options = 4; case 4: { - if (tag == 34u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(34u)) { DO_(input->IncrementRecursionDepth()); DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_options())); @@ -543,7 +547,8 @@ bool Type::MergePartialFromCodedStream( // .google.protobuf.SourceContext source_context = 5; case 5: { - if (tag == 42u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(42u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_source_context())); } else { @@ -554,7 +559,8 @@ bool Type::MergePartialFromCodedStream( // .google.protobuf.Syntax syntax = 6; case 6: { - if (tag == 48u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(48u)) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -607,7 +613,7 @@ void Type::SerializeWithCachedSizes( } // repeated string oneofs = 3; - for (int i = 0; i < this->oneofs_size(); i++) { + for (int i = 0, n = this->oneofs_size(); i < n; i++) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->oneofs(i).data(), this->oneofs(i).length(), ::google::protobuf::internal::WireFormatLite::SERIALIZE, @@ -660,7 +666,7 @@ void Type::SerializeWithCachedSizes( } // repeated string oneofs = 3; - for (int i = 0; i < this->oneofs_size(); i++) { + for (int i = 0, n = this->oneofs_size(); i < n; i++) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->oneofs(i).data(), this->oneofs(i).length(), ::google::protobuf::internal::WireFormatLite::SERIALIZE, @@ -711,7 +717,7 @@ size_t Type::ByteSizeLong() const { // repeated string oneofs = 3; total_size += 1 * ::google::protobuf::internal::FromIntSize(this->oneofs_size()); - for (int i = 0; i < this->oneofs_size(); i++) { + for (int i = 0, n = this->oneofs_size(); i < n; i++) { total_size += ::google::protobuf::internal::WireFormatLite::StringSize( this->oneofs(i)); } @@ -957,6 +963,12 @@ void Type::set_oneofs(int index, const ::std::string& value) { // @@protoc_insertion_point(field_set:google.protobuf.Type.oneofs) oneofs_.Mutable(index)->assign(value); } +#if LANG_CXX11 +void Type::set_oneofs(int index, ::std::string&& value) { + // @@protoc_insertion_point(field_set:google.protobuf.Type.oneofs) + oneofs_.Mutable(index)->assign(std::move(value)); +} +#endif void Type::set_oneofs(int index, const char* value) { oneofs_.Mutable(index)->assign(value); // @@protoc_insertion_point(field_set_char:google.protobuf.Type.oneofs) @@ -974,6 +986,12 @@ void Type::add_oneofs(const ::std::string& value) { oneofs_.Add()->assign(value); // @@protoc_insertion_point(field_add:google.protobuf.Type.oneofs) } +#if LANG_CXX11 +void Type::add_oneofs(::std::string&& value) { + oneofs_.Add()->assign(std::move(value)); + // @@protoc_insertion_point(field_add:google.protobuf.Type.oneofs) +} +#endif void Type::add_oneofs(const char* value) { oneofs_.Add()->assign(value); // @@protoc_insertion_point(field_add_char:google.protobuf.Type.oneofs) @@ -1231,7 +1249,8 @@ bool Field::MergePartialFromCodedStream( switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // .google.protobuf.Field.Kind kind = 1; case 1: { - if (tag == 8u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(8u)) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -1245,7 +1264,8 @@ bool Field::MergePartialFromCodedStream( // .google.protobuf.Field.Cardinality cardinality = 2; case 2: { - if (tag == 16u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(16u)) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -1259,7 +1279,8 @@ bool Field::MergePartialFromCodedStream( // int32 number = 3; case 3: { - if (tag == 24u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(24u)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -1272,7 +1293,8 @@ bool Field::MergePartialFromCodedStream( // string name = 4; case 4: { - if (tag == 34u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(34u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -1287,7 +1309,8 @@ bool Field::MergePartialFromCodedStream( // string type_url = 6; case 6: { - if (tag == 50u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(50u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_type_url())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -1302,7 +1325,8 @@ bool Field::MergePartialFromCodedStream( // int32 oneof_index = 7; case 7: { - if (tag == 56u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(56u)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -1315,7 +1339,8 @@ bool Field::MergePartialFromCodedStream( // bool packed = 8; case 8: { - if (tag == 64u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(64u)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -1328,7 +1353,8 @@ bool Field::MergePartialFromCodedStream( // repeated .google.protobuf.Option options = 9; case 9: { - if (tag == 74u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(74u)) { DO_(input->IncrementRecursionDepth()); DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_options())); @@ -1341,7 +1367,8 @@ bool Field::MergePartialFromCodedStream( // string json_name = 10; case 10: { - if (tag == 82u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(82u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_json_name())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -1356,7 +1383,8 @@ bool Field::MergePartialFromCodedStream( // string default_value = 11; case 11: { - if (tag == 90u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(90u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_default_value())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -2267,7 +2295,8 @@ bool Enum::MergePartialFromCodedStream( switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // string name = 1; case 1: { - if (tag == 10u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(10u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -2282,7 +2311,8 @@ bool Enum::MergePartialFromCodedStream( // repeated .google.protobuf.EnumValue enumvalue = 2; case 2: { - if (tag == 18u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(18u)) { DO_(input->IncrementRecursionDepth()); DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_enumvalue())); @@ -2295,7 +2325,8 @@ bool Enum::MergePartialFromCodedStream( // repeated .google.protobuf.Option options = 3; case 3: { - if (tag == 26u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(26u)) { DO_(input->IncrementRecursionDepth()); DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_options())); @@ -2308,7 +2339,8 @@ bool Enum::MergePartialFromCodedStream( // .google.protobuf.SourceContext source_context = 4; case 4: { - if (tag == 34u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(34u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_source_context())); } else { @@ -2319,7 +2351,8 @@ bool Enum::MergePartialFromCodedStream( // .google.protobuf.Syntax syntax = 5; case 5: { - if (tag == 40u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(40u)) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -2876,7 +2909,8 @@ bool EnumValue::MergePartialFromCodedStream( switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // string name = 1; case 1: { - if (tag == 10u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(10u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -2891,7 +2925,8 @@ bool EnumValue::MergePartialFromCodedStream( // int32 number = 2; case 2: { - if (tag == 16u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(16u)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -2904,7 +2939,8 @@ bool EnumValue::MergePartialFromCodedStream( // repeated .google.protobuf.Option options = 3; case 3: { - if (tag == 26u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(26u)) { DO_(input->IncrementRecursionDepth()); DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_options())); @@ -3367,7 +3403,8 @@ bool Option::MergePartialFromCodedStream( switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // string name = 1; case 1: { - if (tag == 10u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(10u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -3382,7 +3419,8 @@ bool Option::MergePartialFromCodedStream( // .google.protobuf.Any value = 2; case 2: { - if (tag == 18u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(18u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_value())); } else { diff --git a/src/google/protobuf/type.pb.h b/src/google/protobuf/type.pb.h index a327e7bd..ae816008 100644 --- a/src/google/protobuf/type.pb.h +++ b/src/google/protobuf/type.pb.h @@ -254,10 +254,16 @@ class LIBPROTOBUF_EXPORT Type : public ::google::protobuf::Message /* @@protoc_i const ::std::string& oneofs(int index) const; ::std::string* mutable_oneofs(int index); void set_oneofs(int index, const ::std::string& value); + #if LANG_CXX11 + void set_oneofs(int index, ::std::string&& value); + #endif void set_oneofs(int index, const char* value); void set_oneofs(int index, const char* value, size_t size); ::std::string* add_oneofs(); void add_oneofs(const ::std::string& value); + #if LANG_CXX11 + void add_oneofs(::std::string&& value); + #endif void add_oneofs(const char* value); void add_oneofs(const char* value, size_t size); const ::google::protobuf::RepeatedPtrField< ::std::string>& oneofs() const; @@ -1144,6 +1150,12 @@ inline void Type::set_oneofs(int index, const ::std::string& value) { // @@protoc_insertion_point(field_set:google.protobuf.Type.oneofs) oneofs_.Mutable(index)->assign(value); } +#if LANG_CXX11 +inline void Type::set_oneofs(int index, ::std::string&& value) { + // @@protoc_insertion_point(field_set:google.protobuf.Type.oneofs) + oneofs_.Mutable(index)->assign(std::move(value)); +} +#endif inline void Type::set_oneofs(int index, const char* value) { oneofs_.Mutable(index)->assign(value); // @@protoc_insertion_point(field_set_char:google.protobuf.Type.oneofs) @@ -1161,6 +1173,12 @@ inline void Type::add_oneofs(const ::std::string& value) { oneofs_.Add()->assign(value); // @@protoc_insertion_point(field_add:google.protobuf.Type.oneofs) } +#if LANG_CXX11 +inline void Type::add_oneofs(::std::string&& value) { + oneofs_.Add()->assign(std::move(value)); + // @@protoc_insertion_point(field_add:google.protobuf.Type.oneofs) +} +#endif inline void Type::add_oneofs(const char* value) { oneofs_.Add()->assign(value); // @@protoc_insertion_point(field_add_char:google.protobuf.Type.oneofs) diff --git a/src/google/protobuf/unittest_proto3.proto b/src/google/protobuf/unittest_proto3.proto index f59d2178..a27b1b26 100644 --- a/src/google/protobuf/unittest_proto3.proto +++ b/src/google/protobuf/unittest_proto3.proto @@ -200,6 +200,9 @@ message TestMutualRecursionB { int32 optional_int32 = 2; } +message TestEnumAllowAlias { + TestEnumWithDupValue value = 1; +} // Test an enum that has multiple values with the same number. enum TestEnumWithDupValue { diff --git a/src/google/protobuf/util/internal/protostream_objectsource.cc b/src/google/protobuf/util/internal/protostream_objectsource.cc index 3591febf..f9fd7b01 100644 --- a/src/google/protobuf/util/internal/protostream_objectsource.cc +++ b/src/google/protobuf/util/internal/protostream_objectsource.cc @@ -120,6 +120,7 @@ ProtoStreamObjectSource::ProtoStreamObjectSource( own_typeinfo_(true), type_(type), use_lower_camel_for_enums_(false), + use_ints_for_enums_(false), recursion_depth_(0), max_recursion_depth_(kDefaultMaxRecursionDepth), render_unknown_fields_(false), @@ -135,6 +136,7 @@ ProtoStreamObjectSource::ProtoStreamObjectSource( own_typeinfo_(false), type_(type), use_lower_camel_for_enums_(false), + use_ints_for_enums_(false), recursion_depth_(0), max_recursion_depth_(kDefaultMaxRecursionDepth), render_unknown_fields_(false), @@ -858,6 +860,12 @@ Status ProtoStreamObjectSource::RenderNonMessageField( break; } + // No need to lookup enum type if we need to render int. + if (use_ints_for_enums_) { + ow->RenderInt32(field_name, buffer32); + break; + } + // Get the nested enum type for this field. // TODO(skarvaje): Avoid string manipulation. Find ways to speed this // up. diff --git a/src/google/protobuf/util/internal/protostream_objectsource.h b/src/google/protobuf/util/internal/protostream_objectsource.h index 88ca652b..63d5f455 100644 --- a/src/google/protobuf/util/internal/protostream_objectsource.h +++ b/src/google/protobuf/util/internal/protostream_objectsource.h @@ -110,6 +110,12 @@ class LIBPROTOBUF_EXPORT ProtoStreamObjectSource : public ObjectSource { use_lower_camel_for_enums_ = value; } + // Sets whether to always output enums as ints, by default this is off, and + // enums are rendered as strings. + void set_use_ints_for_enums(bool value) { + use_ints_for_enums_ = value; + } + // Sets the max recursion depth of proto message to be deserialized. Proto // messages over this depth will fail to be deserialized. // Default value is 64. @@ -285,6 +291,9 @@ class LIBPROTOBUF_EXPORT ProtoStreamObjectSource : public ObjectSource { // Whether to render enums using lowerCamelCase. Defaults to false. bool use_lower_camel_for_enums_; + // Whether to render enums as ints always. Defaults to false. + bool use_ints_for_enums_; + // Tracks current recursion depth. mutable int recursion_depth_; diff --git a/src/google/protobuf/util/internal/protostream_objectsource_test.cc b/src/google/protobuf/util/internal/protostream_objectsource_test.cc index 1286bdb9..e215c4ab 100644 --- a/src/google/protobuf/util/internal/protostream_objectsource_test.cc +++ b/src/google/protobuf/util/internal/protostream_objectsource_test.cc @@ -102,6 +102,7 @@ class ProtostreamObjectSourceTest mock_(), ow_(&mock_), use_lower_camel_for_enums_(false), + use_ints_for_enums_(false), add_trailing_zeros_(false) { helper_.ResetTypeInfo(Book::descriptor(), Proto3Message::descriptor()); } @@ -123,6 +124,7 @@ class ProtostreamObjectSourceTest google::protobuf::scoped_ptr<ProtoStreamObjectSource> os( helper_.NewProtoSource(&in_stream, GetTypeUrl(descriptor))); if (use_lower_camel_for_enums_) os->set_use_lower_camel_for_enums(true); + if (use_ints_for_enums_) os->set_use_ints_for_enums(true); os->set_max_recursion_depth(64); return os->WriteTo(&mock_); } @@ -270,6 +272,8 @@ class ProtostreamObjectSourceTest void UseLowerCamelForEnums() { use_lower_camel_for_enums_ = true; } + void UseIntsForEnums() { use_ints_for_enums_ = true; } + void AddTrailingZeros() { add_trailing_zeros_ = true; } testing::TypeInfoTestHelper helper_; @@ -277,6 +281,7 @@ class ProtostreamObjectSourceTest ::testing::NiceMock<MockObjectWriter> mock_; ExpectingObjectWriter ow_; bool use_lower_camel_for_enums_; + bool use_ints_for_enums_; bool add_trailing_zeros_; }; @@ -498,6 +503,18 @@ TEST_P(ProtostreamObjectSourceTest, EnumCaseIsUnchangedByDefault) { DoTest(book, Book::descriptor()); } +TEST_P(ProtostreamObjectSourceTest, UseIntsForEnumsTest) { + Book book; + book.set_type(Book::ACTION_AND_ADVENTURE); + + UseIntsForEnums(); + + ow_.StartObject("") + ->RenderInt32("type", 3) + ->EndObject(); + DoTest(book, Book::descriptor()); +} + TEST_P(ProtostreamObjectSourceTest, UnknownEnum) { Proto3Message message; message.set_enum_value(static_cast<Proto3Message::NestedEnum>(1234)); diff --git a/src/google/protobuf/util/json_util.cc b/src/google/protobuf/util/json_util.cc index d7ac2dba..129b6eaf 100644 --- a/src/google/protobuf/util/json_util.cc +++ b/src/google/protobuf/util/json_util.cc @@ -49,22 +49,25 @@ namespace protobuf { namespace util { namespace internal { +ZeroCopyStreamByteSink::~ZeroCopyStreamByteSink() { + stream_->BackUp(buffer_size_); +} + void ZeroCopyStreamByteSink::Append(const char* bytes, size_t len) { - while (len > 0) { - void* buffer; - int length; - if (!stream_->Next(&buffer, &length)) { - // There isn't a way for ByteSink to report errors. + while (true) { + if (len <= buffer_size_) { + memcpy(buffer_, bytes, len); + buffer_ = static_cast<char*>(buffer_) + len; + buffer_size_ -= len; return; } - if (len < length) { - memcpy(buffer, bytes, len); - stream_->BackUp(length - len); - break; - } else { - memcpy(buffer, bytes, length); - bytes += length; - len -= length; + 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; + return; } } } @@ -79,6 +82,7 @@ util::Status BinaryToJsonStream(TypeResolver* resolver, google::protobuf::Type type; RETURN_IF_ERROR(resolver->ResolveMessageType(type_url, &type)); converter::ProtoStreamObjectSource proto_source(&in_stream, resolver, type); + proto_source.set_use_ints_for_enums(options.always_print_enums_as_ints); io::CodedOutputStream out_stream(json_output); converter::JsonObjectWriter json_writer(options.add_whitespace ? " " : "", &out_stream); diff --git a/src/google/protobuf/util/json_util.h b/src/google/protobuf/util/json_util.h index 6d3cee52..53b1d1ba 100644 --- a/src/google/protobuf/util/json_util.h +++ b/src/google/protobuf/util/json_util.h @@ -61,9 +61,13 @@ struct JsonPrintOptions { // set to 0 will be omitted. Set this flag to true will override the default // behavior and print primitive fields regardless of their values. bool always_print_primitive_fields; + // Whether to always print enums as ints. By default they are rendered as + // strings. + bool always_print_enums_as_ints; JsonPrintOptions() : add_whitespace(false), - always_print_primitive_fields(false) { + always_print_primitive_fields(false), + always_print_enums_as_ints(false) { } }; @@ -172,12 +176,15 @@ namespace internal { class LIBPROTOBUF_EXPORT ZeroCopyStreamByteSink : public strings::ByteSink { public: explicit ZeroCopyStreamByteSink(io::ZeroCopyOutputStream* stream) - : stream_(stream) {} + : stream_(stream), buffer_size_(0) {} + ~ZeroCopyStreamByteSink(); virtual void Append(const char* bytes, size_t len); private: io::ZeroCopyOutputStream* stream_; + void* buffer_; + int buffer_size_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ZeroCopyStreamByteSink); }; diff --git a/src/google/protobuf/util/json_util_test.cc b/src/google/protobuf/util/json_util_test.cc index bf35ae3e..b0c2f494 100644 --- a/src/google/protobuf/util/json_util_test.cc +++ b/src/google/protobuf/util/json_util_test.cc @@ -160,6 +160,29 @@ TEST_F(JsonUtilTest, TestDefaultValues) { ToJson(m, options)); } +TEST_F(JsonUtilTest, TestAlwaysPrintEnumsAsInts) { + TestMessage orig; + orig.set_enum_value(proto3::BAR); + orig.add_repeated_enum_value(proto3::FOO); + orig.add_repeated_enum_value(proto3::BAR); + + JsonPrintOptions print_options; + print_options.always_print_enums_as_ints = true; + + string expected_json = + "{\"enumValue\":1,\"repeatedEnumValue\":[0,1]}"; + EXPECT_EQ(expected_json, ToJson(orig, print_options)); + + TestMessage parsed; + JsonParseOptions parse_options; + ASSERT_TRUE(FromJson(expected_json, &parsed, parse_options)); + + EXPECT_EQ(proto3::BAR, parsed.enum_value()); + EXPECT_EQ(2, parsed.repeated_enum_value_size()); + EXPECT_EQ(proto3::FOO, parsed.repeated_enum_value(0)); + EXPECT_EQ(proto3::BAR, parsed.repeated_enum_value(1)); +} + TEST_F(JsonUtilTest, ParseMessage) { // Some random message but good enough to verify that the parsing warpper // functions are working properly. diff --git a/src/google/protobuf/wire_format_lite.h b/src/google/protobuf/wire_format_lite.h index bc076f6b..60355144 100644 --- a/src/google/protobuf/wire_format_lite.h +++ b/src/google/protobuf/wire_format_lite.h @@ -46,6 +46,16 @@ #include <google/protobuf/message_lite.h> #include <google/protobuf/io/coded_stream.h> // for CodedOutputStream::Varint32Size +// Avoid conflict with iOS where <ConditionalMacros.h> #defines TYPE_BOOL. +// +// If some one needs the macro TYPE_BOOL in a file that includes this header, it's +// possible to bring it back using push/pop_macro as follows. +// +// #pragma push_macro("TYPE_BOOL") +// #include this header and/or all headers that need the macro to be undefined. +// #pragma pop_macro("TYPE_BOOL") +#undef TYPE_BOOL + namespace google { namespace protobuf { diff --git a/src/google/protobuf/wrappers.pb.cc b/src/google/protobuf/wrappers.pb.cc index 3b9bf7a4..d614de9d 100644 --- a/src/google/protobuf/wrappers.pb.cc +++ b/src/google/protobuf/wrappers.pb.cc @@ -312,7 +312,8 @@ bool DoubleValue::MergePartialFromCodedStream( switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // double value = 1; case 1: { - if (tag == 9u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(9u)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< double, ::google::protobuf::internal::WireFormatLite::TYPE_DOUBLE>( @@ -567,7 +568,8 @@ bool FloatValue::MergePartialFromCodedStream( switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // float value = 1; case 1: { - if (tag == 13u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(13u)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( @@ -822,7 +824,8 @@ bool Int64Value::MergePartialFromCodedStream( switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // int64 value = 1; case 1: { - if (tag == 8u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(8u)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>( @@ -1079,7 +1082,8 @@ bool UInt64Value::MergePartialFromCodedStream( switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // uint64 value = 1; case 1: { - if (tag == 8u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(8u)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint64, ::google::protobuf::internal::WireFormatLite::TYPE_UINT64>( @@ -1336,7 +1340,8 @@ bool Int32Value::MergePartialFromCodedStream( switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // int32 value = 1; case 1: { - if (tag == 8u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(8u)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -1593,7 +1598,8 @@ bool UInt32Value::MergePartialFromCodedStream( switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // uint32 value = 1; case 1: { - if (tag == 8u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(8u)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( @@ -1850,7 +1856,8 @@ bool BoolValue::MergePartialFromCodedStream( switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // bool value = 1; case 1: { - if (tag == 8u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(8u)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -2110,7 +2117,8 @@ bool StringValue::MergePartialFromCodedStream( switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // string value = 1; case 1: { - if (tag == 10u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(10u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_value())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -2437,7 +2445,8 @@ bool BytesValue::MergePartialFromCodedStream( switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // bytes value = 1; case 1: { - if (tag == 10u) { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(10u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadBytes( input, this->mutable_value())); } else { |