Sync from Piper @359788468 PROTOBUF_SYNC_PIPER
diff --git a/CHANGES.txt b/CHANGES.txt index 47cacd9..d73ef27 100644 --- a/CHANGES.txt +++ b/CHANGES.txt
@@ -1,3 +1,8 @@ +2021-02-25 version 3.15.3 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript) + + Ruby + * Ruby <2.7 now uses WeakMap too, which prevents memory leaks. (#8341) + 2021-02-23 version 3.15.2 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript) Ruby
diff --git a/Protobuf.podspec b/Protobuf.podspec index a2f415e..b2958e0 100644 --- a/Protobuf.podspec +++ b/Protobuf.podspec
@@ -5,7 +5,7 @@ # dependent projects use the :git notation to refer to the library. Pod::Spec.new do |s| s.name = 'Protobuf' - s.version = '3.15.2' + s.version = '3.15.3' s.summary = 'Protocol Buffers v.3 runtime library for Objective-C.' s.homepage = 'https://github.com/protocolbuffers/protobuf' s.license = '3-Clause BSD License'
diff --git a/conformance/conformance_cpp.cc b/conformance/conformance_cpp.cc index 9546518..d27612b 100644 --- a/conformance/conformance_cpp.cc +++ b/conformance/conformance_cpp.cc
@@ -55,6 +55,7 @@ using google::protobuf::util::NewTypeResolverForDescriptorPool; using google::protobuf::util::TypeResolver; using protobuf_test_messages::proto3::TestAllTypesProto3; +using protobuf_test_messages::proto2::TestAllTypesProto2; using std::string; static const char kTypeUrlPrefix[] = "type.googleapis.com"; @@ -102,6 +103,8 @@ void DoTest(const ConformanceRequest& request, ConformanceResponse* response) { Message *test_message; + google::protobuf::LinkMessageReflection<TestAllTypesProto2>(); + google::protobuf::LinkMessageReflection<TestAllTypesProto3>(); const Descriptor *descriptor = DescriptorPool::generated_pool()->FindMessageTypeByName( request.message_type()); if (!descriptor) {
diff --git a/csharp/Google.Protobuf.Tools.nuspec b/csharp/Google.Protobuf.Tools.nuspec index 34a381d..60c7fec 100644 --- a/csharp/Google.Protobuf.Tools.nuspec +++ b/csharp/Google.Protobuf.Tools.nuspec
@@ -5,7 +5,7 @@ <title>Google Protocol Buffers tools</title> <summary>Tools for Protocol Buffers - Google's data interchange format.</summary> <description>See project site for more info.</description> - <version>3.15.2</version> + <version>3.15.3</version> <authors>Google Inc.</authors> <owners>protobuf-packages</owners> <licenseUrl>https://github.com/protocolbuffers/protobuf/blob/master/LICENSE</licenseUrl>
diff --git a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestProto3Optional.cs b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestProto3Optional.cs index 7d3a238..b56c99e 100644 --- a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestProto3Optional.cs +++ b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestProto3Optional.cs
@@ -25,49 +25,54 @@ byte[] descriptorData = global::System.Convert.FromBase64String( string.Concat( "Ci5nb29nbGUvcHJvdG9idWYvdW5pdHRlc3RfcHJvdG8zX29wdGlvbmFsLnBy", - "b3RvEhFwcm90b2J1Zl91bml0dGVzdCKxCgoSVGVzdFByb3RvM09wdGlvbmFs", - "EhsKDm9wdGlvbmFsX2ludDMyGAEgASgFSACIAQESGwoOb3B0aW9uYWxfaW50", - "NjQYAiABKANIAYgBARIcCg9vcHRpb25hbF91aW50MzIYAyABKA1IAogBARIc", - "Cg9vcHRpb25hbF91aW50NjQYBCABKARIA4gBARIcCg9vcHRpb25hbF9zaW50", - "MzIYBSABKBFIBIgBARIcCg9vcHRpb25hbF9zaW50NjQYBiABKBJIBYgBARId", - "ChBvcHRpb25hbF9maXhlZDMyGAcgASgHSAaIAQESHQoQb3B0aW9uYWxfZml4", - "ZWQ2NBgIIAEoBkgHiAEBEh4KEW9wdGlvbmFsX3NmaXhlZDMyGAkgASgPSAiI", - "AQESHgoRb3B0aW9uYWxfc2ZpeGVkNjQYCiABKBBICYgBARIbCg5vcHRpb25h", - "bF9mbG9hdBgLIAEoAkgKiAEBEhwKD29wdGlvbmFsX2RvdWJsZRgMIAEoAUgL", - "iAEBEhoKDW9wdGlvbmFsX2Jvb2wYDSABKAhIDIgBARIcCg9vcHRpb25hbF9z", - "dHJpbmcYDiABKAlIDYgBARIbCg5vcHRpb25hbF9ieXRlcxgPIAEoDEgOiAEB", - "Eh4KDW9wdGlvbmFsX2NvcmQYECABKAlCAggBSA+IAQESWQoXb3B0aW9uYWxf", - "bmVzdGVkX21lc3NhZ2UYEiABKAsyMy5wcm90b2J1Zl91bml0dGVzdC5UZXN0", - "UHJvdG8zT3B0aW9uYWwuTmVzdGVkTWVzc2FnZUgQiAEBElkKE2xhenlfbmVz", - "dGVkX21lc3NhZ2UYEyABKAsyMy5wcm90b2J1Zl91bml0dGVzdC5UZXN0UHJv", - "dG8zT3B0aW9uYWwuTmVzdGVkTWVzc2FnZUICKAFIEYgBARJTChRvcHRpb25h", - "bF9uZXN0ZWRfZW51bRgVIAEoDjIwLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RQ", - "cm90bzNPcHRpb25hbC5OZXN0ZWRFbnVtSBKIAQESFgoOc2luZ3VsYXJfaW50", - "MzIYFiABKAUSFgoOc2luZ3VsYXJfaW50NjQYFyABKAMaJwoNTmVzdGVkTWVz", - "c2FnZRIPCgJiYhgBIAEoBUgAiAEBQgUKA19iYiJKCgpOZXN0ZWRFbnVtEg8K", - "C1VOU1BFQ0lGSUVEEAASBwoDRk9PEAESBwoDQkFSEAISBwoDQkFaEAMSEAoD", - "TkVHEP///////////wFCEQoPX29wdGlvbmFsX2ludDMyQhEKD19vcHRpb25h", - "bF9pbnQ2NEISChBfb3B0aW9uYWxfdWludDMyQhIKEF9vcHRpb25hbF91aW50", - "NjRCEgoQX29wdGlvbmFsX3NpbnQzMkISChBfb3B0aW9uYWxfc2ludDY0QhMK", - "EV9vcHRpb25hbF9maXhlZDMyQhMKEV9vcHRpb25hbF9maXhlZDY0QhQKEl9v", - "cHRpb25hbF9zZml4ZWQzMkIUChJfb3B0aW9uYWxfc2ZpeGVkNjRCEQoPX29w", - "dGlvbmFsX2Zsb2F0QhIKEF9vcHRpb25hbF9kb3VibGVCEAoOX29wdGlvbmFs", - "X2Jvb2xCEgoQX29wdGlvbmFsX3N0cmluZ0IRCg9fb3B0aW9uYWxfYnl0ZXNC", - "EAoOX29wdGlvbmFsX2NvcmRCGgoYX29wdGlvbmFsX25lc3RlZF9tZXNzYWdl", - "QhYKFF9sYXp5X25lc3RlZF9tZXNzYWdlQhcKFV9vcHRpb25hbF9uZXN0ZWRf", - "ZW51bSKJAgoZVGVzdFByb3RvM09wdGlvbmFsTWVzc2FnZRJSCg5uZXN0ZWRf", - "bWVzc2FnZRgBIAEoCzI6LnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RQcm90bzNP", - "cHRpb25hbE1lc3NhZ2UuTmVzdGVkTWVzc2FnZRJgChdvcHRpb25hbF9uZXN0", - "ZWRfbWVzc2FnZRgCIAEoCzI6LnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RQcm90", - "bzNPcHRpb25hbE1lc3NhZ2UuTmVzdGVkTWVzc2FnZUgAiAEBGhoKDU5lc3Rl", - "ZE1lc3NhZ2USCQoBcxgBIAEoCUIaChhfb3B0aW9uYWxfbmVzdGVkX21lc3Nh", - "Z2VCJQohY29tLmdvb2dsZS5wcm90b2J1Zi50ZXN0aW5nLnByb3RvUAFiBnBy", - "b3RvMw==")); + "b3RvEhFwcm90b2J1Zl91bml0dGVzdBogZ29vZ2xlL3Byb3RvYnVmL2Rlc2Ny", + "aXB0b3IucHJvdG8isQoKElRlc3RQcm90bzNPcHRpb25hbBIbCg5vcHRpb25h", + "bF9pbnQzMhgBIAEoBUgAiAEBEhsKDm9wdGlvbmFsX2ludDY0GAIgASgDSAGI", + "AQESHAoPb3B0aW9uYWxfdWludDMyGAMgASgNSAKIAQESHAoPb3B0aW9uYWxf", + "dWludDY0GAQgASgESAOIAQESHAoPb3B0aW9uYWxfc2ludDMyGAUgASgRSASI", + "AQESHAoPb3B0aW9uYWxfc2ludDY0GAYgASgSSAWIAQESHQoQb3B0aW9uYWxf", + "Zml4ZWQzMhgHIAEoB0gGiAEBEh0KEG9wdGlvbmFsX2ZpeGVkNjQYCCABKAZI", + "B4gBARIeChFvcHRpb25hbF9zZml4ZWQzMhgJIAEoD0gIiAEBEh4KEW9wdGlv", + "bmFsX3NmaXhlZDY0GAogASgQSAmIAQESGwoOb3B0aW9uYWxfZmxvYXQYCyAB", + "KAJICogBARIcCg9vcHRpb25hbF9kb3VibGUYDCABKAFIC4gBARIaCg1vcHRp", + "b25hbF9ib29sGA0gASgISAyIAQESHAoPb3B0aW9uYWxfc3RyaW5nGA4gASgJ", + "SA2IAQESGwoOb3B0aW9uYWxfYnl0ZXMYDyABKAxIDogBARIeCg1vcHRpb25h", + "bF9jb3JkGBAgASgJQgIIAUgPiAEBElkKF29wdGlvbmFsX25lc3RlZF9tZXNz", + "YWdlGBIgASgLMjMucHJvdG9idWZfdW5pdHRlc3QuVGVzdFByb3RvM09wdGlv", + "bmFsLk5lc3RlZE1lc3NhZ2VIEIgBARJZChNsYXp5X25lc3RlZF9tZXNzYWdl", + "GBMgASgLMjMucHJvdG9idWZfdW5pdHRlc3QuVGVzdFByb3RvM09wdGlvbmFs", + "Lk5lc3RlZE1lc3NhZ2VCAigBSBGIAQESUwoUb3B0aW9uYWxfbmVzdGVkX2Vu", + "dW0YFSABKA4yMC5wcm90b2J1Zl91bml0dGVzdC5UZXN0UHJvdG8zT3B0aW9u", + "YWwuTmVzdGVkRW51bUgSiAEBEhYKDnNpbmd1bGFyX2ludDMyGBYgASgFEhYK", + "DnNpbmd1bGFyX2ludDY0GBcgASgDGicKDU5lc3RlZE1lc3NhZ2USDwoCYmIY", + "ASABKAVIAIgBAUIFCgNfYmIiSgoKTmVzdGVkRW51bRIPCgtVTlNQRUNJRklF", + "RBAAEgcKA0ZPTxABEgcKA0JBUhACEgcKA0JBWhADEhAKA05FRxD/////////", + "//8BQhEKD19vcHRpb25hbF9pbnQzMkIRCg9fb3B0aW9uYWxfaW50NjRCEgoQ", + "X29wdGlvbmFsX3VpbnQzMkISChBfb3B0aW9uYWxfdWludDY0QhIKEF9vcHRp", + "b25hbF9zaW50MzJCEgoQX29wdGlvbmFsX3NpbnQ2NEITChFfb3B0aW9uYWxf", + "Zml4ZWQzMkITChFfb3B0aW9uYWxfZml4ZWQ2NEIUChJfb3B0aW9uYWxfc2Zp", + "eGVkMzJCFAoSX29wdGlvbmFsX3NmaXhlZDY0QhEKD19vcHRpb25hbF9mbG9h", + "dEISChBfb3B0aW9uYWxfZG91YmxlQhAKDl9vcHRpb25hbF9ib29sQhIKEF9v", + "cHRpb25hbF9zdHJpbmdCEQoPX29wdGlvbmFsX2J5dGVzQhAKDl9vcHRpb25h", + "bF9jb3JkQhoKGF9vcHRpb25hbF9uZXN0ZWRfbWVzc2FnZUIWChRfbGF6eV9u", + "ZXN0ZWRfbWVzc2FnZUIXChVfb3B0aW9uYWxfbmVzdGVkX2VudW0iiQIKGVRl", + "c3RQcm90bzNPcHRpb25hbE1lc3NhZ2USUgoObmVzdGVkX21lc3NhZ2UYASAB", + "KAsyOi5wcm90b2J1Zl91bml0dGVzdC5UZXN0UHJvdG8zT3B0aW9uYWxNZXNz", + "YWdlLk5lc3RlZE1lc3NhZ2USYAoXb3B0aW9uYWxfbmVzdGVkX21lc3NhZ2UY", + "AiABKAsyOi5wcm90b2J1Zl91bml0dGVzdC5UZXN0UHJvdG8zT3B0aW9uYWxN", + "ZXNzYWdlLk5lc3RlZE1lc3NhZ2VIAIgBARoaCg1OZXN0ZWRNZXNzYWdlEgkK", + "AXMYASABKAlCGgoYX29wdGlvbmFsX25lc3RlZF9tZXNzYWdlIqkBChhQcm90", + "bzNPcHRpb25hbEV4dGVuc2lvbnMyPAoPZXh0X25vX29wdGlvbmFsEh8uZ29v", + "Z2xlLnByb3RvYnVmLk1lc3NhZ2VPcHRpb25zGIjN2akBIAEoBTJBChFleHRf", + "d2l0aF9vcHRpb25hbBIfLmdvb2dsZS5wcm90b2J1Zi5NZXNzYWdlT3B0aW9u", + "cxiJzdmpASABKAWIAQE6DMDozM0KCMjozM0KEEIlCiFjb20uZ29vZ2xlLnBy", + "b3RvYnVmLnRlc3RpbmcucHJvdG9QAWIGcHJvdG8z")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, - new pbr::FileDescriptor[] { }, + new pbr::FileDescriptor[] { global::Google.Protobuf.Reflection.DescriptorReflection.Descriptor, }, new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::ProtobufUnittest.TestProto3Optional), global::ProtobufUnittest.TestProto3Optional.Parser, new[]{ "OptionalInt32", "OptionalInt64", "OptionalUint32", "OptionalUint64", "OptionalSint32", "OptionalSint64", "OptionalFixed32", "OptionalFixed64", "OptionalSfixed32", "OptionalSfixed64", "OptionalFloat", "OptionalDouble", "OptionalBool", "OptionalString", "OptionalBytes", "OptionalCord", "OptionalNestedMessage", "LazyNestedMessage", "OptionalNestedEnum", "SingularInt32", "SingularInt64" }, new[]{ "OptionalInt32", "OptionalInt64", "OptionalUint32", "OptionalUint64", "OptionalSint32", "OptionalSint64", "OptionalFixed32", "OptionalFixed64", "OptionalSfixed32", "OptionalSfixed64", "OptionalFloat", "OptionalDouble", "OptionalBool", "OptionalString", "OptionalBytes", "OptionalCord", "OptionalNestedMessage", "LazyNestedMessage", "OptionalNestedEnum" }, new[]{ typeof(global::ProtobufUnittest.TestProto3Optional.Types.NestedEnum) }, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::ProtobufUnittest.TestProto3Optional.Types.NestedMessage), global::ProtobufUnittest.TestProto3Optional.Types.NestedMessage.Parser, new[]{ "Bb" }, new[]{ "Bb" }, null, null, null)}), - new pbr::GeneratedClrTypeInfo(typeof(global::ProtobufUnittest.TestProto3OptionalMessage), global::ProtobufUnittest.TestProto3OptionalMessage.Parser, new[]{ "NestedMessage", "OptionalNestedMessage" }, new[]{ "OptionalNestedMessage" }, null, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::ProtobufUnittest.TestProto3OptionalMessage.Types.NestedMessage), global::ProtobufUnittest.TestProto3OptionalMessage.Types.NestedMessage.Parser, new[]{ "S" }, null, null, null, null)}) + new pbr::GeneratedClrTypeInfo(typeof(global::ProtobufUnittest.TestProto3OptionalMessage), global::ProtobufUnittest.TestProto3OptionalMessage.Parser, new[]{ "NestedMessage", "OptionalNestedMessage" }, new[]{ "OptionalNestedMessage" }, null, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::ProtobufUnittest.TestProto3OptionalMessage.Types.NestedMessage), global::ProtobufUnittest.TestProto3OptionalMessage.Types.NestedMessage.Parser, new[]{ "S" }, null, null, null, null)}), + new pbr::GeneratedClrTypeInfo(typeof(global::ProtobufUnittest.Proto3OptionalExtensions), global::ProtobufUnittest.Proto3OptionalExtensions.Parser, null, null, null, new pb::Extension[] { global::ProtobufUnittest.Proto3OptionalExtensions.Extensions.ExtNoOptional, global::ProtobufUnittest.Proto3OptionalExtensions.Extensions.ExtWithOptional }, null) })); } #endregion @@ -1789,6 +1794,153 @@ } + public sealed partial class Proto3OptionalExtensions : pb::IMessage<Proto3OptionalExtensions> + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + , pb::IBufferMessage + #endif + { + private static readonly pb::MessageParser<Proto3OptionalExtensions> _parser = new pb::MessageParser<Proto3OptionalExtensions>(() => new Proto3OptionalExtensions()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser<Proto3OptionalExtensions> Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::ProtobufUnittest.UnittestProto3OptionalReflection.Descriptor.MessageTypes[2]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Proto3OptionalExtensions() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Proto3OptionalExtensions(Proto3OptionalExtensions other) : this() { + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Proto3OptionalExtensions Clone() { + return new Proto3OptionalExtensions(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as Proto3OptionalExtensions); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(Proto3OptionalExtensions other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + output.WriteRawMessage(this); + #else + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(Proto3OptionalExtensions other) { + if (other == null) { + return; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + input.ReadRawMessage(this); + #else + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + } + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + } + } + } + #endif + + #region Extensions + /// <summary>Container for extensions for other messages declared in the Proto3OptionalExtensions message type.</summary> + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static partial class Extensions { + public static readonly pb::Extension<global::Google.Protobuf.Reflection.MessageOptions, int> ExtNoOptional = + new pb::Extension<global::Google.Protobuf.Reflection.MessageOptions, int>(355886728, pb::FieldCodec.ForInt32(2847093824, 0)); + public static readonly pb::Extension<global::Google.Protobuf.Reflection.MessageOptions, int> ExtWithOptional = + new pb::Extension<global::Google.Protobuf.Reflection.MessageOptions, int>(355886729, pb::FieldCodec.ForInt32(2847093832, 0)); + } + #endregion + + } + #endregion }
diff --git a/csharp/src/Google.Protobuf.Test/testprotos.pb b/csharp/src/Google.Protobuf.Test/testprotos.pb index 1569c1e..3cf55f9 100644 --- a/csharp/src/Google.Protobuf.Test/testprotos.pb +++ b/csharp/src/Google.Protobuf.Test/testprotos.pb Binary files differ
diff --git a/csharp/src/Google.Protobuf/Google.Protobuf.csproj b/csharp/src/Google.Protobuf/Google.Protobuf.csproj index 2a778f3..23517d4 100644 --- a/csharp/src/Google.Protobuf/Google.Protobuf.csproj +++ b/csharp/src/Google.Protobuf/Google.Protobuf.csproj
@@ -4,7 +4,7 @@ <Description>C# runtime library for Protocol Buffers - Google's data interchange format.</Description> <Copyright>Copyright 2015, Google Inc.</Copyright> <AssemblyTitle>Google Protocol Buffers</AssemblyTitle> - <VersionPrefix>3.15.2</VersionPrefix> + <VersionPrefix>3.15.3</VersionPrefix> <!-- C# 7.2 is required for Span/BufferWriter/ReadOnlySequence --> <LangVersion>7.2</LangVersion> <Authors>Google Inc.</Authors>
diff --git a/java/bom/pom.xml b/java/bom/pom.xml index 197cf14..cec0911 100644 --- a/java/bom/pom.xml +++ b/java/bom/pom.xml
@@ -4,7 +4,7 @@ <groupId>com.google.protobuf</groupId> <artifactId>protobuf-bom</artifactId> - <version>3.15.2</version> + <version>3.15.3</version> <packaging>pom</packaging> <name>Protocol Buffers [BOM]</name>
diff --git a/java/core/pom.xml b/java/core/pom.xml index 9b6a617..4fc530b 100644 --- a/java/core/pom.xml +++ b/java/core/pom.xml
@@ -4,7 +4,7 @@ <parent> <groupId>com.google.protobuf</groupId> <artifactId>protobuf-parent</artifactId> - <version>3.15.2</version> + <version>3.15.3</version> </parent> <artifactId>protobuf-java</artifactId>
diff --git a/java/core/src/main/java/com/google/protobuf/CodedInputStream.java b/java/core/src/main/java/com/google/protobuf/CodedInputStream.java index ff81e00..00be6f0 100644 --- a/java/core/src/main/java/com/google/protobuf/CodedInputStream.java +++ b/java/core/src/main/java/com/google/protobuf/CodedInputStream.java
@@ -2055,6 +2055,44 @@ totalBytesRetired = 0; } + /* + * The following wrapper methods exist so that InvalidProtocolBufferExceptions thrown by the + * InputStream can be differentiated from ones thrown by CodedInputStream itself. Each call to + * an InputStream method that can throw IOException must be wrapped like this. We do this + * because we sometimes need to modify IPBE instances after they are thrown far away from where + * they are thrown (ex. to add unfinished messages) and we use this signal elsewhere in the + * exception catch chain to know when to perform these operations directly or to wrap the + * exception in their own IPBE so the extra information can be communicated without trampling + * downstream information. + */ + private static int read(InputStream input, byte[] data, int offset, int length) + throws IOException { + try { + return input.read(data, offset, length); + } catch (InvalidProtocolBufferException e) { + e.setThrownFromInputStream(); + throw e; + } + } + + private static long skip(InputStream input, long length) throws IOException { + try { + return input.skip(length); + } catch (InvalidProtocolBufferException e) { + e.setThrownFromInputStream(); + throw e; + } + } + + private static int available(InputStream input) throws IOException { + try { + return input.available(); + } catch (InvalidProtocolBufferException e) { + e.setThrownFromInputStream(); + throw e; + } + } + @Override public int readTag() throws IOException { if (isAtEnd()) { @@ -2783,7 +2821,8 @@ // Here we should refill the buffer as many bytes as possible. int bytesRead = - input.read( + read( + input, buffer, bufferSize, Math.min( @@ -2905,7 +2944,7 @@ // Determine the number of bytes we need to read from the input stream. int sizeLeft = size - bufferedBytes; // TODO(nathanmittler): Consider using a value larger than DEFAULT_BUFFER_SIZE. - if (sizeLeft < DEFAULT_BUFFER_SIZE || sizeLeft <= input.available()) { + if (sizeLeft < DEFAULT_BUFFER_SIZE || sizeLeft <= available(input)) { // Either the bytes we need are known to be available, or the required buffer is // within an allowed threshold - go ahead and allocate the buffer now. final byte[] bytes = new byte[size]; @@ -2919,7 +2958,7 @@ // Fill the remaining bytes from the input stream. int tempPos = bufferedBytes; while (tempPos < bytes.length) { - int n = input.read(bytes, tempPos, size - tempPos); + int n = read(input, bytes, tempPos, size - tempPos); if (n == -1) { throw InvalidProtocolBufferException.truncatedMessage(); } @@ -3047,7 +3086,7 @@ try { while (totalSkipped < size) { int toSkip = size - totalSkipped; - long skipped = input.skip(toSkip); + long skipped = skip(input, toSkip); if (skipped < 0 || skipped > toSkip) { throw new IllegalStateException( input.getClass()
diff --git a/java/core/src/main/java/com/google/protobuf/FieldSet.java b/java/core/src/main/java/com/google/protobuf/FieldSet.java index 1d8592f..f64b50a 100644 --- a/java/core/src/main/java/com/google/protobuf/FieldSet.java +++ b/java/core/src/main/java/com/google/protobuf/FieldSet.java
@@ -282,7 +282,7 @@ // Wrap the contents in a new list so that the caller cannot change // the list's contents after setting it. - final List newList = new ArrayList(); + final List newList = new ArrayList<>(); newList.addAll((List) value); for (final Object element : newList) { verifyType(descriptor, element);
diff --git a/java/core/src/main/java/com/google/protobuf/GeneratedMessageLite.java b/java/core/src/main/java/com/google/protobuf/GeneratedMessageLite.java index 5e3ee0f..7db8f32 100644 --- a/java/core/src/main/java/com/google/protobuf/GeneratedMessageLite.java +++ b/java/core/src/main/java/com/google/protobuf/GeneratedMessageLite.java
@@ -1537,11 +1537,16 @@ Schema<T> schema = Protobuf.getInstance().schemaFor(result); schema.mergeFrom(result, CodedInputStreamReader.forCodedInput(input), extensionRegistry); schema.makeImmutable(result); + } catch (InvalidProtocolBufferException e) { + if (e.getThrownFromInputStream()) { + e = new InvalidProtocolBufferException(e); + } + throw e.setUnfinishedMessage(result); } catch (IOException e) { if (e.getCause() instanceof InvalidProtocolBufferException) { throw (InvalidProtocolBufferException) e.getCause(); } - throw new InvalidProtocolBufferException(e.getMessage()).setUnfinishedMessage(result); + throw new InvalidProtocolBufferException(e).setUnfinishedMessage(result); } catch (RuntimeException e) { if (e.getCause() instanceof InvalidProtocolBufferException) { throw (InvalidProtocolBufferException) e.getCause(); @@ -1565,11 +1570,16 @@ if (result.memoizedHashCode != 0) { throw new RuntimeException(); } + } catch (InvalidProtocolBufferException e) { + if (e.getThrownFromInputStream()) { + e = new InvalidProtocolBufferException(e); + } + throw e.setUnfinishedMessage(result); } catch (IOException e) { if (e.getCause() instanceof InvalidProtocolBufferException) { throw (InvalidProtocolBufferException) e.getCause(); } - throw new InvalidProtocolBufferException(e.getMessage()).setUnfinishedMessage(result); + throw new InvalidProtocolBufferException(e).setUnfinishedMessage(result); } catch (IndexOutOfBoundsException e) { throw InvalidProtocolBufferException.truncatedMessage().setUnfinishedMessage(result); } @@ -1727,8 +1737,13 @@ return null; } size = CodedInputStream.readRawVarint32(firstByte, input); + } catch (InvalidProtocolBufferException e) { + if (e.getThrownFromInputStream()) { + e = new InvalidProtocolBufferException(e); + } + throw e; } catch (IOException e) { - throw new InvalidProtocolBufferException(e.getMessage()); + throw new InvalidProtocolBufferException(e); } InputStream limitedInput = new LimitedInputStream(input, size); CodedInputStream codedInput = CodedInputStream.newInstance(limitedInput);
diff --git a/java/core/src/main/java/com/google/protobuf/InvalidProtocolBufferException.java b/java/core/src/main/java/com/google/protobuf/InvalidProtocolBufferException.java index 22f31bb..b47eeef 100644 --- a/java/core/src/main/java/com/google/protobuf/InvalidProtocolBufferException.java +++ b/java/core/src/main/java/com/google/protobuf/InvalidProtocolBufferException.java
@@ -41,6 +41,7 @@ public class InvalidProtocolBufferException extends IOException { private static final long serialVersionUID = -1616151763072450476L; private MessageLite unfinishedMessage = null; + private boolean wasThrownFromInputStream; public InvalidProtocolBufferException(final String description) { super(description); @@ -72,6 +73,28 @@ return unfinishedMessage; } + /** Set by CodedInputStream */ + void setThrownFromInputStream() { + /* This write can be racy if the same exception is stored and then thrown by multiple custom + * InputStreams on different threads. But since it only ever moves from false->true, there's no + * problem. A thread checking this condition after catching this exception from a delegate + * stram of CodedInputStream is guaranteed to always observe true, because a write on the same + * thread set the value when the exception left the delegate. A thread checking the same + * condition with an exception created by CodedInputStream is guaranteed to always see false, + * because the exception has not been exposed to any code that could publish it to other threads + * and cause a write. + */ + wasThrownFromInputStream = true; + } + + /** + * Allows code catching IOException from CodedInputStream to tell whether this instance was thrown + * by a delegate InputStream, rather than directly by a parse failure. + */ + boolean getThrownFromInputStream() { + return wasThrownFromInputStream; + } + /** * Unwraps the underlying {@link IOException} if this exception was caused by an I/O problem. * Otherwise, returns {@code this}.
diff --git a/java/core/src/main/java/com/google/protobuf/UnsafeUtil.java b/java/core/src/main/java/com/google/protobuf/UnsafeUtil.java index 0acf22e..dd459f0 100644 --- a/java/core/src/main/java/com/google/protobuf/UnsafeUtil.java +++ b/java/core/src/main/java/com/google/protobuf/UnsafeUtil.java
@@ -346,7 +346,7 @@ return MEMORY_ACCESSOR.supportsUnsafeByteBufferOperations(); } - private static boolean determineAndroidSupportByAddressSize(Class<?> addressClass) { + static boolean determineAndroidSupportByAddressSize(Class<?> addressClass) { if (!Android.isOnAndroidDevice()) { return false; }
diff --git a/java/lite/pom.xml b/java/lite/pom.xml index 5d307c4..478ba0e 100644 --- a/java/lite/pom.xml +++ b/java/lite/pom.xml
@@ -4,7 +4,7 @@ <parent> <groupId>com.google.protobuf</groupId> <artifactId>protobuf-parent</artifactId> - <version>3.15.2</version> + <version>3.15.3</version> </parent> <artifactId>protobuf-javalite</artifactId>
diff --git a/java/lite/src/test/java/com/google/protobuf/LiteTest.java b/java/lite/src/test/java/com/google/protobuf/LiteTest.java index 140df72..06d244a 100644 --- a/java/lite/src/test/java/com/google/protobuf/LiteTest.java +++ b/java/lite/src/test/java/com/google/protobuf/LiteTest.java
@@ -38,6 +38,7 @@ import com.google.protobuf.UnittestImportPublicLite.PublicImportMessageLite; import com.google.protobuf.UnittestLite.ForeignEnumLite; import com.google.protobuf.UnittestLite.ForeignMessageLite; +import com.google.protobuf.UnittestLite.RecursiveMessage; import com.google.protobuf.UnittestLite.TestAllExtensionsLite; import com.google.protobuf.UnittestLite.TestAllTypesLite; import com.google.protobuf.UnittestLite.TestAllTypesLite.NestedEnum; @@ -61,6 +62,7 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.io.InputStream; import java.io.OutputStream; import java.lang.reflect.Field; import java.nio.ByteBuffer; @@ -1638,6 +1640,160 @@ } } + public void testParseFromStream_IOExceptionNotLost() throws Exception { + final IOException readException = new IOException(); + try { + TestAllTypesLite.parseFrom( + CodedInputStream.newInstance( + new InputStream() { + @Override + public int read() throws IOException { + throw readException; + } + })); + fail(); + } catch (InvalidProtocolBufferException expected) { + boolean found = false; + for (Throwable exception = expected; exception != null; exception = exception.getCause()) { + if (exception == readException) { + found = true; + break; + } + } + if (!found) { + throw new AssertionError("Lost cause of parsing error", expected); + } + } + } + + public void testParseDelimitedFromStream_IOExceptionNotLost() throws Exception { + final IOException readException = new IOException(); + try { + TestAllTypesLite.parseDelimitedFrom( + new InputStream() { + @Override + public int read() throws IOException { + throw readException; + } + }); + fail(); + } catch (InvalidProtocolBufferException expected) { + boolean found = false; + for (Throwable exception = expected; exception != null; exception = exception.getCause()) { + if (exception == readException) { + found = true; + break; + } + } + if (!found) { + throw new AssertionError("Lost cause of parsing error", expected); + } + } + } + + public void testParseFromArray_manyNestedMessagesError() throws Exception { + RecursiveMessage.Builder recursiveMessage = + RecursiveMessage.newBuilder().setPayload(ByteString.copyFrom(new byte[1])); + for (int i = 0; i < 20; i++) { + recursiveMessage = RecursiveMessage.newBuilder().setRecurse(recursiveMessage.build()); + } + byte[] result = recursiveMessage.build().toByteArray(); + result[ + result.length + - CodedOutputStream.computeTagSize(RecursiveMessage.PAYLOAD_FIELD_NUMBER) + - CodedOutputStream.computeLengthDelimitedFieldSize(1)] = + 0; // Set invalid tag + try { + RecursiveMessage.parseFrom(result); + fail("Result was: " + Arrays.toString(result)); + } catch (InvalidProtocolBufferException expected) { + boolean found = false; + int exceptionCount = 0; + for (Throwable exception = expected; exception != null; exception = exception.getCause()) { + if (exception instanceof InvalidProtocolBufferException) { + exceptionCount++; + } + for (StackTraceElement element : exception.getStackTrace()) { + if (InvalidProtocolBufferException.class.getName().equals(element.getClassName()) + && "invalidTag".equals(element.getMethodName())) { + found = true; + } else if (Android.isOnAndroidDevice() + && "decodeUnknownField".equals(element.getMethodName())) { + // Android is missing the first element of the stack trace - b/181147885 + found = true; + } + } + } + if (!found) { + throw new AssertionError("Lost cause of parsing error", expected); + } + if (exceptionCount > 1) { + throw new AssertionError(exceptionCount + " nested parsing exceptions", expected); + } + } + } + + public void testParseFromStream_manyNestedMessagesError() throws Exception { + RecursiveMessage.Builder recursiveMessage = + RecursiveMessage.newBuilder().setPayload(ByteString.copyFrom(new byte[1])); + for (int i = 0; i < 20; i++) { + recursiveMessage = RecursiveMessage.newBuilder().setRecurse(recursiveMessage.build()); + } + byte[] result = recursiveMessage.build().toByteArray(); + result[ + result.length + - CodedOutputStream.computeTagSize(RecursiveMessage.PAYLOAD_FIELD_NUMBER) + - CodedOutputStream.computeLengthDelimitedFieldSize(1)] = + 0; // Set invalid tag + try { + RecursiveMessage.parseFrom(CodedInputStream.newInstance(new ByteArrayInputStream(result))); + fail("Result was: " + Arrays.toString(result)); + } catch (InvalidProtocolBufferException expected) { + boolean found = false; + int exceptionCount = 0; + for (Throwable exception = expected; exception != null; exception = exception.getCause()) { + if (exception instanceof InvalidProtocolBufferException) { + exceptionCount++; + } + for (StackTraceElement element : exception.getStackTrace()) { + if (InvalidProtocolBufferException.class.getName().equals(element.getClassName()) + && "invalidTag".equals(element.getMethodName())) { + found = true; + } else if (Android.isOnAndroidDevice() && "readTag".equals(element.getMethodName())) { + // Android is missing the first element of the stack trace - b/181147885 + found = true; + } + } + } + if (!found) { + throw new AssertionError("Lost cause of parsing error", expected); + } + if (exceptionCount > 1) { + throw new AssertionError(exceptionCount + " nested parsing exceptions", expected); + } + } + } + + public void testParseFromStream_sneakyNestedException() throws Exception { + final InvalidProtocolBufferException sketchy = + new InvalidProtocolBufferException("Created in a sketchy way!") + .setUnfinishedMessage(TestAllTypesLite.getDefaultInstance()); + try { + RecursiveMessage.parseFrom( + CodedInputStream.newInstance( + new InputStream() { + @Override + public int read() throws IOException { + throw sketchy; + } + })); + fail(); + } catch (InvalidProtocolBufferException expected) { + assertNotSame(expected, sketchy); + } + assertEquals(sketchy.getUnfinishedMessage(), TestAllTypesLite.getDefaultInstance()); + } + public void testMergeFrom_sanity() throws Exception { TestAllTypesLite one = TestUtilLite.getAllLiteSetBuilder().build(); byte[] bytes = one.toByteArray();
diff --git a/java/pom.xml b/java/pom.xml index 25b3e96..dc3e89f 100644 --- a/java/pom.xml +++ b/java/pom.xml
@@ -4,7 +4,7 @@ <groupId>com.google.protobuf</groupId> <artifactId>protobuf-parent</artifactId> - <version>3.15.2</version> + <version>3.15.3</version> <packaging>pom</packaging> <name>Protocol Buffers [Parent]</name>
diff --git a/java/util/pom.xml b/java/util/pom.xml index 778d5ea..9028b1b 100644 --- a/java/util/pom.xml +++ b/java/util/pom.xml
@@ -4,7 +4,7 @@ <parent> <groupId>com.google.protobuf</groupId> <artifactId>protobuf-parent</artifactId> - <version>3.15.2</version> + <version>3.15.3</version> </parent> <artifactId>protobuf-java-util</artifactId>
diff --git a/php/ext/google/protobuf/package.xml b/php/ext/google/protobuf/package.xml index c6990c9..75a440c 100644 --- a/php/ext/google/protobuf/package.xml +++ b/php/ext/google/protobuf/package.xml
@@ -10,11 +10,11 @@ <email>protobuf-opensource@google.com</email> <active>yes</active> </lead> - <date>2021-02-23</date> - <time>11:35:09</time> + <date>2021-02-24</date> + <time>16:49:52</time> <version> - <release>3.15.2</release> - <api>3.15.2</api> + <release>3.15.3</release> + <api>3.15.3</api> </version> <stability> <release>stable</release> @@ -835,5 +835,20 @@ <notes> </notes> </release> + <release> + <version> + <release>3.15.3</release> + <api>3.15.3</api> + </version> + <stability> + <release>stable</release> + <api>stable</api> + </stability> + <date>2021-02-24</date> + <time>16:49:52</time> + <license uri="https://opensource.org/licenses/BSD-3-Clause">3-Clause BSD License</license> + <notes> + </notes> + </release> </changelog> </package>
diff --git a/php/ext/google/protobuf/protobuf.h b/php/ext/google/protobuf/protobuf.h index 9919f4a..a03261c 100644 --- a/php/ext/google/protobuf/protobuf.h +++ b/php/ext/google/protobuf/protobuf.h
@@ -76,7 +76,7 @@ ZEND_ARG_INFO(0, value) ZEND_END_ARG_INFO() -#define PHP_PROTOBUF_VERSION "3.15.2" +#define PHP_PROTOBUF_VERSION "3.15.3" // ptr -> PHP object cache. This is a weak map that caches lazily-created // wrapper objects around upb types:
diff --git a/protoc-artifacts/pom.xml b/protoc-artifacts/pom.xml index 3dc469c..591ab09 100644 --- a/protoc-artifacts/pom.xml +++ b/protoc-artifacts/pom.xml
@@ -8,7 +8,7 @@ </parent> <groupId>com.google.protobuf</groupId> <artifactId>protoc</artifactId> - <version>3.15.2</version> + <version>3.15.3</version> <packaging>pom</packaging> <name>Protobuf Compiler</name> <description>
diff --git a/python/setup.py b/python/setup.py index f97ce48..aab240a 100755 --- a/python/setup.py +++ b/python/setup.py
@@ -279,8 +279,6 @@ "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", ], namespace_packages=['google'], packages=find_packages(
diff --git a/ruby/ext/google/protobuf_c/defs.c b/ruby/ext/google/protobuf_c/defs.c index 10ded86..1d912c1 100644 --- a/ruby/ext/google/protobuf_c/defs.c +++ b/ruby/ext/google/protobuf_c/defs.c
@@ -295,7 +295,7 @@ self->def_to_descriptor = rb_hash_new(); self->symtab = upb_symtab_new(); - ObjectCache_Add(self->symtab, ret, _upb_symtab_arena(self->symtab)); + ObjectCache_Add(self->symtab, ret); return ret; }
diff --git a/ruby/ext/google/protobuf_c/map.c b/ruby/ext/google/protobuf_c/map.c index 9d7d16b..9d0b37e 100644 --- a/ruby/ext/google/protobuf_c/map.c +++ b/ruby/ext/google/protobuf_c/map.c
@@ -93,7 +93,7 @@ if (val == Qnil) { val = Map_alloc(cMap); Map* self; - ObjectCache_Add(map, val, Arena_get(arena)); + ObjectCache_Add(map, val); TypedData_Get_Struct(val, Map, &Map_type, self); self->map = map; self->arena = arena; @@ -318,7 +318,7 @@ self->map = upb_map_new(Arena_get(self->arena), self->key_type, self->value_type_info.type); - ObjectCache_Add(self->map, _self, Arena_get(self->arena)); + ObjectCache_Add(self->map, _self); if (init_arg != Qnil) { Map_merge_into_self(_self, init_arg); @@ -590,9 +590,10 @@ */ static VALUE Map_freeze(VALUE _self) { Map* self = ruby_to_Map(_self); - - ObjectCache_Pin(self->map, _self, Arena_get(self->arena)); - RB_OBJ_FREEZE(_self); + if (!RB_OBJ_FROZEN(_self)) { + Arena_Pin(self->arena, _self); + RB_OBJ_FREEZE(_self); + } return _self; }
diff --git a/ruby/ext/google/protobuf_c/message.c b/ruby/ext/google/protobuf_c/message.c index 77b0e8b..67f2221 100644 --- a/ruby/ext/google/protobuf_c/message.c +++ b/ruby/ext/google/protobuf_c/message.c
@@ -105,7 +105,7 @@ Message* self = ruby_to_Message(self_); self->msg = msg; self->arena = arena; - ObjectCache_Add(msg, self_, Arena_get(arena)); + ObjectCache_Add(msg, self_); } VALUE Message_GetArena(VALUE msg_rb) { @@ -855,8 +855,10 @@ */ static VALUE Message_freeze(VALUE _self) { Message* self = ruby_to_Message(_self); - ObjectCache_Pin(self->msg, _self, Arena_get(self->arena)); - RB_OBJ_FREEZE(_self); + if (!RB_OBJ_FROZEN(_self)) { + Arena_Pin(self->arena, _self); + RB_OBJ_FREEZE(_self); + } return _self; }
diff --git a/ruby/ext/google/protobuf_c/protobuf.c b/ruby/ext/google/protobuf_c/protobuf.c index 737cd28..c27f30a 100644 --- a/ruby/ext/google/protobuf_c/protobuf.c +++ b/ruby/ext/google/protobuf_c/protobuf.c
@@ -167,30 +167,55 @@ // Arena // ----------------------------------------------------------------------------- -void Arena_free(void* data) { upb_arena_free(data); } +typedef struct { + upb_arena *arena; + VALUE pinned_objs; +} Arena; + +static void Arena_mark(void *data) { + Arena *arena = data; + rb_gc_mark(arena->pinned_objs); +} + +static void Arena_free(void *data) { + Arena *arena = data; + upb_arena_free(arena->arena); +} static VALUE cArena; const rb_data_type_t Arena_type = { "Google::Protobuf::Internal::Arena", - { NULL, Arena_free, NULL }, + { Arena_mark, Arena_free, NULL }, + .flags = RUBY_TYPED_FREE_IMMEDIATELY, }; static VALUE Arena_alloc(VALUE klass) { - upb_arena *arena = upb_arena_new(); + Arena *arena = ALLOC(Arena); + arena->arena = upb_arena_new(); + arena->pinned_objs = Qnil; return TypedData_Wrap_Struct(klass, &Arena_type, arena); } upb_arena *Arena_get(VALUE _arena) { - upb_arena *arena; - TypedData_Get_Struct(_arena, upb_arena, &Arena_type, arena); - return arena; + Arena *arena; + TypedData_Get_Struct(_arena, Arena, &Arena_type, arena); + return arena->arena; } VALUE Arena_new() { return Arena_alloc(cArena); } +void Arena_Pin(VALUE _arena, VALUE obj) { + Arena *arena; + TypedData_Get_Struct(_arena, Arena, &Arena_type, arena); + if (arena->pinned_objs == Qnil) { + arena->pinned_objs = rb_ary_new(); + } + rb_ary_push(arena->pinned_objs, obj); +} + void Arena_register(VALUE module) { VALUE internal = rb_define_module_under(module, "Internal"); VALUE klass = rb_define_class_under(internal, "Arena", rb_cObject); @@ -209,15 +234,37 @@ // different wrapper objects for the same C object, which saves memory and // preserves object identity. // -// We use Hash and/or WeakMap for the cache. WeakMap is faster overall -// (probably due to removal being integrated with GC) but doesn't work for Ruby -// <2.7 (see note below). We need Hash for Ruby <2.7 and for cases where we -// need to GC-root the object (notably when the object has been frozen). +// We use WeakMap for the cache. For Ruby <2.7 we also need a secondary Hash +// to store WeakMap keys because Ruby <2.7 WeakMap doesn't allow non-finalizable +// keys. #if RUBY_API_VERSION_CODE >= 20700 -#define USE_WEAK_MAP 1 +#define USE_SECONDARY_MAP 0 #else -#define USE_WEAK_MAP 0 +#define USE_SECONDARY_MAP 1 +#endif + +#if USE_SECONDARY_MAP + +// Maps Numeric -> Object. The object is then used as a key into the WeakMap. +// This is needed for Ruby <2.7 where a number cannot be a key to WeakMap. +// The object is used only for its identity; it does not contain any data. +VALUE secondary_map = Qnil; + +static void SecondaryMap_Init() { + rb_gc_register_address(&secondary_map); + secondary_map = rb_hash_new(); +} + +static VALUE SecondaryMap_Get(VALUE key) { + VALUE ret = rb_hash_lookup(secondary_map, key); + if (ret == Qnil) { + ret = rb_eval_string("Object.new"); + rb_hash_aset(secondary_map, key, ret); + } + return ret; +} + #endif static VALUE ObjectCache_GetKey(const void* key) { @@ -225,106 +272,41 @@ memcpy(&buf, &key, sizeof(key)); intptr_t key_int = (intptr_t)key; PBRUBY_ASSERT((key_int & 3) == 0); - return LL2NUM(key_int >> 2); -} - -// Strong object cache, uses regular Hash and GC-roots objects. -// - For Ruby <2.7, used for all objects. -// - For Ruby >=2.7, used only for frozen objects, so we preserve the "frozen" -// bit (since this information is not preserved at the upb level). - -VALUE strong_obj_cache = Qnil; - -static void StrongObjectCache_Init() { - rb_gc_register_address(&strong_obj_cache); - strong_obj_cache = rb_hash_new(); -} - -static void StrongObjectCache_Remove(void* key) { - VALUE key_rb = ObjectCache_GetKey(key); - PBRUBY_ASSERT(rb_hash_lookup(strong_obj_cache, key_rb) != Qnil); - rb_hash_delete(strong_obj_cache, key_rb); -} - -static VALUE StrongObjectCache_Get(const void* key) { - VALUE key_rb = ObjectCache_GetKey(key); - return rb_hash_lookup(strong_obj_cache, key_rb); -} - -static void StrongObjectCache_Add(const void* key, VALUE val, - upb_arena* arena) { - PBRUBY_ASSERT(StrongObjectCache_Get(key) == Qnil); - VALUE key_rb = ObjectCache_GetKey(key); - rb_hash_aset(strong_obj_cache, key_rb, val); - upb_arena_addcleanup(arena, (void*)key, StrongObjectCache_Remove); -} - -// Weak object cache. This speeds up the test suite significantly, so we -// presume it speeds up real code also. However we can only use it in Ruby -// >=2.7 due to: -// https://bugs.ruby-lang.org/issues/16035 - -#if USE_WEAK_MAP - -VALUE weak_obj_cache = Qnil; - -static void WeakObjectCache_Init() { - rb_gc_register_address(&weak_obj_cache); - VALUE klass = rb_eval_string("ObjectSpace::WeakMap"); - weak_obj_cache = rb_class_new_instance(0, NULL, klass); -} - -static VALUE WeakObjectCache_Get(const void* key) { - VALUE key_rb = ObjectCache_GetKey(key); - VALUE ret = rb_funcall(weak_obj_cache, rb_intern("[]"), 1, key_rb); + VALUE ret = LL2NUM(key_int >> 2); +#if USE_SECONDARY_MAP + ret = SecondaryMap_Get(ret); +#endif return ret; } -static void WeakObjectCache_Add(const void* key, VALUE val) { - PBRUBY_ASSERT(WeakObjectCache_Get(key) == Qnil); - VALUE key_rb = ObjectCache_GetKey(key); - rb_funcall(weak_obj_cache, rb_intern("[]="), 2, key_rb, val); - PBRUBY_ASSERT(WeakObjectCache_Get(key) == val); -} - -#endif - // Public ObjectCache API. +VALUE weak_obj_cache = Qnil; +ID item_get; +ID item_set; + static void ObjectCache_Init() { - StrongObjectCache_Init(); -#if USE_WEAK_MAP - WeakObjectCache_Init(); + rb_gc_register_address(&weak_obj_cache); + VALUE klass = rb_eval_string("ObjectSpace::WeakMap"); + weak_obj_cache = rb_class_new_instance(0, NULL, klass); + item_get = rb_intern("[]"); + item_set = rb_intern("[]="); +#if USE_SECONDARY_MAP + SecondaryMap_Init(); #endif } -void ObjectCache_Add(const void* key, VALUE val, upb_arena *arena) { -#if USE_WEAK_MAP - (void)arena; - WeakObjectCache_Add(key, val); -#else - StrongObjectCache_Add(key, val, arena); -#endif +void ObjectCache_Add(const void* key, VALUE val) { + PBRUBY_ASSERT(ObjectCache_Get(key) == Qnil); + VALUE key_rb = ObjectCache_GetKey(key); + rb_funcall(weak_obj_cache, item_set, 2, key_rb, val); + PBRUBY_ASSERT(ObjectCache_Get(key) == val); } // Returns the cached object for this key, if any. Otherwise returns Qnil. VALUE ObjectCache_Get(const void* key) { -#if USE_WEAK_MAP - return WeakObjectCache_Get(key); -#else - return StrongObjectCache_Get(key); -#endif -} - -void ObjectCache_Pin(const void* key, VALUE val, upb_arena *arena) { -#if USE_WEAK_MAP - PBRUBY_ASSERT(WeakObjectCache_Get(key) == val); - // This will GC-root the object, but we'll still use the weak map for - // actual lookup. - StrongObjectCache_Add(key, val, arena); -#else - // Value is already pinned, nothing to do. -#endif + VALUE key_rb = ObjectCache_GetKey(key); + return rb_funcall(weak_obj_cache, item_get, 1, key_rb); } /*
diff --git a/ruby/ext/google/protobuf_c/protobuf.h b/ruby/ext/google/protobuf_c/protobuf.h index 90fb0a2..e4873b3 100644 --- a/ruby/ext/google/protobuf_c/protobuf.h +++ b/ruby/ext/google/protobuf_c/protobuf.h
@@ -55,6 +55,13 @@ VALUE Arena_new(); upb_arena *Arena_get(VALUE arena); +// Pins this Ruby object to the lifetime of this arena, so that as long as the +// arena is alive this object will not be collected. +// +// We use this to guarantee that the "frozen" bit on the object will be +// remembered, even if the user drops their reference to this precise object. +void Arena_Pin(VALUE arena, VALUE obj); + // ----------------------------------------------------------------------------- // ObjectCache // ----------------------------------------------------------------------------- @@ -68,19 +75,11 @@ // Adds an entry to the cache. The "arena" parameter must give the arena that // "key" was allocated from. In Ruby <2.7.0, it will be used to remove the key // from the cache when the arena is destroyed. -void ObjectCache_Add(const void* key, VALUE val, upb_arena *arena); +void ObjectCache_Add(const void* key, VALUE val); // Returns the cached object for this key, if any. Otherwise returns Qnil. VALUE ObjectCache_Get(const void* key); -// Pins the previously added object so it is GC-rooted. This turns the -// reference to "val" from weak to strong. We use this to guarantee that the -// "frozen" bit on the object will be remembered, even if the user drops their -// reference to this precise object. -// -// The "arena" parameter must give the arena that "key" was allocated from. -void ObjectCache_Pin(const void* key, VALUE val, upb_arena *arena); - // ----------------------------------------------------------------------------- // StringBuilder, for inspect // -----------------------------------------------------------------------------
diff --git a/ruby/ext/google/protobuf_c/repeated_field.c b/ruby/ext/google/protobuf_c/repeated_field.c index 65ca3c6..da3e7ef 100644 --- a/ruby/ext/google/protobuf_c/repeated_field.c +++ b/ruby/ext/google/protobuf_c/repeated_field.c
@@ -88,7 +88,7 @@ if (val == Qnil) { val = RepeatedField_alloc(cRepeatedField); RepeatedField* self; - ObjectCache_Add(array, val, Arena_get(arena)); + ObjectCache_Add(array, val); TypedData_Get_Struct(val, RepeatedField, &RepeatedField_type, self); self->array = array; self->arena = arena; @@ -500,9 +500,10 @@ */ static VALUE RepeatedField_freeze(VALUE _self) { RepeatedField* self = ruby_to_RepeatedField(_self); - - ObjectCache_Pin(self->array, _self, Arena_get(self->arena)); - RB_OBJ_FREEZE(_self); + if (!RB_OBJ_FROZEN(_self)) { + Arena_Pin(self->arena, _self); + RB_OBJ_FREEZE(_self); + } return _self; } @@ -610,7 +611,7 @@ self->type_info = TypeInfo_FromClass(argc, argv, 0, &self->type_class, &ary); self->array = upb_array_new(arena, self->type_info.type); - ObjectCache_Add(self->array, _self, arena); + ObjectCache_Add(self->array, _self); if (ary != Qnil) { if (!RB_TYPE_P(ary, T_ARRAY)) {
diff --git a/ruby/google-protobuf.gemspec b/ruby/google-protobuf.gemspec index 6896a23..dde0c30 100644 --- a/ruby/google-protobuf.gemspec +++ b/ruby/google-protobuf.gemspec
@@ -1,6 +1,6 @@ Gem::Specification.new do |s| s.name = "google-protobuf" - s.version = "3.15.2" + s.version = "3.15.3" git_tag = "v#{s.version.to_s.sub('.rc.', '-rc')}" # Converts X.Y.Z.rc.N to vX.Y.Z-rcN, used for the git tag s.licenses = ["BSD-3-Clause"] s.summary = "Protocol Buffers"
diff --git a/src/google/protobuf/any.pb.cc b/src/google/protobuf/any.pb.cc index aea98c0..c16e188 100644 --- a/src/google/protobuf/any.pb.cc +++ b/src/google/protobuf/any.pb.cc
@@ -68,10 +68,8 @@ schemas, file_default_instances, TableStruct_google_2fprotobuf_2fany_2eproto::offsets, file_level_metadata_google_2fprotobuf_2fany_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fany_2eproto, file_level_service_descriptors_google_2fprotobuf_2fany_2eproto, }; -PROTOBUF_ATTRIBUTE_WEAK ::PROTOBUF_NAMESPACE_ID::Metadata -descriptor_table_google_2fprotobuf_2fany_2eproto_metadata_getter(int index) { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fany_2eproto); - return descriptor_table_google_2fprotobuf_2fany_2eproto.file_level_metadata[index]; +PROTOBUF_ATTRIBUTE_WEAK const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable* descriptor_table_google_2fprotobuf_2fany_2eproto_getter() { + return &descriptor_table_google_2fprotobuf_2fany_2eproto; } // Force running AddDescriptors() at dynamic initialization time. @@ -323,10 +321,11 @@ } ::PROTOBUF_NAMESPACE_ID::Metadata Any::GetMetadata() const { - return GetMetadataStatic(); + return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + &descriptor_table_google_2fprotobuf_2fany_2eproto_getter, &descriptor_table_google_2fprotobuf_2fany_2eproto_once, + file_level_metadata_google_2fprotobuf_2fany_2eproto[0]); } - // @@protoc_insertion_point(namespace_scope) PROTOBUF_NAMESPACE_CLOSE PROTOBUF_NAMESPACE_OPEN
diff --git a/src/google/protobuf/any.pb.h b/src/google/protobuf/any.pb.h index beef647..de52306 100644 --- a/src/google/protobuf/any.pb.h +++ b/src/google/protobuf/any.pb.h
@@ -53,7 +53,6 @@ static const ::PROTOBUF_NAMESPACE_ID::uint32 offsets[]; }; extern PROTOBUF_EXPORT const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fany_2eproto; -PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Metadata descriptor_table_google_2fprotobuf_2fany_2eproto_metadata_getter(int index); PROTOBUF_NAMESPACE_OPEN class Any; struct AnyDefaultTypeInternal; @@ -96,10 +95,10 @@ return GetDescriptor(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; + return default_instance().GetMetadata().descriptor; } static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; + return default_instance().GetMetadata().reflection; } static const Any& default_instance() { return *internal_default_instance(); @@ -200,12 +199,6 @@ public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - return ::descriptor_table_google_2fprotobuf_2fany_2eproto_metadata_getter(kIndexInFileMessages); - } - - public: // nested types ---------------------------------------------------- @@ -218,10 +211,8 @@ // string type_url = 1; void clear_type_url(); const std::string& type_url() const; - void set_type_url(const std::string& value); - void set_type_url(std::string&& value); - void set_type_url(const char* value); - void set_type_url(const char* value, size_t size); + template <typename ArgT0 = const std::string&, typename... ArgT> + void set_type_url(ArgT0&& arg0, ArgT... args); std::string* mutable_type_url(); std::string* release_type_url(); void set_allocated_type_url(std::string* type_url); @@ -234,10 +225,8 @@ // bytes value = 2; void clear_value(); const std::string& value() const; - void set_value(const std::string& value); - void set_value(std::string&& value); - void set_value(const char* value); - void set_value(const void* value, size_t size); + template <typename ArgT0 = const std::string&, typename... ArgT> + void set_value(ArgT0&& arg0, ArgT... args); std::string* mutable_value(); std::string* release_value(); void set_allocated_value(std::string* value); @@ -279,8 +268,11 @@ // @@protoc_insertion_point(field_get:google.protobuf.Any.type_url) return _internal_type_url(); } -inline void Any::set_type_url(const std::string& value) { - _internal_set_type_url(value); +template <typename ArgT0, typename... ArgT> +PROTOBUF_ALWAYS_INLINE +inline void Any::set_type_url(ArgT0&& arg0, ArgT... args) { + + type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); // @@protoc_insertion_point(field_set:google.protobuf.Any.type_url) } inline std::string* Any::mutable_type_url() { @@ -294,25 +286,6 @@ type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); } -inline void Any::set_type_url(std::string&& value) { - - type_url_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Any.type_url) -} -inline void Any::set_type_url(const char* value) { - GOOGLE_DCHECK(value != nullptr); - - type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:google.protobuf.Any.type_url) -} -inline void Any::set_type_url(const char* value, - size_t size) { - - type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast<const char*>(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.Any.type_url) -} inline std::string* Any::_internal_mutable_type_url() { return type_url_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); @@ -340,8 +313,11 @@ // @@protoc_insertion_point(field_get:google.protobuf.Any.value) return _internal_value(); } -inline void Any::set_value(const std::string& value) { - _internal_set_value(value); +template <typename ArgT0, typename... ArgT> +PROTOBUF_ALWAYS_INLINE +inline void Any::set_value(ArgT0&& arg0, ArgT... args) { + + value_.SetBytes(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); // @@protoc_insertion_point(field_set:google.protobuf.Any.value) } inline std::string* Any::mutable_value() { @@ -355,25 +331,6 @@ value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); } -inline void Any::set_value(std::string&& value) { - - value_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Any.value) -} -inline void Any::set_value(const char* value) { - GOOGLE_DCHECK(value != nullptr); - - value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:google.protobuf.Any.value) -} -inline void Any::set_value(const void* value, - size_t size) { - - value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast<const char*>(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.Any.value) -} inline std::string* Any::_internal_mutable_value() { return value_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena());
diff --git a/src/google/protobuf/api.pb.cc b/src/google/protobuf/api.pb.cc index c26b213..1ee6112 100644 --- a/src/google/protobuf/api.pb.cc +++ b/src/google/protobuf/api.pb.cc
@@ -150,10 +150,8 @@ schemas, file_default_instances, TableStruct_google_2fprotobuf_2fapi_2eproto::offsets, file_level_metadata_google_2fprotobuf_2fapi_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fapi_2eproto, file_level_service_descriptors_google_2fprotobuf_2fapi_2eproto, }; -PROTOBUF_ATTRIBUTE_WEAK ::PROTOBUF_NAMESPACE_ID::Metadata -descriptor_table_google_2fprotobuf_2fapi_2eproto_metadata_getter(int index) { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fapi_2eproto); - return descriptor_table_google_2fprotobuf_2fapi_2eproto.file_level_metadata[index]; +PROTOBUF_ATTRIBUTE_WEAK const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable* descriptor_table_google_2fprotobuf_2fapi_2eproto_getter() { + return &descriptor_table_google_2fprotobuf_2fapi_2eproto; } // Force running AddDescriptors() at dynamic initialization time. @@ -575,10 +573,11 @@ } ::PROTOBUF_NAMESPACE_ID::Metadata Api::GetMetadata() const { - return GetMetadataStatic(); + return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + &descriptor_table_google_2fprotobuf_2fapi_2eproto_getter, &descriptor_table_google_2fprotobuf_2fapi_2eproto_once, + file_level_metadata_google_2fprotobuf_2fapi_2eproto[0]); } - // =================================================================== class Method::_Internal { @@ -968,10 +967,11 @@ } ::PROTOBUF_NAMESPACE_ID::Metadata Method::GetMetadata() const { - return GetMetadataStatic(); + return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + &descriptor_table_google_2fprotobuf_2fapi_2eproto_getter, &descriptor_table_google_2fprotobuf_2fapi_2eproto_once, + file_level_metadata_google_2fprotobuf_2fapi_2eproto[1]); } - // =================================================================== class Mixin::_Internal { @@ -1206,10 +1206,11 @@ } ::PROTOBUF_NAMESPACE_ID::Metadata Mixin::GetMetadata() const { - return GetMetadataStatic(); + return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + &descriptor_table_google_2fprotobuf_2fapi_2eproto_getter, &descriptor_table_google_2fprotobuf_2fapi_2eproto_once, + file_level_metadata_google_2fprotobuf_2fapi_2eproto[2]); } - // @@protoc_insertion_point(namespace_scope) PROTOBUF_NAMESPACE_CLOSE PROTOBUF_NAMESPACE_OPEN
diff --git a/src/google/protobuf/api.pb.h b/src/google/protobuf/api.pb.h index aa202b4..ee9f92b 100644 --- a/src/google/protobuf/api.pb.h +++ b/src/google/protobuf/api.pb.h
@@ -55,7 +55,6 @@ static const ::PROTOBUF_NAMESPACE_ID::uint32 offsets[]; }; extern PROTOBUF_EXPORT const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fapi_2eproto; -PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Metadata descriptor_table_google_2fprotobuf_2fapi_2eproto_metadata_getter(int index); PROTOBUF_NAMESPACE_OPEN class Api; struct ApiDefaultTypeInternal; @@ -106,10 +105,10 @@ return GetDescriptor(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; + return default_instance().GetMetadata().descriptor; } static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; + return default_instance().GetMetadata().reflection; } static const Api& default_instance() { return *internal_default_instance(); @@ -177,12 +176,6 @@ public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - return ::descriptor_table_google_2fprotobuf_2fapi_2eproto_metadata_getter(kIndexInFileMessages); - } - - public: // nested types ---------------------------------------------------- @@ -254,10 +247,8 @@ // string name = 1; void clear_name(); const std::string& name() const; - void set_name(const std::string& value); - void set_name(std::string&& value); - void set_name(const char* value); - void set_name(const char* value, size_t size); + template <typename ArgT0 = const std::string&, typename... ArgT> + void set_name(ArgT0&& arg0, ArgT... args); std::string* mutable_name(); std::string* release_name(); void set_allocated_name(std::string* name); @@ -270,10 +261,8 @@ // string version = 4; void clear_version(); const std::string& version() const; - void set_version(const std::string& value); - void set_version(std::string&& value); - void set_version(const char* value); - void set_version(const char* value, size_t size); + template <typename ArgT0 = const std::string&, typename... ArgT> + void set_version(ArgT0&& arg0, ArgT... args); std::string* mutable_version(); std::string* release_version(); void set_allocated_version(std::string* version); @@ -359,10 +348,10 @@ return GetDescriptor(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; + return default_instance().GetMetadata().descriptor; } static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; + return default_instance().GetMetadata().reflection; } static const Method& default_instance() { return *internal_default_instance(); @@ -430,12 +419,6 @@ public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - return ::descriptor_table_google_2fprotobuf_2fapi_2eproto_metadata_getter(kIndexInFileMessages); - } - - public: // nested types ---------------------------------------------------- @@ -471,10 +454,8 @@ // string name = 1; void clear_name(); const std::string& name() const; - void set_name(const std::string& value); - void set_name(std::string&& value); - void set_name(const char* value); - void set_name(const char* value, size_t size); + template <typename ArgT0 = const std::string&, typename... ArgT> + void set_name(ArgT0&& arg0, ArgT... args); std::string* mutable_name(); std::string* release_name(); void set_allocated_name(std::string* name); @@ -487,10 +468,8 @@ // string request_type_url = 2; void clear_request_type_url(); const std::string& request_type_url() const; - void set_request_type_url(const std::string& value); - void set_request_type_url(std::string&& value); - void set_request_type_url(const char* value); - void set_request_type_url(const char* value, size_t size); + template <typename ArgT0 = const std::string&, typename... ArgT> + void set_request_type_url(ArgT0&& arg0, ArgT... args); std::string* mutable_request_type_url(); std::string* release_request_type_url(); void set_allocated_request_type_url(std::string* request_type_url); @@ -503,10 +482,8 @@ // string response_type_url = 4; void clear_response_type_url(); const std::string& response_type_url() const; - void set_response_type_url(const std::string& value); - void set_response_type_url(std::string&& value); - void set_response_type_url(const char* value); - void set_response_type_url(const char* value, size_t size); + template <typename ArgT0 = const std::string&, typename... ArgT> + void set_response_type_url(ArgT0&& arg0, ArgT... args); std::string* mutable_response_type_url(); std::string* release_response_type_url(); void set_allocated_response_type_url(std::string* response_type_url); @@ -592,10 +569,10 @@ return GetDescriptor(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; + return default_instance().GetMetadata().descriptor; } static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; + return default_instance().GetMetadata().reflection; } static const Mixin& default_instance() { return *internal_default_instance(); @@ -663,12 +640,6 @@ public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - return ::descriptor_table_google_2fprotobuf_2fapi_2eproto_metadata_getter(kIndexInFileMessages); - } - - public: // nested types ---------------------------------------------------- @@ -681,10 +652,8 @@ // string name = 1; void clear_name(); const std::string& name() const; - void set_name(const std::string& value); - void set_name(std::string&& value); - void set_name(const char* value); - void set_name(const char* value, size_t size); + template <typename ArgT0 = const std::string&, typename... ArgT> + void set_name(ArgT0&& arg0, ArgT... args); std::string* mutable_name(); std::string* release_name(); void set_allocated_name(std::string* name); @@ -697,10 +666,8 @@ // string root = 2; void clear_root(); const std::string& root() const; - void set_root(const std::string& value); - void set_root(std::string&& value); - void set_root(const char* value); - void set_root(const char* value, size_t size); + template <typename ArgT0 = const std::string&, typename... ArgT> + void set_root(ArgT0&& arg0, ArgT... args); std::string* mutable_root(); std::string* release_root(); void set_allocated_root(std::string* root); @@ -741,8 +708,11 @@ // @@protoc_insertion_point(field_get:google.protobuf.Api.name) return _internal_name(); } -inline void Api::set_name(const std::string& value) { - _internal_set_name(value); +template <typename ArgT0, typename... ArgT> +PROTOBUF_ALWAYS_INLINE +inline void Api::set_name(ArgT0&& arg0, ArgT... args) { + + name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); // @@protoc_insertion_point(field_set:google.protobuf.Api.name) } inline std::string* Api::mutable_name() { @@ -756,25 +726,6 @@ name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); } -inline void Api::set_name(std::string&& value) { - - name_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Api.name) -} -inline void Api::set_name(const char* value) { - GOOGLE_DCHECK(value != nullptr); - - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:google.protobuf.Api.name) -} -inline void Api::set_name(const char* value, - size_t size) { - - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast<const char*>(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.Api.name) -} inline std::string* Api::_internal_mutable_name() { return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); @@ -877,8 +828,11 @@ // @@protoc_insertion_point(field_get:google.protobuf.Api.version) return _internal_version(); } -inline void Api::set_version(const std::string& value) { - _internal_set_version(value); +template <typename ArgT0, typename... ArgT> +PROTOBUF_ALWAYS_INLINE +inline void Api::set_version(ArgT0&& arg0, ArgT... args) { + + version_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); // @@protoc_insertion_point(field_set:google.protobuf.Api.version) } inline std::string* Api::mutable_version() { @@ -892,25 +846,6 @@ version_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); } -inline void Api::set_version(std::string&& value) { - - version_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Api.version) -} -inline void Api::set_version(const char* value) { - GOOGLE_DCHECK(value != nullptr); - - version_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:google.protobuf.Api.version) -} -inline void Api::set_version(const char* value, - size_t size) { - - version_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast<const char*>(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.Api.version) -} inline std::string* Api::_internal_mutable_version() { return version_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); @@ -1078,8 +1013,11 @@ // @@protoc_insertion_point(field_get:google.protobuf.Method.name) return _internal_name(); } -inline void Method::set_name(const std::string& value) { - _internal_set_name(value); +template <typename ArgT0, typename... ArgT> +PROTOBUF_ALWAYS_INLINE +inline void Method::set_name(ArgT0&& arg0, ArgT... args) { + + name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); // @@protoc_insertion_point(field_set:google.protobuf.Method.name) } inline std::string* Method::mutable_name() { @@ -1093,25 +1031,6 @@ name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); } -inline void Method::set_name(std::string&& value) { - - name_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Method.name) -} -inline void Method::set_name(const char* value) { - GOOGLE_DCHECK(value != nullptr); - - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:google.protobuf.Method.name) -} -inline void Method::set_name(const char* value, - size_t size) { - - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast<const char*>(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.Method.name) -} inline std::string* Method::_internal_mutable_name() { return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); @@ -1139,8 +1058,11 @@ // @@protoc_insertion_point(field_get:google.protobuf.Method.request_type_url) return _internal_request_type_url(); } -inline void Method::set_request_type_url(const std::string& value) { - _internal_set_request_type_url(value); +template <typename ArgT0, typename... ArgT> +PROTOBUF_ALWAYS_INLINE +inline void Method::set_request_type_url(ArgT0&& arg0, ArgT... args) { + + request_type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); // @@protoc_insertion_point(field_set:google.protobuf.Method.request_type_url) } inline std::string* Method::mutable_request_type_url() { @@ -1154,25 +1076,6 @@ request_type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); } -inline void Method::set_request_type_url(std::string&& value) { - - request_type_url_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Method.request_type_url) -} -inline void Method::set_request_type_url(const char* value) { - GOOGLE_DCHECK(value != nullptr); - - request_type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:google.protobuf.Method.request_type_url) -} -inline void Method::set_request_type_url(const char* value, - size_t size) { - - request_type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast<const char*>(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.Method.request_type_url) -} inline std::string* Method::_internal_mutable_request_type_url() { return request_type_url_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); @@ -1220,8 +1123,11 @@ // @@protoc_insertion_point(field_get:google.protobuf.Method.response_type_url) return _internal_response_type_url(); } -inline void Method::set_response_type_url(const std::string& value) { - _internal_set_response_type_url(value); +template <typename ArgT0, typename... ArgT> +PROTOBUF_ALWAYS_INLINE +inline void Method::set_response_type_url(ArgT0&& arg0, ArgT... args) { + + response_type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); // @@protoc_insertion_point(field_set:google.protobuf.Method.response_type_url) } inline std::string* Method::mutable_response_type_url() { @@ -1235,25 +1141,6 @@ response_type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); } -inline void Method::set_response_type_url(std::string&& value) { - - response_type_url_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Method.response_type_url) -} -inline void Method::set_response_type_url(const char* value) { - GOOGLE_DCHECK(value != nullptr); - - response_type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:google.protobuf.Method.response_type_url) -} -inline void Method::set_response_type_url(const char* value, - size_t size) { - - response_type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast<const char*>(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.Method.response_type_url) -} inline std::string* Method::_internal_mutable_response_type_url() { return response_type_url_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); @@ -1361,8 +1248,11 @@ // @@protoc_insertion_point(field_get:google.protobuf.Mixin.name) return _internal_name(); } -inline void Mixin::set_name(const std::string& value) { - _internal_set_name(value); +template <typename ArgT0, typename... ArgT> +PROTOBUF_ALWAYS_INLINE +inline void Mixin::set_name(ArgT0&& arg0, ArgT... args) { + + name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); // @@protoc_insertion_point(field_set:google.protobuf.Mixin.name) } inline std::string* Mixin::mutable_name() { @@ -1376,25 +1266,6 @@ name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); } -inline void Mixin::set_name(std::string&& value) { - - name_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Mixin.name) -} -inline void Mixin::set_name(const char* value) { - GOOGLE_DCHECK(value != nullptr); - - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:google.protobuf.Mixin.name) -} -inline void Mixin::set_name(const char* value, - size_t size) { - - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast<const char*>(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.Mixin.name) -} inline std::string* Mixin::_internal_mutable_name() { return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); @@ -1422,8 +1293,11 @@ // @@protoc_insertion_point(field_get:google.protobuf.Mixin.root) return _internal_root(); } -inline void Mixin::set_root(const std::string& value) { - _internal_set_root(value); +template <typename ArgT0, typename... ArgT> +PROTOBUF_ALWAYS_INLINE +inline void Mixin::set_root(ArgT0&& arg0, ArgT... args) { + + root_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); // @@protoc_insertion_point(field_set:google.protobuf.Mixin.root) } inline std::string* Mixin::mutable_root() { @@ -1437,25 +1311,6 @@ root_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); } -inline void Mixin::set_root(std::string&& value) { - - root_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Mixin.root) -} -inline void Mixin::set_root(const char* value) { - GOOGLE_DCHECK(value != nullptr); - - root_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:google.protobuf.Mixin.root) -} -inline void Mixin::set_root(const char* value, - size_t size) { - - root_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast<const char*>(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.Mixin.root) -} inline std::string* Mixin::_internal_mutable_root() { return root_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena());
diff --git a/src/google/protobuf/arenastring.h b/src/google/protobuf/arenastring.h index 927553c..4238579 100644 --- a/src/google/protobuf/arenastring.h +++ b/src/google/protobuf/arenastring.h
@@ -193,6 +193,34 @@ void Set(EmptyDefault, std::string&& value, ::google::protobuf::Arena* arena); void Set(NonEmptyDefault, ConstStringParam value, ::google::protobuf::Arena* arena); void Set(NonEmptyDefault, std::string&& value, ::google::protobuf::Arena* arena); + template <typename FirstParam> + void Set(FirstParam p1, const char* str, ::google::protobuf::Arena* arena) { + Set(p1, ConstStringParam(str), arena); + } + template <typename FirstParam> + void Set(FirstParam p1, const char* str, size_t size, + ::google::protobuf::Arena* arena) { + ConstStringParam sp{str, size}; // for string_view and `const string &` + Set(p1, sp, arena); + } + template <typename FirstParam, typename RefWrappedType> + void Set(FirstParam p1, + std::reference_wrapper<RefWrappedType> const_string_ref, + ::google::protobuf::Arena* arena) { + Set(p1, const_string_ref.get(), arena); + } + + template <typename FirstParam, typename SecondParam> + void SetBytes(FirstParam p1, SecondParam&& p2, ::google::protobuf::Arena* arena) { + Set(p1, static_cast<SecondParam&&>(p2), arena); + } + template <typename FirstParam> + void SetBytes(FirstParam p1, const void* str, size_t size, + ::google::protobuf::Arena* arena) { + // must work whether ConstStringParam is string_view or `const string &` + ConstStringParam sp{static_cast<const char*>(str), size}; + Set(p1, sp, arena); + } // Basic accessors. const std::string& Get() const PROTOBUF_NDEBUG_INLINE {
diff --git a/src/google/protobuf/compiler/command_line_interface.cc b/src/google/protobuf/compiler/command_line_interface.cc index 48594c4..28b0bfa 100644 --- a/src/google/protobuf/compiler/command_line_interface.cc +++ b/src/google/protobuf/compiler/command_line_interface.cc
@@ -1036,16 +1036,6 @@ } - for (auto fd : parsed_files) { - if (!AllowProto3Optional(*fd) && ContainsProto3Optional(fd)) { - std::cerr << fd->name() - << ": This file contains proto3 optional fields, but " - "--experimental_allow_proto3_optional was not set." - << std::endl; - return 1; - } - } - // We construct a separate GeneratorContext for each output location. Note // that two code generators may output to the same location, in which case // they should share a single GeneratorContext so that OpenForInsert() works. @@ -1214,13 +1204,6 @@ } // namespace -bool CommandLineInterface::AllowProto3Optional( - const FileDescriptor& file) const { - // Proto3 optional is enabled by default now, the experimental flag is no - // longer required. - return true; -} - bool CommandLineInterface::VerifyInputFilesInDescriptors( DescriptorDatabase* database) { @@ -1337,7 +1320,6 @@ source_info_in_descriptor_set_ = false; disallow_services_ = false; direct_dependencies_explicitly_set_ = false; - allow_proto3_optional_ = false; deterministic_output_ = false; } @@ -1857,8 +1839,7 @@ } else if (name == "--experimental_allow_proto3_optional") { - allow_proto3_optional_ = true; - + // Flag is no longer observed, but we allow it for backward compat. } else if (name == "--encode" || name == "--decode" || name == "--decode_raw") { if (mode_ != MODE_COMPILE) {
diff --git a/src/google/protobuf/compiler/command_line_interface.h b/src/google/protobuf/compiler/command_line_interface.h index 12ba653..4ff2471 100644 --- a/src/google/protobuf/compiler/command_line_interface.h +++ b/src/google/protobuf/compiler/command_line_interface.h
@@ -226,11 +226,6 @@ bool MakeInputsBeProtoPathRelative(DiskSourceTree* source_tree, DescriptorDatabase* fallback_database); - // Is this .proto file whitelisted, or do we have a command-line flag allowing - // us to use proto3 optional? This is a temporary control to avoid people from - // using proto3 optional until code generators have implemented it. - bool AllowProto3Optional(const FileDescriptor& file) const; - // Fails if these files use proto3 optional and the code generator doesn't // support it. This is a permanent check. bool EnforceProto3OptionalSupport( @@ -448,9 +443,6 @@ // Was the --disallow_services flag used? bool disallow_services_ = false; - // Was the --experimental_allow_proto3_optional flag used? - bool allow_proto3_optional_ = false; - // When using --encode, this will be passed to SetSerializationDeterministic. bool deterministic_output_ = false;
diff --git a/src/google/protobuf/compiler/command_line_interface_unittest.cc b/src/google/protobuf/compiler/command_line_interface_unittest.cc index 2bf0582..74dc9bf 100644 --- a/src/google/protobuf/compiler/command_line_interface_unittest.cc +++ b/src/google/protobuf/compiler/command_line_interface_unittest.cc
@@ -2378,7 +2378,6 @@ ExpectErrorText("Missing value for flag: --test_out\n"); } - TEST_F(CommandLineInterfaceTest, Proto3OptionalDisallowedNoCodegenSupport) { CreateTempFile("google/foo.proto", "syntax = \"proto3\";\n"
diff --git a/src/google/protobuf/compiler/cpp/cpp_file.cc b/src/google/protobuf/compiler/cpp/cpp_file.cc index 70941d8..d47a0d6 100644 --- a/src/google/protobuf/compiler/cpp/cpp_file.cc +++ b/src/google/protobuf/compiler/cpp/cpp_file.cc
@@ -694,10 +694,6 @@ if (!message_generators_.empty()) { format("static ::$proto_ns$::Metadata $file_level_metadata$[$1$];\n", message_generators_.size()); - } else { - format( - "static " - "constexpr ::$proto_ns$::Metadata* $file_level_metadata$ = nullptr;\n"); } if (!enum_generators_.empty()) { format( @@ -855,24 +851,30 @@ " false, $1$, $2$, $3$, \"$filename$\", \n" " &$desc_table$_once, $4$, $5$, $6$,\n" " schemas, file_default_instances, $tablename$::offsets,\n" - " $file_level_metadata$, $file_level_enum_descriptors$, " + " $7$, $file_level_enum_descriptors$, " "$file_level_service_descriptors$,\n" "};\n" // This function exists to be marked as weak. - // It can significantly speed up compilation by breaking up the SCC. + // It can significantly speed up compilation by breaking up LLVM's SCC in + // the .pb.cc tranlation units. Large translation units see a reduction of + // more than 35% of walltime for optimized builds. // Without the weak attribute all the messages in the file, including all - // the vtables and everything they use become part of the same SCC. + // the vtables and everything they use become part of the same SCC through + // a cycle like: + // GetMetadata -> descriptor table -> default instances -> + // vtables -> GetMetadata // By adding a weak function here we break the connection from the // individual vtables back into the descriptor table. - "PROTOBUF_ATTRIBUTE_WEAK ::$proto_ns$::Metadata\n" - "$desc_table$_metadata_getter(int index) {\n" - " ::$proto_ns$::internal::AssignDescriptors(&$desc_table$);\n" - " return $desc_table$.file_level_metadata[index];\n" + "PROTOBUF_ATTRIBUTE_WEAK const ::$proto_ns$::internal::DescriptorTable* " + "$desc_table$_getter() {\n" + " return &$desc_table$;\n" "}\n" "\n", eager ? "true" : "false", file_data.size(), protodef_name, num_deps == 0 ? "nullptr" : variables_["desc_table"] + "_deps", num_deps, - message_generators_.size()); + message_generators_.size(), + message_generators_.empty() ? "nullptr" + : variables_["file_level_metadata"]); // For descriptor.proto we want to avoid doing any dynamic initialization, // because in some situations that would otherwise pull in a lot of @@ -1288,9 +1290,7 @@ if (HasDescriptorMethods(file_, options_)) { format( "extern $dllexport_decl $const ::$proto_ns$::internal::DescriptorTable " - "$desc_table$;\n" - "$dllexport_decl $::$proto_ns$::Metadata " - "$desc_table$_metadata_getter(int index);\n"); + "$desc_table$;\n"); } }
diff --git a/src/google/protobuf/compiler/cpp/cpp_message.cc b/src/google/protobuf/compiler/cpp/cpp_message.cc index 4878d18..73e66ae 100644 --- a/src/google/protobuf/compiler/cpp/cpp_message.cc +++ b/src/google/protobuf/compiler/cpp/cpp_message.cc
@@ -1076,19 +1076,9 @@ if (HasDescriptorMethods(descriptor_->file(), options_)) { format( " void MergeFrom(const ::$proto_ns$::Message& other) final;\n" - " ::$proto_ns$::Metadata GetMetadata() const final;\n" - " private:\n" - " static ::$proto_ns$::Metadata GetMetadataStatic() {\n" - " ::$proto_ns$::internal::AssignDescriptors(&::$desc_table$);\n" - " return ::$desc_table$.file_level_metadata[$1$];\n" - " }\n" - "\n" - " public:\n" - "};\n", - index_in_file_messages_); - } else { - format("};\n"); + " ::$proto_ns$::Metadata GetMetadata() const final;\n"); } + format("};\n"); return; } @@ -1168,10 +1158,10 @@ // separately. format( "static const ::$proto_ns$::Descriptor* GetDescriptor() {\n" - " return GetMetadataStatic().descriptor;\n" + " return default_instance().GetMetadata().descriptor;\n" "}\n" "static const ::$proto_ns$::Reflection* GetReflection() {\n" - " return GetMetadataStatic().reflection;\n" + " return default_instance().GetMetadata().reflection;\n" "}\n"); } @@ -1380,12 +1370,6 @@ if (HasDescriptorMethods(descriptor_->file(), options_)) { format( "::$proto_ns$::Metadata GetMetadata() const final;\n" - "private:\n" - "static ::$proto_ns$::Metadata GetMetadataStatic() {\n" - " return ::$desc_table$_metadata_getter(kIndexInFileMessages);\n" - "}\n" - "\n" - "public:\n" "\n"); } else { format( @@ -1889,8 +1873,11 @@ if (HasDescriptorMethods(descriptor_->file(), options_)) { format( "::$proto_ns$::Metadata $classname$::GetMetadata() const {\n" - " return GetMetadataStatic();\n" - "}\n"); + " return ::$proto_ns$::internal::AssignDescriptors(\n" + " &$desc_table$_getter, &$desc_table$_once,\n" + " $file_level_metadata$[$1$]);\n" + "}\n", + index_in_file_messages_); format( "void $classname$::MergeFrom(\n" " const ::$proto_ns$::Message& other) {\n" @@ -2029,9 +2016,11 @@ if (HasDescriptorMethods(descriptor_->file(), options_)) { format( "::$proto_ns$::Metadata $classname$::GetMetadata() const {\n" - " return GetMetadataStatic();\n" - "}\n" - "\n"); + " return ::$proto_ns$::internal::AssignDescriptors(\n" + " &$desc_table$_getter, &$desc_table$_once,\n" + " $file_level_metadata$[$1$]);\n" + "}\n", + index_in_file_messages_); } else { format( "std::string $classname$::GetTypeName() const {\n"
diff --git a/src/google/protobuf/compiler/cpp/cpp_plugin_unittest.cc b/src/google/protobuf/compiler/cpp/cpp_plugin_unittest.cc index 31f3f0c..373f38d 100644 --- a/src/google/protobuf/compiler/cpp/cpp_plugin_unittest.cc +++ b/src/google/protobuf/compiler/cpp/cpp_plugin_unittest.cc
@@ -80,13 +80,9 @@ // Check field accessors for a required string: TryInsert("test.pb.h", "field_get:foo.Bar.requiredString", context); TryInsert("test.pb.h", "field_set:foo.Bar.requiredString", context); - TryInsert("test.pb.h", "field_set_char:foo.Bar.requiredString", context); - TryInsert("test.pb.h", "field_set_pointer:foo.Bar.requiredString", context); TryInsert("test.pb.h", "field_mutable:foo.Bar.requiredString", context); TryInsert("test.pb.h", "field_set_allocated:foo.Bar.requiredString", context); - TryInsert("test.pb.h", "field_set_char:foo.Bar.requiredString", context); - TryInsert("test.pb.h", "field_set_pointer:foo.Bar.requiredString", context); // Check field accessors for a repeated string: TryInsert("test.pb.h", "field_get:foo.Bar.repeatedString", context); @@ -104,12 +100,8 @@ // Check field accessors for a string inside oneof{}: TryInsert("test.pb.h", "field_get:foo.Bar.oneOfString", context); TryInsert("test.pb.h", "field_set:foo.Bar.oneOfString", context); - TryInsert("test.pb.h", "field_set_char:foo.Bar.oneOfString", context); - TryInsert("test.pb.h", "field_set_pointer:foo.Bar.oneOfString", context); TryInsert("test.pb.h", "field_mutable:foo.Bar.oneOfString", context); TryInsert("test.pb.h", "field_set_allocated:foo.Bar.oneOfString", context); - TryInsert("test.pb.h", "field_set_char:foo.Bar.oneOfString", context); - TryInsert("test.pb.h", "field_set_pointer:foo.Bar.oneOfString", context); // Check field accessors for an optional message: TryInsert("test.pb.h", "field_get:foo.Bar.optMessage", context);
diff --git a/src/google/protobuf/compiler/cpp/cpp_string_field.cc b/src/google/protobuf/compiler/cpp/cpp_string_field.cc index 3769437..dc9d9b8 100644 --- a/src/google/protobuf/compiler/cpp/cpp_string_field.cc +++ b/src/google/protobuf/compiler/cpp/cpp_string_field.cc
@@ -82,6 +82,8 @@ : "lazy_variable"]; (*variables)["pointer_type"] = descriptor->type() == FieldDescriptor::TYPE_BYTES ? "void" : "char"; + (*variables)["setter"] = + descriptor->type() == FieldDescriptor::TYPE_BYTES ? "SetBytes" : "Set"; (*variables)["null_check"] = (*variables)["DCHK"] + "(value != nullptr);\n"; // NOTE: Escaped here to unblock proto1->proto2 migration. // TODO(liujisi): Extend this to apply for other conflicting methods. @@ -155,19 +157,10 @@ format( "$deprecated_attr$const std::string& ${1$$name$$}$() const;\n" - "$deprecated_attr$void ${1$set_$name$$}$(const std::string& value);\n" - "$deprecated_attr$void ${1$set_$name$$}$(std::string&& value);\n" - "$deprecated_attr$void ${1$set_$name$$}$(const char* value);\n", + "template <typename ArgT0 = const std::string&, typename... ArgT>\n" + "$deprecated_attr$void ${1$set_$name$$}$(ArgT0&& arg0, ArgT... args);\n", descriptor_); - if (!options_.opensource_runtime) { - format( - "$deprecated_attr$void ${1$set_$name$$}$(::StringPiece value);\n", - descriptor_); - } format( - "$deprecated_attr$void ${1$set_$name$$}$(const $pointer_type$* " - "value, size_t size)" - ";\n" "$deprecated_attr$std::string* ${1$mutable_$name$$}$();\n" "$deprecated_attr$std::string* ${1$$release_name$$}$();\n" "$deprecated_attr$void ${1$set_allocated_$name$$}$(std::string* " @@ -202,9 +195,13 @@ format( " return _internal_$name$();\n" "}\n" - "inline void $classname$::set_$name$(const std::string& value) {\n" + "template <typename ArgT0, typename... ArgT>\n" + "PROTOBUF_ALWAYS_INLINE\n" + "inline void $classname$::set_$name$(ArgT0&& arg0, ArgT... args) {\n" "$annotate_accessor$" - " _internal_set_$name$(value);\n" + " $set_hasbit$\n" + " $name$_.$setter$($default_value_tag$, static_cast<ArgT0 &&>(arg0)," + " args..., GetArena());\n" " // @@protoc_insertion_point(field_set:$full_name$)\n" "}\n" "inline std::string* $classname$::mutable_$name$() {\n" @@ -219,40 +216,8 @@ "value) {\n" " $set_hasbit$\n" " $name$_.Set($default_value_tag$, value, GetArena());\n" - "}\n" - "inline void $classname$::set_$name$(std::string&& value) {\n" - "$annotate_accessor$" - " $set_hasbit$\n" - " $name$_.Set(\n" - " $default_value_tag$, ::std::move(value), GetArena());\n" - " // @@protoc_insertion_point(field_set_rvalue:$full_name$)\n" - "}\n" - "inline void $classname$::set_$name$(const char* value) {\n" - "$annotate_accessor$" - " $null_check$" - " $set_hasbit$\n" - " $name$_.Set($default_value_tag$, $string_piece$(value), GetArena());\n" - " // @@protoc_insertion_point(field_set_char:$full_name$)\n" "}\n"); - if (!options_.opensource_runtime) { - format( - "inline void $classname$::set_$name$(::StringPiece value) {\n" - "$annotate_accessor$" - " $set_hasbit$\n" - " $name$_.Set($default_value_tag$, value,GetArena());\n" - " // @@protoc_insertion_point(field_set_string_piece:$full_name$)\n" - "}\n"); - } format( - "inline " - "void $classname$::set_$name$(const $pointer_type$* value,\n" - " size_t size) {\n" - "$annotate_accessor$" - " $set_hasbit$\n" - " $name$_.Set($default_value_tag$, $string_piece$(\n" - " reinterpret_cast<const char*>(value), size), GetArena());\n" - " // @@protoc_insertion_point(field_set_pointer:$full_name$)\n" - "}\n" "inline std::string* $classname$::_internal_mutable_$name$() {\n" " $set_hasbit$\n" " return $name$_.Mutable($default_variable_or_tag$, GetArena());\n" @@ -431,9 +396,16 @@ " // @@protoc_insertion_point(field_get:$full_name$)\n" " return _internal_$name$();\n" "}\n" - "inline void $classname$::set_$name$(const std::string& value) {\n" + "template <typename ArgT0, typename... ArgT>\n" + "inline void $classname$::set_$name$(ArgT0&& arg0, ArgT... args) {\n" "$annotate_accessor$" - " _internal_set_$name$(value);\n" + " if (!_internal_has_$name$()) {\n" + " clear_$oneof_name$();\n" + " set_has_$name$();\n" + " $field_member$.UnsafeSetDefault($init_value$);\n" + " }\n" + " $field_member$.$setter$($default_value_tag$," + " static_cast<ArgT0 &&>(arg0), args..., GetArena());\n" " // @@protoc_insertion_point(field_set:$full_name$)\n" "}\n" "inline std::string* $classname$::mutable_$name$() {\n" @@ -455,60 +427,8 @@ " $field_member$.UnsafeSetDefault($init_value$);\n" " }\n" " $field_member$.Set($default_value_tag$, value, GetArena());\n" - "}\n" - "inline void $classname$::set_$name$(std::string&& value) {\n" - "$annotate_accessor$" - " // @@protoc_insertion_point(field_set:$full_name$)\n" - " if (!_internal_has_$name$()) {\n" - " clear_$oneof_name$();\n" - " set_has_$name$();\n" - " $field_member$.UnsafeSetDefault($init_value$);\n" - " }\n" - " $field_member$.Set(\n" - " $default_value_tag$, ::std::move(value), GetArena());\n" - " // @@protoc_insertion_point(field_set_rvalue:$full_name$)\n" - "}\n" - "inline void $classname$::set_$name$(const char* value) {\n" - "$annotate_accessor$" - " $null_check$" - " if (!_internal_has_$name$()) {\n" - " clear_$oneof_name$();\n" - " set_has_$name$();\n" - " $field_member$.UnsafeSetDefault($init_value$);\n" - " }\n" - " $field_member$.Set($default_value_tag$,\n" - " $string_piece$(value), GetArena());\n" - " // @@protoc_insertion_point(field_set_char:$full_name$)\n" "}\n"); - if (!options_.opensource_runtime) { - format( - "inline void $classname$::set_$name$(::StringPiece value) {\n" - "$annotate_accessor$" - " if (!_internal_has_$name$()) {\n" - " clear_$oneof_name$();\n" - " set_has_$name$();\n" - " $field_member$.UnsafeSetDefault($init_value$);\n" - " }\n" - " $field_member$.Set($default_value_tag$, value, GetArena());\n" - " // @@protoc_insertion_point(field_set_string_piece:$full_name$)\n" - "}\n"); - } format( - "inline " - "void $classname$::set_$name$(const $pointer_type$* value,\n" - " size_t size) {\n" - "$annotate_accessor$" - " if (!_internal_has_$name$()) {\n" - " clear_$oneof_name$();\n" - " set_has_$name$();\n" - " $field_member$.UnsafeSetDefault($init_value$);\n" - " }\n" - " $field_member$.Set(\n" - " $default_value_tag$, $string_piece$(\n" - " reinterpret_cast<const char*>(value), size),\n" - " GetArena());\n" - " // @@protoc_insertion_point(field_set_pointer:$full_name$)\n" - "}\n" "inline std::string* $classname$::_internal_mutable_$name$() {\n" " if (!_internal_has_$name$()) {\n" " clear_$oneof_name$();\n"
diff --git a/src/google/protobuf/compiler/java/java_context.cc b/src/google/protobuf/compiler/java/java_context.cc index d74a7ed..fea870f 100644 --- a/src/google/protobuf/compiler/java/java_context.cc +++ b/src/google/protobuf/compiler/java/java_context.cc
@@ -108,6 +108,7 @@ InitializeFieldGeneratorInfoForMessage(message->nested_type(i)); } std::vector<const FieldDescriptor*> fields; + fields.reserve(message->field_count()); for (int i = 0; i < message->field_count(); ++i) { fields.push_back(message->field(i)); }
diff --git a/src/google/protobuf/compiler/java/java_map_field_lite.cc b/src/google/protobuf/compiler/java/java_map_field_lite.cc index 4fa939f..63c1ad3 100644 --- a/src/google/protobuf/compiler/java/java_map_field_lite.cc +++ b/src/google/protobuf/compiler/java/java_map_field_lite.cc
@@ -95,9 +95,13 @@ // We use `x.getClass()` as a null check because it generates less bytecode // than an `if (x == null) { throw ... }` statement. (*variables)["key_null_check"] = - IsReferenceType(keyJavaType) ? "key.getClass();" : ""; + IsReferenceType(keyJavaType) + ? "java.lang.Class<?> keyClass = key.getClass();" + : ""; (*variables)["value_null_check"] = - IsReferenceType(valueJavaType) ? "value.getClass();" : ""; + IsReferenceType(valueJavaType) + ? "java.lang.Class<?> valueClass = value.getClass();" + : ""; if (GetJavaType(value) == JAVATYPE_ENUM) { // We store enums as Integers internally.
diff --git a/src/google/protobuf/compiler/java/java_message.cc b/src/google/protobuf/compiler/java/java_message.cc index f9d4e43..ba31775 100644 --- a/src/google/protobuf/compiler/java/java_message.cc +++ b/src/google/protobuf/compiler/java/java_message.cc
@@ -571,6 +571,7 @@ SortFieldsByNumber(descriptor_)); std::vector<const Descriptor::ExtensionRange*> sorted_extensions; + sorted_extensions.reserve(descriptor_->extension_range_count()); for (int i = 0; i < descriptor_->extension_range_count(); ++i) { sorted_extensions.push_back(descriptor_->extension_range(i)); }
diff --git a/src/google/protobuf/compiler/java/java_primitive_field_lite.cc b/src/google/protobuf/compiler/java/java_primitive_field_lite.cc index e807066..11facdd 100644 --- a/src/google/protobuf/compiler/java/java_primitive_field_lite.cc +++ b/src/google/protobuf/compiler/java/java_primitive_field_lite.cc
@@ -127,7 +127,8 @@ if (IsReferenceType(javaType)) { // We use `x.getClass()` as a null check because it generates less bytecode // than an `if (x == null) { throw ... }` statement. - (*variables)["null_check"] = " value.getClass();\n"; + (*variables)["null_check"] = + " java.lang.Class<?> valueClass = value.getClass();\n"; } else { (*variables)["null_check"] = ""; }
diff --git a/src/google/protobuf/compiler/java/java_string_field_lite.cc b/src/google/protobuf/compiler/java/java_string_field_lite.cc index 25bfedc..a0c2773 100644 --- a/src/google/protobuf/compiler/java/java_string_field_lite.cc +++ b/src/google/protobuf/compiler/java/java_string_field_lite.cc
@@ -77,7 +77,8 @@ WireFormat::TagSize(descriptor->number(), GetType(descriptor))); // We use `x.getClass()` as a null check because it generates less bytecode // than an `if (x == null) { throw ... }` statement. - (*variables)["null_check"] = " value.getClass();\n"; + (*variables)["null_check"] = + " java.lang.Class<?> valueClass = value.getClass();\n"; // TODO(birdo): Add @deprecated javadoc when generating javadoc is supported // by the proto compiler
diff --git a/src/google/protobuf/compiler/plugin.pb.cc b/src/google/protobuf/compiler/plugin.pb.cc index f59504d..564e237 100644 --- a/src/google/protobuf/compiler/plugin.pb.cc +++ b/src/google/protobuf/compiler/plugin.pb.cc
@@ -181,10 +181,8 @@ schemas, file_default_instances, TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto::offsets, file_level_metadata_google_2fprotobuf_2fcompiler_2fplugin_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fcompiler_2fplugin_2eproto, file_level_service_descriptors_google_2fprotobuf_2fcompiler_2fplugin_2eproto, }; -PROTOBUF_ATTRIBUTE_WEAK ::PROTOBUF_NAMESPACE_ID::Metadata -descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_metadata_getter(int index) { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto); - return descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto.file_level_metadata[index]; +PROTOBUF_ATTRIBUTE_WEAK const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable* descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_getter() { + return &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto; } // Force running AddDescriptors() at dynamic initialization time. @@ -530,10 +528,11 @@ } ::PROTOBUF_NAMESPACE_ID::Metadata Version::GetMetadata() const { - return GetMetadataStatic(); + return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_getter, &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once, + file_level_metadata_google_2fprotobuf_2fcompiler_2fplugin_2eproto[0]); } - // =================================================================== class CodeGeneratorRequest::_Internal { @@ -873,10 +872,11 @@ } ::PROTOBUF_NAMESPACE_ID::Metadata CodeGeneratorRequest::GetMetadata() const { - return GetMetadataStatic(); + return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_getter, &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once, + file_level_metadata_google_2fprotobuf_2fcompiler_2fplugin_2eproto[1]); } - // =================================================================== class CodeGeneratorResponse_File::_Internal { @@ -1235,10 +1235,11 @@ } ::PROTOBUF_NAMESPACE_ID::Metadata CodeGeneratorResponse_File::GetMetadata() const { - return GetMetadataStatic(); + return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_getter, &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once, + file_level_metadata_google_2fprotobuf_2fcompiler_2fplugin_2eproto[2]); } - // =================================================================== class CodeGeneratorResponse::_Internal { @@ -1520,10 +1521,11 @@ } ::PROTOBUF_NAMESPACE_ID::Metadata CodeGeneratorResponse::GetMetadata() const { - return GetMetadataStatic(); + return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_getter, &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once, + file_level_metadata_google_2fprotobuf_2fcompiler_2fplugin_2eproto[3]); } - // @@protoc_insertion_point(namespace_scope) } // namespace compiler PROTOBUF_NAMESPACE_CLOSE
diff --git a/src/google/protobuf/compiler/plugin.pb.h b/src/google/protobuf/compiler/plugin.pb.h index 8edc7aa..78a6d93 100644 --- a/src/google/protobuf/compiler/plugin.pb.h +++ b/src/google/protobuf/compiler/plugin.pb.h
@@ -61,7 +61,6 @@ static const ::PROTOBUF_NAMESPACE_ID::uint32 offsets[]; }; extern PROTOC_EXPORT const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto; -PROTOC_EXPORT ::PROTOBUF_NAMESPACE_ID::Metadata descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_metadata_getter(int index); PROTOBUF_NAMESPACE_OPEN namespace compiler { class CodeGeneratorRequest; @@ -149,10 +148,10 @@ return GetDescriptor(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; + return default_instance().GetMetadata().descriptor; } static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; + return default_instance().GetMetadata().reflection; } static const Version& default_instance() { return *internal_default_instance(); @@ -220,12 +219,6 @@ public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - return ::descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_metadata_getter(kIndexInFileMessages); - } - - public: // nested types ---------------------------------------------------- @@ -244,10 +237,8 @@ public: void clear_suffix(); const std::string& suffix() const; - void set_suffix(const std::string& value); - void set_suffix(std::string&& value); - void set_suffix(const char* value); - void set_suffix(const char* value, size_t size); + template <typename ArgT0 = const std::string&, typename... ArgT> + void set_suffix(ArgT0&& arg0, ArgT... args); std::string* mutable_suffix(); std::string* release_suffix(); void set_allocated_suffix(std::string* suffix); @@ -350,10 +341,10 @@ return GetDescriptor(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; + return default_instance().GetMetadata().descriptor; } static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; + return default_instance().GetMetadata().reflection; } static const CodeGeneratorRequest& default_instance() { return *internal_default_instance(); @@ -421,12 +412,6 @@ public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - return ::descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_metadata_getter(kIndexInFileMessages); - } - - public: // nested types ---------------------------------------------------- @@ -487,10 +472,8 @@ public: void clear_parameter(); const std::string& parameter() const; - void set_parameter(const std::string& value); - void set_parameter(std::string&& value); - void set_parameter(const char* value); - void set_parameter(const char* value, size_t size); + template <typename ArgT0 = const std::string&, typename... ArgT> + void set_parameter(ArgT0&& arg0, ArgT... args); std::string* mutable_parameter(); std::string* release_parameter(); void set_allocated_parameter(std::string* parameter); @@ -572,10 +555,10 @@ return GetDescriptor(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; + return default_instance().GetMetadata().descriptor; } static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; + return default_instance().GetMetadata().reflection; } static const CodeGeneratorResponse_File& default_instance() { return *internal_default_instance(); @@ -643,12 +626,6 @@ public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - return ::descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_metadata_getter(kIndexInFileMessages); - } - - public: // nested types ---------------------------------------------------- @@ -667,10 +644,8 @@ public: void clear_name(); const std::string& name() const; - void set_name(const std::string& value); - void set_name(std::string&& value); - void set_name(const char* value); - void set_name(const char* value, size_t size); + template <typename ArgT0 = const std::string&, typename... ArgT> + void set_name(ArgT0&& arg0, ArgT... args); std::string* mutable_name(); std::string* release_name(); void set_allocated_name(std::string* name); @@ -687,10 +662,8 @@ public: void clear_insertion_point(); const std::string& insertion_point() const; - void set_insertion_point(const std::string& value); - void set_insertion_point(std::string&& value); - void set_insertion_point(const char* value); - void set_insertion_point(const char* value, size_t size); + template <typename ArgT0 = const std::string&, typename... ArgT> + void set_insertion_point(ArgT0&& arg0, ArgT... args); std::string* mutable_insertion_point(); std::string* release_insertion_point(); void set_allocated_insertion_point(std::string* insertion_point); @@ -707,10 +680,8 @@ public: void clear_content(); const std::string& content() const; - void set_content(const std::string& value); - void set_content(std::string&& value); - void set_content(const char* value); - void set_content(const char* value, size_t size); + template <typename ArgT0 = const std::string&, typename... ArgT> + void set_content(ArgT0&& arg0, ArgT... args); std::string* mutable_content(); std::string* release_content(); void set_allocated_content(std::string* content); @@ -792,10 +763,10 @@ return GetDescriptor(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; + return default_instance().GetMetadata().descriptor; } static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; + return default_instance().GetMetadata().reflection; } static const CodeGeneratorResponse& default_instance() { return *internal_default_instance(); @@ -863,12 +834,6 @@ public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - return ::descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_metadata_getter(kIndexInFileMessages); - } - - public: // nested types ---------------------------------------------------- @@ -936,10 +901,8 @@ public: void clear_error(); const std::string& error() const; - void set_error(const std::string& value); - void set_error(std::string&& value); - void set_error(const char* value); - void set_error(const char* value, size_t size); + template <typename ArgT0 = const std::string&, typename... ArgT> + void set_error(ArgT0&& arg0, ArgT... args); std::string* mutable_error(); std::string* release_error(); void set_allocated_error(std::string* error); @@ -1087,8 +1050,11 @@ // @@protoc_insertion_point(field_get:google.protobuf.compiler.Version.suffix) return _internal_suffix(); } -inline void Version::set_suffix(const std::string& value) { - _internal_set_suffix(value); +template <typename ArgT0, typename... ArgT> +PROTOBUF_ALWAYS_INLINE +inline void Version::set_suffix(ArgT0&& arg0, ArgT... args) { + _has_bits_[0] |= 0x00000001u; + suffix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); // @@protoc_insertion_point(field_set:google.protobuf.compiler.Version.suffix) } inline std::string* Version::mutable_suffix() { @@ -1102,25 +1068,6 @@ _has_bits_[0] |= 0x00000001u; suffix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); } -inline void Version::set_suffix(std::string&& value) { - _has_bits_[0] |= 0x00000001u; - suffix_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.Version.suffix) -} -inline void Version::set_suffix(const char* value) { - GOOGLE_DCHECK(value != nullptr); - _has_bits_[0] |= 0x00000001u; - suffix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.Version.suffix) -} -inline void Version::set_suffix(const char* value, - size_t size) { - _has_bits_[0] |= 0x00000001u; - suffix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast<const char*>(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.Version.suffix) -} inline std::string* Version::_internal_mutable_suffix() { _has_bits_[0] |= 0x00000001u; return suffix_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); @@ -1238,8 +1185,11 @@ // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorRequest.parameter) return _internal_parameter(); } -inline void CodeGeneratorRequest::set_parameter(const std::string& value) { - _internal_set_parameter(value); +template <typename ArgT0, typename... ArgT> +PROTOBUF_ALWAYS_INLINE +inline void CodeGeneratorRequest::set_parameter(ArgT0&& arg0, ArgT... args) { + _has_bits_[0] |= 0x00000001u; + parameter_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorRequest.parameter) } inline std::string* CodeGeneratorRequest::mutable_parameter() { @@ -1253,25 +1203,6 @@ _has_bits_[0] |= 0x00000001u; parameter_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); } -inline void CodeGeneratorRequest::set_parameter(std::string&& value) { - _has_bits_[0] |= 0x00000001u; - parameter_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.CodeGeneratorRequest.parameter) -} -inline void CodeGeneratorRequest::set_parameter(const char* value) { - GOOGLE_DCHECK(value != nullptr); - _has_bits_[0] |= 0x00000001u; - parameter_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorRequest.parameter) -} -inline void CodeGeneratorRequest::set_parameter(const char* value, - size_t size) { - _has_bits_[0] |= 0x00000001u; - parameter_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast<const char*>(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorRequest.parameter) -} inline std::string* CodeGeneratorRequest::_internal_mutable_parameter() { _has_bits_[0] |= 0x00000001u; return parameter_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); @@ -1434,8 +1365,11 @@ // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.name) return _internal_name(); } -inline void CodeGeneratorResponse_File::set_name(const std::string& value) { - _internal_set_name(value); +template <typename ArgT0, typename... ArgT> +PROTOBUF_ALWAYS_INLINE +inline void CodeGeneratorResponse_File::set_name(ArgT0&& arg0, ArgT... args) { + _has_bits_[0] |= 0x00000001u; + name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.name) } inline std::string* CodeGeneratorResponse_File::mutable_name() { @@ -1449,25 +1383,6 @@ _has_bits_[0] |= 0x00000001u; name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); } -inline void CodeGeneratorResponse_File::set_name(std::string&& value) { - _has_bits_[0] |= 0x00000001u; - name_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.CodeGeneratorResponse.File.name) -} -inline void CodeGeneratorResponse_File::set_name(const char* value) { - GOOGLE_DCHECK(value != nullptr); - _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorResponse.File.name) -} -inline void CodeGeneratorResponse_File::set_name(const char* value, - size_t size) { - _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast<const char*>(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorResponse.File.name) -} inline std::string* CodeGeneratorResponse_File::_internal_mutable_name() { _has_bits_[0] |= 0x00000001u; return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); @@ -1507,8 +1422,11 @@ // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) return _internal_insertion_point(); } -inline void CodeGeneratorResponse_File::set_insertion_point(const std::string& value) { - _internal_set_insertion_point(value); +template <typename ArgT0, typename... ArgT> +PROTOBUF_ALWAYS_INLINE +inline void CodeGeneratorResponse_File::set_insertion_point(ArgT0&& arg0, ArgT... args) { + _has_bits_[0] |= 0x00000002u; + insertion_point_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) } inline std::string* CodeGeneratorResponse_File::mutable_insertion_point() { @@ -1522,25 +1440,6 @@ _has_bits_[0] |= 0x00000002u; insertion_point_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); } -inline void CodeGeneratorResponse_File::set_insertion_point(std::string&& value) { - _has_bits_[0] |= 0x00000002u; - insertion_point_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) -} -inline void CodeGeneratorResponse_File::set_insertion_point(const char* value) { - GOOGLE_DCHECK(value != nullptr); - _has_bits_[0] |= 0x00000002u; - insertion_point_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) -} -inline void CodeGeneratorResponse_File::set_insertion_point(const char* value, - size_t size) { - _has_bits_[0] |= 0x00000002u; - insertion_point_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast<const char*>(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) -} inline std::string* CodeGeneratorResponse_File::_internal_mutable_insertion_point() { _has_bits_[0] |= 0x00000002u; return insertion_point_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); @@ -1580,8 +1479,11 @@ // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.content) return _internal_content(); } -inline void CodeGeneratorResponse_File::set_content(const std::string& value) { - _internal_set_content(value); +template <typename ArgT0, typename... ArgT> +PROTOBUF_ALWAYS_INLINE +inline void CodeGeneratorResponse_File::set_content(ArgT0&& arg0, ArgT... args) { + _has_bits_[0] |= 0x00000004u; + content_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.content) } inline std::string* CodeGeneratorResponse_File::mutable_content() { @@ -1595,25 +1497,6 @@ _has_bits_[0] |= 0x00000004u; content_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); } -inline void CodeGeneratorResponse_File::set_content(std::string&& value) { - _has_bits_[0] |= 0x00000004u; - content_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.CodeGeneratorResponse.File.content) -} -inline void CodeGeneratorResponse_File::set_content(const char* value) { - GOOGLE_DCHECK(value != nullptr); - _has_bits_[0] |= 0x00000004u; - content_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorResponse.File.content) -} -inline void CodeGeneratorResponse_File::set_content(const char* value, - size_t size) { - _has_bits_[0] |= 0x00000004u; - content_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast<const char*>(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorResponse.File.content) -} inline std::string* CodeGeneratorResponse_File::_internal_mutable_content() { _has_bits_[0] |= 0x00000004u; return content_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); @@ -1736,8 +1619,11 @@ // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.error) return _internal_error(); } -inline void CodeGeneratorResponse::set_error(const std::string& value) { - _internal_set_error(value); +template <typename ArgT0, typename... ArgT> +PROTOBUF_ALWAYS_INLINE +inline void CodeGeneratorResponse::set_error(ArgT0&& arg0, ArgT... args) { + _has_bits_[0] |= 0x00000001u; + error_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.error) } inline std::string* CodeGeneratorResponse::mutable_error() { @@ -1751,25 +1637,6 @@ _has_bits_[0] |= 0x00000001u; error_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); } -inline void CodeGeneratorResponse::set_error(std::string&& value) { - _has_bits_[0] |= 0x00000001u; - error_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.CodeGeneratorResponse.error) -} -inline void CodeGeneratorResponse::set_error(const char* value) { - GOOGLE_DCHECK(value != nullptr); - _has_bits_[0] |= 0x00000001u; - error_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorResponse.error) -} -inline void CodeGeneratorResponse::set_error(const char* value, - size_t size) { - _has_bits_[0] |= 0x00000001u; - error_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast<const char*>(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorResponse.error) -} inline std::string* CodeGeneratorResponse::_internal_mutable_error() { _has_bits_[0] |= 0x00000001u; return error_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena());
diff --git a/src/google/protobuf/descriptor.pb.cc b/src/google/protobuf/descriptor.pb.cc index 8ceaa19..d51236c 100644 --- a/src/google/protobuf/descriptor.pb.cc +++ b/src/google/protobuf/descriptor.pb.cc
@@ -1055,10 +1055,8 @@ schemas, file_default_instances, TableStruct_google_2fprotobuf_2fdescriptor_2eproto::offsets, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fdescriptor_2eproto, file_level_service_descriptors_google_2fprotobuf_2fdescriptor_2eproto, }; -PROTOBUF_ATTRIBUTE_WEAK ::PROTOBUF_NAMESPACE_ID::Metadata -descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_metadata_getter(int index) { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto); - return descriptor_table_google_2fprotobuf_2fdescriptor_2eproto.file_level_metadata[index]; +PROTOBUF_ATTRIBUTE_WEAK const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable* descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter() { + return &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto; } // Force running AddDescriptors() at dynamic initialization time. @@ -1424,10 +1422,11 @@ } ::PROTOBUF_NAMESPACE_ID::Metadata FileDescriptorSet::GetMetadata() const { - return GetMetadataStatic(); + return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, + file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[0]); } - // =================================================================== class FileDescriptorProto::_Internal { @@ -2077,10 +2076,11 @@ } ::PROTOBUF_NAMESPACE_ID::Metadata FileDescriptorProto::GetMetadata() const { - return GetMetadataStatic(); + return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, + file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[1]); } - // =================================================================== class DescriptorProto_ExtensionRange::_Internal { @@ -2372,10 +2372,11 @@ } ::PROTOBUF_NAMESPACE_ID::Metadata DescriptorProto_ExtensionRange::GetMetadata() const { - return GetMetadataStatic(); + return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, + file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[2]); } - // =================================================================== class DescriptorProto_ReservedRange::_Internal { @@ -2621,10 +2622,11 @@ } ::PROTOBUF_NAMESPACE_ID::Metadata DescriptorProto_ReservedRange::GetMetadata() const { - return GetMetadataStatic(); + return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, + file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[3]); } - // =================================================================== class DescriptorProto::_Internal { @@ -3161,10 +3163,11 @@ } ::PROTOBUF_NAMESPACE_ID::Metadata DescriptorProto::GetMetadata() const { - return GetMetadataStatic(); + return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, + file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[4]); } - // =================================================================== class ExtensionRangeOptions::_Internal { @@ -3377,10 +3380,11 @@ } ::PROTOBUF_NAMESPACE_ID::Metadata ExtensionRangeOptions::GetMetadata() const { - return GetMetadataStatic(); + return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, + file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[5]); } - // =================================================================== class FieldDescriptorProto::_Internal { @@ -4000,10 +4004,11 @@ } ::PROTOBUF_NAMESPACE_ID::Metadata FieldDescriptorProto::GetMetadata() const { - return GetMetadataStatic(); + return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, + file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[6]); } - // =================================================================== class OneofDescriptorProto::_Internal { @@ -4271,10 +4276,11 @@ } ::PROTOBUF_NAMESPACE_ID::Metadata OneofDescriptorProto::GetMetadata() const { - return GetMetadataStatic(); + return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, + file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[7]); } - // =================================================================== class EnumDescriptorProto_EnumReservedRange::_Internal { @@ -4520,10 +4526,11 @@ } ::PROTOBUF_NAMESPACE_ID::Metadata EnumDescriptorProto_EnumReservedRange::GetMetadata() const { - return GetMetadataStatic(); + return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, + file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[8]); } - // =================================================================== class EnumDescriptorProto::_Internal { @@ -4895,10 +4902,11 @@ } ::PROTOBUF_NAMESPACE_ID::Metadata EnumDescriptorProto::GetMetadata() const { - return GetMetadataStatic(); + return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, + file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[9]); } - // =================================================================== class EnumValueDescriptorProto::_Internal { @@ -5204,10 +5212,11 @@ } ::PROTOBUF_NAMESPACE_ID::Metadata EnumValueDescriptorProto::GetMetadata() const { - return GetMetadataStatic(); + return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, + file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[10]); } - // =================================================================== class ServiceDescriptorProto::_Internal { @@ -5508,10 +5517,11 @@ } ::PROTOBUF_NAMESPACE_ID::Metadata ServiceDescriptorProto::GetMetadata() const { - return GetMetadataStatic(); + return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, + file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[11]); } - // =================================================================== class MethodDescriptorProto::_Internal { @@ -5934,10 +5944,11 @@ } ::PROTOBUF_NAMESPACE_ID::Metadata MethodDescriptorProto::GetMetadata() const { - return GetMetadataStatic(); + return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, + file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[12]); } - // =================================================================== class FileOptions::_Internal { @@ -6913,10 +6924,11 @@ } ::PROTOBUF_NAMESPACE_ID::Metadata FileOptions::GetMetadata() const { - return GetMetadataStatic(); + return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, + file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[13]); } - // =================================================================== class MessageOptions::_Internal { @@ -7259,10 +7271,11 @@ } ::PROTOBUF_NAMESPACE_ID::Metadata MessageOptions::GetMetadata() const { - return GetMetadataStatic(); + return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, + file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[14]); } - // =================================================================== class FieldOptions::_Internal { @@ -7670,10 +7683,11 @@ } ::PROTOBUF_NAMESPACE_ID::Metadata FieldOptions::GetMetadata() const { - return GetMetadataStatic(); + return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, + file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[15]); } - // =================================================================== class OneofOptions::_Internal { @@ -7886,10 +7900,11 @@ } ::PROTOBUF_NAMESPACE_ID::Metadata OneofOptions::GetMetadata() const { - return GetMetadataStatic(); + return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, + file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[16]); } - // =================================================================== class EnumOptions::_Internal { @@ -8182,10 +8197,11 @@ } ::PROTOBUF_NAMESPACE_ID::Metadata EnumOptions::GetMetadata() const { - return GetMetadataStatic(); + return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, + file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[17]); } - // =================================================================== class EnumValueOptions::_Internal { @@ -8435,10 +8451,11 @@ } ::PROTOBUF_NAMESPACE_ID::Metadata EnumValueOptions::GetMetadata() const { - return GetMetadataStatic(); + return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, + file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[18]); } - // =================================================================== class ServiceOptions::_Internal { @@ -8688,10 +8705,11 @@ } ::PROTOBUF_NAMESPACE_ID::Metadata ServiceOptions::GetMetadata() const { - return GetMetadataStatic(); + return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, + file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[19]); } - // =================================================================== class MethodOptions::_Internal { @@ -8993,10 +9011,11 @@ } ::PROTOBUF_NAMESPACE_ID::Metadata MethodOptions::GetMetadata() const { - return GetMetadataStatic(); + return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, + file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[20]); } - // =================================================================== class UninterpretedOption_NamePart::_Internal { @@ -9263,10 +9282,11 @@ } ::PROTOBUF_NAMESPACE_ID::Metadata UninterpretedOption_NamePart::GetMetadata() const { - return GetMetadataStatic(); + return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, + file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[21]); } - // =================================================================== class UninterpretedOption::_Internal { @@ -9700,10 +9720,11 @@ } ::PROTOBUF_NAMESPACE_ID::Metadata UninterpretedOption::GetMetadata() const { - return GetMetadataStatic(); + return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, + file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[22]); } - // =================================================================== class SourceCodeInfo_Location::_Internal { @@ -10085,10 +10106,11 @@ } ::PROTOBUF_NAMESPACE_ID::Metadata SourceCodeInfo_Location::GetMetadata() const { - return GetMetadataStatic(); + return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, + file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[23]); } - // =================================================================== class SourceCodeInfo::_Internal { @@ -10279,10 +10301,11 @@ } ::PROTOBUF_NAMESPACE_ID::Metadata SourceCodeInfo::GetMetadata() const { - return GetMetadataStatic(); + return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, + file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[24]); } - // =================================================================== class GeneratedCodeInfo_Annotation::_Internal { @@ -10612,10 +10635,11 @@ } ::PROTOBUF_NAMESPACE_ID::Metadata GeneratedCodeInfo_Annotation::GetMetadata() const { - return GetMetadataStatic(); + return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, + file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[25]); } - // =================================================================== class GeneratedCodeInfo::_Internal { @@ -10806,10 +10830,11 @@ } ::PROTOBUF_NAMESPACE_ID::Metadata GeneratedCodeInfo::GetMetadata() const { - return GetMetadataStatic(); + return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, + file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[26]); } - // @@protoc_insertion_point(namespace_scope) PROTOBUF_NAMESPACE_CLOSE PROTOBUF_NAMESPACE_OPEN
diff --git a/src/google/protobuf/descriptor.pb.h b/src/google/protobuf/descriptor.pb.h index cce46c3..4553dd5 100644 --- a/src/google/protobuf/descriptor.pb.h +++ b/src/google/protobuf/descriptor.pb.h
@@ -54,7 +54,6 @@ static const ::PROTOBUF_NAMESPACE_ID::uint32 offsets[]; }; extern PROTOBUF_EXPORT const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fdescriptor_2eproto; -PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Metadata descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_metadata_getter(int index); PROTOBUF_NAMESPACE_OPEN class DescriptorProto; struct DescriptorProtoDefaultTypeInternal; @@ -367,10 +366,10 @@ return GetDescriptor(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; + return default_instance().GetMetadata().descriptor; } static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; + return default_instance().GetMetadata().reflection; } static const FileDescriptorSet& default_instance() { return *internal_default_instance(); @@ -438,12 +437,6 @@ public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_metadata_getter(kIndexInFileMessages); - } - - public: // nested types ---------------------------------------------------- @@ -520,10 +513,10 @@ return GetDescriptor(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; + return default_instance().GetMetadata().descriptor; } static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; + return default_instance().GetMetadata().reflection; } static const FileDescriptorProto& default_instance() { return *internal_default_instance(); @@ -591,12 +584,6 @@ public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_metadata_getter(kIndexInFileMessages); - } - - public: // nested types ---------------------------------------------------- @@ -763,10 +750,8 @@ public: void clear_name(); const std::string& name() const; - void set_name(const std::string& value); - void set_name(std::string&& value); - void set_name(const char* value); - void set_name(const char* value, size_t size); + template <typename ArgT0 = const std::string&, typename... ArgT> + void set_name(ArgT0&& arg0, ArgT... args); std::string* mutable_name(); std::string* release_name(); void set_allocated_name(std::string* name); @@ -783,10 +768,8 @@ public: void clear_package(); const std::string& package() const; - void set_package(const std::string& value); - void set_package(std::string&& value); - void set_package(const char* value); - void set_package(const char* value, size_t size); + template <typename ArgT0 = const std::string&, typename... ArgT> + void set_package(ArgT0&& arg0, ArgT... args); std::string* mutable_package(); std::string* release_package(); void set_allocated_package(std::string* package); @@ -803,10 +786,8 @@ public: void clear_syntax(); const std::string& syntax() const; - void set_syntax(const std::string& value); - void set_syntax(std::string&& value); - void set_syntax(const char* value); - void set_syntax(const char* value, size_t size); + template <typename ArgT0 = const std::string&, typename... ArgT> + void set_syntax(ArgT0&& arg0, ArgT... args); std::string* mutable_syntax(); std::string* release_syntax(); void set_allocated_syntax(std::string* syntax); @@ -914,10 +895,10 @@ return GetDescriptor(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; + return default_instance().GetMetadata().descriptor; } static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; + return default_instance().GetMetadata().reflection; } static const DescriptorProto_ExtensionRange& default_instance() { return *internal_default_instance(); @@ -985,12 +966,6 @@ public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_metadata_getter(kIndexInFileMessages); - } - - public: // nested types ---------------------------------------------------- @@ -1098,10 +1073,10 @@ return GetDescriptor(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; + return default_instance().GetMetadata().descriptor; } static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; + return default_instance().GetMetadata().reflection; } static const DescriptorProto_ReservedRange& default_instance() { return *internal_default_instance(); @@ -1169,12 +1144,6 @@ public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_metadata_getter(kIndexInFileMessages); - } - - public: // nested types ---------------------------------------------------- @@ -1262,10 +1231,10 @@ return GetDescriptor(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; + return default_instance().GetMetadata().descriptor; } static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; + return default_instance().GetMetadata().reflection; } static const DescriptorProto& default_instance() { return *internal_default_instance(); @@ -1333,12 +1302,6 @@ public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_metadata_getter(kIndexInFileMessages); - } - - public: // nested types ---------------------------------------------------- @@ -1516,10 +1479,8 @@ public: void clear_name(); const std::string& name() const; - void set_name(const std::string& value); - void set_name(std::string&& value); - void set_name(const char* value); - void set_name(const char* value, size_t size); + template <typename ArgT0 = const std::string&, typename... ArgT> + void set_name(ArgT0&& arg0, ArgT... args); std::string* mutable_name(); std::string* release_name(); void set_allocated_name(std::string* name); @@ -1607,10 +1568,10 @@ return GetDescriptor(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; + return default_instance().GetMetadata().descriptor; } static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; + return default_instance().GetMetadata().reflection; } static const ExtensionRangeOptions& default_instance() { return *internal_default_instance(); @@ -1678,12 +1639,6 @@ public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_metadata_getter(kIndexInFileMessages); - } - - public: // nested types ---------------------------------------------------- @@ -1763,10 +1718,10 @@ return GetDescriptor(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; + return default_instance().GetMetadata().descriptor; } static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; + return default_instance().GetMetadata().reflection; } static const FieldDescriptorProto& default_instance() { return *internal_default_instance(); @@ -1834,12 +1789,6 @@ public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_metadata_getter(kIndexInFileMessages); - } - - public: // nested types ---------------------------------------------------- @@ -1959,10 +1908,8 @@ public: void clear_name(); const std::string& name() const; - void set_name(const std::string& value); - void set_name(std::string&& value); - void set_name(const char* value); - void set_name(const char* value, size_t size); + template <typename ArgT0 = const std::string&, typename... ArgT> + void set_name(ArgT0&& arg0, ArgT... args); std::string* mutable_name(); std::string* release_name(); void set_allocated_name(std::string* name); @@ -1979,10 +1926,8 @@ public: void clear_extendee(); const std::string& extendee() const; - void set_extendee(const std::string& value); - void set_extendee(std::string&& value); - void set_extendee(const char* value); - void set_extendee(const char* value, size_t size); + template <typename ArgT0 = const std::string&, typename... ArgT> + void set_extendee(ArgT0&& arg0, ArgT... args); std::string* mutable_extendee(); std::string* release_extendee(); void set_allocated_extendee(std::string* extendee); @@ -1999,10 +1944,8 @@ public: void clear_type_name(); const std::string& type_name() const; - void set_type_name(const std::string& value); - void set_type_name(std::string&& value); - void set_type_name(const char* value); - void set_type_name(const char* value, size_t size); + template <typename ArgT0 = const std::string&, typename... ArgT> + void set_type_name(ArgT0&& arg0, ArgT... args); std::string* mutable_type_name(); std::string* release_type_name(); void set_allocated_type_name(std::string* type_name); @@ -2019,10 +1962,8 @@ public: void clear_default_value(); const std::string& default_value() const; - void set_default_value(const std::string& value); - void set_default_value(std::string&& value); - void set_default_value(const char* value); - void set_default_value(const char* value, size_t size); + template <typename ArgT0 = const std::string&, typename... ArgT> + void set_default_value(ArgT0&& arg0, ArgT... args); std::string* mutable_default_value(); std::string* release_default_value(); void set_allocated_default_value(std::string* default_value); @@ -2039,10 +1980,8 @@ public: void clear_json_name(); const std::string& json_name() const; - void set_json_name(const std::string& value); - void set_json_name(std::string&& value); - void set_json_name(const char* value); - void set_json_name(const char* value, size_t size); + template <typename ArgT0 = const std::string&, typename... ArgT> + void set_json_name(ArgT0&& arg0, ArgT... args); std::string* mutable_json_name(); std::string* release_json_name(); void set_allocated_json_name(std::string* json_name); @@ -2196,10 +2135,10 @@ return GetDescriptor(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; + return default_instance().GetMetadata().descriptor; } static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; + return default_instance().GetMetadata().reflection; } static const OneofDescriptorProto& default_instance() { return *internal_default_instance(); @@ -2267,12 +2206,6 @@ public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_metadata_getter(kIndexInFileMessages); - } - - public: // nested types ---------------------------------------------------- @@ -2289,10 +2222,8 @@ public: void clear_name(); const std::string& name() const; - void set_name(const std::string& value); - void set_name(std::string&& value); - void set_name(const char* value); - void set_name(const char* value, size_t size); + template <typename ArgT0 = const std::string&, typename... ArgT> + void set_name(ArgT0&& arg0, ArgT... args); std::string* mutable_name(); std::string* release_name(); void set_allocated_name(std::string* name); @@ -2372,10 +2303,10 @@ return GetDescriptor(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; + return default_instance().GetMetadata().descriptor; } static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; + return default_instance().GetMetadata().reflection; } static const EnumDescriptorProto_EnumReservedRange& default_instance() { return *internal_default_instance(); @@ -2443,12 +2374,6 @@ public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_metadata_getter(kIndexInFileMessages); - } - - public: // nested types ---------------------------------------------------- @@ -2536,10 +2461,10 @@ return GetDescriptor(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; + return default_instance().GetMetadata().descriptor; } static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; + return default_instance().GetMetadata().reflection; } static const EnumDescriptorProto& default_instance() { return *internal_default_instance(); @@ -2607,12 +2532,6 @@ public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_metadata_getter(kIndexInFileMessages); - } - - public: // nested types ---------------------------------------------------- @@ -2694,10 +2613,8 @@ public: void clear_name(); const std::string& name() const; - void set_name(const std::string& value); - void set_name(std::string&& value); - void set_name(const char* value); - void set_name(const char* value, size_t size); + template <typename ArgT0 = const std::string&, typename... ArgT> + void set_name(ArgT0&& arg0, ArgT... args); std::string* mutable_name(); std::string* release_name(); void set_allocated_name(std::string* name); @@ -2780,10 +2697,10 @@ return GetDescriptor(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; + return default_instance().GetMetadata().descriptor; } static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; + return default_instance().GetMetadata().reflection; } static const EnumValueDescriptorProto& default_instance() { return *internal_default_instance(); @@ -2851,12 +2768,6 @@ public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_metadata_getter(kIndexInFileMessages); - } - - public: // nested types ---------------------------------------------------- @@ -2874,10 +2785,8 @@ public: void clear_name(); const std::string& name() const; - void set_name(const std::string& value); - void set_name(std::string&& value); - void set_name(const char* value); - void set_name(const char* value, size_t size); + template <typename ArgT0 = const std::string&, typename... ArgT> + void set_name(ArgT0&& arg0, ArgT... args); std::string* mutable_name(); std::string* release_name(); void set_allocated_name(std::string* name); @@ -2971,10 +2880,10 @@ return GetDescriptor(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; + return default_instance().GetMetadata().descriptor; } static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; + return default_instance().GetMetadata().reflection; } static const ServiceDescriptorProto& default_instance() { return *internal_default_instance(); @@ -3042,12 +2951,6 @@ public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_metadata_getter(kIndexInFileMessages); - } - - public: // nested types ---------------------------------------------------- @@ -3083,10 +2986,8 @@ public: void clear_name(); const std::string& name() const; - void set_name(const std::string& value); - void set_name(std::string&& value); - void set_name(const char* value); - void set_name(const char* value, size_t size); + template <typename ArgT0 = const std::string&, typename... ArgT> + void set_name(ArgT0&& arg0, ArgT... args); std::string* mutable_name(); std::string* release_name(); void set_allocated_name(std::string* name); @@ -3167,10 +3068,10 @@ return GetDescriptor(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; + return default_instance().GetMetadata().descriptor; } static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; + return default_instance().GetMetadata().reflection; } static const MethodDescriptorProto& default_instance() { return *internal_default_instance(); @@ -3238,12 +3139,6 @@ public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_metadata_getter(kIndexInFileMessages); - } - - public: // nested types ---------------------------------------------------- @@ -3264,10 +3159,8 @@ public: void clear_name(); const std::string& name() const; - void set_name(const std::string& value); - void set_name(std::string&& value); - void set_name(const char* value); - void set_name(const char* value, size_t size); + template <typename ArgT0 = const std::string&, typename... ArgT> + void set_name(ArgT0&& arg0, ArgT... args); std::string* mutable_name(); std::string* release_name(); void set_allocated_name(std::string* name); @@ -3284,10 +3177,8 @@ public: void clear_input_type(); const std::string& input_type() const; - void set_input_type(const std::string& value); - void set_input_type(std::string&& value); - void set_input_type(const char* value); - void set_input_type(const char* value, size_t size); + template <typename ArgT0 = const std::string&, typename... ArgT> + void set_input_type(ArgT0&& arg0, ArgT... args); std::string* mutable_input_type(); std::string* release_input_type(); void set_allocated_input_type(std::string* input_type); @@ -3304,10 +3195,8 @@ public: void clear_output_type(); const std::string& output_type() const; - void set_output_type(const std::string& value); - void set_output_type(std::string&& value); - void set_output_type(const char* value); - void set_output_type(const char* value, size_t size); + template <typename ArgT0 = const std::string&, typename... ArgT> + void set_output_type(ArgT0&& arg0, ArgT... args); std::string* mutable_output_type(); std::string* release_output_type(); void set_allocated_output_type(std::string* output_type); @@ -3417,10 +3306,10 @@ return GetDescriptor(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; + return default_instance().GetMetadata().descriptor; } static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; + return default_instance().GetMetadata().reflection; } static const FileOptions& default_instance() { return *internal_default_instance(); @@ -3488,12 +3377,6 @@ public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_metadata_getter(kIndexInFileMessages); - } - - public: // nested types ---------------------------------------------------- @@ -3579,10 +3462,8 @@ public: void clear_java_package(); const std::string& java_package() const; - void set_java_package(const std::string& value); - void set_java_package(std::string&& value); - void set_java_package(const char* value); - void set_java_package(const char* value, size_t size); + template <typename ArgT0 = const std::string&, typename... ArgT> + void set_java_package(ArgT0&& arg0, ArgT... args); std::string* mutable_java_package(); std::string* release_java_package(); void set_allocated_java_package(std::string* java_package); @@ -3599,10 +3480,8 @@ public: void clear_java_outer_classname(); const std::string& java_outer_classname() const; - void set_java_outer_classname(const std::string& value); - void set_java_outer_classname(std::string&& value); - void set_java_outer_classname(const char* value); - void set_java_outer_classname(const char* value, size_t size); + template <typename ArgT0 = const std::string&, typename... ArgT> + void set_java_outer_classname(ArgT0&& arg0, ArgT... args); std::string* mutable_java_outer_classname(); std::string* release_java_outer_classname(); void set_allocated_java_outer_classname(std::string* java_outer_classname); @@ -3619,10 +3498,8 @@ public: void clear_go_package(); const std::string& go_package() const; - void set_go_package(const std::string& value); - void set_go_package(std::string&& value); - void set_go_package(const char* value); - void set_go_package(const char* value, size_t size); + template <typename ArgT0 = const std::string&, typename... ArgT> + void set_go_package(ArgT0&& arg0, ArgT... args); std::string* mutable_go_package(); std::string* release_go_package(); void set_allocated_go_package(std::string* go_package); @@ -3639,10 +3516,8 @@ public: void clear_objc_class_prefix(); const std::string& objc_class_prefix() const; - void set_objc_class_prefix(const std::string& value); - void set_objc_class_prefix(std::string&& value); - void set_objc_class_prefix(const char* value); - void set_objc_class_prefix(const char* value, size_t size); + template <typename ArgT0 = const std::string&, typename... ArgT> + void set_objc_class_prefix(ArgT0&& arg0, ArgT... args); std::string* mutable_objc_class_prefix(); std::string* release_objc_class_prefix(); void set_allocated_objc_class_prefix(std::string* objc_class_prefix); @@ -3659,10 +3534,8 @@ public: void clear_csharp_namespace(); const std::string& csharp_namespace() const; - void set_csharp_namespace(const std::string& value); - void set_csharp_namespace(std::string&& value); - void set_csharp_namespace(const char* value); - void set_csharp_namespace(const char* value, size_t size); + template <typename ArgT0 = const std::string&, typename... ArgT> + void set_csharp_namespace(ArgT0&& arg0, ArgT... args); std::string* mutable_csharp_namespace(); std::string* release_csharp_namespace(); void set_allocated_csharp_namespace(std::string* csharp_namespace); @@ -3679,10 +3552,8 @@ public: void clear_swift_prefix(); const std::string& swift_prefix() const; - void set_swift_prefix(const std::string& value); - void set_swift_prefix(std::string&& value); - void set_swift_prefix(const char* value); - void set_swift_prefix(const char* value, size_t size); + template <typename ArgT0 = const std::string&, typename... ArgT> + void set_swift_prefix(ArgT0&& arg0, ArgT... args); std::string* mutable_swift_prefix(); std::string* release_swift_prefix(); void set_allocated_swift_prefix(std::string* swift_prefix); @@ -3699,10 +3570,8 @@ public: void clear_php_class_prefix(); const std::string& php_class_prefix() const; - void set_php_class_prefix(const std::string& value); - void set_php_class_prefix(std::string&& value); - void set_php_class_prefix(const char* value); - void set_php_class_prefix(const char* value, size_t size); + template <typename ArgT0 = const std::string&, typename... ArgT> + void set_php_class_prefix(ArgT0&& arg0, ArgT... args); std::string* mutable_php_class_prefix(); std::string* release_php_class_prefix(); void set_allocated_php_class_prefix(std::string* php_class_prefix); @@ -3719,10 +3588,8 @@ public: void clear_php_namespace(); const std::string& php_namespace() const; - void set_php_namespace(const std::string& value); - void set_php_namespace(std::string&& value); - void set_php_namespace(const char* value); - void set_php_namespace(const char* value, size_t size); + template <typename ArgT0 = const std::string&, typename... ArgT> + void set_php_namespace(ArgT0&& arg0, ArgT... args); std::string* mutable_php_namespace(); std::string* release_php_namespace(); void set_allocated_php_namespace(std::string* php_namespace); @@ -3739,10 +3606,8 @@ public: void clear_php_metadata_namespace(); const std::string& php_metadata_namespace() const; - void set_php_metadata_namespace(const std::string& value); - void set_php_metadata_namespace(std::string&& value); - void set_php_metadata_namespace(const char* value); - void set_php_metadata_namespace(const char* value, size_t size); + template <typename ArgT0 = const std::string&, typename... ArgT> + void set_php_metadata_namespace(ArgT0&& arg0, ArgT... args); std::string* mutable_php_metadata_namespace(); std::string* release_php_metadata_namespace(); void set_allocated_php_metadata_namespace(std::string* php_metadata_namespace); @@ -3759,10 +3624,8 @@ public: void clear_ruby_package(); const std::string& ruby_package() const; - void set_ruby_package(const std::string& value); - void set_ruby_package(std::string&& value); - void set_ruby_package(const char* value); - void set_ruby_package(const char* value, size_t size); + template <typename ArgT0 = const std::string&, typename... ArgT> + void set_ruby_package(ArgT0&& arg0, ArgT... args); std::string* mutable_ruby_package(); std::string* release_ruby_package(); void set_allocated_ruby_package(std::string* ruby_package); @@ -3976,10 +3839,10 @@ return GetDescriptor(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; + return default_instance().GetMetadata().descriptor; } static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; + return default_instance().GetMetadata().reflection; } static const MessageOptions& default_instance() { return *internal_default_instance(); @@ -4047,12 +3910,6 @@ public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_metadata_getter(kIndexInFileMessages); - } - - public: // nested types ---------------------------------------------------- @@ -4193,10 +4050,10 @@ return GetDescriptor(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; + return default_instance().GetMetadata().descriptor; } static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; + return default_instance().GetMetadata().reflection; } static const FieldOptions& default_instance() { return *internal_default_instance(); @@ -4264,12 +4121,6 @@ public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_metadata_getter(kIndexInFileMessages); - } - - public: // nested types ---------------------------------------------------- @@ -4504,10 +4355,10 @@ return GetDescriptor(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; + return default_instance().GetMetadata().descriptor; } static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; + return default_instance().GetMetadata().reflection; } static const OneofOptions& default_instance() { return *internal_default_instance(); @@ -4575,12 +4426,6 @@ public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_metadata_getter(kIndexInFileMessages); - } - - public: // nested types ---------------------------------------------------- @@ -4660,10 +4505,10 @@ return GetDescriptor(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; + return default_instance().GetMetadata().descriptor; } static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; + return default_instance().GetMetadata().reflection; } static const EnumOptions& default_instance() { return *internal_default_instance(); @@ -4731,12 +4576,6 @@ public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_metadata_getter(kIndexInFileMessages); - } - - public: // nested types ---------------------------------------------------- @@ -4847,10 +4686,10 @@ return GetDescriptor(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; + return default_instance().GetMetadata().descriptor; } static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; + return default_instance().GetMetadata().reflection; } static const EnumValueOptions& default_instance() { return *internal_default_instance(); @@ -4918,12 +4757,6 @@ public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_metadata_getter(kIndexInFileMessages); - } - - public: // nested types ---------------------------------------------------- @@ -5019,10 +4852,10 @@ return GetDescriptor(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; + return default_instance().GetMetadata().descriptor; } static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; + return default_instance().GetMetadata().reflection; } static const ServiceOptions& default_instance() { return *internal_default_instance(); @@ -5090,12 +4923,6 @@ public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_metadata_getter(kIndexInFileMessages); - } - - public: // nested types ---------------------------------------------------- @@ -5191,10 +5018,10 @@ return GetDescriptor(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; + return default_instance().GetMetadata().descriptor; } static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; + return default_instance().GetMetadata().reflection; } static const MethodOptions& default_instance() { return *internal_default_instance(); @@ -5262,12 +5089,6 @@ public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_metadata_getter(kIndexInFileMessages); - } - - public: // nested types ---------------------------------------------------- @@ -5410,10 +5231,10 @@ return GetDescriptor(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; + return default_instance().GetMetadata().descriptor; } static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; + return default_instance().GetMetadata().reflection; } static const UninterpretedOption_NamePart& default_instance() { return *internal_default_instance(); @@ -5481,12 +5302,6 @@ public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_metadata_getter(kIndexInFileMessages); - } - - public: // nested types ---------------------------------------------------- @@ -5503,10 +5318,8 @@ public: void clear_name_part(); const std::string& name_part() const; - void set_name_part(const std::string& value); - void set_name_part(std::string&& value); - void set_name_part(const char* value); - void set_name_part(const char* value, size_t size); + template <typename ArgT0 = const std::string&, typename... ArgT> + void set_name_part(ArgT0&& arg0, ArgT... args); std::string* mutable_name_part(); std::string* release_name_part(); void set_allocated_name_part(std::string* name_part); @@ -5584,10 +5397,10 @@ return GetDescriptor(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; + return default_instance().GetMetadata().descriptor; } static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; + return default_instance().GetMetadata().reflection; } static const UninterpretedOption& default_instance() { return *internal_default_instance(); @@ -5655,12 +5468,6 @@ public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_metadata_getter(kIndexInFileMessages); - } - - public: // nested types ---------------------------------------------------- @@ -5702,10 +5509,8 @@ public: void clear_identifier_value(); const std::string& identifier_value() const; - void set_identifier_value(const std::string& value); - void set_identifier_value(std::string&& value); - void set_identifier_value(const char* value); - void set_identifier_value(const char* value, size_t size); + template <typename ArgT0 = const std::string&, typename... ArgT> + void set_identifier_value(ArgT0&& arg0, ArgT... args); std::string* mutable_identifier_value(); std::string* release_identifier_value(); void set_allocated_identifier_value(std::string* identifier_value); @@ -5722,10 +5527,8 @@ public: void clear_string_value(); const std::string& string_value() const; - void set_string_value(const std::string& value); - void set_string_value(std::string&& value); - void set_string_value(const char* value); - void set_string_value(const void* value, size_t size); + template <typename ArgT0 = const std::string&, typename... ArgT> + void set_string_value(ArgT0&& arg0, ArgT... args); std::string* mutable_string_value(); std::string* release_string_value(); void set_allocated_string_value(std::string* string_value); @@ -5742,10 +5545,8 @@ public: void clear_aggregate_value(); const std::string& aggregate_value() const; - void set_aggregate_value(const std::string& value); - void set_aggregate_value(std::string&& value); - void set_aggregate_value(const char* value); - void set_aggregate_value(const char* value, size_t size); + template <typename ArgT0 = const std::string&, typename... ArgT> + void set_aggregate_value(ArgT0&& arg0, ArgT... args); std::string* mutable_aggregate_value(); std::string* release_aggregate_value(); void set_allocated_aggregate_value(std::string* aggregate_value); @@ -5851,10 +5652,10 @@ return GetDescriptor(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; + return default_instance().GetMetadata().descriptor; } static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; + return default_instance().GetMetadata().reflection; } static const SourceCodeInfo_Location& default_instance() { return *internal_default_instance(); @@ -5922,12 +5723,6 @@ public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_metadata_getter(kIndexInFileMessages); - } - - public: // nested types ---------------------------------------------------- @@ -6015,10 +5810,8 @@ public: void clear_leading_comments(); const std::string& leading_comments() const; - void set_leading_comments(const std::string& value); - void set_leading_comments(std::string&& value); - void set_leading_comments(const char* value); - void set_leading_comments(const char* value, size_t size); + template <typename ArgT0 = const std::string&, typename... ArgT> + void set_leading_comments(ArgT0&& arg0, ArgT... args); std::string* mutable_leading_comments(); std::string* release_leading_comments(); void set_allocated_leading_comments(std::string* leading_comments); @@ -6035,10 +5828,8 @@ public: void clear_trailing_comments(); const std::string& trailing_comments() const; - void set_trailing_comments(const std::string& value); - void set_trailing_comments(std::string&& value); - void set_trailing_comments(const char* value); - void set_trailing_comments(const char* value, size_t size); + template <typename ArgT0 = const std::string&, typename... ArgT> + void set_trailing_comments(ArgT0&& arg0, ArgT... args); std::string* mutable_trailing_comments(); std::string* release_trailing_comments(); void set_allocated_trailing_comments(std::string* trailing_comments); @@ -6105,10 +5896,10 @@ return GetDescriptor(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; + return default_instance().GetMetadata().descriptor; } static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; + return default_instance().GetMetadata().reflection; } static const SourceCodeInfo& default_instance() { return *internal_default_instance(); @@ -6176,12 +5967,6 @@ public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_metadata_getter(kIndexInFileMessages); - } - - public: // nested types ---------------------------------------------------- @@ -6260,10 +6045,10 @@ return GetDescriptor(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; + return default_instance().GetMetadata().descriptor; } static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; + return default_instance().GetMetadata().reflection; } static const GeneratedCodeInfo_Annotation& default_instance() { return *internal_default_instance(); @@ -6331,12 +6116,6 @@ public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_metadata_getter(kIndexInFileMessages); - } - - public: // nested types ---------------------------------------------------- @@ -6377,10 +6156,8 @@ public: void clear_source_file(); const std::string& source_file() const; - void set_source_file(const std::string& value); - void set_source_file(std::string&& value); - void set_source_file(const char* value); - void set_source_file(const char* value, size_t size); + template <typename ArgT0 = const std::string&, typename... ArgT> + void set_source_file(ArgT0&& arg0, ArgT... args); std::string* mutable_source_file(); std::string* release_source_file(); void set_allocated_source_file(std::string* source_file); @@ -6471,10 +6248,10 @@ return GetDescriptor(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; + return default_instance().GetMetadata().descriptor; } static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; + return default_instance().GetMetadata().reflection; } static const GeneratedCodeInfo& default_instance() { return *internal_default_instance(); @@ -6542,12 +6319,6 @@ public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_metadata_getter(kIndexInFileMessages); - } - - public: // nested types ---------------------------------------------------- @@ -6657,8 +6428,11 @@ // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.name) return _internal_name(); } -inline void FileDescriptorProto::set_name(const std::string& value) { - _internal_set_name(value); +template <typename ArgT0, typename... ArgT> +PROTOBUF_ALWAYS_INLINE +inline void FileDescriptorProto::set_name(ArgT0&& arg0, ArgT... args) { + _has_bits_[0] |= 0x00000001u; + name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.name) } inline std::string* FileDescriptorProto::mutable_name() { @@ -6672,25 +6446,6 @@ _has_bits_[0] |= 0x00000001u; name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); } -inline void FileDescriptorProto::set_name(std::string&& value) { - _has_bits_[0] |= 0x00000001u; - name_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileDescriptorProto.name) -} -inline void FileDescriptorProto::set_name(const char* value) { - GOOGLE_DCHECK(value != nullptr); - _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:google.protobuf.FileDescriptorProto.name) -} -inline void FileDescriptorProto::set_name(const char* value, - size_t size) { - _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast<const char*>(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileDescriptorProto.name) -} inline std::string* FileDescriptorProto::_internal_mutable_name() { _has_bits_[0] |= 0x00000001u; return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); @@ -6730,8 +6485,11 @@ // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.package) return _internal_package(); } -inline void FileDescriptorProto::set_package(const std::string& value) { - _internal_set_package(value); +template <typename ArgT0, typename... ArgT> +PROTOBUF_ALWAYS_INLINE +inline void FileDescriptorProto::set_package(ArgT0&& arg0, ArgT... args) { + _has_bits_[0] |= 0x00000002u; + package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.package) } inline std::string* FileDescriptorProto::mutable_package() { @@ -6745,25 +6503,6 @@ _has_bits_[0] |= 0x00000002u; package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); } -inline void FileDescriptorProto::set_package(std::string&& value) { - _has_bits_[0] |= 0x00000002u; - package_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileDescriptorProto.package) -} -inline void FileDescriptorProto::set_package(const char* value) { - GOOGLE_DCHECK(value != nullptr); - _has_bits_[0] |= 0x00000002u; - package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:google.protobuf.FileDescriptorProto.package) -} -inline void FileDescriptorProto::set_package(const char* value, - size_t size) { - _has_bits_[0] |= 0x00000002u; - package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast<const char*>(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileDescriptorProto.package) -} inline std::string* FileDescriptorProto::_internal_mutable_package() { _has_bits_[0] |= 0x00000002u; return package_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); @@ -7293,8 +7032,11 @@ // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.syntax) return _internal_syntax(); } -inline void FileDescriptorProto::set_syntax(const std::string& value) { - _internal_set_syntax(value); +template <typename ArgT0, typename... ArgT> +PROTOBUF_ALWAYS_INLINE +inline void FileDescriptorProto::set_syntax(ArgT0&& arg0, ArgT... args) { + _has_bits_[0] |= 0x00000004u; + syntax_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.syntax) } inline std::string* FileDescriptorProto::mutable_syntax() { @@ -7308,25 +7050,6 @@ _has_bits_[0] |= 0x00000004u; syntax_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); } -inline void FileDescriptorProto::set_syntax(std::string&& value) { - _has_bits_[0] |= 0x00000004u; - syntax_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileDescriptorProto.syntax) -} -inline void FileDescriptorProto::set_syntax(const char* value) { - GOOGLE_DCHECK(value != nullptr); - _has_bits_[0] |= 0x00000004u; - syntax_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:google.protobuf.FileDescriptorProto.syntax) -} -inline void FileDescriptorProto::set_syntax(const char* value, - size_t size) { - _has_bits_[0] |= 0x00000004u; - syntax_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast<const char*>(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileDescriptorProto.syntax) -} inline std::string* FileDescriptorProto::_internal_mutable_syntax() { _has_bits_[0] |= 0x00000004u; return syntax_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); @@ -7573,8 +7296,11 @@ // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.name) return _internal_name(); } -inline void DescriptorProto::set_name(const std::string& value) { - _internal_set_name(value); +template <typename ArgT0, typename... ArgT> +PROTOBUF_ALWAYS_INLINE +inline void DescriptorProto::set_name(ArgT0&& arg0, ArgT... args) { + _has_bits_[0] |= 0x00000001u; + name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.name) } inline std::string* DescriptorProto::mutable_name() { @@ -7588,25 +7314,6 @@ _has_bits_[0] |= 0x00000001u; name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); } -inline void DescriptorProto::set_name(std::string&& value) { - _has_bits_[0] |= 0x00000001u; - name_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.DescriptorProto.name) -} -inline void DescriptorProto::set_name(const char* value) { - GOOGLE_DCHECK(value != nullptr); - _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:google.protobuf.DescriptorProto.name) -} -inline void DescriptorProto::set_name(const char* value, - size_t size) { - _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast<const char*>(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.DescriptorProto.name) -} inline std::string* DescriptorProto::_internal_mutable_name() { _has_bits_[0] |= 0x00000001u; return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); @@ -8123,8 +7830,11 @@ // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.name) return _internal_name(); } -inline void FieldDescriptorProto::set_name(const std::string& value) { - _internal_set_name(value); +template <typename ArgT0, typename... ArgT> +PROTOBUF_ALWAYS_INLINE +inline void FieldDescriptorProto::set_name(ArgT0&& arg0, ArgT... args) { + _has_bits_[0] |= 0x00000001u; + name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.name) } inline std::string* FieldDescriptorProto::mutable_name() { @@ -8138,25 +7848,6 @@ _has_bits_[0] |= 0x00000001u; name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); } -inline void FieldDescriptorProto::set_name(std::string&& value) { - _has_bits_[0] |= 0x00000001u; - name_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FieldDescriptorProto.name) -} -inline void FieldDescriptorProto::set_name(const char* value) { - GOOGLE_DCHECK(value != nullptr); - _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:google.protobuf.FieldDescriptorProto.name) -} -inline void FieldDescriptorProto::set_name(const char* value, - size_t size) { - _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast<const char*>(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.FieldDescriptorProto.name) -} inline std::string* FieldDescriptorProto::_internal_mutable_name() { _has_bits_[0] |= 0x00000001u; return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); @@ -8282,8 +7973,11 @@ // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.type_name) return _internal_type_name(); } -inline void FieldDescriptorProto::set_type_name(const std::string& value) { - _internal_set_type_name(value); +template <typename ArgT0, typename... ArgT> +PROTOBUF_ALWAYS_INLINE +inline void FieldDescriptorProto::set_type_name(ArgT0&& arg0, ArgT... args) { + _has_bits_[0] |= 0x00000004u; + type_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.type_name) } inline std::string* FieldDescriptorProto::mutable_type_name() { @@ -8297,25 +7991,6 @@ _has_bits_[0] |= 0x00000004u; type_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); } -inline void FieldDescriptorProto::set_type_name(std::string&& value) { - _has_bits_[0] |= 0x00000004u; - type_name_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FieldDescriptorProto.type_name) -} -inline void FieldDescriptorProto::set_type_name(const char* value) { - GOOGLE_DCHECK(value != nullptr); - _has_bits_[0] |= 0x00000004u; - type_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:google.protobuf.FieldDescriptorProto.type_name) -} -inline void FieldDescriptorProto::set_type_name(const char* value, - size_t size) { - _has_bits_[0] |= 0x00000004u; - type_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast<const char*>(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.FieldDescriptorProto.type_name) -} inline std::string* FieldDescriptorProto::_internal_mutable_type_name() { _has_bits_[0] |= 0x00000004u; return type_name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); @@ -8355,8 +8030,11 @@ // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.extendee) return _internal_extendee(); } -inline void FieldDescriptorProto::set_extendee(const std::string& value) { - _internal_set_extendee(value); +template <typename ArgT0, typename... ArgT> +PROTOBUF_ALWAYS_INLINE +inline void FieldDescriptorProto::set_extendee(ArgT0&& arg0, ArgT... args) { + _has_bits_[0] |= 0x00000002u; + extendee_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.extendee) } inline std::string* FieldDescriptorProto::mutable_extendee() { @@ -8370,25 +8048,6 @@ _has_bits_[0] |= 0x00000002u; extendee_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); } -inline void FieldDescriptorProto::set_extendee(std::string&& value) { - _has_bits_[0] |= 0x00000002u; - extendee_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FieldDescriptorProto.extendee) -} -inline void FieldDescriptorProto::set_extendee(const char* value) { - GOOGLE_DCHECK(value != nullptr); - _has_bits_[0] |= 0x00000002u; - extendee_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:google.protobuf.FieldDescriptorProto.extendee) -} -inline void FieldDescriptorProto::set_extendee(const char* value, - size_t size) { - _has_bits_[0] |= 0x00000002u; - extendee_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast<const char*>(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.FieldDescriptorProto.extendee) -} inline std::string* FieldDescriptorProto::_internal_mutable_extendee() { _has_bits_[0] |= 0x00000002u; return extendee_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); @@ -8428,8 +8087,11 @@ // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.default_value) return _internal_default_value(); } -inline void FieldDescriptorProto::set_default_value(const std::string& value) { - _internal_set_default_value(value); +template <typename ArgT0, typename... ArgT> +PROTOBUF_ALWAYS_INLINE +inline void FieldDescriptorProto::set_default_value(ArgT0&& arg0, ArgT... args) { + _has_bits_[0] |= 0x00000008u; + default_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.default_value) } inline std::string* FieldDescriptorProto::mutable_default_value() { @@ -8443,25 +8105,6 @@ _has_bits_[0] |= 0x00000008u; default_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); } -inline void FieldDescriptorProto::set_default_value(std::string&& value) { - _has_bits_[0] |= 0x00000008u; - default_value_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FieldDescriptorProto.default_value) -} -inline void FieldDescriptorProto::set_default_value(const char* value) { - GOOGLE_DCHECK(value != nullptr); - _has_bits_[0] |= 0x00000008u; - default_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:google.protobuf.FieldDescriptorProto.default_value) -} -inline void FieldDescriptorProto::set_default_value(const char* value, - size_t size) { - _has_bits_[0] |= 0x00000008u; - default_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast<const char*>(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.FieldDescriptorProto.default_value) -} inline std::string* FieldDescriptorProto::_internal_mutable_default_value() { _has_bits_[0] |= 0x00000008u; return default_value_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); @@ -8529,8 +8172,11 @@ // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.json_name) return _internal_json_name(); } -inline void FieldDescriptorProto::set_json_name(const std::string& value) { - _internal_set_json_name(value); +template <typename ArgT0, typename... ArgT> +PROTOBUF_ALWAYS_INLINE +inline void FieldDescriptorProto::set_json_name(ArgT0&& arg0, ArgT... args) { + _has_bits_[0] |= 0x00000010u; + json_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.json_name) } inline std::string* FieldDescriptorProto::mutable_json_name() { @@ -8544,25 +8190,6 @@ _has_bits_[0] |= 0x00000010u; json_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); } -inline void FieldDescriptorProto::set_json_name(std::string&& value) { - _has_bits_[0] |= 0x00000010u; - json_name_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FieldDescriptorProto.json_name) -} -inline void FieldDescriptorProto::set_json_name(const char* value) { - GOOGLE_DCHECK(value != nullptr); - _has_bits_[0] |= 0x00000010u; - json_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:google.protobuf.FieldDescriptorProto.json_name) -} -inline void FieldDescriptorProto::set_json_name(const char* value, - size_t size) { - _has_bits_[0] |= 0x00000010u; - json_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast<const char*>(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.FieldDescriptorProto.json_name) -} inline std::string* FieldDescriptorProto::_internal_mutable_json_name() { _has_bits_[0] |= 0x00000010u; return json_name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); @@ -8717,8 +8344,11 @@ // @@protoc_insertion_point(field_get:google.protobuf.OneofDescriptorProto.name) return _internal_name(); } -inline void OneofDescriptorProto::set_name(const std::string& value) { - _internal_set_name(value); +template <typename ArgT0, typename... ArgT> +PROTOBUF_ALWAYS_INLINE +inline void OneofDescriptorProto::set_name(ArgT0&& arg0, ArgT... args) { + _has_bits_[0] |= 0x00000001u; + name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); // @@protoc_insertion_point(field_set:google.protobuf.OneofDescriptorProto.name) } inline std::string* OneofDescriptorProto::mutable_name() { @@ -8732,25 +8362,6 @@ _has_bits_[0] |= 0x00000001u; name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); } -inline void OneofDescriptorProto::set_name(std::string&& value) { - _has_bits_[0] |= 0x00000001u; - name_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.OneofDescriptorProto.name) -} -inline void OneofDescriptorProto::set_name(const char* value) { - GOOGLE_DCHECK(value != nullptr); - _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:google.protobuf.OneofDescriptorProto.name) -} -inline void OneofDescriptorProto::set_name(const char* value, - size_t size) { - _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast<const char*>(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.OneofDescriptorProto.name) -} inline std::string* OneofDescriptorProto::_internal_mutable_name() { _has_bits_[0] |= 0x00000001u; return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); @@ -8937,8 +8548,11 @@ // @@protoc_insertion_point(field_get:google.protobuf.EnumDescriptorProto.name) return _internal_name(); } -inline void EnumDescriptorProto::set_name(const std::string& value) { - _internal_set_name(value); +template <typename ArgT0, typename... ArgT> +PROTOBUF_ALWAYS_INLINE +inline void EnumDescriptorProto::set_name(ArgT0&& arg0, ArgT... args) { + _has_bits_[0] |= 0x00000001u; + name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); // @@protoc_insertion_point(field_set:google.protobuf.EnumDescriptorProto.name) } inline std::string* EnumDescriptorProto::mutable_name() { @@ -8952,25 +8566,6 @@ _has_bits_[0] |= 0x00000001u; name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); } -inline void EnumDescriptorProto::set_name(std::string&& value) { - _has_bits_[0] |= 0x00000001u; - name_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.EnumDescriptorProto.name) -} -inline void EnumDescriptorProto::set_name(const char* value) { - GOOGLE_DCHECK(value != nullptr); - _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:google.protobuf.EnumDescriptorProto.name) -} -inline void EnumDescriptorProto::set_name(const char* value, - size_t size) { - _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast<const char*>(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.EnumDescriptorProto.name) -} inline std::string* EnumDescriptorProto::_internal_mutable_name() { _has_bits_[0] |= 0x00000001u; return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); @@ -9249,8 +8844,11 @@ // @@protoc_insertion_point(field_get:google.protobuf.EnumValueDescriptorProto.name) return _internal_name(); } -inline void EnumValueDescriptorProto::set_name(const std::string& value) { - _internal_set_name(value); +template <typename ArgT0, typename... ArgT> +PROTOBUF_ALWAYS_INLINE +inline void EnumValueDescriptorProto::set_name(ArgT0&& arg0, ArgT... args) { + _has_bits_[0] |= 0x00000001u; + name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); // @@protoc_insertion_point(field_set:google.protobuf.EnumValueDescriptorProto.name) } inline std::string* EnumValueDescriptorProto::mutable_name() { @@ -9264,25 +8862,6 @@ _has_bits_[0] |= 0x00000001u; name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); } -inline void EnumValueDescriptorProto::set_name(std::string&& value) { - _has_bits_[0] |= 0x00000001u; - name_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.EnumValueDescriptorProto.name) -} -inline void EnumValueDescriptorProto::set_name(const char* value) { - GOOGLE_DCHECK(value != nullptr); - _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:google.protobuf.EnumValueDescriptorProto.name) -} -inline void EnumValueDescriptorProto::set_name(const char* value, - size_t size) { - _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast<const char*>(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.EnumValueDescriptorProto.name) -} inline std::string* EnumValueDescriptorProto::_internal_mutable_name() { _has_bits_[0] |= 0x00000001u; return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); @@ -9437,8 +9016,11 @@ // @@protoc_insertion_point(field_get:google.protobuf.ServiceDescriptorProto.name) return _internal_name(); } -inline void ServiceDescriptorProto::set_name(const std::string& value) { - _internal_set_name(value); +template <typename ArgT0, typename... ArgT> +PROTOBUF_ALWAYS_INLINE +inline void ServiceDescriptorProto::set_name(ArgT0&& arg0, ArgT... args) { + _has_bits_[0] |= 0x00000001u; + name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); // @@protoc_insertion_point(field_set:google.protobuf.ServiceDescriptorProto.name) } inline std::string* ServiceDescriptorProto::mutable_name() { @@ -9452,25 +9034,6 @@ _has_bits_[0] |= 0x00000001u; name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); } -inline void ServiceDescriptorProto::set_name(std::string&& value) { - _has_bits_[0] |= 0x00000001u; - name_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.ServiceDescriptorProto.name) -} -inline void ServiceDescriptorProto::set_name(const char* value) { - GOOGLE_DCHECK(value != nullptr); - _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:google.protobuf.ServiceDescriptorProto.name) -} -inline void ServiceDescriptorProto::set_name(const char* value, - size_t size) { - _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast<const char*>(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.ServiceDescriptorProto.name) -} inline std::string* ServiceDescriptorProto::_internal_mutable_name() { _has_bits_[0] |= 0x00000001u; return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); @@ -9636,8 +9199,11 @@ // @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.name) return _internal_name(); } -inline void MethodDescriptorProto::set_name(const std::string& value) { - _internal_set_name(value); +template <typename ArgT0, typename... ArgT> +PROTOBUF_ALWAYS_INLINE +inline void MethodDescriptorProto::set_name(ArgT0&& arg0, ArgT... args) { + _has_bits_[0] |= 0x00000001u; + name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); // @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.name) } inline std::string* MethodDescriptorProto::mutable_name() { @@ -9651,25 +9217,6 @@ _has_bits_[0] |= 0x00000001u; name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); } -inline void MethodDescriptorProto::set_name(std::string&& value) { - _has_bits_[0] |= 0x00000001u; - name_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.MethodDescriptorProto.name) -} -inline void MethodDescriptorProto::set_name(const char* value) { - GOOGLE_DCHECK(value != nullptr); - _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:google.protobuf.MethodDescriptorProto.name) -} -inline void MethodDescriptorProto::set_name(const char* value, - size_t size) { - _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast<const char*>(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.MethodDescriptorProto.name) -} inline std::string* MethodDescriptorProto::_internal_mutable_name() { _has_bits_[0] |= 0x00000001u; return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); @@ -9709,8 +9256,11 @@ // @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.input_type) return _internal_input_type(); } -inline void MethodDescriptorProto::set_input_type(const std::string& value) { - _internal_set_input_type(value); +template <typename ArgT0, typename... ArgT> +PROTOBUF_ALWAYS_INLINE +inline void MethodDescriptorProto::set_input_type(ArgT0&& arg0, ArgT... args) { + _has_bits_[0] |= 0x00000002u; + input_type_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); // @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.input_type) } inline std::string* MethodDescriptorProto::mutable_input_type() { @@ -9724,25 +9274,6 @@ _has_bits_[0] |= 0x00000002u; input_type_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); } -inline void MethodDescriptorProto::set_input_type(std::string&& value) { - _has_bits_[0] |= 0x00000002u; - input_type_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.MethodDescriptorProto.input_type) -} -inline void MethodDescriptorProto::set_input_type(const char* value) { - GOOGLE_DCHECK(value != nullptr); - _has_bits_[0] |= 0x00000002u; - input_type_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:google.protobuf.MethodDescriptorProto.input_type) -} -inline void MethodDescriptorProto::set_input_type(const char* value, - size_t size) { - _has_bits_[0] |= 0x00000002u; - input_type_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast<const char*>(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.MethodDescriptorProto.input_type) -} inline std::string* MethodDescriptorProto::_internal_mutable_input_type() { _has_bits_[0] |= 0x00000002u; return input_type_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); @@ -9782,8 +9313,11 @@ // @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.output_type) return _internal_output_type(); } -inline void MethodDescriptorProto::set_output_type(const std::string& value) { - _internal_set_output_type(value); +template <typename ArgT0, typename... ArgT> +PROTOBUF_ALWAYS_INLINE +inline void MethodDescriptorProto::set_output_type(ArgT0&& arg0, ArgT... args) { + _has_bits_[0] |= 0x00000004u; + output_type_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); // @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.output_type) } inline std::string* MethodDescriptorProto::mutable_output_type() { @@ -9797,25 +9331,6 @@ _has_bits_[0] |= 0x00000004u; output_type_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); } -inline void MethodDescriptorProto::set_output_type(std::string&& value) { - _has_bits_[0] |= 0x00000004u; - output_type_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.MethodDescriptorProto.output_type) -} -inline void MethodDescriptorProto::set_output_type(const char* value) { - GOOGLE_DCHECK(value != nullptr); - _has_bits_[0] |= 0x00000004u; - output_type_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:google.protobuf.MethodDescriptorProto.output_type) -} -inline void MethodDescriptorProto::set_output_type(const char* value, - size_t size) { - _has_bits_[0] |= 0x00000004u; - output_type_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast<const char*>(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.MethodDescriptorProto.output_type) -} inline std::string* MethodDescriptorProto::_internal_mutable_output_type() { _has_bits_[0] |= 0x00000004u; return output_type_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); @@ -9998,8 +9513,11 @@ // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.java_package) return _internal_java_package(); } -inline void FileOptions::set_java_package(const std::string& value) { - _internal_set_java_package(value); +template <typename ArgT0, typename... ArgT> +PROTOBUF_ALWAYS_INLINE +inline void FileOptions::set_java_package(ArgT0&& arg0, ArgT... args) { + _has_bits_[0] |= 0x00000001u; + java_package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_package) } inline std::string* FileOptions::mutable_java_package() { @@ -10013,25 +9531,6 @@ _has_bits_[0] |= 0x00000001u; java_package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); } -inline void FileOptions::set_java_package(std::string&& value) { - _has_bits_[0] |= 0x00000001u; - java_package_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.java_package) -} -inline void FileOptions::set_java_package(const char* value) { - GOOGLE_DCHECK(value != nullptr); - _has_bits_[0] |= 0x00000001u; - java_package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.java_package) -} -inline void FileOptions::set_java_package(const char* value, - size_t size) { - _has_bits_[0] |= 0x00000001u; - java_package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast<const char*>(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.java_package) -} inline std::string* FileOptions::_internal_mutable_java_package() { _has_bits_[0] |= 0x00000001u; return java_package_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); @@ -10071,8 +9570,11 @@ // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.java_outer_classname) return _internal_java_outer_classname(); } -inline void FileOptions::set_java_outer_classname(const std::string& value) { - _internal_set_java_outer_classname(value); +template <typename ArgT0, typename... ArgT> +PROTOBUF_ALWAYS_INLINE +inline void FileOptions::set_java_outer_classname(ArgT0&& arg0, ArgT... args) { + _has_bits_[0] |= 0x00000002u; + java_outer_classname_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_outer_classname) } inline std::string* FileOptions::mutable_java_outer_classname() { @@ -10086,25 +9588,6 @@ _has_bits_[0] |= 0x00000002u; java_outer_classname_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); } -inline void FileOptions::set_java_outer_classname(std::string&& value) { - _has_bits_[0] |= 0x00000002u; - java_outer_classname_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.java_outer_classname) -} -inline void FileOptions::set_java_outer_classname(const char* value) { - GOOGLE_DCHECK(value != nullptr); - _has_bits_[0] |= 0x00000002u; - java_outer_classname_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.java_outer_classname) -} -inline void FileOptions::set_java_outer_classname(const char* value, - size_t size) { - _has_bits_[0] |= 0x00000002u; - java_outer_classname_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast<const char*>(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.java_outer_classname) -} inline std::string* FileOptions::_internal_mutable_java_outer_classname() { _has_bits_[0] |= 0x00000002u; return java_outer_classname_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); @@ -10257,8 +9740,11 @@ // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.go_package) return _internal_go_package(); } -inline void FileOptions::set_go_package(const std::string& value) { - _internal_set_go_package(value); +template <typename ArgT0, typename... ArgT> +PROTOBUF_ALWAYS_INLINE +inline void FileOptions::set_go_package(ArgT0&& arg0, ArgT... args) { + _has_bits_[0] |= 0x00000004u; + go_package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.go_package) } inline std::string* FileOptions::mutable_go_package() { @@ -10272,25 +9758,6 @@ _has_bits_[0] |= 0x00000004u; go_package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); } -inline void FileOptions::set_go_package(std::string&& value) { - _has_bits_[0] |= 0x00000004u; - go_package_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.go_package) -} -inline void FileOptions::set_go_package(const char* value) { - GOOGLE_DCHECK(value != nullptr); - _has_bits_[0] |= 0x00000004u; - go_package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.go_package) -} -inline void FileOptions::set_go_package(const char* value, - size_t size) { - _has_bits_[0] |= 0x00000004u; - go_package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast<const char*>(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.go_package) -} inline std::string* FileOptions::_internal_mutable_go_package() { _has_bits_[0] |= 0x00000004u; return go_package_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); @@ -10498,8 +9965,11 @@ // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.objc_class_prefix) return _internal_objc_class_prefix(); } -inline void FileOptions::set_objc_class_prefix(const std::string& value) { - _internal_set_objc_class_prefix(value); +template <typename ArgT0, typename... ArgT> +PROTOBUF_ALWAYS_INLINE +inline void FileOptions::set_objc_class_prefix(ArgT0&& arg0, ArgT... args) { + _has_bits_[0] |= 0x00000008u; + objc_class_prefix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.objc_class_prefix) } inline std::string* FileOptions::mutable_objc_class_prefix() { @@ -10513,25 +9983,6 @@ _has_bits_[0] |= 0x00000008u; objc_class_prefix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); } -inline void FileOptions::set_objc_class_prefix(std::string&& value) { - _has_bits_[0] |= 0x00000008u; - objc_class_prefix_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.objc_class_prefix) -} -inline void FileOptions::set_objc_class_prefix(const char* value) { - GOOGLE_DCHECK(value != nullptr); - _has_bits_[0] |= 0x00000008u; - objc_class_prefix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.objc_class_prefix) -} -inline void FileOptions::set_objc_class_prefix(const char* value, - size_t size) { - _has_bits_[0] |= 0x00000008u; - objc_class_prefix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast<const char*>(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.objc_class_prefix) -} inline std::string* FileOptions::_internal_mutable_objc_class_prefix() { _has_bits_[0] |= 0x00000008u; return objc_class_prefix_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); @@ -10571,8 +10022,11 @@ // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.csharp_namespace) return _internal_csharp_namespace(); } -inline void FileOptions::set_csharp_namespace(const std::string& value) { - _internal_set_csharp_namespace(value); +template <typename ArgT0, typename... ArgT> +PROTOBUF_ALWAYS_INLINE +inline void FileOptions::set_csharp_namespace(ArgT0&& arg0, ArgT... args) { + _has_bits_[0] |= 0x00000010u; + csharp_namespace_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_namespace) } inline std::string* FileOptions::mutable_csharp_namespace() { @@ -10586,25 +10040,6 @@ _has_bits_[0] |= 0x00000010u; csharp_namespace_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); } -inline void FileOptions::set_csharp_namespace(std::string&& value) { - _has_bits_[0] |= 0x00000010u; - csharp_namespace_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.csharp_namespace) -} -inline void FileOptions::set_csharp_namespace(const char* value) { - GOOGLE_DCHECK(value != nullptr); - _has_bits_[0] |= 0x00000010u; - csharp_namespace_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.csharp_namespace) -} -inline void FileOptions::set_csharp_namespace(const char* value, - size_t size) { - _has_bits_[0] |= 0x00000010u; - csharp_namespace_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast<const char*>(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.csharp_namespace) -} inline std::string* FileOptions::_internal_mutable_csharp_namespace() { _has_bits_[0] |= 0x00000010u; return csharp_namespace_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); @@ -10644,8 +10079,11 @@ // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.swift_prefix) return _internal_swift_prefix(); } -inline void FileOptions::set_swift_prefix(const std::string& value) { - _internal_set_swift_prefix(value); +template <typename ArgT0, typename... ArgT> +PROTOBUF_ALWAYS_INLINE +inline void FileOptions::set_swift_prefix(ArgT0&& arg0, ArgT... args) { + _has_bits_[0] |= 0x00000020u; + swift_prefix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.swift_prefix) } inline std::string* FileOptions::mutable_swift_prefix() { @@ -10659,25 +10097,6 @@ _has_bits_[0] |= 0x00000020u; swift_prefix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); } -inline void FileOptions::set_swift_prefix(std::string&& value) { - _has_bits_[0] |= 0x00000020u; - swift_prefix_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.swift_prefix) -} -inline void FileOptions::set_swift_prefix(const char* value) { - GOOGLE_DCHECK(value != nullptr); - _has_bits_[0] |= 0x00000020u; - swift_prefix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.swift_prefix) -} -inline void FileOptions::set_swift_prefix(const char* value, - size_t size) { - _has_bits_[0] |= 0x00000020u; - swift_prefix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast<const char*>(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.swift_prefix) -} inline std::string* FileOptions::_internal_mutable_swift_prefix() { _has_bits_[0] |= 0x00000020u; return swift_prefix_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); @@ -10717,8 +10136,11 @@ // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.php_class_prefix) return _internal_php_class_prefix(); } -inline void FileOptions::set_php_class_prefix(const std::string& value) { - _internal_set_php_class_prefix(value); +template <typename ArgT0, typename... ArgT> +PROTOBUF_ALWAYS_INLINE +inline void FileOptions::set_php_class_prefix(ArgT0&& arg0, ArgT... args) { + _has_bits_[0] |= 0x00000040u; + php_class_prefix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.php_class_prefix) } inline std::string* FileOptions::mutable_php_class_prefix() { @@ -10732,25 +10154,6 @@ _has_bits_[0] |= 0x00000040u; php_class_prefix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); } -inline void FileOptions::set_php_class_prefix(std::string&& value) { - _has_bits_[0] |= 0x00000040u; - php_class_prefix_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.php_class_prefix) -} -inline void FileOptions::set_php_class_prefix(const char* value) { - GOOGLE_DCHECK(value != nullptr); - _has_bits_[0] |= 0x00000040u; - php_class_prefix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.php_class_prefix) -} -inline void FileOptions::set_php_class_prefix(const char* value, - size_t size) { - _has_bits_[0] |= 0x00000040u; - php_class_prefix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast<const char*>(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.php_class_prefix) -} inline std::string* FileOptions::_internal_mutable_php_class_prefix() { _has_bits_[0] |= 0x00000040u; return php_class_prefix_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); @@ -10790,8 +10193,11 @@ // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.php_namespace) return _internal_php_namespace(); } -inline void FileOptions::set_php_namespace(const std::string& value) { - _internal_set_php_namespace(value); +template <typename ArgT0, typename... ArgT> +PROTOBUF_ALWAYS_INLINE +inline void FileOptions::set_php_namespace(ArgT0&& arg0, ArgT... args) { + _has_bits_[0] |= 0x00000080u; + php_namespace_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.php_namespace) } inline std::string* FileOptions::mutable_php_namespace() { @@ -10805,25 +10211,6 @@ _has_bits_[0] |= 0x00000080u; php_namespace_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); } -inline void FileOptions::set_php_namespace(std::string&& value) { - _has_bits_[0] |= 0x00000080u; - php_namespace_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.php_namespace) -} -inline void FileOptions::set_php_namespace(const char* value) { - GOOGLE_DCHECK(value != nullptr); - _has_bits_[0] |= 0x00000080u; - php_namespace_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.php_namespace) -} -inline void FileOptions::set_php_namespace(const char* value, - size_t size) { - _has_bits_[0] |= 0x00000080u; - php_namespace_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast<const char*>(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.php_namespace) -} inline std::string* FileOptions::_internal_mutable_php_namespace() { _has_bits_[0] |= 0x00000080u; return php_namespace_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); @@ -10863,8 +10250,11 @@ // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.php_metadata_namespace) return _internal_php_metadata_namespace(); } -inline void FileOptions::set_php_metadata_namespace(const std::string& value) { - _internal_set_php_metadata_namespace(value); +template <typename ArgT0, typename... ArgT> +PROTOBUF_ALWAYS_INLINE +inline void FileOptions::set_php_metadata_namespace(ArgT0&& arg0, ArgT... args) { + _has_bits_[0] |= 0x00000100u; + php_metadata_namespace_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.php_metadata_namespace) } inline std::string* FileOptions::mutable_php_metadata_namespace() { @@ -10878,25 +10268,6 @@ _has_bits_[0] |= 0x00000100u; php_metadata_namespace_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); } -inline void FileOptions::set_php_metadata_namespace(std::string&& value) { - _has_bits_[0] |= 0x00000100u; - php_metadata_namespace_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.php_metadata_namespace) -} -inline void FileOptions::set_php_metadata_namespace(const char* value) { - GOOGLE_DCHECK(value != nullptr); - _has_bits_[0] |= 0x00000100u; - php_metadata_namespace_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.php_metadata_namespace) -} -inline void FileOptions::set_php_metadata_namespace(const char* value, - size_t size) { - _has_bits_[0] |= 0x00000100u; - php_metadata_namespace_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast<const char*>(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.php_metadata_namespace) -} inline std::string* FileOptions::_internal_mutable_php_metadata_namespace() { _has_bits_[0] |= 0x00000100u; return php_metadata_namespace_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); @@ -10936,8 +10307,11 @@ // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.ruby_package) return _internal_ruby_package(); } -inline void FileOptions::set_ruby_package(const std::string& value) { - _internal_set_ruby_package(value); +template <typename ArgT0, typename... ArgT> +PROTOBUF_ALWAYS_INLINE +inline void FileOptions::set_ruby_package(ArgT0&& arg0, ArgT... args) { + _has_bits_[0] |= 0x00000200u; + ruby_package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.ruby_package) } inline std::string* FileOptions::mutable_ruby_package() { @@ -10951,25 +10325,6 @@ _has_bits_[0] |= 0x00000200u; ruby_package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); } -inline void FileOptions::set_ruby_package(std::string&& value) { - _has_bits_[0] |= 0x00000200u; - ruby_package_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.ruby_package) -} -inline void FileOptions::set_ruby_package(const char* value) { - GOOGLE_DCHECK(value != nullptr); - _has_bits_[0] |= 0x00000200u; - ruby_package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.ruby_package) -} -inline void FileOptions::set_ruby_package(const char* value, - size_t size) { - _has_bits_[0] |= 0x00000200u; - ruby_package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast<const char*>(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.ruby_package) -} inline std::string* FileOptions::_internal_mutable_ruby_package() { _has_bits_[0] |= 0x00000200u; return ruby_package_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); @@ -11804,8 +11159,11 @@ // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.NamePart.name_part) return _internal_name_part(); } -inline void UninterpretedOption_NamePart::set_name_part(const std::string& value) { - _internal_set_name_part(value); +template <typename ArgT0, typename... ArgT> +PROTOBUF_ALWAYS_INLINE +inline void UninterpretedOption_NamePart::set_name_part(ArgT0&& arg0, ArgT... args) { + _has_bits_[0] |= 0x00000001u; + name_part_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.NamePart.name_part) } inline std::string* UninterpretedOption_NamePart::mutable_name_part() { @@ -11819,25 +11177,6 @@ _has_bits_[0] |= 0x00000001u; name_part_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); } -inline void UninterpretedOption_NamePart::set_name_part(std::string&& value) { - _has_bits_[0] |= 0x00000001u; - name_part_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.UninterpretedOption.NamePart.name_part) -} -inline void UninterpretedOption_NamePart::set_name_part(const char* value) { - GOOGLE_DCHECK(value != nullptr); - _has_bits_[0] |= 0x00000001u; - name_part_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:google.protobuf.UninterpretedOption.NamePart.name_part) -} -inline void UninterpretedOption_NamePart::set_name_part(const char* value, - size_t size) { - _has_bits_[0] |= 0x00000001u; - name_part_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast<const char*>(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.UninterpretedOption.NamePart.name_part) -} inline std::string* UninterpretedOption_NamePart::_internal_mutable_name_part() { _has_bits_[0] |= 0x00000001u; return name_part_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); @@ -11948,8 +11287,11 @@ // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.identifier_value) return _internal_identifier_value(); } -inline void UninterpretedOption::set_identifier_value(const std::string& value) { - _internal_set_identifier_value(value); +template <typename ArgT0, typename... ArgT> +PROTOBUF_ALWAYS_INLINE +inline void UninterpretedOption::set_identifier_value(ArgT0&& arg0, ArgT... args) { + _has_bits_[0] |= 0x00000001u; + identifier_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.identifier_value) } inline std::string* UninterpretedOption::mutable_identifier_value() { @@ -11963,25 +11305,6 @@ _has_bits_[0] |= 0x00000001u; identifier_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); } -inline void UninterpretedOption::set_identifier_value(std::string&& value) { - _has_bits_[0] |= 0x00000001u; - identifier_value_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.UninterpretedOption.identifier_value) -} -inline void UninterpretedOption::set_identifier_value(const char* value) { - GOOGLE_DCHECK(value != nullptr); - _has_bits_[0] |= 0x00000001u; - identifier_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:google.protobuf.UninterpretedOption.identifier_value) -} -inline void UninterpretedOption::set_identifier_value(const char* value, - size_t size) { - _has_bits_[0] |= 0x00000001u; - identifier_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast<const char*>(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.UninterpretedOption.identifier_value) -} inline std::string* UninterpretedOption::_internal_mutable_identifier_value() { _has_bits_[0] |= 0x00000001u; return identifier_value_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); @@ -12105,8 +11428,11 @@ // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.string_value) return _internal_string_value(); } -inline void UninterpretedOption::set_string_value(const std::string& value) { - _internal_set_string_value(value); +template <typename ArgT0, typename... ArgT> +PROTOBUF_ALWAYS_INLINE +inline void UninterpretedOption::set_string_value(ArgT0&& arg0, ArgT... args) { + _has_bits_[0] |= 0x00000002u; + string_value_.SetBytes(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.string_value) } inline std::string* UninterpretedOption::mutable_string_value() { @@ -12120,25 +11446,6 @@ _has_bits_[0] |= 0x00000002u; string_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); } -inline void UninterpretedOption::set_string_value(std::string&& value) { - _has_bits_[0] |= 0x00000002u; - string_value_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.UninterpretedOption.string_value) -} -inline void UninterpretedOption::set_string_value(const char* value) { - GOOGLE_DCHECK(value != nullptr); - _has_bits_[0] |= 0x00000002u; - string_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:google.protobuf.UninterpretedOption.string_value) -} -inline void UninterpretedOption::set_string_value(const void* value, - size_t size) { - _has_bits_[0] |= 0x00000002u; - string_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast<const char*>(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.UninterpretedOption.string_value) -} inline std::string* UninterpretedOption::_internal_mutable_string_value() { _has_bits_[0] |= 0x00000002u; return string_value_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); @@ -12178,8 +11485,11 @@ // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.aggregate_value) return _internal_aggregate_value(); } -inline void UninterpretedOption::set_aggregate_value(const std::string& value) { - _internal_set_aggregate_value(value); +template <typename ArgT0, typename... ArgT> +PROTOBUF_ALWAYS_INLINE +inline void UninterpretedOption::set_aggregate_value(ArgT0&& arg0, ArgT... args) { + _has_bits_[0] |= 0x00000004u; + aggregate_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.aggregate_value) } inline std::string* UninterpretedOption::mutable_aggregate_value() { @@ -12193,25 +11503,6 @@ _has_bits_[0] |= 0x00000004u; aggregate_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); } -inline void UninterpretedOption::set_aggregate_value(std::string&& value) { - _has_bits_[0] |= 0x00000004u; - aggregate_value_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.UninterpretedOption.aggregate_value) -} -inline void UninterpretedOption::set_aggregate_value(const char* value) { - GOOGLE_DCHECK(value != nullptr); - _has_bits_[0] |= 0x00000004u; - aggregate_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:google.protobuf.UninterpretedOption.aggregate_value) -} -inline void UninterpretedOption::set_aggregate_value(const char* value, - size_t size) { - _has_bits_[0] |= 0x00000004u; - aggregate_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast<const char*>(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.UninterpretedOption.aggregate_value) -} inline std::string* UninterpretedOption::_internal_mutable_aggregate_value() { _has_bits_[0] |= 0x00000004u; return aggregate_value_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); @@ -12349,8 +11640,11 @@ // @@protoc_insertion_point(field_get:google.protobuf.SourceCodeInfo.Location.leading_comments) return _internal_leading_comments(); } -inline void SourceCodeInfo_Location::set_leading_comments(const std::string& value) { - _internal_set_leading_comments(value); +template <typename ArgT0, typename... ArgT> +PROTOBUF_ALWAYS_INLINE +inline void SourceCodeInfo_Location::set_leading_comments(ArgT0&& arg0, ArgT... args) { + _has_bits_[0] |= 0x00000001u; + leading_comments_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); // @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.leading_comments) } inline std::string* SourceCodeInfo_Location::mutable_leading_comments() { @@ -12364,25 +11658,6 @@ _has_bits_[0] |= 0x00000001u; leading_comments_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); } -inline void SourceCodeInfo_Location::set_leading_comments(std::string&& value) { - _has_bits_[0] |= 0x00000001u; - leading_comments_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.SourceCodeInfo.Location.leading_comments) -} -inline void SourceCodeInfo_Location::set_leading_comments(const char* value) { - GOOGLE_DCHECK(value != nullptr); - _has_bits_[0] |= 0x00000001u; - leading_comments_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:google.protobuf.SourceCodeInfo.Location.leading_comments) -} -inline void SourceCodeInfo_Location::set_leading_comments(const char* value, - size_t size) { - _has_bits_[0] |= 0x00000001u; - leading_comments_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast<const char*>(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.SourceCodeInfo.Location.leading_comments) -} inline std::string* SourceCodeInfo_Location::_internal_mutable_leading_comments() { _has_bits_[0] |= 0x00000001u; return leading_comments_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); @@ -12422,8 +11697,11 @@ // @@protoc_insertion_point(field_get:google.protobuf.SourceCodeInfo.Location.trailing_comments) return _internal_trailing_comments(); } -inline void SourceCodeInfo_Location::set_trailing_comments(const std::string& value) { - _internal_set_trailing_comments(value); +template <typename ArgT0, typename... ArgT> +PROTOBUF_ALWAYS_INLINE +inline void SourceCodeInfo_Location::set_trailing_comments(ArgT0&& arg0, ArgT... args) { + _has_bits_[0] |= 0x00000002u; + trailing_comments_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); // @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.trailing_comments) } inline std::string* SourceCodeInfo_Location::mutable_trailing_comments() { @@ -12437,25 +11715,6 @@ _has_bits_[0] |= 0x00000002u; trailing_comments_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); } -inline void SourceCodeInfo_Location::set_trailing_comments(std::string&& value) { - _has_bits_[0] |= 0x00000002u; - trailing_comments_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.SourceCodeInfo.Location.trailing_comments) -} -inline void SourceCodeInfo_Location::set_trailing_comments(const char* value) { - GOOGLE_DCHECK(value != nullptr); - _has_bits_[0] |= 0x00000002u; - trailing_comments_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:google.protobuf.SourceCodeInfo.Location.trailing_comments) -} -inline void SourceCodeInfo_Location::set_trailing_comments(const char* value, - size_t size) { - _has_bits_[0] |= 0x00000002u; - trailing_comments_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast<const char*>(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.SourceCodeInfo.Location.trailing_comments) -} inline std::string* SourceCodeInfo_Location::_internal_mutable_trailing_comments() { _has_bits_[0] |= 0x00000002u; return trailing_comments_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); @@ -12663,8 +11922,11 @@ // @@protoc_insertion_point(field_get:google.protobuf.GeneratedCodeInfo.Annotation.source_file) return _internal_source_file(); } -inline void GeneratedCodeInfo_Annotation::set_source_file(const std::string& value) { - _internal_set_source_file(value); +template <typename ArgT0, typename... ArgT> +PROTOBUF_ALWAYS_INLINE +inline void GeneratedCodeInfo_Annotation::set_source_file(ArgT0&& arg0, ArgT... args) { + _has_bits_[0] |= 0x00000001u; + source_file_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); // @@protoc_insertion_point(field_set:google.protobuf.GeneratedCodeInfo.Annotation.source_file) } inline std::string* GeneratedCodeInfo_Annotation::mutable_source_file() { @@ -12678,25 +11940,6 @@ _has_bits_[0] |= 0x00000001u; source_file_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); } -inline void GeneratedCodeInfo_Annotation::set_source_file(std::string&& value) { - _has_bits_[0] |= 0x00000001u; - source_file_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.GeneratedCodeInfo.Annotation.source_file) -} -inline void GeneratedCodeInfo_Annotation::set_source_file(const char* value) { - GOOGLE_DCHECK(value != nullptr); - _has_bits_[0] |= 0x00000001u; - source_file_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:google.protobuf.GeneratedCodeInfo.Annotation.source_file) -} -inline void GeneratedCodeInfo_Annotation::set_source_file(const char* value, - size_t size) { - _has_bits_[0] |= 0x00000001u; - source_file_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast<const char*>(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.GeneratedCodeInfo.Annotation.source_file) -} inline std::string* GeneratedCodeInfo_Annotation::_internal_mutable_source_file() { _has_bits_[0] |= 0x00000001u; return source_file_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena());
diff --git a/src/google/protobuf/duration.pb.cc b/src/google/protobuf/duration.pb.cc index d04e32b..d00883d 100644 --- a/src/google/protobuf/duration.pb.cc +++ b/src/google/protobuf/duration.pb.cc
@@ -67,10 +67,8 @@ schemas, file_default_instances, TableStruct_google_2fprotobuf_2fduration_2eproto::offsets, file_level_metadata_google_2fprotobuf_2fduration_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fduration_2eproto, file_level_service_descriptors_google_2fprotobuf_2fduration_2eproto, }; -PROTOBUF_ATTRIBUTE_WEAK ::PROTOBUF_NAMESPACE_ID::Metadata -descriptor_table_google_2fprotobuf_2fduration_2eproto_metadata_getter(int index) { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fduration_2eproto); - return descriptor_table_google_2fprotobuf_2fduration_2eproto.file_level_metadata[index]; +PROTOBUF_ATTRIBUTE_WEAK const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable* descriptor_table_google_2fprotobuf_2fduration_2eproto_getter() { + return &descriptor_table_google_2fprotobuf_2fduration_2eproto; } // Force running AddDescriptors() at dynamic initialization time. @@ -297,10 +295,11 @@ } ::PROTOBUF_NAMESPACE_ID::Metadata Duration::GetMetadata() const { - return GetMetadataStatic(); + return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + &descriptor_table_google_2fprotobuf_2fduration_2eproto_getter, &descriptor_table_google_2fprotobuf_2fduration_2eproto_once, + file_level_metadata_google_2fprotobuf_2fduration_2eproto[0]); } - // @@protoc_insertion_point(namespace_scope) PROTOBUF_NAMESPACE_CLOSE PROTOBUF_NAMESPACE_OPEN
diff --git a/src/google/protobuf/duration.pb.h b/src/google/protobuf/duration.pb.h index 341fd80..0017f95 100644 --- a/src/google/protobuf/duration.pb.h +++ b/src/google/protobuf/duration.pb.h
@@ -53,7 +53,6 @@ static const ::PROTOBUF_NAMESPACE_ID::uint32 offsets[]; }; extern PROTOBUF_EXPORT const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fduration_2eproto; -PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Metadata descriptor_table_google_2fprotobuf_2fduration_2eproto_metadata_getter(int index); PROTOBUF_NAMESPACE_OPEN class Duration; struct DurationDefaultTypeInternal; @@ -96,10 +95,10 @@ return GetDescriptor(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; + return default_instance().GetMetadata().descriptor; } static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; + return default_instance().GetMetadata().reflection; } static const Duration& default_instance() { return *internal_default_instance(); @@ -167,12 +166,6 @@ public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - return ::descriptor_table_google_2fprotobuf_2fduration_2eproto_metadata_getter(kIndexInFileMessages); - } - - public: // nested types ----------------------------------------------------
diff --git a/src/google/protobuf/empty.pb.cc b/src/google/protobuf/empty.pb.cc index 42d7f3b..c86d5f2 100644 --- a/src/google/protobuf/empty.pb.cc +++ b/src/google/protobuf/empty.pb.cc
@@ -62,10 +62,8 @@ schemas, file_default_instances, TableStruct_google_2fprotobuf_2fempty_2eproto::offsets, file_level_metadata_google_2fprotobuf_2fempty_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fempty_2eproto, file_level_service_descriptors_google_2fprotobuf_2fempty_2eproto, }; -PROTOBUF_ATTRIBUTE_WEAK ::PROTOBUF_NAMESPACE_ID::Metadata -descriptor_table_google_2fprotobuf_2fempty_2eproto_metadata_getter(int index) { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fempty_2eproto); - return descriptor_table_google_2fprotobuf_2fempty_2eproto.file_level_metadata[index]; +PROTOBUF_ATTRIBUTE_WEAK const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable* descriptor_table_google_2fprotobuf_2fempty_2eproto_getter() { + return &descriptor_table_google_2fprotobuf_2fempty_2eproto; } // Force running AddDescriptors() at dynamic initialization time. @@ -225,10 +223,11 @@ } ::PROTOBUF_NAMESPACE_ID::Metadata Empty::GetMetadata() const { - return GetMetadataStatic(); + return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + &descriptor_table_google_2fprotobuf_2fempty_2eproto_getter, &descriptor_table_google_2fprotobuf_2fempty_2eproto_once, + file_level_metadata_google_2fprotobuf_2fempty_2eproto[0]); } - // @@protoc_insertion_point(namespace_scope) PROTOBUF_NAMESPACE_CLOSE PROTOBUF_NAMESPACE_OPEN
diff --git a/src/google/protobuf/empty.pb.h b/src/google/protobuf/empty.pb.h index 49de6ea..2ee8544 100644 --- a/src/google/protobuf/empty.pb.h +++ b/src/google/protobuf/empty.pb.h
@@ -53,7 +53,6 @@ static const ::PROTOBUF_NAMESPACE_ID::uint32 offsets[]; }; extern PROTOBUF_EXPORT const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fempty_2eproto; -PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Metadata descriptor_table_google_2fprotobuf_2fempty_2eproto_metadata_getter(int index); PROTOBUF_NAMESPACE_OPEN class Empty; struct EmptyDefaultTypeInternal; @@ -96,10 +95,10 @@ return GetDescriptor(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; + return default_instance().GetMetadata().descriptor; } static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; + return default_instance().GetMetadata().reflection; } static const Empty& default_instance() { return *internal_default_instance(); @@ -167,12 +166,6 @@ public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - return ::descriptor_table_google_2fprotobuf_2fempty_2eproto_metadata_getter(kIndexInFileMessages); - } - - public: // nested types ----------------------------------------------------
diff --git a/src/google/protobuf/field_mask.pb.cc b/src/google/protobuf/field_mask.pb.cc index 5a23fc7..d368693 100644 --- a/src/google/protobuf/field_mask.pb.cc +++ b/src/google/protobuf/field_mask.pb.cc
@@ -65,10 +65,8 @@ schemas, file_default_instances, TableStruct_google_2fprotobuf_2ffield_5fmask_2eproto::offsets, file_level_metadata_google_2fprotobuf_2ffield_5fmask_2eproto, file_level_enum_descriptors_google_2fprotobuf_2ffield_5fmask_2eproto, file_level_service_descriptors_google_2fprotobuf_2ffield_5fmask_2eproto, }; -PROTOBUF_ATTRIBUTE_WEAK ::PROTOBUF_NAMESPACE_ID::Metadata -descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto_metadata_getter(int index) { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto); - return descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto.file_level_metadata[index]; +PROTOBUF_ATTRIBUTE_WEAK const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable* descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto_getter() { + return &descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto; } // Force running AddDescriptors() at dynamic initialization time. @@ -270,10 +268,11 @@ } ::PROTOBUF_NAMESPACE_ID::Metadata FieldMask::GetMetadata() const { - return GetMetadataStatic(); + return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + &descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto_getter, &descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto_once, + file_level_metadata_google_2fprotobuf_2ffield_5fmask_2eproto[0]); } - // @@protoc_insertion_point(namespace_scope) PROTOBUF_NAMESPACE_CLOSE PROTOBUF_NAMESPACE_OPEN
diff --git a/src/google/protobuf/field_mask.pb.h b/src/google/protobuf/field_mask.pb.h index 12d39ab..f0cef60 100644 --- a/src/google/protobuf/field_mask.pb.h +++ b/src/google/protobuf/field_mask.pb.h
@@ -53,7 +53,6 @@ static const ::PROTOBUF_NAMESPACE_ID::uint32 offsets[]; }; extern PROTOBUF_EXPORT const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto; -PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Metadata descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto_metadata_getter(int index); PROTOBUF_NAMESPACE_OPEN class FieldMask; struct FieldMaskDefaultTypeInternal; @@ -96,10 +95,10 @@ return GetDescriptor(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; + return default_instance().GetMetadata().descriptor; } static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; + return default_instance().GetMetadata().reflection; } static const FieldMask& default_instance() { return *internal_default_instance(); @@ -167,12 +166,6 @@ public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - return ::descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto_metadata_getter(kIndexInFileMessages); - } - - public: // nested types ----------------------------------------------------
diff --git a/src/google/protobuf/generated_message_reflection.cc b/src/google/protobuf/generated_message_reflection.cc index b2ffe1f..3260e30 100644 --- a/src/google/protobuf/generated_message_reflection.cc +++ b/src/google/protobuf/generated_message_reflection.cc
@@ -2520,6 +2520,17 @@ namespace internal { +Metadata AssignDescriptors(const DescriptorTable* (*table)(), + internal::once_flag* once, + const Metadata& metadata) { + call_once(*once, [=] { + auto* t = table(); + AssignDescriptorsImpl(t, t->is_eager); + }); + + return metadata; +} + void AssignDescriptors(const DescriptorTable* table, bool eager) { if (!eager) eager = table->is_eager; call_once(*table->once, AssignDescriptorsImpl, table, eager);
diff --git a/src/google/protobuf/generated_message_reflection.h b/src/google/protobuf/generated_message_reflection.h index 5916cb7..b34f722 100644 --- a/src/google/protobuf/generated_message_reflection.h +++ b/src/google/protobuf/generated_message_reflection.h
@@ -290,6 +290,14 @@ void PROTOBUF_EXPORT AssignDescriptors(const DescriptorTable* table, bool eager = false); +// Overload used to implement GetMetadataStatic in the generated code. +// See comments in compiler/cpp/internal/file.cc as to why. +// It takes a `Metadata` and returns it to allow for tail calls and reduce +// binary size. +Metadata PROTOBUF_EXPORT AssignDescriptors(const DescriptorTable* (*table)(), + internal::once_flag* once, + const Metadata& metadata); + // These cannot be in lite so we put them in the reflection. PROTOBUF_EXPORT void UnknownFieldSetSerializer(const uint8* base, uint32 offset, uint32 tag, uint32 has_offset,
diff --git a/src/google/protobuf/io/coded_stream.h b/src/google/protobuf/io/coded_stream.h index df8c449..97626f7 100644 --- a/src/google/protobuf/io/coded_stream.h +++ b/src/google/protobuf/io/coded_stream.h
@@ -851,11 +851,11 @@ } static constexpr int TagSize(uint32 tag) { - return (tag < (1 << 7)) - ? 1 - : (tag < (1 << 14)) - ? 2 - : (tag < (1 << 21)) ? 3 : (tag < (1 << 28)) ? 4 : 5; + return (tag < (1 << 7)) ? 1 + : (tag < (1 << 14)) ? 2 + : (tag < (1 << 21)) ? 3 + : (tag < (1 << 28)) ? 4 + : 5; } PROTOBUF_ALWAYS_INLINE uint8* WriteTag(uint32 num, uint32 wt, uint8* ptr) { @@ -1181,12 +1181,11 @@ // Compile-time equivalent of VarintSize32(). template <uint32 Value> struct StaticVarintSize32 { - static const size_t value = - (Value < (1 << 7)) - ? 1 - : (Value < (1 << 14)) - ? 2 - : (Value < (1 << 21)) ? 3 : (Value < (1 << 28)) ? 4 : 5; + static const size_t value = (Value < (1 << 7)) ? 1 + : (Value < (1 << 14)) ? 2 + : (Value < (1 << 21)) ? 3 + : (Value < (1 << 28)) ? 4 + : 5; }; // Returns the total number of bytes written since this object was created.
diff --git a/src/google/protobuf/metadata_lite.h b/src/google/protobuf/metadata_lite.h index 8e1d24e..1f8d8fc 100644 --- a/src/google/protobuf/metadata_lite.h +++ b/src/google/protobuf/metadata_lite.h
@@ -67,7 +67,7 @@ template <typename T> void Delete() { // Note that Delete<> should be called not more than once. - if (have_unknown_fields() && arena() == NULL) { + if (have_unknown_fields()) { DeleteOutOfLineHelper<T>(); } } @@ -204,7 +204,9 @@ template <typename T> PROTOBUF_NOINLINE void DeleteOutOfLineHelper() { - delete PtrValue<Container<T>>(); + if (arena() == NULL) { + delete PtrValue<Container<T>>(); + } } template <typename T>
diff --git a/src/google/protobuf/port_def.inc b/src/google/protobuf/port_def.inc index ae9fef4..6a9403f 100644 --- a/src/google/protobuf/port_def.inc +++ b/src/google/protobuf/port_def.inc
@@ -198,22 +198,24 @@ // You can #define these annotations yourself if the default implementation // is not right for you. +#ifndef PROTOBUF_NO_INLINE #ifdef GOOGLE_ATTRIBUTE_ALWAYS_INLINE #define PROTOBUF_ALWAYS_INLINE GOOGLE_ATTRIBUTE_ALWAYS_INLINE #define PROTOBUF_NDEBUG_INLINE GOOGLE_ATTRIBUTE_ALWAYS_INLINE -#else -#if defined(__GNUC__) && \ +#elif defined(__GNUC__) && \ (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) // For functions we want to force inline. // Introduced in gcc 3.1. #define PROTOBUF_ALWAYS_INLINE __attribute__((always_inline)) #define PROTOBUF_NDEBUG_INLINE __attribute__((always_inline)) -#else +#endif +#endif + +#ifndef PROTOBUF_ALWAYS_INLINE // Other compilers will have to figure it out for themselves. #define PROTOBUF_ALWAYS_INLINE #define PROTOBUF_NDEBUG_INLINE #endif -#endif #ifdef GOOGLE_ATTRIBUTE_NOINLINE #define PROTOBUF_NOINLINE GOOGLE_ATTRIBUTE_NOINLINE
diff --git a/src/google/protobuf/proto3_arena_unittest.cc b/src/google/protobuf/proto3_arena_unittest.cc index 7731b28..83be3d8 100644 --- a/src/google/protobuf/proto3_arena_unittest.cc +++ b/src/google/protobuf/proto3_arena_unittest.cc
@@ -317,6 +317,35 @@ } } +TEST(Proto3OptionalTest, Extensions) { + const DescriptorPool* p = DescriptorPool::generated_pool(); + const FieldDescriptor* no_optional = p->FindExtensionByName( + "protobuf_unittest.Proto3OptionalExtensions.ext_no_optional"); + const FieldDescriptor* with_optional = p->FindExtensionByName( + "protobuf_unittest.Proto3OptionalExtensions.ext_with_optional"); + GOOGLE_CHECK(no_optional); + GOOGLE_CHECK(with_optional); + EXPECT_FALSE(no_optional->has_optional_keyword()); + EXPECT_TRUE(with_optional->has_optional_keyword()); + + const Descriptor* d = protobuf_unittest::Proto3OptionalExtensions::descriptor(); + EXPECT_TRUE(d->options().HasExtension( + protobuf_unittest::Proto3OptionalExtensions::ext_no_optional)); + EXPECT_TRUE(d->options().HasExtension( + protobuf_unittest::Proto3OptionalExtensions::ext_with_optional)); + EXPECT_EQ(8, d->options().GetExtension( + protobuf_unittest::Proto3OptionalExtensions::ext_no_optional)); + EXPECT_EQ(16, + d->options().GetExtension( + protobuf_unittest::Proto3OptionalExtensions::ext_with_optional)); + + const Descriptor* d2 = protobuf_unittest::TestProto3Optional::descriptor(); + EXPECT_FALSE(d2->options().HasExtension( + protobuf_unittest::Proto3OptionalExtensions::ext_no_optional)); + EXPECT_FALSE(d2->options().HasExtension( + protobuf_unittest::Proto3OptionalExtensions::ext_with_optional)); +} + TEST(Proto3OptionalTest, OptionalField) { protobuf_unittest::TestProto3Optional msg; EXPECT_FALSE(msg.has_optional_int32());
diff --git a/src/google/protobuf/repeated_field.cc b/src/google/protobuf/repeated_field.cc index f5e83ff..addd26ce 100644 --- a/src/google/protobuf/repeated_field.cc +++ b/src/google/protobuf/repeated_field.cc
@@ -98,6 +98,15 @@ } } +void* RepeatedPtrFieldBase::AddOutOfLineHelper(void* obj) { + if (!rep_ || rep_->allocated_size == total_size_) { + InternalExtend(1); // Equivalent to "Reserve(total_size_ + 1)" + } + ++rep_->allocated_size; + rep_->elements[current_size_++] = obj; + return obj; +} + void RepeatedPtrFieldBase::CloseGap(int start, int num) { if (rep_ == NULL) return; // Close up a gap of "num" elements starting at offset "start".
diff --git a/src/google/protobuf/repeated_field.h b/src/google/protobuf/repeated_field.h index 9ba9e93..43ca458 100644 --- a/src/google/protobuf/repeated_field.h +++ b/src/google/protobuf/repeated_field.h
@@ -171,9 +171,14 @@ public: constexpr RepeatedField(); explicit RepeatedField(Arena* arena); + RepeatedField(const RepeatedField& other); - template <typename Iter> - RepeatedField(Iter begin, const Iter& end); + + template <typename Iter, + typename = typename std::enable_if<std::is_constructible< + Element, decltype(*std::declval<Iter>())>::value>::type> + RepeatedField(Iter begin, Iter end); + ~RepeatedField(); RepeatedField& operator=(const RepeatedField& other); @@ -769,6 +774,11 @@ // Reserve() and MergeFrom() to reduce code size. |extend_amount| must be > 0. void** InternalExtend(int extend_amount); + // Internal helper for Add: add "obj" as the next element in the + // array, including potentially resizing the array with Reserve if + // needed + void* AddOutOfLineHelper(void* obj); + // The reflection implementation needs to call protected methods directly, // reinterpreting pointers as being to Message instead of a specific Message // subclass. @@ -923,8 +933,12 @@ explicit RepeatedPtrField(Arena* arena); RepeatedPtrField(const RepeatedPtrField& other); - template <typename Iter> - RepeatedPtrField(Iter begin, const Iter& end); + + template <typename Iter, + typename = typename std::enable_if<std::is_constructible< + Element, decltype(*std::declval<Iter>())>::value>::type> + RepeatedPtrField(Iter begin, Iter end); + ~RepeatedPtrField(); RepeatedPtrField& operator=(const RepeatedPtrField& other); @@ -1197,8 +1211,8 @@ } template <typename Element> -template <typename Iter> -RepeatedField<Element>::RepeatedField(Iter begin, const Iter& end) +template <typename Iter, typename> +RepeatedField<Element>::RepeatedField(Iter begin, Iter end) : current_size_(0), total_size_(0), arena_or_elements_(nullptr) { Add(begin, end); } @@ -1747,14 +1761,10 @@ if (rep_ != NULL && current_size_ < rep_->allocated_size) { return cast<TypeHandler>(rep_->elements[current_size_++]); } - if (!rep_ || rep_->allocated_size == total_size_) { - Reserve(total_size_ + 1); - } - ++rep_->allocated_size; typename TypeHandler::Type* result = TypeHandler::NewFromPrototype(prototype, arena_); - rep_->elements[current_size_++] = result; - return result; + return reinterpret_cast<typename TypeHandler::Type*>( + AddOutOfLineHelper(result)); } template <typename TypeHandler, @@ -1828,9 +1838,19 @@ void RepeatedPtrFieldBase::MergeFromInnerLoop(void** our_elems, void** other_elems, int length, int already_allocated) { - // Split into two loops, over ranges [0, allocated) and [allocated, length), - // to avoid a branch within the loop. - for (int i = 0; i < already_allocated && i < length; i++) { + if (already_allocated < length) { + Arena* arena = GetArena(); + typename TypeHandler::Type* elem_prototype = + reinterpret_cast<typename TypeHandler::Type*>(other_elems[0]); + for (int i = already_allocated; i < length; i++) { + // Allocate a new empty element that we'll merge into below + typename TypeHandler::Type* new_elem = + TypeHandler::NewFromPrototype(elem_prototype, arena); + our_elems[i] = new_elem; + } + } + // Main loop that does the actual merging + for (int i = 0; i < length; i++) { // Already allocated: use existing element. typename TypeHandler::Type* other_elem = reinterpret_cast<typename TypeHandler::Type*>(other_elems[i]); @@ -1838,16 +1858,6 @@ reinterpret_cast<typename TypeHandler::Type*>(our_elems[i]); TypeHandler::Merge(*other_elem, new_elem); } - Arena* arena = GetArena(); - for (int i = already_allocated; i < length; i++) { - // Not allocated: alloc a new element first, then merge it. - typename TypeHandler::Type* other_elem = - reinterpret_cast<typename TypeHandler::Type*>(other_elems[i]); - typename TypeHandler::Type* new_elem = - TypeHandler::NewFromPrototype(other_elem, arena); - TypeHandler::Merge(*other_elem, new_elem); - our_elems[i] = new_elem; - } } template <typename TypeHandler> @@ -2110,9 +2120,8 @@ } template <typename Element> -template <typename Iter> -inline RepeatedPtrField<Element>::RepeatedPtrField(Iter begin, - const Iter& end) { +template <typename Iter, typename> +inline RepeatedPtrField<Element>::RepeatedPtrField(Iter begin, Iter end) { int reserve = internal::CalculateReserve(begin, end); if (reserve != -1) { Reserve(reserve);
diff --git a/src/google/protobuf/source_context.pb.cc b/src/google/protobuf/source_context.pb.cc index 641862e..aed802b 100644 --- a/src/google/protobuf/source_context.pb.cc +++ b/src/google/protobuf/source_context.pb.cc
@@ -65,10 +65,8 @@ schemas, file_default_instances, TableStruct_google_2fprotobuf_2fsource_5fcontext_2eproto::offsets, file_level_metadata_google_2fprotobuf_2fsource_5fcontext_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fsource_5fcontext_2eproto, file_level_service_descriptors_google_2fprotobuf_2fsource_5fcontext_2eproto, }; -PROTOBUF_ATTRIBUTE_WEAK ::PROTOBUF_NAMESPACE_ID::Metadata -descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto_metadata_getter(int index) { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto); - return descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto.file_level_metadata[index]; +PROTOBUF_ATTRIBUTE_WEAK const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable* descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto_getter() { + return &descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto; } // Force running AddDescriptors() at dynamic initialization time. @@ -271,10 +269,11 @@ } ::PROTOBUF_NAMESPACE_ID::Metadata SourceContext::GetMetadata() const { - return GetMetadataStatic(); + return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + &descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto_getter, &descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto_once, + file_level_metadata_google_2fprotobuf_2fsource_5fcontext_2eproto[0]); } - // @@protoc_insertion_point(namespace_scope) PROTOBUF_NAMESPACE_CLOSE PROTOBUF_NAMESPACE_OPEN
diff --git a/src/google/protobuf/source_context.pb.h b/src/google/protobuf/source_context.pb.h index e64b0a0..95967cf 100644 --- a/src/google/protobuf/source_context.pb.h +++ b/src/google/protobuf/source_context.pb.h
@@ -53,7 +53,6 @@ static const ::PROTOBUF_NAMESPACE_ID::uint32 offsets[]; }; extern PROTOBUF_EXPORT const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto; -PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Metadata descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto_metadata_getter(int index); PROTOBUF_NAMESPACE_OPEN class SourceContext; struct SourceContextDefaultTypeInternal; @@ -96,10 +95,10 @@ return GetDescriptor(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; + return default_instance().GetMetadata().descriptor; } static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; + return default_instance().GetMetadata().reflection; } static const SourceContext& default_instance() { return *internal_default_instance(); @@ -167,12 +166,6 @@ public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - return ::descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto_metadata_getter(kIndexInFileMessages); - } - - public: // nested types ---------------------------------------------------- @@ -184,10 +177,8 @@ // string file_name = 1; void clear_file_name(); const std::string& file_name() const; - void set_file_name(const std::string& value); - void set_file_name(std::string&& value); - void set_file_name(const char* value); - void set_file_name(const char* value, size_t size); + template <typename ArgT0 = const std::string&, typename... ArgT> + void set_file_name(ArgT0&& arg0, ArgT... args); std::string* mutable_file_name(); std::string* release_file_name(); void set_allocated_file_name(std::string* file_name); @@ -227,8 +218,11 @@ // @@protoc_insertion_point(field_get:google.protobuf.SourceContext.file_name) return _internal_file_name(); } -inline void SourceContext::set_file_name(const std::string& value) { - _internal_set_file_name(value); +template <typename ArgT0, typename... ArgT> +PROTOBUF_ALWAYS_INLINE +inline void SourceContext::set_file_name(ArgT0&& arg0, ArgT... args) { + + file_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); // @@protoc_insertion_point(field_set:google.protobuf.SourceContext.file_name) } inline std::string* SourceContext::mutable_file_name() { @@ -242,25 +236,6 @@ file_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); } -inline void SourceContext::set_file_name(std::string&& value) { - - file_name_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.SourceContext.file_name) -} -inline void SourceContext::set_file_name(const char* value) { - GOOGLE_DCHECK(value != nullptr); - - file_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:google.protobuf.SourceContext.file_name) -} -inline void SourceContext::set_file_name(const char* value, - size_t size) { - - file_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast<const char*>(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.SourceContext.file_name) -} inline std::string* SourceContext::_internal_mutable_file_name() { return file_name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena());
diff --git a/src/google/protobuf/struct.pb.cc b/src/google/protobuf/struct.pb.cc index 61e9f80..7f461f1 100644 --- a/src/google/protobuf/struct.pb.cc +++ b/src/google/protobuf/struct.pb.cc
@@ -143,10 +143,8 @@ schemas, file_default_instances, TableStruct_google_2fprotobuf_2fstruct_2eproto::offsets, file_level_metadata_google_2fprotobuf_2fstruct_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fstruct_2eproto, file_level_service_descriptors_google_2fprotobuf_2fstruct_2eproto, }; -PROTOBUF_ATTRIBUTE_WEAK ::PROTOBUF_NAMESPACE_ID::Metadata -descriptor_table_google_2fprotobuf_2fstruct_2eproto_metadata_getter(int index) { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fstruct_2eproto); - return descriptor_table_google_2fprotobuf_2fstruct_2eproto.file_level_metadata[index]; +PROTOBUF_ATTRIBUTE_WEAK const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable* descriptor_table_google_2fprotobuf_2fstruct_2eproto_getter() { + return &descriptor_table_google_2fprotobuf_2fstruct_2eproto; } // Force running AddDescriptors() at dynamic initialization time. @@ -175,7 +173,9 @@ MergeFromInternal(other); } ::PROTOBUF_NAMESPACE_ID::Metadata Struct_FieldsEntry_DoNotUse::GetMetadata() const { - return GetMetadataStatic(); + return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + &descriptor_table_google_2fprotobuf_2fstruct_2eproto_getter, &descriptor_table_google_2fprotobuf_2fstruct_2eproto_once, + file_level_metadata_google_2fprotobuf_2fstruct_2eproto[0]); } void Struct_FieldsEntry_DoNotUse::MergeFrom( const ::PROTOBUF_NAMESPACE_ID::Message& other) { @@ -408,10 +408,11 @@ } ::PROTOBUF_NAMESPACE_ID::Metadata Struct::GetMetadata() const { - return GetMetadataStatic(); + return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + &descriptor_table_google_2fprotobuf_2fstruct_2eproto_getter, &descriptor_table_google_2fprotobuf_2fstruct_2eproto_once, + file_level_metadata_google_2fprotobuf_2fstruct_2eproto[1]); } - // =================================================================== class Value::_Internal { @@ -847,10 +848,11 @@ } ::PROTOBUF_NAMESPACE_ID::Metadata Value::GetMetadata() const { - return GetMetadataStatic(); + return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + &descriptor_table_google_2fprotobuf_2fstruct_2eproto_getter, &descriptor_table_google_2fprotobuf_2fstruct_2eproto_once, + file_level_metadata_google_2fprotobuf_2fstruct_2eproto[2]); } - // =================================================================== class ListValue::_Internal { @@ -1041,10 +1043,11 @@ } ::PROTOBUF_NAMESPACE_ID::Metadata ListValue::GetMetadata() const { - return GetMetadataStatic(); + return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + &descriptor_table_google_2fprotobuf_2fstruct_2eproto_getter, &descriptor_table_google_2fprotobuf_2fstruct_2eproto_once, + file_level_metadata_google_2fprotobuf_2fstruct_2eproto[3]); } - // @@protoc_insertion_point(namespace_scope) PROTOBUF_NAMESPACE_CLOSE PROTOBUF_NAMESPACE_OPEN
diff --git a/src/google/protobuf/struct.pb.h b/src/google/protobuf/struct.pb.h index f3f01df..7f1b540 100644 --- a/src/google/protobuf/struct.pb.h +++ b/src/google/protobuf/struct.pb.h
@@ -57,7 +57,6 @@ static const ::PROTOBUF_NAMESPACE_ID::uint32 offsets[]; }; extern PROTOBUF_EXPORT const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fstruct_2eproto; -PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Metadata descriptor_table_google_2fprotobuf_2fstruct_2eproto_metadata_getter(int index); PROTOBUF_NAMESPACE_OPEN class ListValue; struct ListValueDefaultTypeInternal; @@ -127,13 +126,6 @@ static bool ValidateValue(void*) { return true; } void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& other) final; ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_google_2fprotobuf_2fstruct_2eproto); - return ::descriptor_table_google_2fprotobuf_2fstruct_2eproto.file_level_metadata[0]; - } - - public: }; // ------------------------------------------------------------------- @@ -168,10 +160,10 @@ return GetDescriptor(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; + return default_instance().GetMetadata().descriptor; } static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; + return default_instance().GetMetadata().reflection; } static const Struct& default_instance() { return *internal_default_instance(); @@ -239,12 +231,6 @@ public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - return ::descriptor_table_google_2fprotobuf_2fstruct_2eproto_metadata_getter(kIndexInFileMessages); - } - - public: // nested types ---------------------------------------------------- @@ -318,10 +304,10 @@ return GetDescriptor(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; + return default_instance().GetMetadata().descriptor; } static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; + return default_instance().GetMetadata().reflection; } static const Value& default_instance() { return *internal_default_instance(); @@ -399,12 +385,6 @@ public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - return ::descriptor_table_google_2fprotobuf_2fstruct_2eproto_metadata_getter(kIndexInFileMessages); - } - - public: // nested types ---------------------------------------------------- @@ -451,10 +431,8 @@ public: void clear_string_value(); const std::string& string_value() const; - void set_string_value(const std::string& value); - void set_string_value(std::string&& value); - void set_string_value(const char* value); - void set_string_value(const char* value, size_t size); + template <typename ArgT0 = const std::string&, typename... ArgT> + void set_string_value(ArgT0&& arg0, ArgT... args); std::string* mutable_string_value(); std::string* release_string_value(); void set_allocated_string_value(std::string* string_value); @@ -578,10 +556,10 @@ return GetDescriptor(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; + return default_instance().GetMetadata().descriptor; } static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; + return default_instance().GetMetadata().reflection; } static const ListValue& default_instance() { return *internal_default_instance(); @@ -649,12 +627,6 @@ public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - return ::descriptor_table_google_2fprotobuf_2fstruct_2eproto_metadata_getter(kIndexInFileMessages); - } - - public: // nested types ---------------------------------------------------- @@ -834,8 +806,14 @@ // @@protoc_insertion_point(field_get:google.protobuf.Value.string_value) return _internal_string_value(); } -inline void Value::set_string_value(const std::string& value) { - _internal_set_string_value(value); +template <typename ArgT0, typename... ArgT> +inline void Value::set_string_value(ArgT0&& arg0, ArgT... args) { + if (!_internal_has_string_value()) { + clear_kind(); + set_has_string_value(); + kind_.string_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + } + kind_.string_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); // @@protoc_insertion_point(field_set:google.protobuf.Value.string_value) } inline std::string* Value::mutable_string_value() { @@ -856,41 +834,6 @@ } kind_.string_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); } -inline void Value::set_string_value(std::string&& value) { - // @@protoc_insertion_point(field_set:google.protobuf.Value.string_value) - if (!_internal_has_string_value()) { - clear_kind(); - set_has_string_value(); - kind_.string_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - } - kind_.string_value_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Value.string_value) -} -inline void Value::set_string_value(const char* value) { - GOOGLE_DCHECK(value != nullptr); - if (!_internal_has_string_value()) { - clear_kind(); - set_has_string_value(); - kind_.string_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - } - kind_.string_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, - ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:google.protobuf.Value.string_value) -} -inline void Value::set_string_value(const char* value, - size_t size) { - if (!_internal_has_string_value()) { - clear_kind(); - set_has_string_value(); - kind_.string_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - } - kind_.string_value_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast<const char*>(value), size), - GetArena()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.Value.string_value) -} inline std::string* Value::_internal_mutable_string_value() { if (!_internal_has_string_value()) { clear_kind();
diff --git a/src/google/protobuf/timestamp.pb.cc b/src/google/protobuf/timestamp.pb.cc index ac920a1..1ca2e71 100644 --- a/src/google/protobuf/timestamp.pb.cc +++ b/src/google/protobuf/timestamp.pb.cc
@@ -67,10 +67,8 @@ schemas, file_default_instances, TableStruct_google_2fprotobuf_2ftimestamp_2eproto::offsets, file_level_metadata_google_2fprotobuf_2ftimestamp_2eproto, file_level_enum_descriptors_google_2fprotobuf_2ftimestamp_2eproto, file_level_service_descriptors_google_2fprotobuf_2ftimestamp_2eproto, }; -PROTOBUF_ATTRIBUTE_WEAK ::PROTOBUF_NAMESPACE_ID::Metadata -descriptor_table_google_2fprotobuf_2ftimestamp_2eproto_metadata_getter(int index) { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_google_2fprotobuf_2ftimestamp_2eproto); - return descriptor_table_google_2fprotobuf_2ftimestamp_2eproto.file_level_metadata[index]; +PROTOBUF_ATTRIBUTE_WEAK const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable* descriptor_table_google_2fprotobuf_2ftimestamp_2eproto_getter() { + return &descriptor_table_google_2fprotobuf_2ftimestamp_2eproto; } // Force running AddDescriptors() at dynamic initialization time. @@ -297,10 +295,11 @@ } ::PROTOBUF_NAMESPACE_ID::Metadata Timestamp::GetMetadata() const { - return GetMetadataStatic(); + return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + &descriptor_table_google_2fprotobuf_2ftimestamp_2eproto_getter, &descriptor_table_google_2fprotobuf_2ftimestamp_2eproto_once, + file_level_metadata_google_2fprotobuf_2ftimestamp_2eproto[0]); } - // @@protoc_insertion_point(namespace_scope) PROTOBUF_NAMESPACE_CLOSE PROTOBUF_NAMESPACE_OPEN
diff --git a/src/google/protobuf/timestamp.pb.h b/src/google/protobuf/timestamp.pb.h index f2802bb..5a58db5 100644 --- a/src/google/protobuf/timestamp.pb.h +++ b/src/google/protobuf/timestamp.pb.h
@@ -53,7 +53,6 @@ static const ::PROTOBUF_NAMESPACE_ID::uint32 offsets[]; }; extern PROTOBUF_EXPORT const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2ftimestamp_2eproto; -PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Metadata descriptor_table_google_2fprotobuf_2ftimestamp_2eproto_metadata_getter(int index); PROTOBUF_NAMESPACE_OPEN class Timestamp; struct TimestampDefaultTypeInternal; @@ -96,10 +95,10 @@ return GetDescriptor(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; + return default_instance().GetMetadata().descriptor; } static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; + return default_instance().GetMetadata().reflection; } static const Timestamp& default_instance() { return *internal_default_instance(); @@ -167,12 +166,6 @@ public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - return ::descriptor_table_google_2fprotobuf_2ftimestamp_2eproto_metadata_getter(kIndexInFileMessages); - } - - public: // nested types ----------------------------------------------------
diff --git a/src/google/protobuf/type.pb.cc b/src/google/protobuf/type.pb.cc index e2f7a8f..cff9744 100644 --- a/src/google/protobuf/type.pb.cc +++ b/src/google/protobuf/type.pb.cc
@@ -229,10 +229,8 @@ schemas, file_default_instances, TableStruct_google_2fprotobuf_2ftype_2eproto::offsets, file_level_metadata_google_2fprotobuf_2ftype_2eproto, file_level_enum_descriptors_google_2fprotobuf_2ftype_2eproto, file_level_service_descriptors_google_2fprotobuf_2ftype_2eproto, }; -PROTOBUF_ATTRIBUTE_WEAK ::PROTOBUF_NAMESPACE_ID::Metadata -descriptor_table_google_2fprotobuf_2ftype_2eproto_metadata_getter(int index) { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_google_2fprotobuf_2ftype_2eproto); - return descriptor_table_google_2fprotobuf_2ftype_2eproto.file_level_metadata[index]; +PROTOBUF_ATTRIBUTE_WEAK const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable* descriptor_table_google_2fprotobuf_2ftype_2eproto_getter() { + return &descriptor_table_google_2fprotobuf_2ftype_2eproto; } // Force running AddDescriptors() at dynamic initialization time. @@ -712,10 +710,11 @@ } ::PROTOBUF_NAMESPACE_ID::Metadata Type::GetMetadata() const { - return GetMetadataStatic(); + return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + &descriptor_table_google_2fprotobuf_2ftype_2eproto_getter, &descriptor_table_google_2fprotobuf_2ftype_2eproto_once, + file_level_metadata_google_2fprotobuf_2ftype_2eproto[0]); } - // =================================================================== class Field::_Internal { @@ -1189,10 +1188,11 @@ } ::PROTOBUF_NAMESPACE_ID::Metadata Field::GetMetadata() const { - return GetMetadataStatic(); + return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + &descriptor_table_google_2fprotobuf_2ftype_2eproto_getter, &descriptor_table_google_2fprotobuf_2ftype_2eproto_once, + file_level_metadata_google_2fprotobuf_2ftype_2eproto[1]); } - // =================================================================== class Enum::_Internal { @@ -1535,10 +1535,11 @@ } ::PROTOBUF_NAMESPACE_ID::Metadata Enum::GetMetadata() const { - return GetMetadataStatic(); + return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + &descriptor_table_google_2fprotobuf_2ftype_2eproto_getter, &descriptor_table_google_2fprotobuf_2ftype_2eproto_once, + file_level_metadata_google_2fprotobuf_2ftype_2eproto[2]); } - // =================================================================== class EnumValue::_Internal { @@ -1794,10 +1795,11 @@ } ::PROTOBUF_NAMESPACE_ID::Metadata EnumValue::GetMetadata() const { - return GetMetadataStatic(); + return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + &descriptor_table_google_2fprotobuf_2ftype_2eproto_getter, &descriptor_table_google_2fprotobuf_2ftype_2eproto_once, + file_level_metadata_google_2fprotobuf_2ftype_2eproto[3]); } - // =================================================================== class Option::_Internal { @@ -2042,10 +2044,11 @@ } ::PROTOBUF_NAMESPACE_ID::Metadata Option::GetMetadata() const { - return GetMetadataStatic(); + return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + &descriptor_table_google_2fprotobuf_2ftype_2eproto_getter, &descriptor_table_google_2fprotobuf_2ftype_2eproto_once, + file_level_metadata_google_2fprotobuf_2ftype_2eproto[4]); } - // @@protoc_insertion_point(namespace_scope) PROTOBUF_NAMESPACE_CLOSE PROTOBUF_NAMESPACE_OPEN
diff --git a/src/google/protobuf/type.pb.h b/src/google/protobuf/type.pb.h index 84698bd..06a30c8 100644 --- a/src/google/protobuf/type.pb.h +++ b/src/google/protobuf/type.pb.h
@@ -56,7 +56,6 @@ static const ::PROTOBUF_NAMESPACE_ID::uint32 offsets[]; }; extern PROTOBUF_EXPORT const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2ftype_2eproto; -PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Metadata descriptor_table_google_2fprotobuf_2ftype_2eproto_metadata_getter(int index); PROTOBUF_NAMESPACE_OPEN class Enum; struct EnumDefaultTypeInternal; @@ -209,10 +208,10 @@ return GetDescriptor(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; + return default_instance().GetMetadata().descriptor; } static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; + return default_instance().GetMetadata().reflection; } static const Type& default_instance() { return *internal_default_instance(); @@ -280,12 +279,6 @@ public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - return ::descriptor_table_google_2fprotobuf_2ftype_2eproto_metadata_getter(kIndexInFileMessages); - } - - public: // nested types ---------------------------------------------------- @@ -362,10 +355,8 @@ // string name = 1; void clear_name(); const std::string& name() const; - void set_name(const std::string& value); - void set_name(std::string&& value); - void set_name(const char* value); - void set_name(const char* value, size_t size); + template <typename ArgT0 = const std::string&, typename... ArgT> + void set_name(ArgT0&& arg0, ArgT... args); std::string* mutable_name(); std::string* release_name(); void set_allocated_name(std::string* name); @@ -450,10 +441,10 @@ return GetDescriptor(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; + return default_instance().GetMetadata().descriptor; } static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; + return default_instance().GetMetadata().reflection; } static const Field& default_instance() { return *internal_default_instance(); @@ -521,12 +512,6 @@ public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - return ::descriptor_table_google_2fprotobuf_2ftype_2eproto_metadata_getter(kIndexInFileMessages); - } - - public: // nested types ---------------------------------------------------- @@ -663,10 +648,8 @@ // string name = 4; void clear_name(); const std::string& name() const; - void set_name(const std::string& value); - void set_name(std::string&& value); - void set_name(const char* value); - void set_name(const char* value, size_t size); + template <typename ArgT0 = const std::string&, typename... ArgT> + void set_name(ArgT0&& arg0, ArgT... args); std::string* mutable_name(); std::string* release_name(); void set_allocated_name(std::string* name); @@ -679,10 +662,8 @@ // string type_url = 6; void clear_type_url(); const std::string& type_url() const; - void set_type_url(const std::string& value); - void set_type_url(std::string&& value); - void set_type_url(const char* value); - void set_type_url(const char* value, size_t size); + template <typename ArgT0 = const std::string&, typename... ArgT> + void set_type_url(ArgT0&& arg0, ArgT... args); std::string* mutable_type_url(); std::string* release_type_url(); void set_allocated_type_url(std::string* type_url); @@ -695,10 +676,8 @@ // string json_name = 10; void clear_json_name(); const std::string& json_name() const; - void set_json_name(const std::string& value); - void set_json_name(std::string&& value); - void set_json_name(const char* value); - void set_json_name(const char* value, size_t size); + template <typename ArgT0 = const std::string&, typename... ArgT> + void set_json_name(ArgT0&& arg0, ArgT... args); std::string* mutable_json_name(); std::string* release_json_name(); void set_allocated_json_name(std::string* json_name); @@ -711,10 +690,8 @@ // string default_value = 11; void clear_default_value(); const std::string& default_value() const; - void set_default_value(const std::string& value); - void set_default_value(std::string&& value); - void set_default_value(const char* value); - void set_default_value(const char* value, size_t size); + template <typename ArgT0 = const std::string&, typename... ArgT> + void set_default_value(ArgT0&& arg0, ArgT... args); std::string* mutable_default_value(); std::string* release_default_value(); void set_allocated_default_value(std::string* default_value); @@ -821,10 +798,10 @@ return GetDescriptor(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; + return default_instance().GetMetadata().descriptor; } static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; + return default_instance().GetMetadata().reflection; } static const Enum& default_instance() { return *internal_default_instance(); @@ -892,12 +869,6 @@ public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - return ::descriptor_table_google_2fprotobuf_2ftype_2eproto_metadata_getter(kIndexInFileMessages); - } - - public: // nested types ---------------------------------------------------- @@ -949,10 +920,8 @@ // string name = 1; void clear_name(); const std::string& name() const; - void set_name(const std::string& value); - void set_name(std::string&& value); - void set_name(const char* value); - void set_name(const char* value, size_t size); + template <typename ArgT0 = const std::string&, typename... ArgT> + void set_name(ArgT0&& arg0, ArgT... args); std::string* mutable_name(); std::string* release_name(); void set_allocated_name(std::string* name); @@ -1036,10 +1005,10 @@ return GetDescriptor(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; + return default_instance().GetMetadata().descriptor; } static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; + return default_instance().GetMetadata().reflection; } static const EnumValue& default_instance() { return *internal_default_instance(); @@ -1107,12 +1076,6 @@ public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - return ::descriptor_table_google_2fprotobuf_2ftype_2eproto_metadata_getter(kIndexInFileMessages); - } - - public: // nested types ---------------------------------------------------- @@ -1144,10 +1107,8 @@ // string name = 1; void clear_name(); const std::string& name() const; - void set_name(const std::string& value); - void set_name(std::string&& value); - void set_name(const char* value); - void set_name(const char* value, size_t size); + template <typename ArgT0 = const std::string&, typename... ArgT> + void set_name(ArgT0&& arg0, ArgT... args); std::string* mutable_name(); std::string* release_name(); void set_allocated_name(std::string* name); @@ -1211,10 +1172,10 @@ return GetDescriptor(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; + return default_instance().GetMetadata().descriptor; } static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; + return default_instance().GetMetadata().reflection; } static const Option& default_instance() { return *internal_default_instance(); @@ -1282,12 +1243,6 @@ public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - return ::descriptor_table_google_2fprotobuf_2ftype_2eproto_metadata_getter(kIndexInFileMessages); - } - - public: // nested types ---------------------------------------------------- @@ -1300,10 +1255,8 @@ // string name = 1; void clear_name(); const std::string& name() const; - void set_name(const std::string& value); - void set_name(std::string&& value); - void set_name(const char* value); - void set_name(const char* value, size_t size); + template <typename ArgT0 = const std::string&, typename... ArgT> + void set_name(ArgT0&& arg0, ArgT... args); std::string* mutable_name(); std::string* release_name(); void set_allocated_name(std::string* name); @@ -1362,8 +1315,11 @@ // @@protoc_insertion_point(field_get:google.protobuf.Type.name) return _internal_name(); } -inline void Type::set_name(const std::string& value) { - _internal_set_name(value); +template <typename ArgT0, typename... ArgT> +PROTOBUF_ALWAYS_INLINE +inline void Type::set_name(ArgT0&& arg0, ArgT... args) { + + name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); // @@protoc_insertion_point(field_set:google.protobuf.Type.name) } inline std::string* Type::mutable_name() { @@ -1377,25 +1333,6 @@ name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); } -inline void Type::set_name(std::string&& value) { - - name_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Type.name) -} -inline void Type::set_name(const char* value) { - GOOGLE_DCHECK(value != nullptr); - - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:google.protobuf.Type.name) -} -inline void Type::set_name(const char* value, - size_t size) { - - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast<const char*>(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.Type.name) -} inline std::string* Type::_internal_mutable_name() { return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); @@ -1736,8 +1673,11 @@ // @@protoc_insertion_point(field_get:google.protobuf.Field.name) return _internal_name(); } -inline void Field::set_name(const std::string& value) { - _internal_set_name(value); +template <typename ArgT0, typename... ArgT> +PROTOBUF_ALWAYS_INLINE +inline void Field::set_name(ArgT0&& arg0, ArgT... args) { + + name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); // @@protoc_insertion_point(field_set:google.protobuf.Field.name) } inline std::string* Field::mutable_name() { @@ -1751,25 +1691,6 @@ name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); } -inline void Field::set_name(std::string&& value) { - - name_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Field.name) -} -inline void Field::set_name(const char* value) { - GOOGLE_DCHECK(value != nullptr); - - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:google.protobuf.Field.name) -} -inline void Field::set_name(const char* value, - size_t size) { - - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast<const char*>(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.Field.name) -} inline std::string* Field::_internal_mutable_name() { return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); @@ -1797,8 +1718,11 @@ // @@protoc_insertion_point(field_get:google.protobuf.Field.type_url) return _internal_type_url(); } -inline void Field::set_type_url(const std::string& value) { - _internal_set_type_url(value); +template <typename ArgT0, typename... ArgT> +PROTOBUF_ALWAYS_INLINE +inline void Field::set_type_url(ArgT0&& arg0, ArgT... args) { + + type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); // @@protoc_insertion_point(field_set:google.protobuf.Field.type_url) } inline std::string* Field::mutable_type_url() { @@ -1812,25 +1736,6 @@ type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); } -inline void Field::set_type_url(std::string&& value) { - - type_url_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Field.type_url) -} -inline void Field::set_type_url(const char* value) { - GOOGLE_DCHECK(value != nullptr); - - type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:google.protobuf.Field.type_url) -} -inline void Field::set_type_url(const char* value, - size_t size) { - - type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast<const char*>(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.Field.type_url) -} inline std::string* Field::_internal_mutable_type_url() { return type_url_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); @@ -1937,8 +1842,11 @@ // @@protoc_insertion_point(field_get:google.protobuf.Field.json_name) return _internal_json_name(); } -inline void Field::set_json_name(const std::string& value) { - _internal_set_json_name(value); +template <typename ArgT0, typename... ArgT> +PROTOBUF_ALWAYS_INLINE +inline void Field::set_json_name(ArgT0&& arg0, ArgT... args) { + + json_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); // @@protoc_insertion_point(field_set:google.protobuf.Field.json_name) } inline std::string* Field::mutable_json_name() { @@ -1952,25 +1860,6 @@ json_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); } -inline void Field::set_json_name(std::string&& value) { - - json_name_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Field.json_name) -} -inline void Field::set_json_name(const char* value) { - GOOGLE_DCHECK(value != nullptr); - - json_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:google.protobuf.Field.json_name) -} -inline void Field::set_json_name(const char* value, - size_t size) { - - json_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast<const char*>(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.Field.json_name) -} inline std::string* Field::_internal_mutable_json_name() { return json_name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); @@ -1998,8 +1887,11 @@ // @@protoc_insertion_point(field_get:google.protobuf.Field.default_value) return _internal_default_value(); } -inline void Field::set_default_value(const std::string& value) { - _internal_set_default_value(value); +template <typename ArgT0, typename... ArgT> +PROTOBUF_ALWAYS_INLINE +inline void Field::set_default_value(ArgT0&& arg0, ArgT... args) { + + default_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); // @@protoc_insertion_point(field_set:google.protobuf.Field.default_value) } inline std::string* Field::mutable_default_value() { @@ -2013,25 +1905,6 @@ default_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); } -inline void Field::set_default_value(std::string&& value) { - - default_value_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Field.default_value) -} -inline void Field::set_default_value(const char* value) { - GOOGLE_DCHECK(value != nullptr); - - default_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:google.protobuf.Field.default_value) -} -inline void Field::set_default_value(const char* value, - size_t size) { - - default_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast<const char*>(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.Field.default_value) -} inline std::string* Field::_internal_mutable_default_value() { return default_value_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); @@ -2063,8 +1936,11 @@ // @@protoc_insertion_point(field_get:google.protobuf.Enum.name) return _internal_name(); } -inline void Enum::set_name(const std::string& value) { - _internal_set_name(value); +template <typename ArgT0, typename... ArgT> +PROTOBUF_ALWAYS_INLINE +inline void Enum::set_name(ArgT0&& arg0, ArgT... args) { + + name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); // @@protoc_insertion_point(field_set:google.protobuf.Enum.name) } inline std::string* Enum::mutable_name() { @@ -2078,25 +1954,6 @@ name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); } -inline void Enum::set_name(std::string&& value) { - - name_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Enum.name) -} -inline void Enum::set_name(const char* value) { - GOOGLE_DCHECK(value != nullptr); - - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:google.protobuf.Enum.name) -} -inline void Enum::set_name(const char* value, - size_t size) { - - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast<const char*>(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.Enum.name) -} inline std::string* Enum::_internal_mutable_name() { return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); @@ -2303,8 +2160,11 @@ // @@protoc_insertion_point(field_get:google.protobuf.EnumValue.name) return _internal_name(); } -inline void EnumValue::set_name(const std::string& value) { - _internal_set_name(value); +template <typename ArgT0, typename... ArgT> +PROTOBUF_ALWAYS_INLINE +inline void EnumValue::set_name(ArgT0&& arg0, ArgT... args) { + + name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); // @@protoc_insertion_point(field_set:google.protobuf.EnumValue.name) } inline std::string* EnumValue::mutable_name() { @@ -2318,25 +2178,6 @@ name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); } -inline void EnumValue::set_name(std::string&& value) { - - name_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.EnumValue.name) -} -inline void EnumValue::set_name(const char* value) { - GOOGLE_DCHECK(value != nullptr); - - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:google.protobuf.EnumValue.name) -} -inline void EnumValue::set_name(const char* value, - size_t size) { - - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast<const char*>(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.EnumValue.name) -} inline std::string* EnumValue::_internal_mutable_name() { return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); @@ -2427,8 +2268,11 @@ // @@protoc_insertion_point(field_get:google.protobuf.Option.name) return _internal_name(); } -inline void Option::set_name(const std::string& value) { - _internal_set_name(value); +template <typename ArgT0, typename... ArgT> +PROTOBUF_ALWAYS_INLINE +inline void Option::set_name(ArgT0&& arg0, ArgT... args) { + + name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); // @@protoc_insertion_point(field_set:google.protobuf.Option.name) } inline std::string* Option::mutable_name() { @@ -2442,25 +2286,6 @@ name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); } -inline void Option::set_name(std::string&& value) { - - name_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Option.name) -} -inline void Option::set_name(const char* value) { - GOOGLE_DCHECK(value != nullptr); - - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:google.protobuf.Option.name) -} -inline void Option::set_name(const char* value, - size_t size) { - - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast<const char*>(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.Option.name) -} inline std::string* Option::_internal_mutable_name() { return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena());
diff --git a/src/google/protobuf/unittest_lite.proto b/src/google/protobuf/unittest_lite.proto index f501f50..92282a6 100644 --- a/src/google/protobuf/unittest_lite.proto +++ b/src/google/protobuf/unittest_lite.proto
@@ -494,3 +494,8 @@ BAR2 = 2; } } + +message RecursiveMessage { + optional RecursiveMessage recurse = 1; + optional bytes payload = 2; +}
diff --git a/src/google/protobuf/unittest_proto3_optional.proto b/src/google/protobuf/unittest_proto3_optional.proto index e760021..09d1718 100644 --- a/src/google/protobuf/unittest_proto3_optional.proto +++ b/src/google/protobuf/unittest_proto3_optional.proto
@@ -32,6 +32,8 @@ package protobuf_unittest; +import "google/protobuf/descriptor.proto"; + option java_multiple_files = true; option java_package = "com.google.protobuf.testing.proto"; @@ -86,3 +88,13 @@ NestedMessage nested_message = 1; optional NestedMessage optional_nested_message = 2; } + +message Proto3OptionalExtensions { + option (protobuf_unittest.Proto3OptionalExtensions.ext_no_optional) = 8; + option (protobuf_unittest.Proto3OptionalExtensions.ext_with_optional) = 16; + + extend google.protobuf.MessageOptions { + int32 ext_no_optional = 355886728; + optional int32 ext_with_optional = 355886729; + } +}
diff --git a/src/google/protobuf/util/internal/constants.h b/src/google/protobuf/util/internal/constants.h index adaf030..65f1a34 100644 --- a/src/google/protobuf/util/internal/constants.h +++ b/src/google/protobuf/util/internal/constants.h
@@ -31,6 +31,8 @@ #ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_CONSTANTS_H__ #define GOOGLE_PROTOBUF_UTIL_CONVERTER_CONSTANTS_H__ +#include <cstdint> + #include <google/protobuf/stubs/common.h> // This file contains constants used by //net/proto2/util/converter. @@ -50,19 +52,19 @@ const char kRfc3339TimeFormatNoPadding[] = "%Y-%m-%dT%H:%M:%S"; // Minimum seconds allowed in a google.protobuf.Timestamp value. -const int64 kTimestampMinSeconds = -62135596800LL; +const int64_t kTimestampMinSeconds = -62135596800LL; // Maximum seconds allowed in a google.protobuf.Timestamp value. -const int64 kTimestampMaxSeconds = 253402300799LL; +const int64_t kTimestampMaxSeconds = 253402300799LL; // Minimum seconds allowed in a google.protobuf.Duration value. -const int64 kDurationMinSeconds = -315576000000LL; +const int64_t kDurationMinSeconds = -315576000000LL; // Maximum seconds allowed in a google.protobuf.Duration value. -const int64 kDurationMaxSeconds = 315576000000LL; +const int64_t kDurationMaxSeconds = 315576000000LL; // Nano seconds in a second. -const int32 kNanosPerSecond = 1000000000; +const int32_t kNanosPerSecond = 1000000000; // Type url representing NULL values in google.protobuf.Struct type. const char kStructNullValueTypeUrl[] =
diff --git a/src/google/protobuf/util/internal/datapiece.cc b/src/google/protobuf/util/internal/datapiece.cc index 4246956..d3a98e5 100644 --- a/src/google/protobuf/util/internal/datapiece.cc +++ b/src/google/protobuf/util/internal/datapiece.cc
@@ -31,6 +31,7 @@ #include <google/protobuf/util/internal/datapiece.h> #include <cmath> +#include <cstdint> #include <limits> #include <google/protobuf/struct.pb.h> @@ -114,54 +115,56 @@ } // namespace -util::StatusOr<int32> DataPiece::ToInt32() const { - if (type_ == TYPE_STRING) return StringToNumber<int32>(safe_strto32); - - if (type_ == TYPE_DOUBLE) - return FloatingPointToIntConvertAndCheck<int32, double>(double_); - - if (type_ == TYPE_FLOAT) - return FloatingPointToIntConvertAndCheck<int32, float>(float_); - - return GenericConvert<int32>(); -} - -util::StatusOr<uint32> DataPiece::ToUint32() const { +util::StatusOr<int32_t> DataPiece::ToInt32() const { if (type_ == TYPE_STRING) - return StringToNumber<uint32>(safe_strtou32); + return StringToNumber<int32_t>(safe_strto32); if (type_ == TYPE_DOUBLE) - return FloatingPointToIntConvertAndCheck<uint32, double>(double_); + return FloatingPointToIntConvertAndCheck<int32_t, double>(double_); if (type_ == TYPE_FLOAT) - return FloatingPointToIntConvertAndCheck<uint32, float>(float_); + return FloatingPointToIntConvertAndCheck<int32_t, float>(float_); - return GenericConvert<uint32>(); + return GenericConvert<int32_t>(); } -util::StatusOr<int64> DataPiece::ToInt64() const { - if (type_ == TYPE_STRING) return StringToNumber<int64>(safe_strto64); - - if (type_ == TYPE_DOUBLE) - return FloatingPointToIntConvertAndCheck<int64, double>(double_); - - if (type_ == TYPE_FLOAT) - return FloatingPointToIntConvertAndCheck<int64, float>(float_); - - return GenericConvert<int64>(); -} - -util::StatusOr<uint64> DataPiece::ToUint64() const { +util::StatusOr<uint32_t> DataPiece::ToUint32() const { if (type_ == TYPE_STRING) - return StringToNumber<uint64>(safe_strtou64); + return StringToNumber<uint32_t>(safe_strtou32); if (type_ == TYPE_DOUBLE) - return FloatingPointToIntConvertAndCheck<uint64, double>(double_); + return FloatingPointToIntConvertAndCheck<uint32_t, double>(double_); if (type_ == TYPE_FLOAT) - return FloatingPointToIntConvertAndCheck<uint64, float>(float_); + return FloatingPointToIntConvertAndCheck<uint32_t, float>(float_); - return GenericConvert<uint64>(); + return GenericConvert<uint32_t>(); +} + +util::StatusOr<int64_t> DataPiece::ToInt64() const { + if (type_ == TYPE_STRING) + return StringToNumber<int64_t>(safe_strto64); + + if (type_ == TYPE_DOUBLE) + return FloatingPointToIntConvertAndCheck<int64_t, double>(double_); + + if (type_ == TYPE_FLOAT) + return FloatingPointToIntConvertAndCheck<int64_t, float>(float_); + + return GenericConvert<int64_t>(); +} + +util::StatusOr<uint64_t> DataPiece::ToUint64() const { + if (type_ == TYPE_STRING) + return StringToNumber<uint64_t>(safe_strtou64); + + if (type_ == TYPE_DOUBLE) + return FloatingPointToIntConvertAndCheck<uint64_t, double>(double_); + + if (type_ == TYPE_FLOAT) + return FloatingPointToIntConvertAndCheck<uint64_t, float>(float_); + + return GenericConvert<uint64_t>(); } util::StatusOr<double> DataPiece::ToDouble() const { @@ -286,7 +289,7 @@ if (value != nullptr) return value->number(); // Check if int version of enum is sent as string. - util::StatusOr<int32> int_value = ToInt32(); + util::StatusOr<int32_t> int_value = ToInt32(); if (int_value.ok()) { if (const google::protobuf::EnumValue* enum_value = FindEnumValueByNumberOrNull(enum_type, int_value.value())) { @@ -334,13 +337,13 @@ util::StatusOr<To> DataPiece::GenericConvert() const { switch (type_) { case TYPE_INT32: - return NumberConvertAndCheck<To, int32>(i32_); + return NumberConvertAndCheck<To, int32_t>(i32_); case TYPE_INT64: - return NumberConvertAndCheck<To, int64>(i64_); + return NumberConvertAndCheck<To, int64_t>(i64_); case TYPE_UINT32: - return NumberConvertAndCheck<To, uint32>(u32_); + return NumberConvertAndCheck<To, uint32_t>(u32_); case TYPE_UINT64: - return NumberConvertAndCheck<To, uint64>(u64_); + return NumberConvertAndCheck<To, uint64_t>(u64_); case TYPE_DOUBLE: return NumberConvertAndCheck<To, double>(double_); case TYPE_FLOAT:
diff --git a/src/google/protobuf/util/internal/datapiece.h b/src/google/protobuf/util/internal/datapiece.h index 03ea128..0b345ae 100644 --- a/src/google/protobuf/util/internal/datapiece.h +++ b/src/google/protobuf/util/internal/datapiece.h
@@ -31,6 +31,7 @@ #ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_DATAPIECE_H__ #define GOOGLE_PROTOBUF_UTIL_CONVERTER_DATAPIECE_H__ +#include <cstdint> #include <string> #include <google/protobuf/stubs/common.h> @@ -75,13 +76,13 @@ }; // Constructors and Destructor - explicit DataPiece(const int32 value) + explicit DataPiece(const int32_t value) : type_(TYPE_INT32), i32_(value), use_strict_base64_decoding_(false) {} - explicit DataPiece(const int64 value) + explicit DataPiece(const int64_t value) : type_(TYPE_INT64), i64_(value), use_strict_base64_decoding_(false) {} - explicit DataPiece(const uint32 value) + explicit DataPiece(const uint32_t value) : type_(TYPE_UINT32), u32_(value), use_strict_base64_decoding_(false) {} - explicit DataPiece(const uint64 value) + explicit DataPiece(const uint64_t value) : type_(TYPE_UINT64), u64_(value), use_strict_base64_decoding_(false) {} explicit DataPiece(const double value) : type_(TYPE_DOUBLE), @@ -125,16 +126,16 @@ // Parses, casts or converts the value stored in the DataPiece into an int32. - util::StatusOr<int32> ToInt32() const; + util::StatusOr<int32_t> ToInt32() const; // Parses, casts or converts the value stored in the DataPiece into a uint32. - util::StatusOr<uint32> ToUint32() const; + util::StatusOr<uint32_t> ToUint32() const; // Parses, casts or converts the value stored in the DataPiece into an int64. - util::StatusOr<int64> ToInt64() const; + util::StatusOr<int64_t> ToInt64() const; // Parses, casts or converts the value stored in the DataPiece into a uint64. - util::StatusOr<uint64> ToUint64() const; + util::StatusOr<uint64_t> ToUint64() const; // Parses, casts or converts the value stored in the DataPiece into a double. util::StatusOr<double> ToDouble() const; @@ -161,7 +162,7 @@ DataPiece(); // Helper to create NULL or ENUM types. - DataPiece(Type type, int32 val) + DataPiece(Type type, int32_t val) : type_(type), i32_(val), use_strict_base64_decoding_(false) {} // Same as the ToEnum() method above but with additional flag to ignore @@ -195,10 +196,10 @@ // Stored piece of data. union { - int32 i32_; - int64 i64_; - uint32 u32_; - uint64 u64_; + int32_t i32_; + int64_t i64_; + uint32_t u32_; + uint64_t u64_; double double_; float float_; bool bool_;
diff --git a/src/google/protobuf/util/internal/default_value_objectwriter.cc b/src/google/protobuf/util/internal/default_value_objectwriter.cc index c9ab446..d6bb788 100644 --- a/src/google/protobuf/util/internal/default_value_objectwriter.cc +++ b/src/google/protobuf/util/internal/default_value_objectwriter.cc
@@ -30,6 +30,7 @@ #include <google/protobuf/util/internal/default_value_objectwriter.h> +#include <cstdint> #include <unordered_map> #include <google/protobuf/util/internal/constants.h> @@ -85,7 +86,7 @@ } DefaultValueObjectWriter* DefaultValueObjectWriter::RenderInt32( - StringPiece name, int32 value) { + StringPiece name, int32_t value) { if (current_ == nullptr) { ow_->RenderInt32(name, value); } else { @@ -95,7 +96,7 @@ } DefaultValueObjectWriter* DefaultValueObjectWriter::RenderUint32( - StringPiece name, uint32 value) { + StringPiece name, uint32_t value) { if (current_ == nullptr) { ow_->RenderUint32(name, value); } else { @@ -105,7 +106,7 @@ } DefaultValueObjectWriter* DefaultValueObjectWriter::RenderInt64( - StringPiece name, int64 value) { + StringPiece name, int64_t value) { if (current_ == nullptr) { ow_->RenderInt64(name, value); } else { @@ -115,7 +116,7 @@ } DefaultValueObjectWriter* DefaultValueObjectWriter::RenderUint64( - StringPiece name, uint64 value) { + StringPiece name, uint64_t value) { if (current_ == nullptr) { ow_->RenderUint64(name, value); } else { @@ -445,19 +446,20 @@ case google::protobuf::Field::TYPE_INT64: case google::protobuf::Field::TYPE_SINT64: case google::protobuf::Field::TYPE_SFIXED64: { - return DataPiece(ConvertTo<int64>( - field.default_value(), &DataPiece::ToInt64, static_cast<int64>(0))); + return DataPiece(ConvertTo<int64_t>( + field.default_value(), &DataPiece::ToInt64, static_cast<int64_t>(0))); } case google::protobuf::Field::TYPE_UINT64: case google::protobuf::Field::TYPE_FIXED64: { - return DataPiece(ConvertTo<uint64>( - field.default_value(), &DataPiece::ToUint64, static_cast<uint64>(0))); + return DataPiece(ConvertTo<uint64_t>(field.default_value(), + &DataPiece::ToUint64, + static_cast<uint64_t>(0))); } case google::protobuf::Field::TYPE_INT32: case google::protobuf::Field::TYPE_SINT32: case google::protobuf::Field::TYPE_SFIXED32: { - return DataPiece(ConvertTo<int32>( - field.default_value(), &DataPiece::ToInt32, static_cast<int32>(0))); + return DataPiece(ConvertTo<int32_t>( + field.default_value(), &DataPiece::ToInt32, static_cast<int32_t>(0))); } case google::protobuf::Field::TYPE_BOOL: { return DataPiece( @@ -471,8 +473,9 @@ } case google::protobuf::Field::TYPE_UINT32: case google::protobuf::Field::TYPE_FIXED32: { - return DataPiece(ConvertTo<uint32>( - field.default_value(), &DataPiece::ToUint32, static_cast<uint32>(0))); + return DataPiece(ConvertTo<uint32_t>(field.default_value(), + &DataPiece::ToUint32, + static_cast<uint32_t>(0))); } case google::protobuf::Field::TYPE_ENUM: { return FindEnumDefault(field, typeinfo, use_ints_for_enums);
diff --git a/src/google/protobuf/util/internal/default_value_objectwriter.h b/src/google/protobuf/util/internal/default_value_objectwriter.h index 08793fc..8236f0a 100644 --- a/src/google/protobuf/util/internal/default_value_objectwriter.h +++ b/src/google/protobuf/util/internal/default_value_objectwriter.h
@@ -31,6 +31,7 @@ #ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_DEFAULT_VALUE_OBJECTWRITER_H__ #define GOOGLE_PROTOBUF_UTIL_CONVERTER_DEFAULT_VALUE_OBJECTWRITER_H__ +#include <cstdint> #include <functional> #include <memory> #include <stack> @@ -95,16 +96,16 @@ bool value) override; DefaultValueObjectWriter* RenderInt32(StringPiece name, - int32 value) override; + int32_t value) override; DefaultValueObjectWriter* RenderUint32(StringPiece name, - uint32 value) override; + uint32_t value) override; DefaultValueObjectWriter* RenderInt64(StringPiece name, - int64 value) override; + int64_t value) override; DefaultValueObjectWriter* RenderUint64(StringPiece name, - uint64 value) override; + uint64_t value) override; DefaultValueObjectWriter* RenderDouble(StringPiece name, double value) override;
diff --git a/src/google/protobuf/util/internal/expecting_objectwriter.h b/src/google/protobuf/util/internal/expecting_objectwriter.h index 2cb7f69..09b2e78 100644 --- a/src/google/protobuf/util/internal/expecting_objectwriter.h +++ b/src/google/protobuf/util/internal/expecting_objectwriter.h
@@ -50,6 +50,8 @@ // ->RenderString("key", "value") // ->EndObject(); +#include <cstdint> + #include <google/protobuf/stubs/common.h> #include <google/protobuf/util/internal/object_writer.h> #include <gmock/gmock.h> @@ -77,13 +79,13 @@ MOCK_METHOD(ObjectWriter*, StartList, (StringPiece), (override)); MOCK_METHOD(ObjectWriter*, EndList, (), (override)); MOCK_METHOD(ObjectWriter*, RenderBool, (StringPiece, bool), (override)); - MOCK_METHOD(ObjectWriter*, RenderInt32, (StringPiece, int32), + MOCK_METHOD(ObjectWriter*, RenderInt32, (StringPiece, int32_t), (override)); - MOCK_METHOD(ObjectWriter*, RenderUint32, (StringPiece, uint32), + MOCK_METHOD(ObjectWriter*, RenderUint32, (StringPiece, uint32_t), (override)); - MOCK_METHOD(ObjectWriter*, RenderInt64, (StringPiece, int64), + MOCK_METHOD(ObjectWriter*, RenderInt64, (StringPiece, int64_t), (override)); - MOCK_METHOD(ObjectWriter*, RenderUint64, (StringPiece, uint64), + MOCK_METHOD(ObjectWriter*, RenderUint64, (StringPiece, uint64_t), (override)); MOCK_METHOD(ObjectWriter*, RenderDouble, (StringPiece, double), (override)); @@ -139,41 +141,41 @@ return this; } - virtual ObjectWriter* RenderInt32(StringPiece name, int32 value) { + virtual ObjectWriter* RenderInt32(StringPiece name, int32_t value) { (name.empty() - ? EXPECT_CALL(*mock_, RenderInt32(IsEmpty(), TypedEq<int32>(value))) + ? EXPECT_CALL(*mock_, RenderInt32(IsEmpty(), TypedEq<int32_t>(value))) : EXPECT_CALL(*mock_, RenderInt32(Eq(std::string(name)), - TypedEq<int32>(value)))) + TypedEq<int32_t>(value)))) .WillOnce(Return(mock_)) .RetiresOnSaturation(); return this; } - virtual ObjectWriter* RenderUint32(StringPiece name, uint32 value) { - (name.empty() - ? EXPECT_CALL(*mock_, RenderUint32(IsEmpty(), TypedEq<uint32>(value))) - : EXPECT_CALL(*mock_, RenderUint32(Eq(std::string(name)), - TypedEq<uint32>(value)))) + virtual ObjectWriter* RenderUint32(StringPiece name, uint32_t value) { + (name.empty() ? EXPECT_CALL(*mock_, RenderUint32(IsEmpty(), + TypedEq<uint32_t>(value))) + : EXPECT_CALL(*mock_, RenderUint32(Eq(std::string(name)), + TypedEq<uint32_t>(value)))) .WillOnce(Return(mock_)) .RetiresOnSaturation(); return this; } - virtual ObjectWriter* RenderInt64(StringPiece name, int64 value) { + virtual ObjectWriter* RenderInt64(StringPiece name, int64_t value) { (name.empty() - ? EXPECT_CALL(*mock_, RenderInt64(IsEmpty(), TypedEq<int64>(value))) + ? EXPECT_CALL(*mock_, RenderInt64(IsEmpty(), TypedEq<int64_t>(value))) : EXPECT_CALL(*mock_, RenderInt64(Eq(std::string(name)), - TypedEq<int64>(value)))) + TypedEq<int64_t>(value)))) .WillOnce(Return(mock_)) .RetiresOnSaturation(); return this; } - virtual ObjectWriter* RenderUint64(StringPiece name, uint64 value) { - (name.empty() - ? EXPECT_CALL(*mock_, RenderUint64(IsEmpty(), TypedEq<uint64>(value))) - : EXPECT_CALL(*mock_, RenderUint64(Eq(std::string(name)), - TypedEq<uint64>(value)))) + virtual ObjectWriter* RenderUint64(StringPiece name, uint64_t value) { + (name.empty() ? EXPECT_CALL(*mock_, RenderUint64(IsEmpty(), + TypedEq<uint64_t>(value))) + : EXPECT_CALL(*mock_, RenderUint64(Eq(std::string(name)), + TypedEq<uint64_t>(value)))) .WillOnce(Return(mock_)) .RetiresOnSaturation(); return this;
diff --git a/src/google/protobuf/util/internal/json_escaping.cc b/src/google/protobuf/util/internal/json_escaping.cc index c5c406f..e4fa8cf 100644 --- a/src/google/protobuf/util/internal/json_escaping.cc +++ b/src/google/protobuf/util/internal/json_escaping.cc
@@ -30,6 +30,8 @@ #include <google/protobuf/util/internal/json_escaping.h> +#include <cstdint> + #include <google/protobuf/stubs/logging.h> #include <google/protobuf/stubs/common.h> @@ -77,7 +79,7 @@ // Determines if the given char value is a unicode surrogate code unit (either // high-surrogate or low-surrogate). -inline bool IsSurrogate(uint32 c) { +inline bool IsSurrogate(uint32_t c) { // Optimized form of: // return c >= kMinHighSurrogate && c <= kMaxLowSurrogate; // (Reduced from 3 ALU instructions to 2 ALU instructions) @@ -86,13 +88,13 @@ // Returns true if the given unicode code point cp is a valid // unicode code point (i.e. in the range 0 <= cp <= kMaxCodePoint). -inline bool IsValidCodePoint(uint32 cp) { +inline bool IsValidCodePoint(uint32_t cp) { return cp <= JsonEscaping::kMaxCodePoint; } // Returns the low surrogate for the given unicode code point. The result is // meaningless if the given code point is not a supplementary character. -inline uint16 ToLowSurrogate(uint32 cp) { +inline uint16_t ToLowSurrogate(uint32_t cp) { return (cp & (JsonEscaping::kMaxLowSurrogate - JsonEscaping::kMinLowSurrogate)) + JsonEscaping::kMinLowSurrogate; @@ -100,7 +102,7 @@ // Returns the high surrogate for the given unicode code point. The result is // meaningless if the given code point is not a supplementary character. -inline uint16 ToHighSurrogate(uint32 cp) { +inline uint16_t ToHighSurrogate(uint32_t cp) { return (cp >> 10) + (JsonEscaping::kMinHighSurrogate - (JsonEscaping::kMinSupplementaryCodePoint >> 10)); } @@ -125,11 +127,11 @@ // Returns false if we encounter an invalid UTF-8 string. Returns true // otherwise, including the case when we reach the end of the input (str) // before a complete unicode code point is read. -bool ReadCodePoint(StringPiece str, int index, uint32* cp, int* num_left, - int* num_read) { +bool ReadCodePoint(StringPiece str, int index, uint32_t* cp, + int* num_left, int* num_read) { if (*num_left == 0) { // Last read was complete. Start reading a new unicode code point. - *cp = static_cast<uint8>(str[index++]); + *cp = static_cast<uint8_t>(str[index++]); *num_read = 1; // The length of the code point is determined from reading the first byte. // @@ -178,7 +180,7 @@ *num_read = 0; } while (*num_left > 0 && index < str.size()) { - uint32 ch = static_cast<uint8>(str[index++]); + uint32_t ch = static_cast<uint8_t>(str[index++]); --(*num_left); ++(*num_read); *cp = (*cp << 6) | (ch & 0x3f); @@ -190,7 +192,7 @@ // Stores the 16-bit unicode code point as its hexadecimal digits in buffer // and returns a StringPiece that points to this buffer. The input buffer needs // to be at least 6 bytes long. -StringPiece ToHex(uint16 cp, char* buffer) { +StringPiece ToHex(uint16_t cp, char* buffer) { buffer[5] = kHex[cp & 0x0f]; cp >>= 4; buffer[4] = kHex[cp & 0x0f]; @@ -204,9 +206,9 @@ // Stores the 32-bit unicode code point as its hexadecimal digits in buffer // and returns a StringPiece that points to this buffer. The input buffer needs // to be at least 12 bytes long. -StringPiece ToSurrogateHex(uint32 cp, char* buffer) { - uint16 low = ToLowSurrogate(cp); - uint16 high = ToHighSurrogate(cp); +StringPiece ToSurrogateHex(uint32_t cp, char* buffer) { + uint16_t low = ToLowSurrogate(cp); + uint16_t high = ToHighSurrogate(cp); buffer[11] = kHex[low & 0x0f]; low >>= 4; @@ -234,7 +236,7 @@ // // If the given unicode code point does not need escaping, an empty // StringPiece is returned. -StringPiece EscapeCodePoint(uint32 cp, char* buffer) { +StringPiece EscapeCodePoint(uint32_t cp, char* buffer) { if (cp < 0xa0) return kCommonEscapes[cp]; switch (cp) { // These are not required by json spec @@ -272,7 +274,8 @@ // Tries to escape the given code point first. If the given code point // does not need to be escaped, but force_output is true, then render // the given multi-byte code point in UTF8 in the buffer and returns it. -StringPiece EscapeCodePoint(uint32 cp, char* buffer, bool force_output) { +StringPiece EscapeCodePoint(uint32_t cp, char* buffer, + bool force_output) { StringPiece sp = EscapeCodePoint(cp, buffer); if (force_output && sp.empty()) { buffer[5] = (cp & 0x3f) | 0x80; @@ -301,7 +304,7 @@ void JsonEscaping::Escape(strings::ByteSource* input, strings::ByteSink* output) { char buffer[12] = "\\udead\\ubee"; - uint32 cp = 0; // Current unicode code point. + uint32_t cp = 0; // Current unicode code point. int num_left = 0; // Num of chars to read to complete the code point. while (input->Available() > 0) { StringPiece str = input->Peek();
diff --git a/src/google/protobuf/util/internal/json_escaping.h b/src/google/protobuf/util/internal/json_escaping.h index d05c335..38cb645 100644 --- a/src/google/protobuf/util/internal/json_escaping.h +++ b/src/google/protobuf/util/internal/json_escaping.h
@@ -31,6 +31,8 @@ #ifndef GOOGLE_PROTOBUF_UTIL_INTERNAL__JSON_ESCAPING_H__ #define GOOGLE_PROTOBUF_UTIL_INTERNAL__JSON_ESCAPING_H__ +#include <cstdint> + #include <google/protobuf/stubs/common.h> #include <google/protobuf/stubs/bytestream.h> @@ -44,34 +46,34 @@ // The minimum value of a unicode high-surrogate code unit in the utf-16 // encoding. A high-surrogate is also known as a leading-surrogate. // See http://www.unicode.org/glossary/#high_surrogate_code_unit - static constexpr uint16 kMinHighSurrogate = 0xd800; + static constexpr uint16_t kMinHighSurrogate = 0xd800; // The maximum value of a unicide high-surrogate code unit in the utf-16 // encoding. A high-surrogate is also known as a leading-surrogate. // See http://www.unicode.org/glossary/#high_surrogate_code_unit - static constexpr uint16 kMaxHighSurrogate = 0xdbff; + static constexpr uint16_t kMaxHighSurrogate = 0xdbff; // The minimum value of a unicode low-surrogate code unit in the utf-16 // encoding. A low-surrogate is also known as a trailing-surrogate. // See http://www.unicode.org/glossary/#low_surrogate_code_unit - static constexpr uint16 kMinLowSurrogate = 0xdc00; + static constexpr uint16_t kMinLowSurrogate = 0xdc00; // The maximum value of a unicode low-surrogate code unit in the utf-16 // encoding. A low-surrogate is also known as a trailing surrogate. // See http://www.unicode.org/glossary/#low_surrogate_code_unit - static constexpr uint16 kMaxLowSurrogate = 0xdfff; + static constexpr uint16_t kMaxLowSurrogate = 0xdfff; // The minimum value of a unicode supplementary code point. // See http://www.unicode.org/glossary/#supplementary_code_point - static constexpr uint32 kMinSupplementaryCodePoint = 0x010000; + static constexpr uint32_t kMinSupplementaryCodePoint = 0x010000; // The minimum value of a unicode code point. // See http://www.unicode.org/glossary/#code_point - static constexpr uint32 kMinCodePoint = 0x000000; + static constexpr uint32_t kMinCodePoint = 0x000000; // The maximum value of a unicode code point. // See http://www.unicode.org/glossary/#code_point - static constexpr uint32 kMaxCodePoint = 0x10ffff; + static constexpr uint32_t kMaxCodePoint = 0x10ffff; JsonEscaping() {} virtual ~JsonEscaping() {}
diff --git a/src/google/protobuf/util/internal/json_objectwriter.cc b/src/google/protobuf/util/internal/json_objectwriter.cc index 32ce2dc..c03eb1d 100644 --- a/src/google/protobuf/util/internal/json_objectwriter.cc +++ b/src/google/protobuf/util/internal/json_objectwriter.cc
@@ -31,6 +31,7 @@ #include <google/protobuf/util/internal/json_objectwriter.h> #include <cmath> +#include <cstdint> #include <limits> #include <google/protobuf/stubs/casts.h> @@ -86,17 +87,17 @@ } JsonObjectWriter* JsonObjectWriter::RenderInt32(StringPiece name, - int32 value) { + int32_t value) { return RenderSimple(name, StrCat(value)); } JsonObjectWriter* JsonObjectWriter::RenderUint32(StringPiece name, - uint32 value) { + uint32_t value) { return RenderSimple(name, StrCat(value)); } JsonObjectWriter* JsonObjectWriter::RenderInt64(StringPiece name, - int64 value) { + int64_t value) { WritePrefix(name); WriteChar('"'); WriteRawString(StrCat(value)); @@ -105,7 +106,7 @@ } JsonObjectWriter* JsonObjectWriter::RenderUint64(StringPiece name, - uint64 value) { + uint64_t value) { WritePrefix(name); WriteChar('"'); WriteRawString(StrCat(value));
diff --git a/src/google/protobuf/util/internal/json_objectwriter.h b/src/google/protobuf/util/internal/json_objectwriter.h index ab372ab..2e9c684 100644 --- a/src/google/protobuf/util/internal/json_objectwriter.h +++ b/src/google/protobuf/util/internal/json_objectwriter.h
@@ -31,6 +31,7 @@ #ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_JSON_OBJECTWRITER_H__ #define GOOGLE_PROTOBUF_UTIL_CONVERTER_JSON_OBJECTWRITER_H__ +#include <cstdint> #include <memory> #include <string> @@ -118,10 +119,12 @@ JsonObjectWriter* StartList(StringPiece name) override; JsonObjectWriter* EndList() override; JsonObjectWriter* RenderBool(StringPiece name, bool value) override; - JsonObjectWriter* RenderInt32(StringPiece name, int32 value) override; - JsonObjectWriter* RenderUint32(StringPiece name, uint32 value) override; - JsonObjectWriter* RenderInt64(StringPiece name, int64 value) override; - JsonObjectWriter* RenderUint64(StringPiece name, uint64 value) override; + JsonObjectWriter* RenderInt32(StringPiece name, int32_t value) override; + JsonObjectWriter* RenderUint32(StringPiece name, + uint32_t value) override; + JsonObjectWriter* RenderInt64(StringPiece name, int64_t value) override; + JsonObjectWriter* RenderUint64(StringPiece name, + uint64_t value) override; JsonObjectWriter* RenderDouble(StringPiece name, double value) override; JsonObjectWriter* RenderFloat(StringPiece name, float value) override; JsonObjectWriter* RenderString(StringPiece name, @@ -218,7 +221,7 @@ // Take the slow-path if we don't have sufficient characters remaining in // our buffer or we have a non-trivial indent string which would prevent // us from using memset. - uint8* out = nullptr; + uint8_t* out = nullptr; if (indent_count_ > 0) { out = stream_->GetDirectBufferForNBytesAndAdvance(len); }
diff --git a/src/google/protobuf/util/internal/json_objectwriter_test.cc b/src/google/protobuf/util/internal/json_objectwriter_test.cc index e9f252b..03395da 100644 --- a/src/google/protobuf/util/internal/json_objectwriter_test.cc +++ b/src/google/protobuf/util/internal/json_objectwriter_test.cc
@@ -30,6 +30,8 @@ #include <google/protobuf/util/internal/json_objectwriter.h> +#include <cstdint> + #include <google/protobuf/io/zero_copy_stream_impl_lite.h> #include <google/protobuf/util/internal/utility.h> #include <gtest/gtest.h> @@ -147,8 +149,8 @@ ->RenderBool("bool", true) ->RenderDouble("double", std::numeric_limits<double>::max()) ->RenderFloat("float", std::numeric_limits<float>::max()) - ->RenderInt32("int", std::numeric_limits<int32>::min()) - ->RenderInt64("long", std::numeric_limits<int64>::min()) + ->RenderInt32("int", std::numeric_limits<int32_t>::min()) + ->RenderInt64("long", std::numeric_limits<int64_t>::min()) ->RenderBytes("bytes", "abracadabra") ->RenderString("string", "string") ->RenderBytes("emptybytes", "")
diff --git a/src/google/protobuf/util/internal/json_stream_parser.cc b/src/google/protobuf/util/internal/json_stream_parser.cc index db18b1a..dc0baca 100644 --- a/src/google/protobuf/util/internal/json_stream_parser.cc +++ b/src/google/protobuf/util/internal/json_stream_parser.cc
@@ -32,16 +32,15 @@ #include <algorithm> #include <cctype> -#include <cerrno> #include <cmath> -#include <cstdlib> -#include <cstring> -#include <limits> #include <memory> +#include <stack> +#include <string> -#include <google/protobuf/stubs/logging.h> #include <google/protobuf/stubs/common.h> +#include <google/protobuf/stubs/logging.h> #include <google/protobuf/stubs/strutil.h> +#include <google/protobuf/stubs/status.h> #include <google/protobuf/util/internal/object_writer.h> #include <google/protobuf/util/internal/json_escaping.h> @@ -50,14 +49,6 @@ namespace protobuf { namespace util { -// Allow these symbols to be referenced as util::Status, util::error::* in -// this file. -namespace error { -using util::error::CANCELLED; -using util::error::INTERNAL; -using util::error::INVALID_ARGUMENT; -} // namespace error - namespace converter { // Number of digits in an escaped UTF-16 code unit ('\\' 'u' X X X X) @@ -146,6 +137,8 @@ key_(), key_storage_(), finishing_(false), + seen_non_whitespace_(false), + allow_no_root_element_(false), parsed_(), parsed_storage_(), string_open_(0), @@ -214,7 +207,8 @@ } else { p_ = json_ = leftover_; if (!is_valid_utf8) { - return ReportFailure("Encountered non UTF-8 code points."); + return ReportFailure("Encountered non UTF-8 code points.", + ParseErrorType::NON_UTF_8); } } @@ -225,7 +219,9 @@ if (result.ok()) { SkipWhitespace(); if (!p_.empty()) { - result = ReportFailure("Parsing terminated before end of input."); + result = + ReportFailure("Parsing terminated before end of input.", + ParseErrorType::PARSING_TERMINATED_BEFORE_END_OF_INPUT); } } return result; @@ -249,7 +245,9 @@ // If we do not expect anything i.e. stack is empty, and we have non-empty // string left to parse, we report an error. if (stack_.empty()) { - return ReportFailure("Parsing terminated before end of input."); + return ReportFailure( + "Parsing terminated before end of input.", + ParseErrorType::PARSING_TERMINATED_BEFORE_END_OF_INPUT); } // If we expect future data i.e. stack is non-empty, and we have some // unparsed data left, we save it for later parse. @@ -258,6 +256,17 @@ return util::Status(); } +bool JsonStreamParser::IsInputAllWhiteSpaces(TokenType type) { + // Conclude the whole input is full of white spaces by: + // - it is at the finishing stage + // - we have run out of the input data + // - haven't seen non-whitespace char so far + if (finishing_ && p_.empty() && type == UNKNOWN && !seen_non_whitespace_) { + return true; + } + return false; +} + util::Status JsonStreamParser::RunParser() { while (!stack_.empty()) { ParseType type = stack_.top(); @@ -266,6 +275,9 @@ util::Status result; switch (type) { case VALUE: + if (allow_no_root_element_ && IsInputAllWhiteSpaces(t)) { + return util::Status(); + } result = ParseValue(t); break; @@ -330,7 +342,7 @@ case BEGIN_NULL: return ParseNull(); case UNKNOWN: - return ReportUnknown("Expected a value."); + return ReportUnknown("Expected a value.", ParseErrorType::EXPECTED_VALUE); default: { if (allow_empty_null_ && IsEmptyNullAllowed(type)) { return ParseEmptyNull(); @@ -343,7 +355,8 @@ if (!finishing_ && p_.length() < kKeywordFalse.length()) { return util::Status(util::error::CANCELLED, ""); } - return ReportFailure("Unexpected token."); + return ReportFailure("Unexpected token.", + ParseErrorType::UNEXPECTED_TOKEN); } } } @@ -381,7 +394,8 @@ if (!finishing_) { return util::Status(util::error::CANCELLED, ""); } - return ReportFailure("Closing quote expected in string."); + return ReportFailure("Closing quote expected in string.", + ParseErrorType::EXPECTED_CLOSING_QUOTE); } // Parse a unicode escape if we found \u in the string. if (data[1] == 'u') { @@ -451,7 +465,8 @@ } // End of string reached without a closing quote, report an error. string_open_ = 0; - return ReportFailure("Closing quote expected in string."); + return ReportFailure("Closing quote expected in string.", + ParseErrorType::EXPECTED_CLOSING_QUOTE); } // Converts a unicode escaped character to a decimal value stored in a char32 @@ -466,14 +481,16 @@ if (!finishing_) { return util::Status(util::error::CANCELLED, ""); } - return ReportFailure("Illegal hex string."); + return ReportFailure("Illegal hex string.", + ParseErrorType::ILLEGAL_HEX_STRING); } GOOGLE_DCHECK_EQ('\\', p_.data()[0]); GOOGLE_DCHECK_EQ('u', p_.data()[1]); uint32 code = 0; for (int i = 2; i < kUnicodeEscapedLength; ++i) { if (!isxdigit(p_.data()[i])) { - return ReportFailure("Invalid escape sequence."); + return ReportFailure("Invalid escape sequence.", + ParseErrorType::INVALID_ESCAPE_SEQUENCE); } code = (code << 4) + hex_digit_to_int(p_.data()[i]); } @@ -484,7 +501,8 @@ return util::Status(util::error::CANCELLED, ""); } if (!coerce_to_utf8_) { - return ReportFailure("Missing low surrogate."); + return ReportFailure("Missing low surrogate.", + ParseErrorType::MISSING_LOW_SURROGATE); } } else if (p_.data()[kUnicodeEscapedLength] == '\\' && p_.data()[kUnicodeEscapedLength + 1] == 'u') { @@ -492,7 +510,8 @@ for (int i = kUnicodeEscapedLength + 2; i < 2 * kUnicodeEscapedLength; ++i) { if (!isxdigit(p_.data()[i])) { - return ReportFailure("Invalid escape sequence."); + return ReportFailure("Invalid escape sequence.", + ParseErrorType::INVALID_ESCAPE_SEQUENCE); } low_code = (low_code << 4) + hex_digit_to_int(p_.data()[i]); } @@ -504,14 +523,17 @@ // Advance past the first code unit escape. p_.remove_prefix(kUnicodeEscapedLength); } else if (!coerce_to_utf8_) { - return ReportFailure("Invalid low surrogate."); + return ReportFailure("Invalid low surrogate.", + ParseErrorType::INVALID_LOW_SURROGATE); } } else if (!coerce_to_utf8_) { - return ReportFailure("Missing low surrogate."); + return ReportFailure("Missing low surrogate.", + ParseErrorType::MISSING_LOW_SURROGATE); } } if (!coerce_to_utf8_ && !IsValidCodePoint(code)) { - return ReportFailure("Invalid unicode code point."); + return ReportFailure("Invalid unicode code point.", + ParseErrorType::INVALID_UNICODE); } char buf[UTFmax]; int len = EncodeAsUTF8Char(code, buf); @@ -542,7 +564,8 @@ break; default: - return ReportFailure("Unable to parse number."); + return ReportFailure("Unable to parse number.", + ParseErrorType::UNABLE_TO_PARSE_NUMBER); } } return result; @@ -551,10 +574,12 @@ util::Status JsonStreamParser::ParseDoubleHelper(const std::string& number, NumberResult* result) { if (!safe_strtod(number, &result->double_val)) { - return ReportFailure("Unable to parse number."); + return ReportFailure("Unable to parse number.", + ParseErrorType::UNABLE_TO_PARSE_NUMBER); } if (!loose_float_number_conversion_ && !std::isfinite(result->double_val)) { - return ReportFailure("Number exceeds the range of double."); + return ReportFailure("Number exceeds the range of double.", + ParseErrorType::NUMBER_EXCEEDS_RANGE_DOUBLE); } result->type = NumberResult::DOUBLE; return util::Status(); @@ -606,7 +631,9 @@ if (!negative) { // Octal/Hex numbers are not valid JSON values. if (number.length() >= 2 && number[0] == '0') { - return ReportFailure("Octal/hex numbers are not valid JSON values."); + return ReportFailure( + "Octal/hex numbers are not valid JSON values.", + ParseErrorType::OCTAL_OR_HEX_ARE_NOT_VALID_JSON_VALUES); } if (safe_strtou64(number, &result->uint_val)) { result->type = NumberResult::UINT; @@ -624,7 +651,9 @@ // Octal/Hex numbers are not valid JSON values. if (number.length() >= 3 && number[1] == '0') { - return ReportFailure("Octal/hex numbers are not valid JSON values."); + return ReportFailure( + "Octal/hex numbers are not valid JSON values.", + ParseErrorType::OCTAL_OR_HEX_ARE_NOT_VALID_JSON_VALUES); } // Negative non-floating point number, parse as an int64. if (safe_strto64(number, &result->int_val)) { @@ -656,7 +685,8 @@ util::Status JsonStreamParser::ParseObjectMid(TokenType type) { if (type == UNKNOWN) { - return ReportUnknown("Expected , or } after key:value pair."); + return ReportUnknown("Expected , or } after key:value pair.", + ParseErrorType::EXPECTED_COMMA_OR_BRACES); } // Object is complete, advance past the comma and render the EndObject. @@ -673,12 +703,14 @@ return util::Status(); } // Illegal token after key:value pair. - return ReportFailure("Expected , or } after key:value pair."); + return ReportFailure("Expected , or } after key:value pair.", + ParseErrorType::EXPECTED_COMMA_OR_BRACES); } util::Status JsonStreamParser::ParseEntry(TokenType type) { if (type == UNKNOWN) { - return ReportUnknown("Expected an object key or }."); + return ReportUnknown("Expected an object key or }.", + ParseErrorType::EXPECTED_OBJECT_KEY_OR_BRACES); } // Close the object and return. This allows for trailing commas. @@ -711,11 +743,13 @@ result = ParseKey(); if (result.ok() && (key_ == kKeywordNull || key_ == kKeywordTrue || key_ == kKeywordFalse)) { - result = ReportFailure("Expected an object key or }."); + result = ReportFailure("Expected an object key or }.", + ParseErrorType::EXPECTED_OBJECT_KEY_OR_BRACES); } } else { // Unknown key type, report an error. - result = ReportFailure("Expected an object key or }."); + result = ReportFailure("Expected an object key or }.", + ParseErrorType::EXPECTED_OBJECT_KEY_OR_BRACES); } // On success we next expect an entry mid ':' then an object mid ',' or '}' if (result.ok()) { @@ -727,14 +761,16 @@ util::Status JsonStreamParser::ParseEntryMid(TokenType type) { if (type == UNKNOWN) { - return ReportUnknown("Expected : between key:value pair."); + return ReportUnknown("Expected : between key:value pair.", + ParseErrorType::EXPECTED_COLON); } if (type == ENTRY_SEPARATOR) { Advance(); stack_.push(VALUE); return util::Status(); } - return ReportFailure("Expected : between key:value pair."); + return ReportFailure("Expected : between key:value pair.", + ParseErrorType::EXPECTED_COLON); } util::Status JsonStreamParser::HandleBeginArray() { @@ -748,7 +784,8 @@ util::Status JsonStreamParser::ParseArrayValue(TokenType type) { if (type == UNKNOWN) { - return ReportUnknown("Expected a value or ] within an array."); + return ReportUnknown("Expected a value or ] within an array.", + ParseErrorType::EXPECTED_VALUE_OR_BRACKET); } if (type == END_ARRAY) { @@ -772,7 +809,8 @@ util::Status JsonStreamParser::ParseArrayMid(TokenType type) { if (type == UNKNOWN) { - return ReportUnknown("Expected , or ] after array value."); + return ReportUnknown("Expected , or ] after array value.", + ParseErrorType::EXPECTED_COMMA_OR_BRACKET); } if (type == END_ARRAY) { @@ -788,7 +826,8 @@ return util::Status(); } // Illegal token after array value. - return ReportFailure("Expected , or ] after array value."); + return ReportFailure("Expected , or ] after array value.", + ParseErrorType::EXPECTED_COMMA_OR_BRACKET); } util::Status JsonStreamParser::ParseTrue() { @@ -824,7 +863,8 @@ stack_.top() == OBJ_MID; } -util::Status JsonStreamParser::ReportFailure(StringPiece message) { +util::Status JsonStreamParser::ReportFailure(StringPiece message, + ParseErrorType parse_code) { static const int kContextLength = 20; const char* p_start = p_.data(); const char* json_start = json_.data(); @@ -834,19 +874,24 @@ StringPiece segment(begin, end - begin); std::string location(p_start - begin, ' '); location.push_back('^'); - return util::Status(util::error::INVALID_ARGUMENT, - StrCat(message, "\n", segment, "\n", location)); + auto status = + util::Status(util::error::INVALID_ARGUMENT, + StrCat(message, "\n", segment, "\n", location)); + + return status; } -util::Status JsonStreamParser::ReportUnknown(StringPiece message) { +util::Status JsonStreamParser::ReportUnknown(StringPiece message, + ParseErrorType parse_code) { // If we aren't finishing the parse, cancel parsing and try later. if (!finishing_) { return util::Status(util::error::CANCELLED, ""); } if (p_.empty()) { - return ReportFailure(StrCat("Unexpected end of string. ", message)); + return ReportFailure(StrCat("Unexpected end of string. ", message), + parse_code); } - return ReportFailure(message); + return ReportFailure(message, parse_code); } util::Status JsonStreamParser::IncrementRecursionDepth( @@ -864,6 +909,9 @@ while (!p_.empty() && ascii_isspace(*p_.data())) { Advance(); } + if (!p_.empty() && !ascii_isspace(*p_.data())) { + seen_non_whitespace_ = true; + } } void JsonStreamParser::Advance() { @@ -878,11 +926,13 @@ if (allow_permissive_key_naming_) { if (!ConsumeKeyPermissive(&p_, &key_)) { - return ReportFailure("Invalid key or variable name."); + return ReportFailure("Invalid key or variable name.", + ParseErrorType::INVALID_KEY_OR_VARIABLE_NAME); } } else { if (!ConsumeKey(&p_, &key_)) { - return ReportFailure("Invalid key or variable name."); + return ReportFailure("Invalid key or variable name.", + ParseErrorType::INVALID_KEY_OR_VARIABLE_NAME); } }
diff --git a/src/google/protobuf/util/internal/json_stream_parser.h b/src/google/protobuf/util/internal/json_stream_parser.h index 5a9eac8..4c93d77 100644 --- a/src/google/protobuf/util/internal/json_stream_parser.h +++ b/src/google/protobuf/util/internal/json_stream_parser.h
@@ -31,6 +31,7 @@ #ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_JSON_STREAM_PARSER_H__ #define GOOGLE_PROTOBUF_UTIL_CONVERTER_JSON_STREAM_PARSER_H__ +#include <cstdint> #include <stack> #include <string> @@ -46,6 +47,7 @@ namespace util { namespace converter { + class ObjectWriter; // A JSON parser that can parse a stream of JSON chunks rather than needing the @@ -74,11 +76,17 @@ explicit JsonStreamParser(ObjectWriter* ow); virtual ~JsonStreamParser(); - // Parses a UTF-8 encoded JSON string from a StringPiece. + // Parses a UTF-8 encoded JSON string from a StringPiece. If the returned + // status is non-ok, the status might contain a payload ParseErrorType with + // type_url kParseErrorTypeUrl and a payload containing string snippet of the + // error with type_url kParseErrorSnippetUrl. util::Status Parse(StringPiece json); - // Finish parsing the JSON string. + // Finish parsing the JSON string. If the returned status is non-ok, the + // status might contain a payload ParseErrorType with type_url + // kParseErrorTypeUrl and a payload containing string snippet of the error + // with type_url kParseErrorSnippetUrl. util::Status FinishParse(); @@ -89,6 +97,30 @@ max_recursion_depth_ = max_depth; } + // Denotes the cause of error. + enum ParseErrorType { + UNKNOWN_PARSE_ERROR, + OCTAL_OR_HEX_ARE_NOT_VALID_JSON_VALUES, + EXPECTED_COLON, + EXPECTED_COMMA_OR_BRACKET, + EXPECTED_VALUE, + EXPECTED_COMMA_OR_BRACES, + EXPECTED_OBJECT_KEY_OR_BRACES, + EXPECTED_VALUE_OR_BRACKET, + INVALID_KEY_OR_VARIABLE_NAME, + NON_UTF_8, + PARSING_TERMINATED_BEFORE_END_OF_INPUT, + UNEXPECTED_TOKEN, + EXPECTED_CLOSING_QUOTE, + ILLEGAL_HEX_STRING, + INVALID_ESCAPE_SEQUENCE, + MISSING_LOW_SURROGATE, + INVALID_LOW_SURROGATE, + INVALID_UNICODE, + UNABLE_TO_PARSE_NUMBER, + NUMBER_EXCEEDS_RANGE_DOUBLE + }; + private: friend class JsonStreamParserTest; // Return the current recursion depth. @@ -125,8 +157,8 @@ Type type; union { double double_val; - int64 int_val; - uint64 uint_val; + int64_t int_val; + uint64_t uint_val; }; }; @@ -198,13 +230,18 @@ // Whether an empty-null is allowed in the current state. bool IsEmptyNullAllowed(TokenType type); + // Whether the whole input is all whitespaces. + bool IsInputAllWhiteSpaces(TokenType type); + // Report a failure as a util::Status. - util::Status ReportFailure(StringPiece message); + util::Status ReportFailure(StringPiece message, + ParseErrorType parse_code); // Report a failure due to an UNKNOWN token type. We check if we hit the // end of the stream and if we're finishing or not to detect what type of // status to return in this case. - util::Status ReportUnknown(StringPiece message); + util::Status ReportUnknown(StringPiece message, + ParseErrorType parse_code); // Helper function to check recursion depth and increment it. It will return // Status::OK if the current depth is allowed. Otherwise an error is returned. @@ -253,6 +290,15 @@ // trying during the next chunk, but during FinishParse() it is an error. bool finishing_; + // Whether non whitespace tokens have been seen during parsing. + // It is used to handle the case of a pure whitespace stream input. + bool seen_non_whitespace_; + + // The JsonStreamParser requires a root element by default and it will raise + // error if the root element is missing. If `allow_no_root_element_` is true, + // the JsonStreamParser can also handle this case. + bool allow_no_root_element_; + // String we parsed during a call to ParseStringHelper(). StringPiece parsed_;
diff --git a/src/google/protobuf/util/internal/json_stream_parser_test.cc b/src/google/protobuf/util/internal/json_stream_parser_test.cc index ac6fe3d..21620c2 100644 --- a/src/google/protobuf/util/internal/json_stream_parser_test.cc +++ b/src/google/protobuf/util/internal/json_stream_parser_test.cc
@@ -30,6 +30,8 @@ #include <google/protobuf/util/internal/json_stream_parser.h> +#include <cstdint> + #include <google/protobuf/stubs/logging.h> #include <google/protobuf/stubs/common.h> #include <google/protobuf/util/internal/expecting_objectwriter.h> @@ -42,11 +44,11 @@ namespace google { namespace protobuf { namespace util { -namespace error { -using util::error::INVALID_ARGUMENT; -} // namespace error namespace converter { +using ParseErrorType = + ::google::protobuf::util::converter::JsonStreamParser::ParseErrorType; + // Tests for the JSON Stream Parser. These tests are intended to be // comprehensive and cover the following: @@ -141,6 +143,17 @@ EXPECT_EQ(error_prefix, error_message.substr(0, error_prefix.size())); } + void DoErrorTest( + StringPiece json, int split, StringPiece error_prefix, + ParseErrorType expected_parse_error_type, + std::function<void(JsonStreamParser*)> setup = [](JsonStreamParser* p) { + }) { + util::Status result = RunTest(json, split, setup); + EXPECT_EQ(util::error::INVALID_ARGUMENT, result.code()); + StringPiece error_message(result.error_message()); + EXPECT_EQ(error_prefix, error_message.substr(0, error_prefix.size())); + } + #ifndef _MSC_VER // TODO(xiaofeng): We have to disable InSequence check for MSVC because it @@ -233,7 +246,7 @@ TEST_F(JsonStreamParserTest, SimpleNegativeInt) { StringPiece str = "-79497823553162765"; for (int i = 0; i <= str.length(); ++i) { - ow_.RenderInt64("", int64{-79497823553162765}); + ow_.RenderInt64("", int64_t{-79497823553162765}); DoTest(str, i); } } @@ -241,7 +254,7 @@ TEST_F(JsonStreamParserTest, SimpleUnsignedInt) { StringPiece str = "11779497823553162765"; for (int i = 0; i <= str.length(); ++i) { - ow_.RenderUint64("", uint64{11779497823553162765u}); + ow_.RenderUint64("", uint64_t{11779497823553162765u}); DoTest(str, i); } } @@ -249,26 +262,31 @@ TEST_F(JsonStreamParserTest, OctalNumberIsInvalid) { StringPiece str = "01234"; for (int i = 0; i <= str.length(); ++i) { - DoErrorTest(str, i, "Octal/hex numbers are not valid JSON values."); + DoErrorTest(str, i, "Octal/hex numbers are not valid JSON values.", + ParseErrorType::OCTAL_OR_HEX_ARE_NOT_VALID_JSON_VALUES); } str = "-01234"; for (int i = 0; i <= str.length(); ++i) { - DoErrorTest(str, i, "Octal/hex numbers are not valid JSON values."); + DoErrorTest(str, i, "Octal/hex numbers are not valid JSON values.", + ParseErrorType::OCTAL_OR_HEX_ARE_NOT_VALID_JSON_VALUES); } } TEST_F(JsonStreamParserTest, HexNumberIsInvalid) { StringPiece str = "0x1234"; for (int i = 0; i <= str.length(); ++i) { - DoErrorTest(str, i, "Octal/hex numbers are not valid JSON values."); + DoErrorTest(str, i, "Octal/hex numbers are not valid JSON values.", + ParseErrorType::OCTAL_OR_HEX_ARE_NOT_VALID_JSON_VALUES); } str = "-0x1234"; for (int i = 0; i <= str.length(); ++i) { - DoErrorTest(str, i, "Octal/hex numbers are not valid JSON values."); + DoErrorTest(str, i, "Octal/hex numbers are not valid JSON values.", + ParseErrorType::OCTAL_OR_HEX_ARE_NOT_VALID_JSON_VALUES); } str = "12x34"; for (int i = 0; i <= str.length(); ++i) { - DoErrorTest(str, i, "Unable to parse number."); + DoErrorTest(str, i, "Unable to parse number.", + ParseErrorType::UNABLE_TO_PARSE_NUMBER); } } @@ -338,14 +356,16 @@ TEST_F(JsonStreamParserTest, UnquotedObjectKeyWithReservedKeyword) { StringPiece str = "{ null: \"a\", true: \"b\", false: \"c\"}"; for (int i = 0; i <= str.length(); ++i) { - DoErrorTest(str, i, "Expected an object key or }."); + DoErrorTest(str, i, "Expected an object key or }.", + ParseErrorType::EXPECTED_OBJECT_KEY_OR_BRACES); } } TEST_F(JsonStreamParserTest, UnquotedObjectKeyWithEmbeddedNonAlphanumeric) { StringPiece str = "{ foo-bar-baz: \"a\"}"; for (int i = 0; i <= str.length(); ++i) { - DoErrorTest(str, i, "Expected : between key:value pair."); + DoErrorTest(str, i, "Expected : between key:value pair.", + ParseErrorType::EXPECTED_COLON); } } @@ -376,7 +396,7 @@ ->RenderInt64("", -127) ->RenderDouble("", 45.3) ->RenderDouble("", -1056.4) - ->RenderUint64("", uint64{11779497823553162765u}) + ->RenderUint64("", uint64_t{11779497823553162765u}) ->EndList() ->StartObject("") ->RenderBool("key", true) @@ -404,7 +424,7 @@ ->RenderInt64("ni", -127) ->RenderDouble("pd", 45.3) ->RenderDouble("nd", -1056.4) - ->RenderUint64("pl", uint64{11779497823553162765u}) + ->RenderUint64("pl", uint64_t{11779497823553162765u}) ->StartList("l") ->StartList("") ->EndList() @@ -421,13 +441,16 @@ TEST_F(JsonStreamParserTest, RejectNonUtf8WhenNotCoerced) { StringPiece json = "{\"address\":\xFF\"חרושת 23, רעננה, ישראל\"}"; for (int i = 0; i <= json.length(); ++i) { - DoErrorTest(json, i, "Encountered non UTF-8 code points."); + DoErrorTest(json, i, "Encountered non UTF-8 code points.", + ParseErrorType::NON_UTF_8); } json = "{\"address\": \"חרושת 23,\xFFרעננה, ישראל\"}"; for (int i = 0; i <= json.length(); ++i) { - DoErrorTest(json, i, "Encountered non UTF-8 code points."); + DoErrorTest(json, i, "Encountered non UTF-8 code points.", + ParseErrorType::NON_UTF_8); } - DoErrorTest("\xFF{}", 0, "Encountered non UTF-8 code points."); + DoErrorTest("\xFF{}", 0, "Encountered non UTF-8 code points.", + ParseErrorType::NON_UTF_8); } // - unicode handling in strings @@ -460,7 +483,8 @@ // A low surrogate alone. StringPiece str = "[\"\\ude36\"]"; for (int i = 0; i <= str.length(); ++i) { - DoErrorTest(str, i, "Invalid unicode code point."); + DoErrorTest(str, i, "Invalid unicode code point.", + ParseErrorType::INVALID_UNICODE); } } @@ -468,22 +492,26 @@ // A high surrogate alone. StringPiece str = "[\"\\ud83d\"]"; for (int i = 0; i <= str.length(); ++i) { - DoErrorTest(str, i, "Missing low surrogate."); + DoErrorTest(str, i, "Missing low surrogate.", + ParseErrorType::MISSING_LOW_SURROGATE); } // A high surrogate with some trailing characters. str = "[\"\\ud83d|ude36\"]"; for (int i = 0; i <= str.length(); ++i) { - DoErrorTest(str, i, "Missing low surrogate."); + DoErrorTest(str, i, "Missing low surrogate.", + ParseErrorType::MISSING_LOW_SURROGATE); } // A high surrogate with half a low surrogate. str = "[\"\\ud83d\\ude--\"]"; for (int i = 0; i <= str.length(); ++i) { - DoErrorTest(str, i, "Invalid escape sequence."); + DoErrorTest(str, i, "Invalid escape sequence.", + ParseErrorType::INVALID_ESCAPE_SEQUENCE); } // Two high surrogates. str = "[\"\\ud83d\\ud83d\"]"; for (int i = 0; i <= str.length(); ++i) { - DoErrorTest(str, i, "Invalid low surrogate."); + DoErrorTest(str, i, "Invalid low surrogate.", + ParseErrorType::INVALID_LOW_SURROGATE); } } @@ -527,21 +555,24 @@ StringPiece str = "truee"; for (int i = 0; i <= str.length(); ++i) { ow_.RenderBool("", true); - DoErrorTest(str, i, "Parsing terminated before end of input."); + DoErrorTest(str, i, "Parsing terminated before end of input.", + ParseErrorType::PARSING_TERMINATED_BEFORE_END_OF_INPUT); } } TEST_F(JsonStreamParserTest, InvalidNumberDashOnly) { StringPiece str = "-"; for (int i = 0; i <= str.length(); ++i) { - DoErrorTest(str, i, "Unable to parse number."); + DoErrorTest(str, i, "Unable to parse number.", + ParseErrorType::UNABLE_TO_PARSE_NUMBER); } } TEST_F(JsonStreamParserTest, InvalidNumberDashName) { StringPiece str = "-foo"; for (int i = 0; i <= str.length(); ++i) { - DoErrorTest(str, i, "Unable to parse number."); + DoErrorTest(str, i, "Unable to parse number.", + ParseErrorType::UNABLE_TO_PARSE_NUMBER); } } @@ -549,7 +580,7 @@ StringPiece str = "[nule]"; for (int i = 0; i <= str.length(); ++i) { ow_.StartList(""); - DoErrorTest(str, i, "Unexpected token."); + DoErrorTest(str, i, "Unexpected token.", ParseErrorType::UNEXPECTED_TOKEN); } } @@ -557,7 +588,8 @@ StringPiece str = "{123false}"; for (int i = 0; i <= str.length(); ++i) { ow_.StartObject(""); - DoErrorTest(str, i, "Expected an object key or }."); + DoErrorTest(str, i, "Expected an object key or }.", + ParseErrorType::EXPECTED_OBJECT_KEY_OR_BRACES); } } @@ -565,14 +597,16 @@ TEST_F(JsonStreamParserTest, MismatchedSingleQuotedLiteral) { StringPiece str = "'Some str\""; for (int i = 0; i <= str.length(); ++i) { - DoErrorTest(str, i, "Closing quote expected in string."); + DoErrorTest(str, i, "Closing quote expected in string.", + ParseErrorType::EXPECTED_CLOSING_QUOTE); } } TEST_F(JsonStreamParserTest, MismatchedDoubleQuotedLiteral) { StringPiece str = "\"Another string that ends poorly!'"; for (int i = 0; i <= str.length(); ++i) { - DoErrorTest(str, i, "Closing quote expected in string."); + DoErrorTest(str, i, "Closing quote expected in string.", + ParseErrorType::EXPECTED_CLOSING_QUOTE); } } @@ -580,14 +614,16 @@ TEST_F(JsonStreamParserTest, UnterminatedLiteralString) { StringPiece str = "\"Forgot the rest of i"; for (int i = 0; i <= str.length(); ++i) { - DoErrorTest(str, i, "Closing quote expected in string."); + DoErrorTest(str, i, "Closing quote expected in string.", + ParseErrorType::EXPECTED_CLOSING_QUOTE); } } TEST_F(JsonStreamParserTest, UnterminatedStringEscape) { StringPiece str = "\"Forgot the rest of \\"; for (int i = 0; i <= str.length(); ++i) { - DoErrorTest(str, i, "Closing quote expected in string."); + DoErrorTest(str, i, "Closing quote expected in string.", + ParseErrorType::EXPECTED_CLOSING_QUOTE); } } @@ -595,7 +631,8 @@ StringPiece str = "[\"Forgot to close the string]"; for (int i = 0; i <= str.length(); ++i) { ow_.StartList(""); - DoErrorTest(str, i, "Closing quote expected in string."); + DoErrorTest(str, i, "Closing quote expected in string.", + ParseErrorType::EXPECTED_CLOSING_QUOTE); } } @@ -603,7 +640,8 @@ StringPiece str = "{f: \"Forgot to close the string}"; for (int i = 0; i <= str.length(); ++i) { ow_.StartObject(""); - DoErrorTest(str, i, "Closing quote expected in string."); + DoErrorTest(str, i, "Closing quote expected in string.", + ParseErrorType::EXPECTED_CLOSING_QUOTE); } } @@ -611,7 +649,8 @@ StringPiece str = "{"; for (int i = 0; i <= str.length(); ++i) { ow_.StartObject(""); - DoErrorTest(str, i, "Unexpected end of string."); + DoErrorTest(str, i, "Unexpected end of string.", + ParseErrorType::EXPECTED_OBJECT_KEY_OR_BRACES); } } @@ -621,7 +660,8 @@ StringPiece str = "{'key': true]"; for (int i = 0; i <= str.length(); ++i) { ow_.StartObject("")->RenderBool("key", true); - DoErrorTest(str, i, "Expected , or } after key:value pair."); + DoErrorTest(str, i, "Expected , or } after key:value pair.", + ParseErrorType::EXPECTED_COMMA_OR_BRACES); } } @@ -629,7 +669,8 @@ StringPiece str = "[true, null}"; for (int i = 0; i <= str.length(); ++i) { ow_.StartList("")->RenderBool("", true)->RenderNull(""); - DoErrorTest(str, i, "Expected , or ] after array value."); + DoErrorTest(str, i, "Expected , or ] after array value.", + ParseErrorType::EXPECTED_COMMA_OR_BRACKET); } } @@ -638,7 +679,8 @@ StringPiece str = "{42: true}"; for (int i = 0; i <= str.length(); ++i) { ow_.StartObject(""); - DoErrorTest(str, i, "Expected an object key or }."); + DoErrorTest(str, i, "Expected an object key or }.", + ParseErrorType::EXPECTED_OBJECT_KEY_OR_BRACES); } } @@ -646,7 +688,8 @@ StringPiece str = "{{bob: true}}"; for (int i = 0; i <= str.length(); ++i) { ow_.StartObject(""); - DoErrorTest(str, i, "Expected an object key or }."); + DoErrorTest(str, i, "Expected an object key or }.", + ParseErrorType::EXPECTED_OBJECT_KEY_OR_BRACES); } } @@ -654,7 +697,8 @@ StringPiece str = "{[null]}"; for (int i = 0; i <= str.length(); ++i) { ow_.StartObject(""); - DoErrorTest(str, i, "Expected an object key or }."); + DoErrorTest(str, i, "Expected an object key or }.", + ParseErrorType::EXPECTED_OBJECT_KEY_OR_BRACES); } } @@ -662,7 +706,8 @@ StringPiece str = "{false}"; for (int i = 0; i <= str.length(); ++i) { ow_.StartObject(""); - DoErrorTest(str, i, "Expected an object key or }."); + DoErrorTest(str, i, "Expected an object key or }.", + ParseErrorType::EXPECTED_OBJECT_KEY_OR_BRACES); } } @@ -670,7 +715,8 @@ StringPiece str = "{\"key\"}"; for (int i = 0; i <= str.length(); ++i) { ow_.StartObject(""); - DoErrorTest(str, i, "Expected : between key:value pair."); + DoErrorTest(str, i, "Expected : between key:value pair.", + ParseErrorType::EXPECTED_COLON); } } @@ -678,7 +724,8 @@ StringPiece str = "{key}"; for (int i = 0; i <= str.length(); ++i) { ow_.StartObject(""); - DoErrorTest(str, i, "Expected : between key:value pair."); + DoErrorTest(str, i, "Expected : between key:value pair.", + ParseErrorType::EXPECTED_COLON); } } @@ -686,7 +733,8 @@ StringPiece str = "{key"; for (int i = 0; i <= str.length(); ++i) { ow_.StartObject(""); - DoErrorTest(str, i, "Unexpected end of string."); + DoErrorTest(str, i, "Unexpected end of string.", + ParseErrorType::EXPECTED_COLON); } } @@ -694,7 +742,7 @@ StringPiece str = "{key:}"; for (int i = 0; i <= str.length(); ++i) { ow_.StartObject(""); - DoErrorTest(str, i, "Unexpected token."); + DoErrorTest(str, i, "Unexpected token.", ParseErrorType::UNEXPECTED_TOKEN); } } @@ -702,7 +750,8 @@ StringPiece str = "{key:20 'hello': true}"; for (int i = 0; i <= str.length(); ++i) { ow_.StartObject("")->RenderUint64("key", 20); - DoErrorTest(str, i, "Expected , or } after key:value pair."); + DoErrorTest(str, i, "Expected , or } after key:value pair.", + ParseErrorType::EXPECTED_COMMA_OR_BRACES); } } @@ -710,7 +759,8 @@ StringPiece str = "{false: 20}"; for (int i = 0; i <= str.length(); ++i) { ow_.StartObject(""); - DoErrorTest(str, i, "Expected an object key or }."); + DoErrorTest(str, i, "Expected an object key or }.", + ParseErrorType::EXPECTED_OBJECT_KEY_OR_BRACES); } } @@ -718,7 +768,8 @@ StringPiece str = "{}}"; for (int i = 0; i <= str.length(); ++i) { ow_.StartObject("")->EndObject(); - DoErrorTest(str, i, "Parsing terminated before end of input."); + DoErrorTest(str, i, "Parsing terminated before end of input.", + ParseErrorType::PARSING_TERMINATED_BEFORE_END_OF_INPUT); } } @@ -742,12 +793,14 @@ StringPiece str = "[1.89769e+308]"; for (int i = 0; i <= str.length(); ++i) { ow_.StartList(""); - DoErrorTest(str, i, "Number exceeds the range of double."); + DoErrorTest(str, i, "Number exceeds the range of double.", + ParseErrorType::NUMBER_EXCEEDS_RANGE_DOUBLE); } str = "[-1.89769e+308]"; for (int i = 0; i <= str.length(); ++i) { ow_.StartList(""); - DoErrorTest(str, i, "Number exceeds the range of double."); + DoErrorTest(str, i, "Number exceeds the range of double.", + ParseErrorType::NUMBER_EXCEEDS_RANGE_DOUBLE); } } @@ -756,7 +809,8 @@ TEST_F(JsonStreamParserTest, UnfinishedEscape) { StringPiece str = "\"\\"; for (int i = 0; i <= str.length(); ++i) { - DoErrorTest(str, i, "Closing quote expected in string."); + DoErrorTest(str, i, "Closing quote expected in string.", + ParseErrorType::EXPECTED_CLOSING_QUOTE); } } @@ -764,7 +818,8 @@ TEST_F(JsonStreamParserTest, UnfinishedUnicodeEscape) { StringPiece str = "\"\\u"; for (int i = 0; i <= str.length(); ++i) { - DoErrorTest(str, i, "Illegal hex string."); + DoErrorTest(str, i, "Illegal hex string.", + ParseErrorType::ILLEGAL_HEX_STRING); } } @@ -772,7 +827,8 @@ TEST_F(JsonStreamParserTest, UnicodeEscapeCutOff) { StringPiece str = "\"\\u12"; for (int i = 0; i <= str.length(); ++i) { - DoErrorTest(str, i, "Illegal hex string."); + DoErrorTest(str, i, "Illegal hex string.", + ParseErrorType::ILLEGAL_HEX_STRING); } } @@ -780,7 +836,8 @@ TEST_F(JsonStreamParserTest, BracketedUnicodeEscape) { StringPiece str = "\"\\u{1f36f}\""; for (int i = 0; i <= str.length(); ++i) { - DoErrorTest(str, i, "Invalid escape sequence."); + DoErrorTest(str, i, "Invalid escape sequence.", + ParseErrorType::INVALID_ESCAPE_SEQUENCE); } } @@ -788,7 +845,8 @@ TEST_F(JsonStreamParserTest, UnicodeEscapeInvalidCharacters) { StringPiece str = "\"\\u12$4hello"; for (int i = 0; i <= str.length(); ++i) { - DoErrorTest(str, i, "Invalid escape sequence."); + DoErrorTest(str, i, "Invalid escape sequence.", + ParseErrorType::INVALID_ESCAPE_SEQUENCE); } } @@ -796,7 +854,8 @@ TEST_F(JsonStreamParserTest, UnicodeEscapeLowHalfSurrogateInvalidCharacters) { StringPiece str = "\"\\ud800\\udcfg\""; for (int i = 0; i <= str.length(); ++i) { - DoErrorTest(str, i, "Invalid escape sequence."); + DoErrorTest(str, i, "Invalid escape sequence.", + ParseErrorType::INVALID_ESCAPE_SEQUENCE); } } @@ -805,7 +864,8 @@ StringPiece str = "{'k1': true,,'k2': false}"; for (int i = 0; i <= str.length(); ++i) { ow_.StartObject("")->RenderBool("k1", true); - DoErrorTest(str, i, "Expected an object key or }."); + DoErrorTest(str, i, "Expected an object key or }.", + ParseErrorType::EXPECTED_OBJECT_KEY_OR_BRACES); } } @@ -813,7 +873,7 @@ StringPiece str = "[true,,false}"; for (int i = 0; i <= str.length(); ++i) { ow_.StartList("")->RenderBool("", true); - DoErrorTest(str, i, "Unexpected token."); + DoErrorTest(str, i, "Unexpected token.", ParseErrorType::UNEXPECTED_TOKEN); } } @@ -822,7 +882,8 @@ StringPiece str = "'hello', 'world'"; for (int i = 0; i <= str.length(); ++i) { ow_.RenderString("", "hello"); - DoErrorTest(str, i, "Parsing terminated before end of input."); + DoErrorTest(str, i, "Parsing terminated before end of input.", + ParseErrorType::PARSING_TERMINATED_BEFORE_END_OF_INPUT); } } @@ -830,7 +891,8 @@ StringPiece str = "{'key': true} 'oops'"; for (int i = 0; i <= str.length(); ++i) { ow_.StartObject("")->RenderBool("key", true)->EndObject(); - DoErrorTest(str, i, "Parsing terminated before end of input."); + DoErrorTest(str, i, "Parsing terminated before end of input.", + ParseErrorType::PARSING_TERMINATED_BEFORE_END_OF_INPUT); } } @@ -838,7 +900,8 @@ StringPiece str = "[null] 'oops'"; for (int i = 0; i <= str.length(); ++i) { ow_.StartList("")->RenderNull("")->EndList(); - DoErrorTest(str, i, "Parsing terminated before end of input."); + DoErrorTest(str, i, "Parsing terminated before end of input.", + ParseErrorType::PARSING_TERMINATED_BEFORE_END_OF_INPUT); } } @@ -846,7 +909,7 @@ TEST_F(JsonStreamParserTest, UnknownCharactersAsValue) { StringPiece str = "*"; for (int i = 0; i <= str.length(); ++i) { - DoErrorTest(str, i, "Expected a value."); + DoErrorTest(str, i, "Expected a value.", ParseErrorType::EXPECTED_VALUE); } } @@ -854,7 +917,8 @@ StringPiece str = "[*]"; for (int i = 0; i <= str.length(); ++i) { ow_.StartList(""); - DoErrorTest(str, i, "Expected a value or ] within an array."); + DoErrorTest(str, i, "Expected a value or ] within an array.", + ParseErrorType::EXPECTED_VALUE_OR_BRACKET); } } @@ -862,7 +926,7 @@ StringPiece str = "{'key': *}"; for (int i = 0; i <= str.length(); ++i) { ow_.StartObject(""); - DoErrorTest(str, i, "Expected a value."); + DoErrorTest(str, i, "Expected a value.", ParseErrorType::EXPECTED_VALUE); } }
diff --git a/src/google/protobuf/util/internal/object_writer.h b/src/google/protobuf/util/internal/object_writer.h index 29b05c1..917a280 100644 --- a/src/google/protobuf/util/internal/object_writer.h +++ b/src/google/protobuf/util/internal/object_writer.h
@@ -31,6 +31,8 @@ #ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_OBJECT_WRITER_H__ #define GOOGLE_PROTOBUF_UTIL_CONVERTER_OBJECT_WRITER_H__ +#include <cstdint> + #include <google/protobuf/stubs/common.h> #include <google/protobuf/stubs/strutil.h> @@ -79,16 +81,18 @@ virtual ObjectWriter* RenderBool(StringPiece name, bool value) = 0; // Renders an 32-bit integer value. - virtual ObjectWriter* RenderInt32(StringPiece name, int32 value) = 0; + virtual ObjectWriter* RenderInt32(StringPiece name, int32_t value) = 0; // Renders an 32-bit unsigned integer value. - virtual ObjectWriter* RenderUint32(StringPiece name, uint32 value) = 0; + virtual ObjectWriter* RenderUint32(StringPiece name, + uint32_t value) = 0; // Renders a 64-bit integer value. - virtual ObjectWriter* RenderInt64(StringPiece name, int64 value) = 0; + virtual ObjectWriter* RenderInt64(StringPiece name, int64_t value) = 0; // Renders an 64-bit unsigned integer value. - virtual ObjectWriter* RenderUint64(StringPiece name, uint64 value) = 0; + virtual ObjectWriter* RenderUint64(StringPiece name, + uint64_t value) = 0; // Renders a double value.
diff --git a/src/google/protobuf/util/internal/proto_writer.cc b/src/google/protobuf/util/internal/proto_writer.cc index 0102259..8821dbe 100644 --- a/src/google/protobuf/util/internal/proto_writer.cc +++ b/src/google/protobuf/util/internal/proto_writer.cc
@@ -30,6 +30,7 @@ #include <google/protobuf/util/internal/proto_writer.h> +#include <cstdint> #include <functional> #include <stack> @@ -122,7 +123,7 @@ // Writes an INT32 field, including tag to the stream. inline util::Status WriteInt32(int field_number, const DataPiece& data, CodedOutputStream* stream) { - util::StatusOr<int32> i32 = data.ToInt32(); + util::StatusOr<int32_t> i32 = data.ToInt32(); if (i32.ok()) { WireFormatLite::WriteInt32(field_number, i32.value(), stream); } @@ -132,7 +133,7 @@ // writes an SFIXED32 field, including tag, to the stream. inline util::Status WriteSFixed32(int field_number, const DataPiece& data, CodedOutputStream* stream) { - util::StatusOr<int32> i32 = data.ToInt32(); + util::StatusOr<int32_t> i32 = data.ToInt32(); if (i32.ok()) { WireFormatLite::WriteSFixed32(field_number, i32.value(), stream); } @@ -142,7 +143,7 @@ // Writes an SINT32 field, including tag, to the stream. inline util::Status WriteSInt32(int field_number, const DataPiece& data, CodedOutputStream* stream) { - util::StatusOr<int32> i32 = data.ToInt32(); + util::StatusOr<int32_t> i32 = data.ToInt32(); if (i32.ok()) { WireFormatLite::WriteSInt32(field_number, i32.value(), stream); } @@ -152,7 +153,7 @@ // Writes a FIXED32 field, including tag, to the stream. inline util::Status WriteFixed32(int field_number, const DataPiece& data, CodedOutputStream* stream) { - util::StatusOr<uint32> u32 = data.ToUint32(); + util::StatusOr<uint32_t> u32 = data.ToUint32(); if (u32.ok()) { WireFormatLite::WriteFixed32(field_number, u32.value(), stream); } @@ -162,7 +163,7 @@ // Writes a UINT32 field, including tag, to the stream. inline util::Status WriteUInt32(int field_number, const DataPiece& data, CodedOutputStream* stream) { - util::StatusOr<uint32> u32 = data.ToUint32(); + util::StatusOr<uint32_t> u32 = data.ToUint32(); if (u32.ok()) { WireFormatLite::WriteUInt32(field_number, u32.value(), stream); } @@ -172,7 +173,7 @@ // Writes an INT64 field, including tag, to the stream. inline util::Status WriteInt64(int field_number, const DataPiece& data, CodedOutputStream* stream) { - util::StatusOr<int64> i64 = data.ToInt64(); + util::StatusOr<int64_t> i64 = data.ToInt64(); if (i64.ok()) { WireFormatLite::WriteInt64(field_number, i64.value(), stream); } @@ -182,7 +183,7 @@ // Writes an SFIXED64 field, including tag, to the stream. inline util::Status WriteSFixed64(int field_number, const DataPiece& data, CodedOutputStream* stream) { - util::StatusOr<int64> i64 = data.ToInt64(); + util::StatusOr<int64_t> i64 = data.ToInt64(); if (i64.ok()) { WireFormatLite::WriteSFixed64(field_number, i64.value(), stream); } @@ -192,7 +193,7 @@ // Writes an SINT64 field, including tag, to the stream. inline util::Status WriteSInt64(int field_number, const DataPiece& data, CodedOutputStream* stream) { - util::StatusOr<int64> i64 = data.ToInt64(); + util::StatusOr<int64_t> i64 = data.ToInt64(); if (i64.ok()) { WireFormatLite::WriteSInt64(field_number, i64.value(), stream); } @@ -202,7 +203,7 @@ // Writes a FIXED64 field, including tag, to the stream. inline util::Status WriteFixed64(int field_number, const DataPiece& data, CodedOutputStream* stream) { - util::StatusOr<uint64> u64 = data.ToUint64(); + util::StatusOr<uint64_t> u64 = data.ToUint64(); if (u64.ok()) { WireFormatLite::WriteFixed64(field_number, u64.value(), stream); } @@ -212,7 +213,7 @@ // Writes a UINT64 field, including tag, to the stream. inline util::Status WriteUInt64(int field_number, const DataPiece& data, CodedOutputStream* stream) { - util::StatusOr<uint64> u64 = data.ToUint64(); + util::StatusOr<uint64_t> u64 = data.ToUint64(); if (u64.ok()) { WireFormatLite::WriteUInt64(field_number, u64.value(), stream); } @@ -431,11 +432,11 @@ return loc; } -bool ProtoWriter::ProtoElement::IsOneofIndexTaken(int32 index) { +bool ProtoWriter::ProtoElement::IsOneofIndexTaken(int32_t index) { return oneof_indices_[index]; } -void ProtoWriter::ProtoElement::TakeOneofIndex(int32 index) { +void ProtoWriter::ProtoElement::TakeOneofIndex(int32_t index) { oneof_indices_[index] = true; } @@ -801,8 +802,8 @@ // size_insert_.front().size: the size (integer) to be inserted. if (!size_insert_.empty() && curr_pos == size_insert_.front().pos) { // Varint32 occupies at most 10 bytes. - uint8 insert_buffer[10]; - uint8* insert_buffer_pos = CodedOutputStream::WriteVarint32ToArray( + uint8_t insert_buffer[10]; + uint8_t* insert_buffer_pos = CodedOutputStream::WriteVarint32ToArray( size_insert_.front().size, insert_buffer); output_->Append(reinterpret_cast<const char*>(insert_buffer), insert_buffer_pos - insert_buffer);
diff --git a/src/google/protobuf/util/internal/proto_writer.h b/src/google/protobuf/util/internal/proto_writer.h index a98c5d8..109c198 100644 --- a/src/google/protobuf/util/internal/proto_writer.h +++ b/src/google/protobuf/util/internal/proto_writer.h
@@ -31,6 +31,7 @@ #ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_PROTO_WRITER_H__ #define GOOGLE_PROTOBUF_UTIL_CONVERTER_PROTO_WRITER_H__ +#include <cstdint> #include <deque> #include <string> #include <vector> @@ -82,16 +83,16 @@ ProtoWriter* RenderBool(StringPiece name, bool value) override { return RenderDataPiece(name, DataPiece(value)); } - ProtoWriter* RenderInt32(StringPiece name, int32 value) override { + ProtoWriter* RenderInt32(StringPiece name, int32_t value) override { return RenderDataPiece(name, DataPiece(value)); } - ProtoWriter* RenderUint32(StringPiece name, uint32 value) override { + ProtoWriter* RenderUint32(StringPiece name, uint32_t value) override { return RenderDataPiece(name, DataPiece(value)); } - ProtoWriter* RenderInt64(StringPiece name, int64 value) override { + ProtoWriter* RenderInt64(StringPiece name, int64_t value) override { return RenderDataPiece(name, DataPiece(value)); } - ProtoWriter* RenderUint64(StringPiece name, uint64 value) override { + ProtoWriter* RenderUint64(StringPiece name, uint64_t value) override { return RenderDataPiece(name, DataPiece(value)); } ProtoWriter* RenderDouble(StringPiece name, double value) override { @@ -204,11 +205,11 @@ } // Returns true if the index is already taken by a preceding oneof input. - bool IsOneofIndexTaken(int32 index); + bool IsOneofIndexTaken(int32_t index); // Marks the oneof 'index' as taken. Future inputs to this oneof will // generate an error. - void TakeOneofIndex(int32 index); + void TakeOneofIndex(int32_t index); bool proto3() { return proto3_; }
diff --git a/src/google/protobuf/util/internal/protostream_objectsource.cc b/src/google/protobuf/util/internal/protostream_objectsource.cc index 49074fb..472aa41 100644 --- a/src/google/protobuf/util/internal/protostream_objectsource.cc +++ b/src/google/protobuf/util/internal/protostream_objectsource.cc
@@ -30,6 +30,7 @@ #include <google/protobuf/util/internal/protostream_objectsource.h> +#include <cstdint> #include <unordered_map> #include <utility> @@ -83,7 +84,7 @@ const google::protobuf::Enum& tech_enum, int number); // Utility function to format nanos. -const std::string FormatNanos(uint32 nanos, bool with_trailing_zeros); +const std::string FormatNanos(uint32_t nanos, bool with_trailing_zeros); util::StatusOr<std::string> MapKeyDefaultValueAsString( const google::protobuf::Field& field) { @@ -148,7 +149,7 @@ } const google::protobuf::Field* ProtoStreamObjectSource::FindAndVerifyField( - const google::protobuf::Type& type, uint32 tag) const { + const google::protobuf::Type& type, uint32_t tag) const { // Lookup the new field in the type by tag number. const google::protobuf::Field* field = FindFieldByNumber(type, tag >> 3); // Verify if the field corresponds to the wire type in tag. @@ -169,7 +170,8 @@ util::Status ProtoStreamObjectSource::WriteMessage( const google::protobuf::Type& type, StringPiece name, - const uint32 end_tag, bool include_start_and_end, ObjectWriter* ow) const { + const uint32_t end_tag, bool include_start_and_end, + ObjectWriter* ow) const { const TypeRenderer* type_renderer = FindTypeRenderer(type.name()); if (type_renderer != nullptr) { @@ -179,7 +181,7 @@ const google::protobuf::Field* field = nullptr; std::string field_name; // last_tag set to dummy value that is different from tag. - uint32 tag = stream_->ReadTag(), last_tag = tag + 1; + uint32_t tag = stream_->ReadTag(), last_tag = tag + 1; UnknownFieldSet unknown_fields; @@ -230,10 +232,10 @@ return util::Status(); } -util::StatusOr<uint32> ProtoStreamObjectSource::RenderList( +util::StatusOr<uint32_t> ProtoStreamObjectSource::RenderList( const google::protobuf::Field* field, StringPiece name, - uint32 list_tag, ObjectWriter* ow) const { - uint32 tag_to_return = 0; + uint32_t list_tag, ObjectWriter* ow) const { + uint32_t tag_to_return = 0; ow->StartList(name); if (IsPackable(*field) && list_tag == @@ -252,19 +254,20 @@ return tag_to_return; } -util::StatusOr<uint32> ProtoStreamObjectSource::RenderMap( +util::StatusOr<uint32_t> ProtoStreamObjectSource::RenderMap( const google::protobuf::Field* field, StringPiece name, - uint32 list_tag, ObjectWriter* ow) const { + uint32_t list_tag, ObjectWriter* ow) const { const google::protobuf::Type* field_type = typeinfo_->GetTypeByTypeUrl(field->type_url()); - uint32 tag_to_return = 0; + uint32_t tag_to_return = 0; do { // Render map entry message type. - uint32 buffer32; + uint32_t buffer32; stream_->ReadVarint32(&buffer32); // message length int old_limit = stream_->PushLimit(buffer32); std::string map_key; - for (uint32 tag = stream_->ReadTag(); tag != 0; tag = stream_->ReadTag()) { + for (uint32_t tag = stream_->ReadTag(); tag != 0; + tag = stream_->ReadTag()) { const google::protobuf::Field* field = FindAndVerifyField(*field_type, tag); if (field == nullptr) { @@ -301,7 +304,7 @@ util::Status ProtoStreamObjectSource::RenderPacked( const google::protobuf::Field* field, ObjectWriter* ow) const { - uint32 length; + uint32_t length; stream_->ReadVarint32(&length); int old_limit = stream_->PushLimit(length); while (stream_->BytesUntilLimit() > 0) { @@ -314,9 +317,9 @@ util::Status ProtoStreamObjectSource::RenderTimestamp( const ProtoStreamObjectSource* os, const google::protobuf::Type& type, StringPiece field_name, ObjectWriter* ow) { - std::pair<int64, int32> p = os->ReadSecondsAndNanos(type); - int64 seconds = p.first; - int32 nanos = p.second; + std::pair<int64_t, int32_t> p = os->ReadSecondsAndNanos(type); + int64_t seconds = p.first; + int32_t nanos = p.second; if (seconds > kTimestampMaxSeconds || seconds < kTimestampMinSeconds) { return util::Status( util::error::INTERNAL, @@ -339,9 +342,9 @@ util::Status ProtoStreamObjectSource::RenderDuration( const ProtoStreamObjectSource* os, const google::protobuf::Type& type, StringPiece field_name, ObjectWriter* ow) { - std::pair<int64, int32> p = os->ReadSecondsAndNanos(type); - int64 seconds = p.first; - int32 nanos = p.second; + std::pair<int64_t, int32_t> p = os->ReadSecondsAndNanos(type); + int64_t seconds = p.first; + int32_t nanos = p.second; if (seconds > kDurationMaxSeconds || seconds < kDurationMinSeconds) { return util::Status( util::error::INTERNAL, @@ -384,8 +387,8 @@ util::Status ProtoStreamObjectSource::RenderDouble( const ProtoStreamObjectSource* os, const google::protobuf::Type& type, StringPiece field_name, ObjectWriter* ow) { - uint32 tag = os->stream_->ReadTag(); - uint64 buffer64 = 0; // default value of Double wrapper value + uint32_t tag = os->stream_->ReadTag(); + uint64_t buffer64 = 0; // default value of Double wrapper value if (tag != 0) { os->stream_->ReadLittleEndian64(&buffer64); os->stream_->ReadTag(); @@ -397,8 +400,8 @@ util::Status ProtoStreamObjectSource::RenderFloat( const ProtoStreamObjectSource* os, const google::protobuf::Type& type, StringPiece field_name, ObjectWriter* ow) { - uint32 tag = os->stream_->ReadTag(); - uint32 buffer32 = 0; // default value of Float wrapper value + uint32_t tag = os->stream_->ReadTag(); + uint32_t buffer32 = 0; // default value of Float wrapper value if (tag != 0) { os->stream_->ReadLittleEndian32(&buffer32); os->stream_->ReadTag(); @@ -410,61 +413,61 @@ util::Status ProtoStreamObjectSource::RenderInt64( const ProtoStreamObjectSource* os, const google::protobuf::Type& type, StringPiece field_name, ObjectWriter* ow) { - uint32 tag = os->stream_->ReadTag(); - uint64 buffer64 = 0; // default value of Int64 wrapper value + uint32_t tag = os->stream_->ReadTag(); + uint64_t buffer64 = 0; // default value of Int64 wrapper value if (tag != 0) { os->stream_->ReadVarint64(&buffer64); os->stream_->ReadTag(); } - ow->RenderInt64(field_name, bit_cast<int64>(buffer64)); + ow->RenderInt64(field_name, bit_cast<int64_t>(buffer64)); return util::Status(); } util::Status ProtoStreamObjectSource::RenderUInt64( const ProtoStreamObjectSource* os, const google::protobuf::Type& type, StringPiece field_name, ObjectWriter* ow) { - uint32 tag = os->stream_->ReadTag(); - uint64 buffer64 = 0; // default value of UInt64 wrapper value + uint32_t tag = os->stream_->ReadTag(); + uint64_t buffer64 = 0; // default value of UInt64 wrapper value if (tag != 0) { os->stream_->ReadVarint64(&buffer64); os->stream_->ReadTag(); } - ow->RenderUint64(field_name, bit_cast<uint64>(buffer64)); + ow->RenderUint64(field_name, bit_cast<uint64_t>(buffer64)); return util::Status(); } util::Status ProtoStreamObjectSource::RenderInt32( const ProtoStreamObjectSource* os, const google::protobuf::Type& type, StringPiece field_name, ObjectWriter* ow) { - uint32 tag = os->stream_->ReadTag(); - uint32 buffer32 = 0; // default value of Int32 wrapper value + uint32_t tag = os->stream_->ReadTag(); + uint32_t buffer32 = 0; // default value of Int32 wrapper value if (tag != 0) { os->stream_->ReadVarint32(&buffer32); os->stream_->ReadTag(); } - ow->RenderInt32(field_name, bit_cast<int32>(buffer32)); + ow->RenderInt32(field_name, bit_cast<int32_t>(buffer32)); return util::Status(); } util::Status ProtoStreamObjectSource::RenderUInt32( const ProtoStreamObjectSource* os, const google::protobuf::Type& type, StringPiece field_name, ObjectWriter* ow) { - uint32 tag = os->stream_->ReadTag(); - uint32 buffer32 = 0; // default value of UInt32 wrapper value + uint32_t tag = os->stream_->ReadTag(); + uint32_t buffer32 = 0; // default value of UInt32 wrapper value if (tag != 0) { os->stream_->ReadVarint32(&buffer32); os->stream_->ReadTag(); } - ow->RenderUint32(field_name, bit_cast<uint32>(buffer32)); + ow->RenderUint32(field_name, bit_cast<uint32_t>(buffer32)); return util::Status(); } util::Status ProtoStreamObjectSource::RenderBool( const ProtoStreamObjectSource* os, const google::protobuf::Type& type, StringPiece field_name, ObjectWriter* ow) { - uint32 tag = os->stream_->ReadTag(); - uint64 buffer64 = 0; // results in 'false' value as default, which is the - // default value of Bool wrapper + uint32_t tag = os->stream_->ReadTag(); + uint64_t buffer64 = 0; // results in 'false' value as default, which is the + // default value of Bool wrapper if (tag != 0) { os->stream_->ReadVarint64(&buffer64); os->stream_->ReadTag(); @@ -476,8 +479,8 @@ util::Status ProtoStreamObjectSource::RenderString( const ProtoStreamObjectSource* os, const google::protobuf::Type& type, StringPiece field_name, ObjectWriter* ow) { - uint32 tag = os->stream_->ReadTag(); - uint32 buffer32; + uint32_t tag = os->stream_->ReadTag(); + uint32_t buffer32; std::string str; // default value of empty for String wrapper if (tag != 0) { os->stream_->ReadVarint32(&buffer32); // string size. @@ -491,8 +494,8 @@ util::Status ProtoStreamObjectSource::RenderBytes( const ProtoStreamObjectSource* os, const google::protobuf::Type& type, StringPiece field_name, ObjectWriter* ow) { - uint32 tag = os->stream_->ReadTag(); - uint32 buffer32; + uint32_t tag = os->stream_->ReadTag(); + uint32_t buffer32; std::string str; if (tag != 0) { os->stream_->ReadVarint32(&buffer32); @@ -507,7 +510,7 @@ const ProtoStreamObjectSource* os, const google::protobuf::Type& type, StringPiece field_name, ObjectWriter* ow) { const google::protobuf::Field* field = nullptr; - uint32 tag = os->stream_->ReadTag(); + uint32_t tag = os->stream_->ReadTag(); ow->StartObject(field_name); while (tag != 0) { field = os->FindAndVerifyField(type, tag); @@ -530,7 +533,7 @@ const ProtoStreamObjectSource* os, const google::protobuf::Type& type, StringPiece field_name, ObjectWriter* ow) { const google::protobuf::Field* field = nullptr; - for (uint32 tag = os->stream_->ReadTag(); tag != 0; + for (uint32_t tag = os->stream_->ReadTag(); tag != 0; tag = os->stream_->ReadTag()) { field = os->FindAndVerifyField(type, tag); if (field == nullptr) { @@ -546,7 +549,7 @@ util::Status ProtoStreamObjectSource::RenderStructListValue( const ProtoStreamObjectSource* os, const google::protobuf::Type& type, StringPiece field_name, ObjectWriter* ow) { - uint32 tag = os->stream_->ReadTag(); + uint32_t tag = os->stream_->ReadTag(); // Render empty list when we find empty ListValue message. if (tag == 0) { @@ -571,7 +574,7 @@ const ProtoStreamObjectSource* os, const google::protobuf::Type& type, StringPiece field_name, ObjectWriter* ow) { // An Any is of the form { string type_url = 1; bytes value = 2; } - uint32 tag; + uint32_t tag; std::string type_url; std::string value; @@ -586,12 +589,12 @@ // //google/protobuf/any.proto if (field->number() == 1) { // read type_url - uint32 type_url_size; + uint32_t type_url_size; os->stream_->ReadVarint32(&type_url_size); os->stream_->ReadString(&type_url, type_url_size); } else if (field->number() == 2) { // read value - uint32 value_size; + uint32_t value_size; os->stream_->ReadVarint32(&value_size); os->stream_->ReadString(&value, value_size); } @@ -647,9 +650,9 @@ const ProtoStreamObjectSource* os, const google::protobuf::Type& type, StringPiece field_name, ObjectWriter* ow) { std::string combined; - uint32 buffer32; - uint32 paths_field_tag = 0; - for (uint32 tag = os->stream_->ReadTag(); tag != 0; + uint32_t buffer32; + uint32_t paths_field_tag = 0; + for (uint32_t tag = os->stream_->ReadTag(); tag != 0; tag = os->stream_->ReadTag()) { if (paths_field_tag == 0) { const google::protobuf::Field* field = os->FindAndVerifyField(type, tag); @@ -737,7 +740,7 @@ // and ends up using a lot of stack space. Keep the stack usage of this // message small in order to preserve stack space and not crash. if (field->kind() == google::protobuf::Field::TYPE_MESSAGE) { - uint32 buffer32; + uint32_t buffer32; stream_->ReadVarint32(&buffer32); // message length int old_limit = stream_->PushLimit(buffer32); // Get the nested message type for this field. @@ -778,8 +781,8 @@ const google::protobuf::Field* field, StringPiece field_name, ObjectWriter* ow) const { // Temporary buffers of different types. - uint32 buffer32 = 0; - uint64 buffer64 = 0; + uint32_t buffer32 = 0; + uint64_t buffer64 = 0; std::string strbuffer; switch (field->kind()) { case google::protobuf::Field::TYPE_BOOL: { @@ -789,7 +792,7 @@ } case google::protobuf::Field::TYPE_INT32: { stream_->ReadVarint32(&buffer32); - ow->RenderInt32(field_name, bit_cast<int32>(buffer32)); + ow->RenderInt32(field_name, bit_cast<int32_t>(buffer32)); break; } case google::protobuf::Field::TYPE_INT64: { @@ -799,7 +802,7 @@ } case google::protobuf::Field::TYPE_UINT32: { stream_->ReadVarint32(&buffer32); - ow->RenderUint32(field_name, bit_cast<uint32>(buffer32)); + ow->RenderUint32(field_name, bit_cast<uint32_t>(buffer32)); break; } case google::protobuf::Field::TYPE_UINT64: { @@ -819,7 +822,7 @@ } case google::protobuf::Field::TYPE_SFIXED32: { stream_->ReadLittleEndian32(&buffer32); - ow->RenderInt32(field_name, bit_cast<int32>(buffer32)); + ow->RenderInt32(field_name, bit_cast<int32_t>(buffer32)); break; } case google::protobuf::Field::TYPE_SFIXED64: { @@ -829,7 +832,7 @@ } case google::protobuf::Field::TYPE_FIXED32: { stream_->ReadLittleEndian32(&buffer32); - ow->RenderUint32(field_name, bit_cast<uint32>(buffer32)); + ow->RenderUint32(field_name, bit_cast<uint32_t>(buffer32)); break; } case google::protobuf::Field::TYPE_FIXED64: { @@ -907,85 +910,85 @@ std::string result; switch (field.kind()) { case google::protobuf::Field::TYPE_BOOL: { - uint64 buffer64; + uint64_t buffer64; stream_->ReadVarint64(&buffer64); result = buffer64 != 0 ? "true" : "false"; break; } case google::protobuf::Field::TYPE_INT32: { - uint32 buffer32; + uint32_t buffer32; stream_->ReadVarint32(&buffer32); - result = StrCat(bit_cast<int32>(buffer32)); + result = StrCat(bit_cast<int32_t>(buffer32)); break; } case google::protobuf::Field::TYPE_INT64: { - uint64 buffer64; + uint64_t buffer64; stream_->ReadVarint64(&buffer64); - result = StrCat(bit_cast<int64>(buffer64)); + result = StrCat(bit_cast<int64_t>(buffer64)); break; } case google::protobuf::Field::TYPE_UINT32: { - uint32 buffer32; + uint32_t buffer32; stream_->ReadVarint32(&buffer32); - result = StrCat(bit_cast<uint32>(buffer32)); + result = StrCat(bit_cast<uint32_t>(buffer32)); break; } case google::protobuf::Field::TYPE_UINT64: { - uint64 buffer64; + uint64_t buffer64; stream_->ReadVarint64(&buffer64); - result = StrCat(bit_cast<uint64>(buffer64)); + result = StrCat(bit_cast<uint64_t>(buffer64)); break; } case google::protobuf::Field::TYPE_SINT32: { - uint32 buffer32; + uint32_t buffer32; stream_->ReadVarint32(&buffer32); result = StrCat(WireFormatLite::ZigZagDecode32(buffer32)); break; } case google::protobuf::Field::TYPE_SINT64: { - uint64 buffer64; + uint64_t buffer64; stream_->ReadVarint64(&buffer64); result = StrCat(WireFormatLite::ZigZagDecode64(buffer64)); break; } case google::protobuf::Field::TYPE_SFIXED32: { - uint32 buffer32; + uint32_t buffer32; stream_->ReadLittleEndian32(&buffer32); - result = StrCat(bit_cast<int32>(buffer32)); + result = StrCat(bit_cast<int32_t>(buffer32)); break; } case google::protobuf::Field::TYPE_SFIXED64: { - uint64 buffer64; + uint64_t buffer64; stream_->ReadLittleEndian64(&buffer64); - result = StrCat(bit_cast<int64>(buffer64)); + result = StrCat(bit_cast<int64_t>(buffer64)); break; } case google::protobuf::Field::TYPE_FIXED32: { - uint32 buffer32; + uint32_t buffer32; stream_->ReadLittleEndian32(&buffer32); - result = StrCat(bit_cast<uint32>(buffer32)); + result = StrCat(bit_cast<uint32_t>(buffer32)); break; } case google::protobuf::Field::TYPE_FIXED64: { - uint64 buffer64; + uint64_t buffer64; stream_->ReadLittleEndian64(&buffer64); - result = StrCat(bit_cast<uint64>(buffer64)); + result = StrCat(bit_cast<uint64_t>(buffer64)); break; } case google::protobuf::Field::TYPE_FLOAT: { - uint32 buffer32; + uint32_t buffer32; stream_->ReadLittleEndian32(&buffer32); result = SimpleFtoa(bit_cast<float>(buffer32)); break; } case google::protobuf::Field::TYPE_DOUBLE: { - uint64 buffer64; + uint64_t buffer64; stream_->ReadLittleEndian64(&buffer64); result = SimpleDtoa(bit_cast<double>(buffer64)); break; } case google::protobuf::Field::TYPE_ENUM: { - uint32 buffer32; + uint32_t buffer32; stream_->ReadVarint32(&buffer32); // Get the nested enum type for this field. // TODO(skarvaje): Avoid string manipulation. Find ways to speed this @@ -1003,13 +1006,13 @@ break; } case google::protobuf::Field::TYPE_STRING: { - uint32 buffer32; + uint32_t buffer32; stream_->ReadVarint32(&buffer32); // string size. stream_->ReadString(&result, buffer32); break; } case google::protobuf::Field::TYPE_BYTES: { - uint32 buffer32; + uint32_t buffer32; stream_->ReadVarint32(&buffer32); // bytes size. stream_->ReadString(&result, buffer32); break; @@ -1030,13 +1033,13 @@ util::converter::IsMap(field, *field_type); } -std::pair<int64, int32> ProtoStreamObjectSource::ReadSecondsAndNanos( +std::pair<int64_t, int32_t> ProtoStreamObjectSource::ReadSecondsAndNanos( const google::protobuf::Type& type) const { - uint64 seconds = 0; - uint32 nanos = 0; - uint32 tag = 0; - int64 signed_seconds = 0; - int32 signed_nanos = 0; + uint64_t seconds = 0; + uint32_t nanos = 0; + uint32_t tag = 0; + int64_t signed_seconds = 0; + int32_t signed_nanos = 0; for (tag = stream_->ReadTag(); tag != 0; tag = stream_->ReadTag()) { const google::protobuf::Field* field = FindAndVerifyField(type, tag); @@ -1049,14 +1052,14 @@ if (field->number() == 1) { // read seconds stream_->ReadVarint64(&seconds); - signed_seconds = bit_cast<int64>(seconds); + signed_seconds = bit_cast<int64_t>(seconds); } else if (field->number() == 2) { // read nanos stream_->ReadVarint32(&nanos); - signed_nanos = bit_cast<int32>(nanos); + signed_nanos = bit_cast<int32_t>(nanos); } } - return std::pair<int64, int32>(signed_seconds, signed_nanos); + return std::pair<int64_t, int32_t>(signed_seconds, signed_nanos); } util::Status ProtoStreamObjectSource::IncrementRecursionDepth( @@ -1104,7 +1107,7 @@ // TODO(skarvaje): Look into optimizing this by not doing computation on // double. -const std::string FormatNanos(uint32 nanos, bool with_trailing_zeros) { +const std::string FormatNanos(uint32_t nanos, bool with_trailing_zeros) { if (nanos == 0) { return with_trailing_zeros ? ".000" : ""; }
diff --git a/src/google/protobuf/util/internal/protostream_objectsource.h b/src/google/protobuf/util/internal/protostream_objectsource.h index 807cbf1..441e4fd 100644 --- a/src/google/protobuf/util/internal/protostream_objectsource.h +++ b/src/google/protobuf/util/internal/protostream_objectsource.h
@@ -31,6 +31,7 @@ #ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_PROTOSTREAM_OBJECTSOURCE_H__ #define GOOGLE_PROTOBUF_UTIL_CONVERTER_PROTOSTREAM_OBJECTSOURCE_H__ +#include <cstdint> #include <functional> #include <string> #include <unordered_map> @@ -73,6 +74,7 @@ // Status status = os.WriteTo(<some ObjectWriter>); class PROTOBUF_EXPORT ProtoStreamObjectSource : public ObjectSource { public: + struct RenderOptions { RenderOptions() = default; RenderOptions(const RenderOptions&) = default; @@ -141,20 +143,20 @@ // already inside of an object, and skip calling StartObject and EndObject. virtual util::Status WriteMessage(const google::protobuf::Type& type, StringPiece name, - const uint32 end_tag, + const uint32_t end_tag, bool include_start_and_end, ObjectWriter* ow) const; // Renders a repeating field (packed or unpacked). Returns the next tag after // reading all sequential repeating elements. The caller should use this tag // before reading more tags from the stream. - virtual util::StatusOr<uint32> RenderList( + virtual util::StatusOr<uint32_t> RenderList( const google::protobuf::Field* field, StringPiece name, - uint32 list_tag, ObjectWriter* ow) const; + uint32_t list_tag, ObjectWriter* ow) const; // Looks up a field and verify its consistency with wire type in tag. const google::protobuf::Field* FindAndVerifyField( - const google::protobuf::Type& type, uint32 tag) const; + const google::protobuf::Type& type, uint32_t tag) const; // Renders a field value to the ObjectWriter. virtual util::Status RenderField(const google::protobuf::Field* field, @@ -187,9 +189,9 @@ // Renders a NWP map. // Returns the next tag after reading all map entries. The caller should use // this tag before reading more tags from the stream. - util::StatusOr<uint32> RenderMap(const google::protobuf::Field* field, - StringPiece name, uint32 list_tag, - ObjectWriter* ow) const; + util::StatusOr<uint32_t> RenderMap(const google::protobuf::Field* field, + StringPiece name, uint32_t list_tag, + ObjectWriter* ow) const; // Renders a packed repeating field. A packed field is stored as: // {tag length item1 item2 item3} instead of the less efficient @@ -281,7 +283,7 @@ // Utility to read int64 and int32 values from a message type in stream_. // Used for reading google.protobuf.Timestamp and Duration messages. - std::pair<int64, int32> ReadSecondsAndNanos( + std::pair<int64_t, int32_t> ReadSecondsAndNanos( const google::protobuf::Type& type) const; // Helper function to check recursion depth and increment it. It will return
diff --git a/src/google/protobuf/util/internal/protostream_objectsource_test.cc b/src/google/protobuf/util/internal/protostream_objectsource_test.cc index 100fef9..5bd5a91 100644 --- a/src/google/protobuf/util/internal/protostream_objectsource_test.cc +++ b/src/google/protobuf/util/internal/protostream_objectsource_test.cc
@@ -30,6 +30,7 @@ #include <google/protobuf/util/internal/protostream_objectsource.h> +#include <cstdint> #include <memory> #include <sstream> @@ -120,9 +121,8 @@ render_options.use_lower_camel_for_enums = use_lower_camel_for_enums_; render_options.use_ints_for_enums = use_ints_for_enums_; render_options.preserve_proto_field_names = use_preserve_proto_field_names_; - std::unique_ptr<ProtoStreamObjectSource> os( - helper_.NewProtoSource(&in_stream, GetTypeUrl(descriptor), - render_options)); + std::unique_ptr<ProtoStreamObjectSource> os(helper_.NewProtoSource( + &in_stream, GetTypeUrl(descriptor), render_options)); os->set_max_recursion_depth(64); return os->WriteTo(&mock_); } @@ -130,13 +130,13 @@ void PrepareExpectingObjectWriterForRepeatedPrimitive() { ow_.StartObject("") ->StartList("repFix32") - ->RenderUint32("", bit_cast<uint32>(3201)) - ->RenderUint32("", bit_cast<uint32>(0)) - ->RenderUint32("", bit_cast<uint32>(3202)) + ->RenderUint32("", bit_cast<uint32_t>(3201)) + ->RenderUint32("", bit_cast<uint32_t>(0)) + ->RenderUint32("", bit_cast<uint32_t>(3202)) ->EndList() ->StartList("repU32") - ->RenderUint32("", bit_cast<uint32>(3203)) - ->RenderUint32("", bit_cast<uint32>(0)) + ->RenderUint32("", bit_cast<uint32_t>(3203)) + ->RenderUint32("", bit_cast<uint32_t>(0)) ->EndList() ->StartList("repI32") ->RenderInt32("", 0) @@ -153,13 +153,13 @@ ->RenderInt32("", 3208) ->EndList() ->StartList("repFix64") - ->RenderUint64("", bit_cast<uint64>(int64{6401})) - ->RenderUint64("", bit_cast<uint64>(int64{0})) + ->RenderUint64("", bit_cast<uint64_t>(int64_t{6401})) + ->RenderUint64("", bit_cast<uint64_t>(int64_t{0})) ->EndList() ->StartList("repU64") - ->RenderUint64("", bit_cast<uint64>(int64{0})) - ->RenderUint64("", bit_cast<uint64>(int64{6402})) - ->RenderUint64("", bit_cast<uint64>(int64{6403})) + ->RenderUint64("", bit_cast<uint64_t>(int64_t{0})) + ->RenderUint64("", bit_cast<uint64_t>(int64_t{6402})) + ->RenderUint64("", bit_cast<uint64_t>(int64_t{6403})) ->EndList() ->StartList("repI64") ->RenderInt64("", 6404L) @@ -321,13 +321,13 @@ primitive.set_bool_(true); ow_.StartObject("") - ->RenderUint32("fix32", bit_cast<uint32>(3201)) - ->RenderUint32("u32", bit_cast<uint32>(3202)) + ->RenderUint32("fix32", bit_cast<uint32_t>(3201)) + ->RenderUint32("u32", bit_cast<uint32_t>(3202)) ->RenderInt32("i32", 3203) ->RenderInt32("sf32", 3204) ->RenderInt32("s32", 3205) - ->RenderUint64("fix64", bit_cast<uint64>(int64{6401})) - ->RenderUint64("u64", bit_cast<uint64>(int64{6402})) + ->RenderUint64("fix64", bit_cast<uint64_t>(int64_t{6401})) + ->RenderUint64("u64", bit_cast<uint64_t>(int64_t{6402})) ->RenderInt64("i64", 6403L) ->RenderInt64("sf64", 6404L) ->RenderInt64("s64", 6405L) @@ -425,10 +425,10 @@ ->RenderBool("", false) ->EndList() ->StartList("name") - ->RenderUint64("", static_cast<uint64>('j')) - ->RenderUint64("", static_cast<uint64>('o')) - ->RenderUint64("", static_cast<uint64>('h')) - ->RenderUint64("", static_cast<uint64>('n')) + ->RenderUint64("", static_cast<uint64_t>('j')) + ->RenderUint64("", static_cast<uint64_t>('o')) + ->RenderUint64("", static_cast<uint64_t>('h')) + ->RenderUint64("", static_cast<uint64_t>('n')) ->EndList() ->RenderString("pseudonym", "phil") ->RenderString("pseudonym", "bob")
diff --git a/src/google/protobuf/util/internal/protostream_objectwriter.cc b/src/google/protobuf/util/internal/protostream_objectwriter.cc index bccea1f..56ca3ca 100644 --- a/src/google/protobuf/util/internal/protostream_objectwriter.cc +++ b/src/google/protobuf/util/internal/protostream_objectwriter.cc
@@ -30,6 +30,7 @@ #include <google/protobuf/util/internal/protostream_objectwriter.h> +#include <cstdint> #include <functional> #include <stack> #include <unordered_map> @@ -129,7 +130,7 @@ Status GetNanosFromStringPiece(StringPiece s_nanos, const char* parse_failure_message, const char* exceeded_limit_message, - int32* nanos) { + int32_t* nanos) { *nanos = 0; // Count the number of leading 0s and consume them. @@ -137,7 +138,7 @@ while (s_nanos.Consume("0")) { num_leading_zeros++; } - int32 i_nanos = 0; + int32_t i_nanos = 0; // 's_nanos' contains fractional seconds -- i.e. 'nanos' is equal to // "0." + s_nanos.ToString() seconds. An int32 is used for the // conversion to 'nanos', rather than a double, so that there is no @@ -156,11 +157,11 @@ if (i_nanos > 0) { // 'scale' is the number of digits to the right of the decimal // point in "0." + s_nanos.ToString() - int32 scale = num_leading_zeros + s_nanos.size(); + int32_t scale = num_leading_zeros + s_nanos.size(); // 'conversion' converts i_nanos into nanoseconds. // conversion = kNanosPerSecond / static_cast<int32>(std::pow(10, scale)) // For efficiency, we precompute the conversion factor. - int32 conversion = 0; + int32_t conversion = 0; switch (scale) { case 1: conversion = 100000000; @@ -921,7 +922,7 @@ switch (data.type()) { case DataPiece::TYPE_INT32: { if (ow->options_.struct_integers_as_strings) { - util::StatusOr<int32> int_value = data.ToInt32(); + util::StatusOr<int32_t> int_value = data.ToInt32(); if (int_value.ok()) { ow->ProtoWriter::RenderDataPiece( "string_value", @@ -934,7 +935,7 @@ } case DataPiece::TYPE_UINT32: { if (ow->options_.struct_integers_as_strings) { - util::StatusOr<uint32> int_value = data.ToUint32(); + util::StatusOr<uint32_t> int_value = data.ToUint32(); if (int_value.ok()) { ow->ProtoWriter::RenderDataPiece( "string_value", @@ -949,7 +950,7 @@ // If the option to treat integers as strings is set, then render them as // strings. Otherwise, fallback to rendering them as double. if (ow->options_.struct_integers_as_strings) { - util::StatusOr<int64> int_value = data.ToInt64(); + util::StatusOr<int64_t> int_value = data.ToInt64(); if (int_value.ok()) { ow->ProtoWriter::RenderDataPiece( "string_value", DataPiece(StrCat(int_value.value()), true)); @@ -963,7 +964,7 @@ // If the option to treat integers as strings is set, then render them as // strings. Otherwise, fallback to rendering them as double. if (ow->options_.struct_integers_as_strings) { - util::StatusOr<uint64> int_value = data.ToUint64(); + util::StatusOr<uint64_t> int_value = data.ToUint64(); if (int_value.ok()) { ow->ProtoWriter::RenderDataPiece( "string_value", DataPiece(StrCat(int_value.value()), true)); @@ -1092,13 +1093,13 @@ StringPiece s_secs, s_nanos; SplitSecondsAndNanos(value, &s_secs, &s_nanos); - uint64 unsigned_seconds; + uint64_t unsigned_seconds; if (!safe_strtou64(s_secs, &unsigned_seconds)) { return Status(util::error::INVALID_ARGUMENT, "Invalid duration format, failed to parse seconds"); } - int32 nanos = 0; + int32_t nanos = 0; Status nanos_status = GetNanosFromStringPiece( s_nanos, "Invalid duration format, failed to parse nano seconds", "Duration value exceeds limits", &nanos); @@ -1107,7 +1108,7 @@ } nanos = sign * nanos; - int64 seconds = sign * unsigned_seconds; + int64_t seconds = sign * unsigned_seconds; if (seconds > kDurationMaxSeconds || seconds < kDurationMinSeconds || nanos <= -kNanosPerSecond || nanos >= kNanosPerSecond) { return Status(util::error::INVALID_ARGUMENT,
diff --git a/src/google/protobuf/util/internal/utility.cc b/src/google/protobuf/util/internal/utility.cc index 1816b68..17ff6dd 100644 --- a/src/google/protobuf/util/internal/utility.cc +++ b/src/google/protobuf/util/internal/utility.cc
@@ -32,6 +32,7 @@ #include <algorithm> #include <cmath> +#include <cstdint> #include <limits> #include <google/protobuf/stubs/callback.h> @@ -63,9 +64,9 @@ return GetBoolFromAny(opt->value()); } -int64 GetInt64OptionOrDefault( +int64_t GetInt64OptionOrDefault( const RepeatedPtrField<google::protobuf::Option>& options, - StringPiece option_name, int64 default_value) { + StringPiece option_name, int64_t default_value) { const google::protobuf::Option* opt = FindOptionOrNull(options, option_name); if (opt == nullptr) { return default_value; @@ -106,7 +107,7 @@ return b.value(); } -int64 GetInt64FromAny(const google::protobuf::Any& any) { +int64_t GetInt64FromAny(const google::protobuf::Any& any) { google::protobuf::Int64Value i; ParseFromAny(any.value(), &i); return i.value(); @@ -179,7 +180,7 @@ } const google::protobuf::Field* FindFieldInTypeByNumberOrNull( - const google::protobuf::Type* type, int32 number) { + const google::protobuf::Type* type, int32_t number) { if (type != nullptr) { for (int i = 0; i < type->fields_size(); ++i) { const google::protobuf::Field& field = type->fields(i); @@ -205,7 +206,7 @@ } const google::protobuf::EnumValue* FindEnumValueByNumberOrNull( - const google::protobuf::Enum* enum_type, int32 value) { + const google::protobuf::Enum* enum_type, int32_t value) { if (enum_type != nullptr) { for (int i = 0; i < enum_type->enumvalue_size(); ++i) { const google::protobuf::EnumValue& enum_value = enum_type->enumvalue(i);
diff --git a/src/google/protobuf/util/internal/utility.h b/src/google/protobuf/util/internal/utility.h index 965579a..b689e84 100644 --- a/src/google/protobuf/util/internal/utility.h +++ b/src/google/protobuf/util/internal/utility.h
@@ -31,6 +31,7 @@ #ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_UTILITY_H__ #define GOOGLE_PROTOBUF_UTIL_CONVERTER_UTILITY_H__ +#include <cstdint> #include <memory> #include <string> #include <utility> @@ -53,7 +54,7 @@ namespace converter { // Size of "type.googleapis.com" -static const int64 kTypeUrlSize = 19; +static const int64_t kTypeUrlSize = 19; // Finds the tech option identified by option_name. Parses the boolean value and // returns it. @@ -64,9 +65,9 @@ // Returns int64 option value. If the option isn't found, returns the // default_value. -PROTOBUF_EXPORT int64 GetInt64OptionOrDefault( +PROTOBUF_EXPORT int64_t GetInt64OptionOrDefault( const RepeatedPtrField<google::protobuf::Option>& options, - StringPiece option_name, int64 default_value); + StringPiece option_name, int64_t default_value); // Returns double option value. If the option isn't found, returns the // default_value. @@ -87,7 +88,7 @@ PROTOBUF_EXPORT bool GetBoolFromAny(const google::protobuf::Any& any); // Returns int64 value contained in Any type. -PROTOBUF_EXPORT int64 GetInt64FromAny(const google::protobuf::Any& any); +PROTOBUF_EXPORT int64_t GetInt64FromAny(const google::protobuf::Any& any); // Returns double value contained in Any type. PROTOBUF_EXPORT double GetDoubleFromAny(const google::protobuf::Any& any); @@ -127,7 +128,7 @@ // Similar to FindFieldInTypeOrNull, but this looks up fields by number. const google::protobuf::Field* FindFieldInTypeByNumberOrNull( - const google::protobuf::Type* type, int32 number); + const google::protobuf::Type* type, int32_t number); // Finds and returns the EnumValue identified by enum_name in the passed tech // Enum object. Returns nullptr if none found. @@ -137,7 +138,7 @@ // Finds and returns the EnumValue identified by value in the passed tech // Enum object. Returns nullptr if none found. const google::protobuf::EnumValue* FindEnumValueByNumberOrNull( - const google::protobuf::Enum* enum_type, int32 value); + const google::protobuf::Enum* enum_type, int32_t value); // Finds and returns the EnumValue identified by enum_name without underscore in // the passed tech Enum object. Returns nullptr if none found.
diff --git a/src/google/protobuf/util/json_util.h b/src/google/protobuf/util/json_util.h index 9954587..73f2783 100644 --- a/src/google/protobuf/util/json_util.h +++ b/src/google/protobuf/util/json_util.h
@@ -36,6 +36,7 @@ #include <google/protobuf/message.h> #include <google/protobuf/util/type_resolver.h> #include <google/protobuf/stubs/bytestream.h> +#include <google/protobuf/stubs/status.h> #include <google/protobuf/stubs/strutil.h> #include <google/protobuf/port_def.inc> @@ -93,11 +94,11 @@ // simple wrapper of BinaryToJsonString(). It will use the DescriptorPool of the // passed-in message to resolve Any types. PROTOBUF_EXPORT util::Status MessageToJsonString(const Message& message, - std::string* output, - const JsonOptions& options); + std::string* output, + const JsonOptions& options); inline util::Status MessageToJsonString(const Message& message, - std::string* output) { + std::string* output) { return MessageToJsonString(message, output, JsonOptions()); } @@ -108,7 +109,7 @@ StringPiece input, Message* message, const JsonParseOptions& options); inline util::Status JsonStringToMessage(StringPiece input, - Message* message) { + Message* message) { return JsonStringToMessage(input, message, JsonParseOptions()); } @@ -123,10 +124,10 @@ io::ZeroCopyInputStream* binary_input, io::ZeroCopyOutputStream* json_output, const JsonPrintOptions& options); -inline util::Status BinaryToJsonStream( - TypeResolver* resolver, const std::string& type_url, - io::ZeroCopyInputStream* binary_input, - io::ZeroCopyOutputStream* json_output) { +inline util::Status BinaryToJsonStream(TypeResolver* resolver, + const std::string& type_url, + io::ZeroCopyInputStream* binary_input, + io::ZeroCopyOutputStream* json_output) { return BinaryToJsonStream(resolver, type_url, binary_input, json_output, JsonPrintOptions()); } @@ -137,9 +138,9 @@ const JsonPrintOptions& options); inline util::Status BinaryToJsonString(TypeResolver* resolver, - const std::string& type_url, - const std::string& binary_input, - std::string* json_output) { + const std::string& type_url, + const std::string& binary_input, + std::string* json_output) { return BinaryToJsonString(resolver, type_url, binary_input, json_output, JsonPrintOptions()); } @@ -168,9 +169,9 @@ const JsonParseOptions& options); inline util::Status JsonToBinaryString(TypeResolver* resolver, - const std::string& type_url, - StringPiece json_input, - std::string* binary_output) { + const std::string& type_url, + StringPiece json_input, + std::string* binary_output) { return JsonToBinaryString(resolver, type_url, json_input, binary_output, JsonParseOptions()); }
diff --git a/src/google/protobuf/util/message_differencer.cc b/src/google/protobuf/util/message_differencer.cc index c3c24da..47e3031 100644 --- a/src/google/protobuf/util/message_differencer.cc +++ b/src/google/protobuf/util/message_differencer.cc
@@ -325,14 +325,7 @@ const MapKeyComparator* key_comparator = GetMapKeyComparator(field); GOOGLE_CHECK(key_comparator == NULL) << "Cannot treat this repeated field as both MAP and " << new_comparison - << " for" - << " comparison. Field name is: " << field->full_name(); - GOOGLE_CHECK(repeated_field_comparisons_.find(field) == - repeated_field_comparisons_.end() || - repeated_field_comparisons_[field] == new_comparison) - << "Cannot treat the same field as both " - << repeated_field_comparisons_[field] << " and " << new_comparison - << ". Field name is: " << field->full_name(); + << " for comparison. Field name is: " << field->full_name(); } void MessageDifferencer::TreatAsSet(const FieldDescriptor* field) {
diff --git a/src/google/protobuf/util/message_differencer.h b/src/google/protobuf/util/message_differencer.h index 61d9f9b..4f2983e 100644 --- a/src/google/protobuf/util/message_differencer.h +++ b/src/google/protobuf/util/message_differencer.h
@@ -431,7 +431,7 @@ // + n^3) in which n^3 is the time complexity of the maximum matching // algorithm. // - // REQUIRES: field->is_repeated() and field not registered with TreatAsList + // REQUIRES: field->is_repeated() and field not registered with TreatAsMap* void TreatAsSet(const FieldDescriptor* field); void TreatAsSmartSet(const FieldDescriptor* field); @@ -439,7 +439,7 @@ // diffing purposes, so different orderings of the same elements will NOT be // considered equal. // - // REQUIRED: field->is_repeated() and field not registered with TreatAsSet + // REQUIRES: field->is_repeated() and field not registered with TreatAsMap* void TreatAsList(const FieldDescriptor* field); // Note that the complexity is similar to treating as SET. void TreatAsSmartList(const FieldDescriptor* field);
diff --git a/src/google/protobuf/util/message_differencer_unittest.cc b/src/google/protobuf/util/message_differencer_unittest.cc index 5a333b3..ada2655 100644 --- a/src/google/protobuf/util/message_differencer_unittest.cc +++ b/src/google/protobuf/util/message_differencer_unittest.cc
@@ -1060,6 +1060,42 @@ EXPECT_TRUE(differencer.CompareWithFields(msg1, msg2, fields1, fields2)); } +TEST(MessageDifferencerTest, RepeatedFieldTreatmentChangeListToSet) { + protobuf_unittest::TestDiffMessage msg1; + protobuf_unittest::TestDiffMessage msg2; + + msg1.add_rv(1); + msg1.add_rv(2); + msg2.add_rv(2); + msg2.add_rv(1); + + util::MessageDifferencer differencer; + differencer.TreatAsList( + protobuf_unittest::TestDiffMessage::descriptor()->FindFieldByName("rv")); + differencer.TreatAsSet( + protobuf_unittest::TestDiffMessage::descriptor()->FindFieldByName("rv")); + + EXPECT_TRUE(differencer.Compare(msg1, msg2)); +} + +TEST(MessageDifferencerTest, RepeatedFieldTreatmentChangeSetToList) { + protobuf_unittest::TestDiffMessage msg1; + protobuf_unittest::TestDiffMessage msg2; + + msg1.add_rv(1); + msg1.add_rv(2); + msg2.add_rv(2); + msg2.add_rv(1); + + util::MessageDifferencer differencer; + differencer.TreatAsSet( + protobuf_unittest::TestDiffMessage::descriptor()->FindFieldByName("rv")); + differencer.TreatAsList( + protobuf_unittest::TestDiffMessage::descriptor()->FindFieldByName("rv")); + + EXPECT_FALSE(differencer.Compare(msg1, msg2)); +} + TEST(MessageDifferencerTest, RepeatedFieldSmartListTest) { // Create the testing protos protobuf_unittest::TestDiffMessage msg1;
diff --git a/src/google/protobuf/util/type_resolver.h b/src/google/protobuf/util/type_resolver.h index 698441b..2bda5c8 100644 --- a/src/google/protobuf/util/type_resolver.h +++ b/src/google/protobuf/util/type_resolver.h
@@ -38,6 +38,7 @@ #include <google/protobuf/stubs/common.h> #include <google/protobuf/type.pb.h> #include <google/protobuf/stubs/status.h> +#include <google/protobuf/stubs/status.h> #include <google/protobuf/port_def.inc> @@ -60,7 +61,7 @@ // Resolves a type url for an enum type. virtual util::Status ResolveEnumType(const std::string& type_url, - google::protobuf::Enum* enum_type) = 0; + google::protobuf::Enum* enum_type) = 0; private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(TypeResolver);
diff --git a/src/google/protobuf/util/type_resolver_util.cc b/src/google/protobuf/util/type_resolver_util.cc index cf2f318..addb334 100644 --- a/src/google/protobuf/util/type_resolver_util.cc +++ b/src/google/protobuf/util/type_resolver_util.cc
@@ -64,7 +64,6 @@ using google::protobuf::UInt32Value; using google::protobuf::UInt64Value; -using util::Status; using util::error::INVALID_ARGUMENT; using util::error::NOT_FOUND;
diff --git a/src/google/protobuf/wrappers.pb.cc b/src/google/protobuf/wrappers.pb.cc index eb691be..3ca8581 100644 --- a/src/google/protobuf/wrappers.pb.cc +++ b/src/google/protobuf/wrappers.pb.cc
@@ -231,10 +231,8 @@ schemas, file_default_instances, TableStruct_google_2fprotobuf_2fwrappers_2eproto::offsets, file_level_metadata_google_2fprotobuf_2fwrappers_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fwrappers_2eproto, file_level_service_descriptors_google_2fprotobuf_2fwrappers_2eproto, }; -PROTOBUF_ATTRIBUTE_WEAK ::PROTOBUF_NAMESPACE_ID::Metadata -descriptor_table_google_2fprotobuf_2fwrappers_2eproto_metadata_getter(int index) { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fwrappers_2eproto); - return descriptor_table_google_2fprotobuf_2fwrappers_2eproto.file_level_metadata[index]; +PROTOBUF_ATTRIBUTE_WEAK const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable* descriptor_table_google_2fprotobuf_2fwrappers_2eproto_getter() { + return &descriptor_table_google_2fprotobuf_2fwrappers_2eproto; } // Force running AddDescriptors() at dynamic initialization time. @@ -424,10 +422,11 @@ } ::PROTOBUF_NAMESPACE_ID::Metadata DoubleValue::GetMetadata() const { - return GetMetadataStatic(); + return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + &descriptor_table_google_2fprotobuf_2fwrappers_2eproto_getter, &descriptor_table_google_2fprotobuf_2fwrappers_2eproto_once, + file_level_metadata_google_2fprotobuf_2fwrappers_2eproto[0]); } - // =================================================================== class FloatValue::_Internal { @@ -611,10 +610,11 @@ } ::PROTOBUF_NAMESPACE_ID::Metadata FloatValue::GetMetadata() const { - return GetMetadataStatic(); + return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + &descriptor_table_google_2fprotobuf_2fwrappers_2eproto_getter, &descriptor_table_google_2fprotobuf_2fwrappers_2eproto_once, + file_level_metadata_google_2fprotobuf_2fwrappers_2eproto[1]); } - // =================================================================== class Int64Value::_Internal { @@ -800,10 +800,11 @@ } ::PROTOBUF_NAMESPACE_ID::Metadata Int64Value::GetMetadata() const { - return GetMetadataStatic(); + return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + &descriptor_table_google_2fprotobuf_2fwrappers_2eproto_getter, &descriptor_table_google_2fprotobuf_2fwrappers_2eproto_once, + file_level_metadata_google_2fprotobuf_2fwrappers_2eproto[2]); } - // =================================================================== class UInt64Value::_Internal { @@ -989,10 +990,11 @@ } ::PROTOBUF_NAMESPACE_ID::Metadata UInt64Value::GetMetadata() const { - return GetMetadataStatic(); + return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + &descriptor_table_google_2fprotobuf_2fwrappers_2eproto_getter, &descriptor_table_google_2fprotobuf_2fwrappers_2eproto_once, + file_level_metadata_google_2fprotobuf_2fwrappers_2eproto[3]); } - // =================================================================== class Int32Value::_Internal { @@ -1178,10 +1180,11 @@ } ::PROTOBUF_NAMESPACE_ID::Metadata Int32Value::GetMetadata() const { - return GetMetadataStatic(); + return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + &descriptor_table_google_2fprotobuf_2fwrappers_2eproto_getter, &descriptor_table_google_2fprotobuf_2fwrappers_2eproto_once, + file_level_metadata_google_2fprotobuf_2fwrappers_2eproto[4]); } - // =================================================================== class UInt32Value::_Internal { @@ -1367,10 +1370,11 @@ } ::PROTOBUF_NAMESPACE_ID::Metadata UInt32Value::GetMetadata() const { - return GetMetadataStatic(); + return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + &descriptor_table_google_2fprotobuf_2fwrappers_2eproto_getter, &descriptor_table_google_2fprotobuf_2fwrappers_2eproto_once, + file_level_metadata_google_2fprotobuf_2fwrappers_2eproto[5]); } - // =================================================================== class BoolValue::_Internal { @@ -1554,10 +1558,11 @@ } ::PROTOBUF_NAMESPACE_ID::Metadata BoolValue::GetMetadata() const { - return GetMetadataStatic(); + return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + &descriptor_table_google_2fprotobuf_2fwrappers_2eproto_getter, &descriptor_table_google_2fprotobuf_2fwrappers_2eproto_once, + file_level_metadata_google_2fprotobuf_2fwrappers_2eproto[6]); } - // =================================================================== class StringValue::_Internal { @@ -1754,10 +1759,11 @@ } ::PROTOBUF_NAMESPACE_ID::Metadata StringValue::GetMetadata() const { - return GetMetadataStatic(); + return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + &descriptor_table_google_2fprotobuf_2fwrappers_2eproto_getter, &descriptor_table_google_2fprotobuf_2fwrappers_2eproto_once, + file_level_metadata_google_2fprotobuf_2fwrappers_2eproto[7]); } - // =================================================================== class BytesValue::_Internal { @@ -1949,10 +1955,11 @@ } ::PROTOBUF_NAMESPACE_ID::Metadata BytesValue::GetMetadata() const { - return GetMetadataStatic(); + return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + &descriptor_table_google_2fprotobuf_2fwrappers_2eproto_getter, &descriptor_table_google_2fprotobuf_2fwrappers_2eproto_once, + file_level_metadata_google_2fprotobuf_2fwrappers_2eproto[8]); } - // @@protoc_insertion_point(namespace_scope) PROTOBUF_NAMESPACE_CLOSE PROTOBUF_NAMESPACE_OPEN
diff --git a/src/google/protobuf/wrappers.pb.h b/src/google/protobuf/wrappers.pb.h index 1c91f7d..65978a8 100644 --- a/src/google/protobuf/wrappers.pb.h +++ b/src/google/protobuf/wrappers.pb.h
@@ -53,7 +53,6 @@ static const ::PROTOBUF_NAMESPACE_ID::uint32 offsets[]; }; extern PROTOBUF_EXPORT const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fwrappers_2eproto; -PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Metadata descriptor_table_google_2fprotobuf_2fwrappers_2eproto_metadata_getter(int index); PROTOBUF_NAMESPACE_OPEN class BoolValue; struct BoolValueDefaultTypeInternal; @@ -128,10 +127,10 @@ return GetDescriptor(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; + return default_instance().GetMetadata().descriptor; } static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; + return default_instance().GetMetadata().reflection; } static const DoubleValue& default_instance() { return *internal_default_instance(); @@ -199,12 +198,6 @@ public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - return ::descriptor_table_google_2fprotobuf_2fwrappers_2eproto_metadata_getter(kIndexInFileMessages); - } - - public: // nested types ---------------------------------------------------- @@ -265,10 +258,10 @@ return GetDescriptor(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; + return default_instance().GetMetadata().descriptor; } static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; + return default_instance().GetMetadata().reflection; } static const FloatValue& default_instance() { return *internal_default_instance(); @@ -336,12 +329,6 @@ public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - return ::descriptor_table_google_2fprotobuf_2fwrappers_2eproto_metadata_getter(kIndexInFileMessages); - } - - public: // nested types ---------------------------------------------------- @@ -402,10 +389,10 @@ return GetDescriptor(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; + return default_instance().GetMetadata().descriptor; } static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; + return default_instance().GetMetadata().reflection; } static const Int64Value& default_instance() { return *internal_default_instance(); @@ -473,12 +460,6 @@ public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - return ::descriptor_table_google_2fprotobuf_2fwrappers_2eproto_metadata_getter(kIndexInFileMessages); - } - - public: // nested types ---------------------------------------------------- @@ -539,10 +520,10 @@ return GetDescriptor(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; + return default_instance().GetMetadata().descriptor; } static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; + return default_instance().GetMetadata().reflection; } static const UInt64Value& default_instance() { return *internal_default_instance(); @@ -610,12 +591,6 @@ public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - return ::descriptor_table_google_2fprotobuf_2fwrappers_2eproto_metadata_getter(kIndexInFileMessages); - } - - public: // nested types ---------------------------------------------------- @@ -676,10 +651,10 @@ return GetDescriptor(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; + return default_instance().GetMetadata().descriptor; } static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; + return default_instance().GetMetadata().reflection; } static const Int32Value& default_instance() { return *internal_default_instance(); @@ -747,12 +722,6 @@ public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - return ::descriptor_table_google_2fprotobuf_2fwrappers_2eproto_metadata_getter(kIndexInFileMessages); - } - - public: // nested types ---------------------------------------------------- @@ -813,10 +782,10 @@ return GetDescriptor(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; + return default_instance().GetMetadata().descriptor; } static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; + return default_instance().GetMetadata().reflection; } static const UInt32Value& default_instance() { return *internal_default_instance(); @@ -884,12 +853,6 @@ public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - return ::descriptor_table_google_2fprotobuf_2fwrappers_2eproto_metadata_getter(kIndexInFileMessages); - } - - public: // nested types ---------------------------------------------------- @@ -950,10 +913,10 @@ return GetDescriptor(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; + return default_instance().GetMetadata().descriptor; } static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; + return default_instance().GetMetadata().reflection; } static const BoolValue& default_instance() { return *internal_default_instance(); @@ -1021,12 +984,6 @@ public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - return ::descriptor_table_google_2fprotobuf_2fwrappers_2eproto_metadata_getter(kIndexInFileMessages); - } - - public: // nested types ---------------------------------------------------- @@ -1087,10 +1044,10 @@ return GetDescriptor(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; + return default_instance().GetMetadata().descriptor; } static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; + return default_instance().GetMetadata().reflection; } static const StringValue& default_instance() { return *internal_default_instance(); @@ -1158,12 +1115,6 @@ public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - return ::descriptor_table_google_2fprotobuf_2fwrappers_2eproto_metadata_getter(kIndexInFileMessages); - } - - public: // nested types ---------------------------------------------------- @@ -1175,10 +1126,8 @@ // string value = 1; void clear_value(); const std::string& value() const; - void set_value(const std::string& value); - void set_value(std::string&& value); - void set_value(const char* value); - void set_value(const char* value, size_t size); + template <typename ArgT0 = const std::string&, typename... ArgT> + void set_value(ArgT0&& arg0, ArgT... args); std::string* mutable_value(); std::string* release_value(); void set_allocated_value(std::string* value); @@ -1231,10 +1180,10 @@ return GetDescriptor(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; + return default_instance().GetMetadata().descriptor; } static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; + return default_instance().GetMetadata().reflection; } static const BytesValue& default_instance() { return *internal_default_instance(); @@ -1302,12 +1251,6 @@ public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - return ::descriptor_table_google_2fprotobuf_2fwrappers_2eproto_metadata_getter(kIndexInFileMessages); - } - - public: // nested types ---------------------------------------------------- @@ -1319,10 +1262,8 @@ // bytes value = 1; void clear_value(); const std::string& value() const; - void set_value(const std::string& value); - void set_value(std::string&& value); - void set_value(const char* value); - void set_value(const void* value, size_t size); + template <typename ArgT0 = const std::string&, typename... ArgT> + void set_value(ArgT0&& arg0, ArgT... args); std::string* mutable_value(); std::string* release_value(); void set_allocated_value(std::string* value); @@ -1530,8 +1471,11 @@ // @@protoc_insertion_point(field_get:google.protobuf.StringValue.value) return _internal_value(); } -inline void StringValue::set_value(const std::string& value) { - _internal_set_value(value); +template <typename ArgT0, typename... ArgT> +PROTOBUF_ALWAYS_INLINE +inline void StringValue::set_value(ArgT0&& arg0, ArgT... args) { + + value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); // @@protoc_insertion_point(field_set:google.protobuf.StringValue.value) } inline std::string* StringValue::mutable_value() { @@ -1545,25 +1489,6 @@ value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); } -inline void StringValue::set_value(std::string&& value) { - - value_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.StringValue.value) -} -inline void StringValue::set_value(const char* value) { - GOOGLE_DCHECK(value != nullptr); - - value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:google.protobuf.StringValue.value) -} -inline void StringValue::set_value(const char* value, - size_t size) { - - value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast<const char*>(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.StringValue.value) -} inline std::string* StringValue::_internal_mutable_value() { return value_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); @@ -1595,8 +1520,11 @@ // @@protoc_insertion_point(field_get:google.protobuf.BytesValue.value) return _internal_value(); } -inline void BytesValue::set_value(const std::string& value) { - _internal_set_value(value); +template <typename ArgT0, typename... ArgT> +PROTOBUF_ALWAYS_INLINE +inline void BytesValue::set_value(ArgT0&& arg0, ArgT... args) { + + value_.SetBytes(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); // @@protoc_insertion_point(field_set:google.protobuf.BytesValue.value) } inline std::string* BytesValue::mutable_value() { @@ -1610,25 +1538,6 @@ value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); } -inline void BytesValue::set_value(std::string&& value) { - - value_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:google.protobuf.BytesValue.value) -} -inline void BytesValue::set_value(const char* value) { - GOOGLE_DCHECK(value != nullptr); - - value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:google.protobuf.BytesValue.value) -} -inline void BytesValue::set_value(const void* value, - size_t size) { - - value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast<const char*>(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.BytesValue.value) -} inline std::string* BytesValue::_internal_mutable_value() { return value_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena());