Sync from Piper @320514613 PROTOBUF_SYNC_PIPER
diff --git a/cmake/README.md b/cmake/README.md index a780722..89d00c1 100644 --- a/cmake/README.md +++ b/cmake/README.md
@@ -66,7 +66,7 @@ step if you are using a release .tar.gz or .zip package): ```console -C:\Path\to\protobuf> git submodule update --init --recursive +C:\Path\to> git submodule update --init --recursive ``` Now go to *cmake* folder in protobuf sources:
diff --git a/conformance/binary_json_conformance_suite.cc b/conformance/binary_json_conformance_suite.cc index f62c705..4a0d8e8 100644 --- a/conformance/binary_json_conformance_suite.cc +++ b/conformance/binary_json_conformance_suite.cc
@@ -3051,6 +3051,29 @@ } ] )"); + RunValidJsonTestWithValidator( + "NullValueInOtherOneofOldFormat", RECOMMENDED, + R"({"oneofNullValue": "NULL_VALUE"})", + [](const Json::Value& value) { + return (value.isMember("oneofNullValue") && + value["oneofNullValue"].isNull()); + }, + true); + RunValidJsonTestWithValidator( + "NullValueInOtherOneofNewFormat", RECOMMENDED, + R"({"oneofNullValue": null})", + [](const Json::Value& value) { + return (value.isMember("oneofNullValue") && + value["oneofNullValue"].isNull()); + }, + true); + RunValidJsonTestWithValidator( + "NullValueInNormalMessage", RECOMMENDED, + R"({"optionalNullValue": null})", + [](const Json::Value& value) { + return value.empty(); + }, + true); } void BinaryAndJsonConformanceSuite::RunJsonTestsForAny() {
diff --git a/csharp/src/Google.Protobuf.Test.TestProtos/TestMessagesProto3.cs b/csharp/src/Google.Protobuf.Test.TestProtos/TestMessagesProto3.cs index 1d49f4c..6f915cb 100644 --- a/csharp/src/Google.Protobuf.Test.TestProtos/TestMessagesProto3.cs +++ b/csharp/src/Google.Protobuf.Test.TestProtos/TestMessagesProto3.cs
@@ -29,7 +29,7 @@ "dWYvYW55LnByb3RvGh5nb29nbGUvcHJvdG9idWYvZHVyYXRpb24ucHJvdG8a", "IGdvb2dsZS9wcm90b2J1Zi9maWVsZF9tYXNrLnByb3RvGhxnb29nbGUvcHJv", "dG9idWYvc3RydWN0LnByb3RvGh9nb29nbGUvcHJvdG9idWYvdGltZXN0YW1w", - "LnByb3RvGh5nb29nbGUvcHJvdG9idWYvd3JhcHBlcnMucHJvdG8iv0QKElRl", + "LnByb3RvGh5nb29nbGUvcHJvdG9idWYvd3JhcHBlcnMucHJvdG8isUUKElRl", "c3RBbGxUeXBlc1Byb3RvMxIWCg5vcHRpb25hbF9pbnQzMhgBIAEoBRIWCg5v", "cHRpb25hbF9pbnQ2NBgCIAEoAxIXCg9vcHRpb25hbF91aW50MzIYAyABKA0S", "FwoPb3B0aW9uYWxfdWludDY0GAQgASgEEhcKD29wdGlvbmFsX3NpbnQzMhgF", @@ -140,99 +140,101 @@ "IAEoBEgAEhUKC29uZW9mX2Zsb2F0GHUgASgCSAASFgoMb25lb2ZfZG91Ymxl", "GHYgASgBSAASUgoKb25lb2ZfZW51bRh3IAEoDjI8LnByb3RvYnVmX3Rlc3Rf", "bWVzc2FnZXMucHJvdG8zLlRlc3RBbGxUeXBlc1Byb3RvMy5OZXN0ZWRFbnVt", - "SAASOgoVb3B0aW9uYWxfYm9vbF93cmFwcGVyGMkBIAEoCzIaLmdvb2dsZS5w", - "cm90b2J1Zi5Cb29sVmFsdWUSPAoWb3B0aW9uYWxfaW50MzJfd3JhcHBlchjK", - "ASABKAsyGy5nb29nbGUucHJvdG9idWYuSW50MzJWYWx1ZRI8ChZvcHRpb25h", - "bF9pbnQ2NF93cmFwcGVyGMsBIAEoCzIbLmdvb2dsZS5wcm90b2J1Zi5JbnQ2", - "NFZhbHVlEj4KF29wdGlvbmFsX3VpbnQzMl93cmFwcGVyGMwBIAEoCzIcLmdv", - "b2dsZS5wcm90b2J1Zi5VSW50MzJWYWx1ZRI+ChdvcHRpb25hbF91aW50NjRf", - "d3JhcHBlchjNASABKAsyHC5nb29nbGUucHJvdG9idWYuVUludDY0VmFsdWUS", - "PAoWb3B0aW9uYWxfZmxvYXRfd3JhcHBlchjOASABKAsyGy5nb29nbGUucHJv", - "dG9idWYuRmxvYXRWYWx1ZRI+ChdvcHRpb25hbF9kb3VibGVfd3JhcHBlchjP", - "ASABKAsyHC5nb29nbGUucHJvdG9idWYuRG91YmxlVmFsdWUSPgoXb3B0aW9u", - "YWxfc3RyaW5nX3dyYXBwZXIY0AEgASgLMhwuZ29vZ2xlLnByb3RvYnVmLlN0", - "cmluZ1ZhbHVlEjwKFm9wdGlvbmFsX2J5dGVzX3dyYXBwZXIY0QEgASgLMhsu", - "Z29vZ2xlLnByb3RvYnVmLkJ5dGVzVmFsdWUSOgoVcmVwZWF0ZWRfYm9vbF93", - "cmFwcGVyGNMBIAMoCzIaLmdvb2dsZS5wcm90b2J1Zi5Cb29sVmFsdWUSPAoW", - "cmVwZWF0ZWRfaW50MzJfd3JhcHBlchjUASADKAsyGy5nb29nbGUucHJvdG9i", - "dWYuSW50MzJWYWx1ZRI8ChZyZXBlYXRlZF9pbnQ2NF93cmFwcGVyGNUBIAMo", - "CzIbLmdvb2dsZS5wcm90b2J1Zi5JbnQ2NFZhbHVlEj4KF3JlcGVhdGVkX3Vp", - "bnQzMl93cmFwcGVyGNYBIAMoCzIcLmdvb2dsZS5wcm90b2J1Zi5VSW50MzJW", - "YWx1ZRI+ChdyZXBlYXRlZF91aW50NjRfd3JhcHBlchjXASADKAsyHC5nb29n", - "bGUucHJvdG9idWYuVUludDY0VmFsdWUSPAoWcmVwZWF0ZWRfZmxvYXRfd3Jh", - "cHBlchjYASADKAsyGy5nb29nbGUucHJvdG9idWYuRmxvYXRWYWx1ZRI+Chdy", - "ZXBlYXRlZF9kb3VibGVfd3JhcHBlchjZASADKAsyHC5nb29nbGUucHJvdG9i", - "dWYuRG91YmxlVmFsdWUSPgoXcmVwZWF0ZWRfc3RyaW5nX3dyYXBwZXIY2gEg", - "AygLMhwuZ29vZ2xlLnByb3RvYnVmLlN0cmluZ1ZhbHVlEjwKFnJlcGVhdGVk", - "X2J5dGVzX3dyYXBwZXIY2wEgAygLMhsuZ29vZ2xlLnByb3RvYnVmLkJ5dGVz", - "VmFsdWUSNQoRb3B0aW9uYWxfZHVyYXRpb24YrQIgASgLMhkuZ29vZ2xlLnBy", - "b3RvYnVmLkR1cmF0aW9uEjcKEm9wdGlvbmFsX3RpbWVzdGFtcBiuAiABKAsy", - "Gi5nb29nbGUucHJvdG9idWYuVGltZXN0YW1wEjgKE29wdGlvbmFsX2ZpZWxk", - "X21hc2sYrwIgASgLMhouZ29vZ2xlLnByb3RvYnVmLkZpZWxkTWFzaxIxCg9v", - "cHRpb25hbF9zdHJ1Y3QYsAIgASgLMhcuZ29vZ2xlLnByb3RvYnVmLlN0cnVj", - "dBIrCgxvcHRpb25hbF9hbnkYsQIgASgLMhQuZ29vZ2xlLnByb3RvYnVmLkFu", - "eRIvCg5vcHRpb25hbF92YWx1ZRiyAiABKAsyFi5nb29nbGUucHJvdG9idWYu", - "VmFsdWUSNQoRcmVwZWF0ZWRfZHVyYXRpb24YtwIgAygLMhkuZ29vZ2xlLnBy", - "b3RvYnVmLkR1cmF0aW9uEjcKEnJlcGVhdGVkX3RpbWVzdGFtcBi4AiADKAsy", - "Gi5nb29nbGUucHJvdG9idWYuVGltZXN0YW1wEjcKEnJlcGVhdGVkX2ZpZWxk", - "bWFzaxi5AiADKAsyGi5nb29nbGUucHJvdG9idWYuRmllbGRNYXNrEjEKD3Jl", - "cGVhdGVkX3N0cnVjdBjEAiADKAsyFy5nb29nbGUucHJvdG9idWYuU3RydWN0", - "EisKDHJlcGVhdGVkX2FueRi7AiADKAsyFC5nb29nbGUucHJvdG9idWYuQW55", - "Ei8KDnJlcGVhdGVkX3ZhbHVlGLwCIAMoCzIWLmdvb2dsZS5wcm90b2J1Zi5W", - "YWx1ZRI4ChNyZXBlYXRlZF9saXN0X3ZhbHVlGL0CIAMoCzIaLmdvb2dsZS5w", - "cm90b2J1Zi5MaXN0VmFsdWUSEwoKZmllbGRuYW1lMRiRAyABKAUSFAoLZmll", - "bGRfbmFtZTIYkgMgASgFEhUKDF9maWVsZF9uYW1lMxiTAyABKAUSFgoNZmll", - "bGRfX25hbWU0XxiUAyABKAUSFAoLZmllbGQwbmFtZTUYlQMgASgFEhYKDWZp", - "ZWxkXzBfbmFtZTYYlgMgASgFEhMKCmZpZWxkTmFtZTcYlwMgASgFEhMKCkZp", - "ZWxkTmFtZTgYmAMgASgFEhQKC2ZpZWxkX05hbWU5GJkDIAEoBRIVCgxGaWVs", - "ZF9OYW1lMTAYmgMgASgFEhUKDEZJRUxEX05BTUUxMRibAyABKAUSFQoMRklF", - "TERfbmFtZTEyGJwDIAEoBRIXCg5fX2ZpZWxkX25hbWUxMxidAyABKAUSFwoO", - "X19GaWVsZF9uYW1lMTQYngMgASgFEhYKDWZpZWxkX19uYW1lMTUYnwMgASgF", - "EhYKDWZpZWxkX19OYW1lMTYYoAMgASgFEhcKDmZpZWxkX25hbWUxN19fGKED", - "IAEoBRIXCg5GaWVsZF9uYW1lMThfXxiiAyABKAUaYgoNTmVzdGVkTWVzc2Fn", - "ZRIJCgFhGAEgASgFEkYKC2NvcmVjdXJzaXZlGAIgASgLMjEucHJvdG9idWZf", - "dGVzdF9tZXNzYWdlcy5wcm90bzMuVGVzdEFsbFR5cGVzUHJvdG8zGjQKEk1h", - "cEludDMySW50MzJFbnRyeRILCgNrZXkYASABKAUSDQoFdmFsdWUYAiABKAU6", - "AjgBGjQKEk1hcEludDY0SW50NjRFbnRyeRILCgNrZXkYASABKAMSDQoFdmFs", - "dWUYAiABKAM6AjgBGjYKFE1hcFVpbnQzMlVpbnQzMkVudHJ5EgsKA2tleRgB", - "IAEoDRINCgV2YWx1ZRgCIAEoDToCOAEaNgoUTWFwVWludDY0VWludDY0RW50", - "cnkSCwoDa2V5GAEgASgEEg0KBXZhbHVlGAIgASgEOgI4ARo2ChRNYXBTaW50", - "MzJTaW50MzJFbnRyeRILCgNrZXkYASABKBESDQoFdmFsdWUYAiABKBE6AjgB", - "GjYKFE1hcFNpbnQ2NFNpbnQ2NEVudHJ5EgsKA2tleRgBIAEoEhINCgV2YWx1", - "ZRgCIAEoEjoCOAEaOAoWTWFwRml4ZWQzMkZpeGVkMzJFbnRyeRILCgNrZXkY", - "ASABKAcSDQoFdmFsdWUYAiABKAc6AjgBGjgKFk1hcEZpeGVkNjRGaXhlZDY0", - "RW50cnkSCwoDa2V5GAEgASgGEg0KBXZhbHVlGAIgASgGOgI4ARo6ChhNYXBT", - "Zml4ZWQzMlNmaXhlZDMyRW50cnkSCwoDa2V5GAEgASgPEg0KBXZhbHVlGAIg", - "ASgPOgI4ARo6ChhNYXBTZml4ZWQ2NFNmaXhlZDY0RW50cnkSCwoDa2V5GAEg", - "ASgQEg0KBXZhbHVlGAIgASgQOgI4ARo0ChJNYXBJbnQzMkZsb2F0RW50cnkS", - "CwoDa2V5GAEgASgFEg0KBXZhbHVlGAIgASgCOgI4ARo1ChNNYXBJbnQzMkRv", - "dWJsZUVudHJ5EgsKA2tleRgBIAEoBRINCgV2YWx1ZRgCIAEoAToCOAEaMgoQ", - "TWFwQm9vbEJvb2xFbnRyeRILCgNrZXkYASABKAgSDQoFdmFsdWUYAiABKAg6", - "AjgBGjYKFE1hcFN0cmluZ1N0cmluZ0VudHJ5EgsKA2tleRgBIAEoCRINCgV2", - "YWx1ZRgCIAEoCToCOAEaNQoTTWFwU3RyaW5nQnl0ZXNFbnRyeRILCgNrZXkY", - "ASABKAkSDQoFdmFsdWUYAiABKAw6AjgBGn4KG01hcFN0cmluZ05lc3RlZE1l", - "c3NhZ2VFbnRyeRILCgNrZXkYASABKAkSTgoFdmFsdWUYAiABKAsyPy5wcm90", - "b2J1Zl90ZXN0X21lc3NhZ2VzLnByb3RvMy5UZXN0QWxsVHlwZXNQcm90bzMu", - "TmVzdGVkTWVzc2FnZToCOAEabQocTWFwU3RyaW5nRm9yZWlnbk1lc3NhZ2VF", - "bnRyeRILCgNrZXkYASABKAkSPAoFdmFsdWUYAiABKAsyLS5wcm90b2J1Zl90", - "ZXN0X21lc3NhZ2VzLnByb3RvMy5Gb3JlaWduTWVzc2FnZToCOAEaeAoYTWFw", - "U3RyaW5nTmVzdGVkRW51bUVudHJ5EgsKA2tleRgBIAEoCRJLCgV2YWx1ZRgC", - "IAEoDjI8LnByb3RvYnVmX3Rlc3RfbWVzc2FnZXMucHJvdG8zLlRlc3RBbGxU", - "eXBlc1Byb3RvMy5OZXN0ZWRFbnVtOgI4ARpnChlNYXBTdHJpbmdGb3JlaWdu", - "RW51bUVudHJ5EgsKA2tleRgBIAEoCRI5CgV2YWx1ZRgCIAEoDjIqLnByb3Rv", - "YnVmX3Rlc3RfbWVzc2FnZXMucHJvdG8zLkZvcmVpZ25FbnVtOgI4ASI5CgpO", - "ZXN0ZWRFbnVtEgcKA0ZPTxAAEgcKA0JBUhABEgcKA0JBWhACEhAKA05FRxD/", - "//////////8BIlkKC0FsaWFzZWRFbnVtEg0KCUFMSUFTX0ZPTxAAEg0KCUFM", - "SUFTX0JBUhABEg0KCUFMSUFTX0JBWhACEgcKA1FVWBACEgcKA3F1eBACEgcK", - "A2JBehACGgIQAUINCgtvbmVvZl9maWVsZEoGCPUDEP8DIhsKDkZvcmVpZ25N", - "ZXNzYWdlEgkKAWMYASABKAUqQAoLRm9yZWlnbkVudW0SDwoLRk9SRUlHTl9G", - "T08QABIPCgtGT1JFSUdOX0JBUhABEg8KC0ZPUkVJR05fQkFaEAJCOAooY29t", - "Lmdvb2dsZS5wcm90b2J1Zl90ZXN0X21lc3NhZ2VzLnByb3RvM0gB+AEBogIG", - "UHJvdG8zYgZwcm90bzM=")); + "SAASNgoQb25lb2ZfbnVsbF92YWx1ZRh4IAEoDjIaLmdvb2dsZS5wcm90b2J1", + "Zi5OdWxsVmFsdWVIABI6ChVvcHRpb25hbF9ib29sX3dyYXBwZXIYyQEgASgL", + "MhouZ29vZ2xlLnByb3RvYnVmLkJvb2xWYWx1ZRI8ChZvcHRpb25hbF9pbnQz", + "Ml93cmFwcGVyGMoBIAEoCzIbLmdvb2dsZS5wcm90b2J1Zi5JbnQzMlZhbHVl", + "EjwKFm9wdGlvbmFsX2ludDY0X3dyYXBwZXIYywEgASgLMhsuZ29vZ2xlLnBy", + "b3RvYnVmLkludDY0VmFsdWUSPgoXb3B0aW9uYWxfdWludDMyX3dyYXBwZXIY", + "zAEgASgLMhwuZ29vZ2xlLnByb3RvYnVmLlVJbnQzMlZhbHVlEj4KF29wdGlv", + "bmFsX3VpbnQ2NF93cmFwcGVyGM0BIAEoCzIcLmdvb2dsZS5wcm90b2J1Zi5V", + "SW50NjRWYWx1ZRI8ChZvcHRpb25hbF9mbG9hdF93cmFwcGVyGM4BIAEoCzIb", + "Lmdvb2dsZS5wcm90b2J1Zi5GbG9hdFZhbHVlEj4KF29wdGlvbmFsX2RvdWJs", + "ZV93cmFwcGVyGM8BIAEoCzIcLmdvb2dsZS5wcm90b2J1Zi5Eb3VibGVWYWx1", + "ZRI+ChdvcHRpb25hbF9zdHJpbmdfd3JhcHBlchjQASABKAsyHC5nb29nbGUu", + "cHJvdG9idWYuU3RyaW5nVmFsdWUSPAoWb3B0aW9uYWxfYnl0ZXNfd3JhcHBl", + "chjRASABKAsyGy5nb29nbGUucHJvdG9idWYuQnl0ZXNWYWx1ZRI6ChVyZXBl", + "YXRlZF9ib29sX3dyYXBwZXIY0wEgAygLMhouZ29vZ2xlLnByb3RvYnVmLkJv", + "b2xWYWx1ZRI8ChZyZXBlYXRlZF9pbnQzMl93cmFwcGVyGNQBIAMoCzIbLmdv", + "b2dsZS5wcm90b2J1Zi5JbnQzMlZhbHVlEjwKFnJlcGVhdGVkX2ludDY0X3dy", + "YXBwZXIY1QEgAygLMhsuZ29vZ2xlLnByb3RvYnVmLkludDY0VmFsdWUSPgoX", + "cmVwZWF0ZWRfdWludDMyX3dyYXBwZXIY1gEgAygLMhwuZ29vZ2xlLnByb3Rv", + "YnVmLlVJbnQzMlZhbHVlEj4KF3JlcGVhdGVkX3VpbnQ2NF93cmFwcGVyGNcB", + "IAMoCzIcLmdvb2dsZS5wcm90b2J1Zi5VSW50NjRWYWx1ZRI8ChZyZXBlYXRl", + "ZF9mbG9hdF93cmFwcGVyGNgBIAMoCzIbLmdvb2dsZS5wcm90b2J1Zi5GbG9h", + "dFZhbHVlEj4KF3JlcGVhdGVkX2RvdWJsZV93cmFwcGVyGNkBIAMoCzIcLmdv", + "b2dsZS5wcm90b2J1Zi5Eb3VibGVWYWx1ZRI+ChdyZXBlYXRlZF9zdHJpbmdf", + "d3JhcHBlchjaASADKAsyHC5nb29nbGUucHJvdG9idWYuU3RyaW5nVmFsdWUS", + "PAoWcmVwZWF0ZWRfYnl0ZXNfd3JhcHBlchjbASADKAsyGy5nb29nbGUucHJv", + "dG9idWYuQnl0ZXNWYWx1ZRI1ChFvcHRpb25hbF9kdXJhdGlvbhitAiABKAsy", + "GS5nb29nbGUucHJvdG9idWYuRHVyYXRpb24SNwoSb3B0aW9uYWxfdGltZXN0", + "YW1wGK4CIAEoCzIaLmdvb2dsZS5wcm90b2J1Zi5UaW1lc3RhbXASOAoTb3B0", + "aW9uYWxfZmllbGRfbWFzaxivAiABKAsyGi5nb29nbGUucHJvdG9idWYuRmll", + "bGRNYXNrEjEKD29wdGlvbmFsX3N0cnVjdBiwAiABKAsyFy5nb29nbGUucHJv", + "dG9idWYuU3RydWN0EisKDG9wdGlvbmFsX2FueRixAiABKAsyFC5nb29nbGUu", + "cHJvdG9idWYuQW55Ei8KDm9wdGlvbmFsX3ZhbHVlGLICIAEoCzIWLmdvb2ds", + "ZS5wcm90b2J1Zi5WYWx1ZRI4ChNvcHRpb25hbF9udWxsX3ZhbHVlGLMCIAEo", + "DjIaLmdvb2dsZS5wcm90b2J1Zi5OdWxsVmFsdWUSNQoRcmVwZWF0ZWRfZHVy", + "YXRpb24YtwIgAygLMhkuZ29vZ2xlLnByb3RvYnVmLkR1cmF0aW9uEjcKEnJl", + "cGVhdGVkX3RpbWVzdGFtcBi4AiADKAsyGi5nb29nbGUucHJvdG9idWYuVGlt", + "ZXN0YW1wEjcKEnJlcGVhdGVkX2ZpZWxkbWFzaxi5AiADKAsyGi5nb29nbGUu", + "cHJvdG9idWYuRmllbGRNYXNrEjEKD3JlcGVhdGVkX3N0cnVjdBjEAiADKAsy", + "Fy5nb29nbGUucHJvdG9idWYuU3RydWN0EisKDHJlcGVhdGVkX2FueRi7AiAD", + "KAsyFC5nb29nbGUucHJvdG9idWYuQW55Ei8KDnJlcGVhdGVkX3ZhbHVlGLwC", + "IAMoCzIWLmdvb2dsZS5wcm90b2J1Zi5WYWx1ZRI4ChNyZXBlYXRlZF9saXN0", + "X3ZhbHVlGL0CIAMoCzIaLmdvb2dsZS5wcm90b2J1Zi5MaXN0VmFsdWUSEwoK", + "ZmllbGRuYW1lMRiRAyABKAUSFAoLZmllbGRfbmFtZTIYkgMgASgFEhUKDF9m", + "aWVsZF9uYW1lMxiTAyABKAUSFgoNZmllbGRfX25hbWU0XxiUAyABKAUSFAoL", + "ZmllbGQwbmFtZTUYlQMgASgFEhYKDWZpZWxkXzBfbmFtZTYYlgMgASgFEhMK", + "CmZpZWxkTmFtZTcYlwMgASgFEhMKCkZpZWxkTmFtZTgYmAMgASgFEhQKC2Zp", + "ZWxkX05hbWU5GJkDIAEoBRIVCgxGaWVsZF9OYW1lMTAYmgMgASgFEhUKDEZJ", + "RUxEX05BTUUxMRibAyABKAUSFQoMRklFTERfbmFtZTEyGJwDIAEoBRIXCg5f", + "X2ZpZWxkX25hbWUxMxidAyABKAUSFwoOX19GaWVsZF9uYW1lMTQYngMgASgF", + "EhYKDWZpZWxkX19uYW1lMTUYnwMgASgFEhYKDWZpZWxkX19OYW1lMTYYoAMg", + "ASgFEhcKDmZpZWxkX25hbWUxN19fGKEDIAEoBRIXCg5GaWVsZF9uYW1lMThf", + "XxiiAyABKAUaYgoNTmVzdGVkTWVzc2FnZRIJCgFhGAEgASgFEkYKC2NvcmVj", + "dXJzaXZlGAIgASgLMjEucHJvdG9idWZfdGVzdF9tZXNzYWdlcy5wcm90bzMu", + "VGVzdEFsbFR5cGVzUHJvdG8zGjQKEk1hcEludDMySW50MzJFbnRyeRILCgNr", + "ZXkYASABKAUSDQoFdmFsdWUYAiABKAU6AjgBGjQKEk1hcEludDY0SW50NjRF", + "bnRyeRILCgNrZXkYASABKAMSDQoFdmFsdWUYAiABKAM6AjgBGjYKFE1hcFVp", + "bnQzMlVpbnQzMkVudHJ5EgsKA2tleRgBIAEoDRINCgV2YWx1ZRgCIAEoDToC", + "OAEaNgoUTWFwVWludDY0VWludDY0RW50cnkSCwoDa2V5GAEgASgEEg0KBXZh", + "bHVlGAIgASgEOgI4ARo2ChRNYXBTaW50MzJTaW50MzJFbnRyeRILCgNrZXkY", + "ASABKBESDQoFdmFsdWUYAiABKBE6AjgBGjYKFE1hcFNpbnQ2NFNpbnQ2NEVu", + "dHJ5EgsKA2tleRgBIAEoEhINCgV2YWx1ZRgCIAEoEjoCOAEaOAoWTWFwRml4", + "ZWQzMkZpeGVkMzJFbnRyeRILCgNrZXkYASABKAcSDQoFdmFsdWUYAiABKAc6", + "AjgBGjgKFk1hcEZpeGVkNjRGaXhlZDY0RW50cnkSCwoDa2V5GAEgASgGEg0K", + "BXZhbHVlGAIgASgGOgI4ARo6ChhNYXBTZml4ZWQzMlNmaXhlZDMyRW50cnkS", + "CwoDa2V5GAEgASgPEg0KBXZhbHVlGAIgASgPOgI4ARo6ChhNYXBTZml4ZWQ2", + "NFNmaXhlZDY0RW50cnkSCwoDa2V5GAEgASgQEg0KBXZhbHVlGAIgASgQOgI4", + "ARo0ChJNYXBJbnQzMkZsb2F0RW50cnkSCwoDa2V5GAEgASgFEg0KBXZhbHVl", + "GAIgASgCOgI4ARo1ChNNYXBJbnQzMkRvdWJsZUVudHJ5EgsKA2tleRgBIAEo", + "BRINCgV2YWx1ZRgCIAEoAToCOAEaMgoQTWFwQm9vbEJvb2xFbnRyeRILCgNr", + "ZXkYASABKAgSDQoFdmFsdWUYAiABKAg6AjgBGjYKFE1hcFN0cmluZ1N0cmlu", + "Z0VudHJ5EgsKA2tleRgBIAEoCRINCgV2YWx1ZRgCIAEoCToCOAEaNQoTTWFw", + "U3RyaW5nQnl0ZXNFbnRyeRILCgNrZXkYASABKAkSDQoFdmFsdWUYAiABKAw6", + "AjgBGn4KG01hcFN0cmluZ05lc3RlZE1lc3NhZ2VFbnRyeRILCgNrZXkYASAB", + "KAkSTgoFdmFsdWUYAiABKAsyPy5wcm90b2J1Zl90ZXN0X21lc3NhZ2VzLnBy", + "b3RvMy5UZXN0QWxsVHlwZXNQcm90bzMuTmVzdGVkTWVzc2FnZToCOAEabQoc", + "TWFwU3RyaW5nRm9yZWlnbk1lc3NhZ2VFbnRyeRILCgNrZXkYASABKAkSPAoF", + "dmFsdWUYAiABKAsyLS5wcm90b2J1Zl90ZXN0X21lc3NhZ2VzLnByb3RvMy5G", + "b3JlaWduTWVzc2FnZToCOAEaeAoYTWFwU3RyaW5nTmVzdGVkRW51bUVudHJ5", + "EgsKA2tleRgBIAEoCRJLCgV2YWx1ZRgCIAEoDjI8LnByb3RvYnVmX3Rlc3Rf", + "bWVzc2FnZXMucHJvdG8zLlRlc3RBbGxUeXBlc1Byb3RvMy5OZXN0ZWRFbnVt", + "OgI4ARpnChlNYXBTdHJpbmdGb3JlaWduRW51bUVudHJ5EgsKA2tleRgBIAEo", + "CRI5CgV2YWx1ZRgCIAEoDjIqLnByb3RvYnVmX3Rlc3RfbWVzc2FnZXMucHJv", + "dG8zLkZvcmVpZ25FbnVtOgI4ASI5CgpOZXN0ZWRFbnVtEgcKA0ZPTxAAEgcK", + "A0JBUhABEgcKA0JBWhACEhAKA05FRxD///////////8BIlkKC0FsaWFzZWRF", + "bnVtEg0KCUFMSUFTX0ZPTxAAEg0KCUFMSUFTX0JBUhABEg0KCUFMSUFTX0JB", + "WhACEgcKA1FVWBACEgcKA3F1eBACEgcKA2JBehACGgIQAUINCgtvbmVvZl9m", + "aWVsZEoGCPUDEP8DIhsKDkZvcmVpZ25NZXNzYWdlEgkKAWMYASABKAUqQAoL", + "Rm9yZWlnbkVudW0SDwoLRk9SRUlHTl9GT08QABIPCgtGT1JFSUdOX0JBUhAB", + "Eg8KC0ZPUkVJR05fQkFaEAJCOAooY29tLmdvb2dsZS5wcm90b2J1Zl90ZXN0", + "X21lc3NhZ2VzLnByb3RvM0gB+AEBogIGUHJvdG8zYgZwcm90bzM=")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { global::Google.Protobuf.WellKnownTypes.AnyReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.DurationReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.FieldMaskReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.StructReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.TimestampReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.WrappersReflection.Descriptor, }, new pbr::GeneratedClrTypeInfo(new[] {typeof(global::ProtobufTestMessages.Proto3.ForeignEnum), }, null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::ProtobufTestMessages.Proto3.TestAllTypesProto3), global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Parser, new[]{ "OptionalInt32", "OptionalInt64", "OptionalUint32", "OptionalUint64", "OptionalSint32", "OptionalSint64", "OptionalFixed32", "OptionalFixed64", "OptionalSfixed32", "OptionalSfixed64", "OptionalFloat", "OptionalDouble", "OptionalBool", "OptionalString", "OptionalBytes", "OptionalNestedMessage", "OptionalForeignMessage", "OptionalNestedEnum", "OptionalForeignEnum", "OptionalAliasedEnum", "OptionalStringPiece", "OptionalCord", "RecursiveMessage", "RepeatedInt32", "RepeatedInt64", "RepeatedUint32", "RepeatedUint64", "RepeatedSint32", "RepeatedSint64", "RepeatedFixed32", "RepeatedFixed64", "RepeatedSfixed32", "RepeatedSfixed64", "RepeatedFloat", "RepeatedDouble", "RepeatedBool", "RepeatedString", "RepeatedBytes", "RepeatedNestedMessage", "RepeatedForeignMessage", "RepeatedNestedEnum", "RepeatedForeignEnum", "RepeatedStringPiece", "RepeatedCord", "PackedInt32", "PackedInt64", "PackedUint32", "PackedUint64", "PackedSint32", "PackedSint64", "PackedFixed32", "PackedFixed64", "PackedSfixed32", "PackedSfixed64", "PackedFloat", "PackedDouble", "PackedBool", "PackedNestedEnum", "UnpackedInt32", "UnpackedInt64", "UnpackedUint32", "UnpackedUint64", "UnpackedSint32", "UnpackedSint64", "UnpackedFixed32", "UnpackedFixed64", "UnpackedSfixed32", "UnpackedSfixed64", "UnpackedFloat", "UnpackedDouble", "UnpackedBool", "UnpackedNestedEnum", "MapInt32Int32", "MapInt64Int64", "MapUint32Uint32", "MapUint64Uint64", "MapSint32Sint32", "MapSint64Sint64", "MapFixed32Fixed32", "MapFixed64Fixed64", "MapSfixed32Sfixed32", "MapSfixed64Sfixed64", "MapInt32Float", "MapInt32Double", "MapBoolBool", "MapStringString", "MapStringBytes", "MapStringNestedMessage", "MapStringForeignMessage", "MapStringNestedEnum", "MapStringForeignEnum", "OneofUint32", "OneofNestedMessage", "OneofString", "OneofBytes", "OneofBool", "OneofUint64", "OneofFloat", "OneofDouble", "OneofEnum", "OptionalBoolWrapper", "OptionalInt32Wrapper", "OptionalInt64Wrapper", "OptionalUint32Wrapper", "OptionalUint64Wrapper", "OptionalFloatWrapper", "OptionalDoubleWrapper", "OptionalStringWrapper", "OptionalBytesWrapper", "RepeatedBoolWrapper", "RepeatedInt32Wrapper", "RepeatedInt64Wrapper", "RepeatedUint32Wrapper", "RepeatedUint64Wrapper", "RepeatedFloatWrapper", "RepeatedDoubleWrapper", "RepeatedStringWrapper", "RepeatedBytesWrapper", "OptionalDuration", "OptionalTimestamp", "OptionalFieldMask", "OptionalStruct", "OptionalAny", "OptionalValue", "RepeatedDuration", "RepeatedTimestamp", "RepeatedFieldmask", "RepeatedStruct", "RepeatedAny", "RepeatedValue", "RepeatedListValue", "Fieldname1", "FieldName2", "FieldName3", "FieldName4", "Field0Name5", "Field0Name6", "FieldName7", "FieldName8", "FieldName9", "FieldName10", "FIELDNAME11", "FIELDName12", "FieldName13", "FieldName14", "FieldName15", "FieldName16", "FieldName17", "FieldName18" }, new[]{ "OneofField" }, new[]{ typeof(global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Types.NestedEnum), typeof(global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Types.AliasedEnum) }, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Types.NestedMessage), global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Types.NestedMessage.Parser, new[]{ "A", "Corecursive" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::ProtobufTestMessages.Proto3.TestAllTypesProto3), global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Parser, new[]{ "OptionalInt32", "OptionalInt64", "OptionalUint32", "OptionalUint64", "OptionalSint32", "OptionalSint64", "OptionalFixed32", "OptionalFixed64", "OptionalSfixed32", "OptionalSfixed64", "OptionalFloat", "OptionalDouble", "OptionalBool", "OptionalString", "OptionalBytes", "OptionalNestedMessage", "OptionalForeignMessage", "OptionalNestedEnum", "OptionalForeignEnum", "OptionalAliasedEnum", "OptionalStringPiece", "OptionalCord", "RecursiveMessage", "RepeatedInt32", "RepeatedInt64", "RepeatedUint32", "RepeatedUint64", "RepeatedSint32", "RepeatedSint64", "RepeatedFixed32", "RepeatedFixed64", "RepeatedSfixed32", "RepeatedSfixed64", "RepeatedFloat", "RepeatedDouble", "RepeatedBool", "RepeatedString", "RepeatedBytes", "RepeatedNestedMessage", "RepeatedForeignMessage", "RepeatedNestedEnum", "RepeatedForeignEnum", "RepeatedStringPiece", "RepeatedCord", "PackedInt32", "PackedInt64", "PackedUint32", "PackedUint64", "PackedSint32", "PackedSint64", "PackedFixed32", "PackedFixed64", "PackedSfixed32", "PackedSfixed64", "PackedFloat", "PackedDouble", "PackedBool", "PackedNestedEnum", "UnpackedInt32", "UnpackedInt64", "UnpackedUint32", "UnpackedUint64", "UnpackedSint32", "UnpackedSint64", "UnpackedFixed32", "UnpackedFixed64", "UnpackedSfixed32", "UnpackedSfixed64", "UnpackedFloat", "UnpackedDouble", "UnpackedBool", "UnpackedNestedEnum", "MapInt32Int32", "MapInt64Int64", "MapUint32Uint32", "MapUint64Uint64", "MapSint32Sint32", "MapSint64Sint64", "MapFixed32Fixed32", "MapFixed64Fixed64", "MapSfixed32Sfixed32", "MapSfixed64Sfixed64", "MapInt32Float", "MapInt32Double", "MapBoolBool", "MapStringString", "MapStringBytes", "MapStringNestedMessage", "MapStringForeignMessage", "MapStringNestedEnum", "MapStringForeignEnum", "OneofUint32", "OneofNestedMessage", "OneofString", "OneofBytes", "OneofBool", "OneofUint64", "OneofFloat", "OneofDouble", "OneofEnum", "OneofNullValue", "OptionalBoolWrapper", "OptionalInt32Wrapper", "OptionalInt64Wrapper", "OptionalUint32Wrapper", "OptionalUint64Wrapper", "OptionalFloatWrapper", "OptionalDoubleWrapper", "OptionalStringWrapper", "OptionalBytesWrapper", "RepeatedBoolWrapper", "RepeatedInt32Wrapper", "RepeatedInt64Wrapper", "RepeatedUint32Wrapper", "RepeatedUint64Wrapper", "RepeatedFloatWrapper", "RepeatedDoubleWrapper", "RepeatedStringWrapper", "RepeatedBytesWrapper", "OptionalDuration", "OptionalTimestamp", "OptionalFieldMask", "OptionalStruct", "OptionalAny", "OptionalValue", "OptionalNullValue", "RepeatedDuration", "RepeatedTimestamp", "RepeatedFieldmask", "RepeatedStruct", "RepeatedAny", "RepeatedValue", "RepeatedListValue", "Fieldname1", "FieldName2", "FieldName3", "FieldName4", "Field0Name5", "Field0Name6", "FieldName7", "FieldName8", "FieldName9", "FieldName10", "FIELDNAME11", "FIELDName12", "FieldName13", "FieldName14", "FieldName15", "FieldName16", "FieldName17", "FieldName18" }, new[]{ "OneofField" }, new[]{ typeof(global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Types.NestedEnum), typeof(global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Types.AliasedEnum) }, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Types.NestedMessage), global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Types.NestedMessage.Parser, new[]{ "A", "Corecursive" }, null, null, null, null), null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, }), new pbr::GeneratedClrTypeInfo(typeof(global::ProtobufTestMessages.Proto3.ForeignMessage), global::ProtobufTestMessages.Proto3.ForeignMessage.Parser, new[]{ "C" }, null, null, null, null) })); @@ -403,6 +405,7 @@ optionalStruct_ = other.optionalStruct_ != null ? other.optionalStruct_.Clone() : null; optionalAny_ = other.optionalAny_ != null ? other.optionalAny_.Clone() : null; optionalValue_ = other.optionalValue_ != null ? other.optionalValue_.Clone() : null; + optionalNullValue_ = other.optionalNullValue_; repeatedDuration_ = other.repeatedDuration_.Clone(); repeatedTimestamp_ = other.repeatedTimestamp_.Clone(); repeatedFieldmask_ = other.repeatedFieldmask_.Clone(); @@ -456,6 +459,9 @@ case OneofFieldOneofCase.OneofEnum: OneofEnum = other.OneofEnum; break; + case OneofFieldOneofCase.OneofNullValue: + OneofNullValue = other.OneofNullValue; + break; } _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); @@ -1513,6 +1519,17 @@ } } + /// <summary>Field number for the "oneof_null_value" field.</summary> + public const int OneofNullValueFieldNumber = 120; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Google.Protobuf.WellKnownTypes.NullValue OneofNullValue { + get { return oneofFieldCase_ == OneofFieldOneofCase.OneofNullValue ? (global::Google.Protobuf.WellKnownTypes.NullValue) oneofField_ : global::Google.Protobuf.WellKnownTypes.NullValue.NullValue; } + set { + oneofField_ = value; + oneofFieldCase_ = OneofFieldOneofCase.OneofNullValue; + } + } + /// <summary>Field number for the "optional_bool_wrapper" field.</summary> public const int OptionalBoolWrapperFieldNumber = 201; private static readonly pb::FieldCodec<bool?> _single_optionalBoolWrapper_codec = pb::FieldCodec.ForStructWrapper<bool>(1610); @@ -1789,6 +1806,17 @@ } } + /// <summary>Field number for the "optional_null_value" field.</summary> + public const int OptionalNullValueFieldNumber = 307; + private global::Google.Protobuf.WellKnownTypes.NullValue optionalNullValue_ = global::Google.Protobuf.WellKnownTypes.NullValue.NullValue; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Google.Protobuf.WellKnownTypes.NullValue OptionalNullValue { + get { return optionalNullValue_; } + set { + optionalNullValue_ = value; + } + } + /// <summary>Field number for the "repeated_duration" field.</summary> public const int RepeatedDurationFieldNumber = 311; private static readonly pb::FieldCodec<global::Google.Protobuf.WellKnownTypes.Duration> _repeated_repeatedDuration_codec @@ -2074,6 +2102,7 @@ OneofFloat = 117, OneofDouble = 118, OneofEnum = 119, + OneofNullValue = 120, } private OneofFieldOneofCase oneofFieldCase_ = OneofFieldOneofCase.None; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -2200,6 +2229,7 @@ if (!pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.Equals(OneofFloat, other.OneofFloat)) return false; if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(OneofDouble, other.OneofDouble)) return false; if (OneofEnum != other.OneofEnum) return false; + if (OneofNullValue != other.OneofNullValue) return false; if (OptionalBoolWrapper != other.OptionalBoolWrapper) return false; if (OptionalInt32Wrapper != other.OptionalInt32Wrapper) return false; if (OptionalInt64Wrapper != other.OptionalInt64Wrapper) return false; @@ -2224,6 +2254,7 @@ if (!object.Equals(OptionalStruct, other.OptionalStruct)) return false; if (!object.Equals(OptionalAny, other.OptionalAny)) return false; if (!object.Equals(OptionalValue, other.OptionalValue)) return false; + if (OptionalNullValue != other.OptionalNullValue) return false; if(!repeatedDuration_.Equals(other.repeatedDuration_)) return false; if(!repeatedTimestamp_.Equals(other.repeatedTimestamp_)) return false; if(!repeatedFieldmask_.Equals(other.repeatedFieldmask_)) return false; @@ -2356,6 +2387,7 @@ if (oneofFieldCase_ == OneofFieldOneofCase.OneofFloat) hash ^= pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.GetHashCode(OneofFloat); if (oneofFieldCase_ == OneofFieldOneofCase.OneofDouble) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(OneofDouble); if (oneofFieldCase_ == OneofFieldOneofCase.OneofEnum) hash ^= OneofEnum.GetHashCode(); + if (oneofFieldCase_ == OneofFieldOneofCase.OneofNullValue) hash ^= OneofNullValue.GetHashCode(); if (optionalBoolWrapper_ != null) hash ^= OptionalBoolWrapper.GetHashCode(); if (optionalInt32Wrapper_ != null) hash ^= OptionalInt32Wrapper.GetHashCode(); if (optionalInt64Wrapper_ != null) hash ^= OptionalInt64Wrapper.GetHashCode(); @@ -2380,6 +2412,7 @@ if (optionalStruct_ != null) hash ^= OptionalStruct.GetHashCode(); if (optionalAny_ != null) hash ^= OptionalAny.GetHashCode(); if (optionalValue_ != null) hash ^= OptionalValue.GetHashCode(); + if (OptionalNullValue != global::Google.Protobuf.WellKnownTypes.NullValue.NullValue) hash ^= OptionalNullValue.GetHashCode(); hash ^= repeatedDuration_.GetHashCode(); hash ^= repeatedTimestamp_.GetHashCode(); hash ^= repeatedFieldmask_.GetHashCode(); @@ -2618,6 +2651,10 @@ output.WriteRawTag(184, 7); output.WriteEnum((int) OneofEnum); } + if (oneofFieldCase_ == OneofFieldOneofCase.OneofNullValue) { + output.WriteRawTag(192, 7); + output.WriteEnum((int) OneofNullValue); + } if (optionalBoolWrapper_ != null) { _single_optionalBoolWrapper_codec.WriteTagAndValue(output, OptionalBoolWrapper); } @@ -2678,6 +2715,10 @@ output.WriteRawTag(146, 19); output.WriteMessage(OptionalValue); } + if (OptionalNullValue != global::Google.Protobuf.WellKnownTypes.NullValue.NullValue) { + output.WriteRawTag(152, 19); + output.WriteEnum((int) OptionalNullValue); + } repeatedDuration_.WriteTo(output, _repeated_repeatedDuration_codec); repeatedTimestamp_.WriteTo(output, _repeated_repeatedTimestamp_codec); repeatedFieldmask_.WriteTo(output, _repeated_repeatedFieldmask_codec); @@ -2962,6 +3003,10 @@ output.WriteRawTag(184, 7); output.WriteEnum((int) OneofEnum); } + if (oneofFieldCase_ == OneofFieldOneofCase.OneofNullValue) { + output.WriteRawTag(192, 7); + output.WriteEnum((int) OneofNullValue); + } if (optionalBoolWrapper_ != null) { _single_optionalBoolWrapper_codec.WriteTagAndValue(ref output, OptionalBoolWrapper); } @@ -3022,6 +3067,10 @@ output.WriteRawTag(146, 19); output.WriteMessage(OptionalValue); } + if (OptionalNullValue != global::Google.Protobuf.WellKnownTypes.NullValue.NullValue) { + output.WriteRawTag(152, 19); + output.WriteEnum((int) OptionalNullValue); + } repeatedDuration_.WriteTo(ref output, _repeated_repeatedDuration_codec); repeatedTimestamp_.WriteTo(ref output, _repeated_repeatedTimestamp_codec); repeatedFieldmask_.WriteTo(ref output, _repeated_repeatedFieldmask_codec); @@ -3274,6 +3323,9 @@ if (oneofFieldCase_ == OneofFieldOneofCase.OneofEnum) { size += 2 + pb::CodedOutputStream.ComputeEnumSize((int) OneofEnum); } + if (oneofFieldCase_ == OneofFieldOneofCase.OneofNullValue) { + size += 2 + pb::CodedOutputStream.ComputeEnumSize((int) OneofNullValue); + } if (optionalBoolWrapper_ != null) { size += _single_optionalBoolWrapper_codec.CalculateSizeWithTag(OptionalBoolWrapper); } @@ -3328,6 +3380,9 @@ if (optionalValue_ != null) { size += 2 + pb::CodedOutputStream.ComputeMessageSize(OptionalValue); } + if (OptionalNullValue != global::Google.Protobuf.WellKnownTypes.NullValue.NullValue) { + size += 2 + pb::CodedOutputStream.ComputeEnumSize((int) OptionalNullValue); + } size += repeatedDuration_.CalculateSize(_repeated_repeatedDuration_codec); size += repeatedTimestamp_.CalculateSize(_repeated_repeatedTimestamp_codec); size += repeatedFieldmask_.CalculateSize(_repeated_repeatedFieldmask_codec); @@ -3636,6 +3691,9 @@ } OptionalValue.MergeFrom(other.OptionalValue); } + if (other.OptionalNullValue != global::Google.Protobuf.WellKnownTypes.NullValue.NullValue) { + OptionalNullValue = other.OptionalNullValue; + } repeatedDuration_.Add(other.repeatedDuration_); repeatedTimestamp_.Add(other.repeatedTimestamp_); repeatedFieldmask_.Add(other.repeatedFieldmask_); @@ -3728,6 +3786,9 @@ case OneofFieldOneofCase.OneofEnum: OneofEnum = other.OneofEnum; break; + case OneofFieldOneofCase.OneofNullValue: + OneofNullValue = other.OneofNullValue; + break; } _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); @@ -4202,6 +4263,11 @@ oneofFieldCase_ = OneofFieldOneofCase.OneofEnum; break; } + case 960: { + oneofField_ = input.ReadEnum(); + oneofFieldCase_ = OneofFieldOneofCase.OneofNullValue; + break; + } case 1610: { bool? value = _single_optionalBoolWrapper_codec.Read(input); if (optionalBoolWrapper_ == null || value != false) { @@ -4343,6 +4409,10 @@ input.ReadMessage(OptionalValue); break; } + case 2456: { + OptionalNullValue = (global::Google.Protobuf.WellKnownTypes.NullValue) input.ReadEnum(); + break; + } case 2490: { repeatedDuration_.AddEntriesFrom(input, _repeated_repeatedDuration_codec); break; @@ -4915,6 +4985,11 @@ oneofFieldCase_ = OneofFieldOneofCase.OneofEnum; break; } + case 960: { + oneofField_ = input.ReadEnum(); + oneofFieldCase_ = OneofFieldOneofCase.OneofNullValue; + break; + } case 1610: { bool? value = _single_optionalBoolWrapper_codec.Read(ref input); if (optionalBoolWrapper_ == null || value != false) { @@ -5056,6 +5131,10 @@ input.ReadMessage(OptionalValue); break; } + case 2456: { + OptionalNullValue = (global::Google.Protobuf.WellKnownTypes.NullValue) input.ReadEnum(); + break; + } case 2490: { repeatedDuration_.AddEntriesFrom(ref input, _repeated_repeatedDuration_codec); break;
diff --git a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestProto3Optional.cs b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestProto3Optional.cs index 451709f..7d3a238 100644 --- a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestProto3Optional.cs +++ b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestProto3Optional.cs
@@ -55,12 +55,19 @@ "X2Jvb2xCEgoQX29wdGlvbmFsX3N0cmluZ0IRCg9fb3B0aW9uYWxfYnl0ZXNC", "EAoOX29wdGlvbmFsX2NvcmRCGgoYX29wdGlvbmFsX25lc3RlZF9tZXNzYWdl", "QhYKFF9sYXp5X25lc3RlZF9tZXNzYWdlQhcKFV9vcHRpb25hbF9uZXN0ZWRf", - "ZW51bUIlCiFjb20uZ29vZ2xlLnByb3RvYnVmLnRlc3RpbmcucHJvdG9QAWIG", - "cHJvdG8z")); + "ZW51bSKJAgoZVGVzdFByb3RvM09wdGlvbmFsTWVzc2FnZRJSCg5uZXN0ZWRf", + "bWVzc2FnZRgBIAEoCzI6LnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RQcm90bzNP", + "cHRpb25hbE1lc3NhZ2UuTmVzdGVkTWVzc2FnZRJgChdvcHRpb25hbF9uZXN0", + "ZWRfbWVzc2FnZRgCIAEoCzI6LnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RQcm90", + "bzNPcHRpb25hbE1lc3NhZ2UuTmVzdGVkTWVzc2FnZUgAiAEBGhoKDU5lc3Rl", + "ZE1lc3NhZ2USCQoBcxgBIAEoCUIaChhfb3B0aW9uYWxfbmVzdGVkX21lc3Nh", + "Z2VCJQohY29tLmdvb2dsZS5wcm90b2J1Zi50ZXN0aW5nLnByb3RvUAFiBnBy", + "b3RvMw==")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, 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.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)}) })); } #endregion @@ -1377,6 +1384,411 @@ } + public sealed partial class TestProto3OptionalMessage : pb::IMessage<TestProto3OptionalMessage> + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + , pb::IBufferMessage + #endif + { + private static readonly pb::MessageParser<TestProto3OptionalMessage> _parser = new pb::MessageParser<TestProto3OptionalMessage>(() => new TestProto3OptionalMessage()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser<TestProto3OptionalMessage> Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::ProtobufUnittest.UnittestProto3OptionalReflection.Descriptor.MessageTypes[1]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public TestProto3OptionalMessage() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public TestProto3OptionalMessage(TestProto3OptionalMessage other) : this() { + nestedMessage_ = other.nestedMessage_ != null ? other.nestedMessage_.Clone() : null; + optionalNestedMessage_ = other.optionalNestedMessage_ != null ? other.optionalNestedMessage_.Clone() : null; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public TestProto3OptionalMessage Clone() { + return new TestProto3OptionalMessage(this); + } + + /// <summary>Field number for the "nested_message" field.</summary> + public const int NestedMessageFieldNumber = 1; + private global::ProtobufUnittest.TestProto3OptionalMessage.Types.NestedMessage nestedMessage_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::ProtobufUnittest.TestProto3OptionalMessage.Types.NestedMessage NestedMessage { + get { return nestedMessage_; } + set { + nestedMessage_ = value; + } + } + + /// <summary>Field number for the "optional_nested_message" field.</summary> + public const int OptionalNestedMessageFieldNumber = 2; + private global::ProtobufUnittest.TestProto3OptionalMessage.Types.NestedMessage optionalNestedMessage_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::ProtobufUnittest.TestProto3OptionalMessage.Types.NestedMessage OptionalNestedMessage { + get { return optionalNestedMessage_; } + set { + optionalNestedMessage_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as TestProto3OptionalMessage); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(TestProto3OptionalMessage other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (!object.Equals(NestedMessage, other.NestedMessage)) return false; + if (!object.Equals(OptionalNestedMessage, other.OptionalNestedMessage)) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (nestedMessage_ != null) hash ^= NestedMessage.GetHashCode(); + if (optionalNestedMessage_ != null) hash ^= OptionalNestedMessage.GetHashCode(); + 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 (nestedMessage_ != null) { + output.WriteRawTag(10); + output.WriteMessage(NestedMessage); + } + if (optionalNestedMessage_ != null) { + output.WriteRawTag(18); + output.WriteMessage(OptionalNestedMessage); + } + 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 (nestedMessage_ != null) { + output.WriteRawTag(10); + output.WriteMessage(NestedMessage); + } + if (optionalNestedMessage_ != null) { + output.WriteRawTag(18); + output.WriteMessage(OptionalNestedMessage); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (nestedMessage_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(NestedMessage); + } + if (optionalNestedMessage_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(OptionalNestedMessage); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(TestProto3OptionalMessage other) { + if (other == null) { + return; + } + if (other.nestedMessage_ != null) { + if (nestedMessage_ == null) { + NestedMessage = new global::ProtobufUnittest.TestProto3OptionalMessage.Types.NestedMessage(); + } + NestedMessage.MergeFrom(other.NestedMessage); + } + if (other.optionalNestedMessage_ != null) { + if (optionalNestedMessage_ == null) { + OptionalNestedMessage = new global::ProtobufUnittest.TestProto3OptionalMessage.Types.NestedMessage(); + } + OptionalNestedMessage.MergeFrom(other.OptionalNestedMessage); + } + _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; + case 10: { + if (nestedMessage_ == null) { + NestedMessage = new global::ProtobufUnittest.TestProto3OptionalMessage.Types.NestedMessage(); + } + input.ReadMessage(NestedMessage); + break; + } + case 18: { + if (optionalNestedMessage_ == null) { + OptionalNestedMessage = new global::ProtobufUnittest.TestProto3OptionalMessage.Types.NestedMessage(); + } + input.ReadMessage(OptionalNestedMessage); + 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; + case 10: { + if (nestedMessage_ == null) { + NestedMessage = new global::ProtobufUnittest.TestProto3OptionalMessage.Types.NestedMessage(); + } + input.ReadMessage(NestedMessage); + break; + } + case 18: { + if (optionalNestedMessage_ == null) { + OptionalNestedMessage = new global::ProtobufUnittest.TestProto3OptionalMessage.Types.NestedMessage(); + } + input.ReadMessage(OptionalNestedMessage); + break; + } + } + } + } + #endif + + #region Nested types + /// <summary>Container for nested types declared in the TestProto3OptionalMessage message type.</summary> + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static partial class Types { + public sealed partial class NestedMessage : pb::IMessage<NestedMessage> + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + , pb::IBufferMessage + #endif + { + private static readonly pb::MessageParser<NestedMessage> _parser = new pb::MessageParser<NestedMessage>(() => new NestedMessage()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser<NestedMessage> Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::ProtobufUnittest.TestProto3OptionalMessage.Descriptor.NestedTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public NestedMessage() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public NestedMessage(NestedMessage other) : this() { + s_ = other.s_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public NestedMessage Clone() { + return new NestedMessage(this); + } + + /// <summary>Field number for the "s" field.</summary> + public const int SFieldNumber = 1; + private string s_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string S { + get { return s_; } + set { + s_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as NestedMessage); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(NestedMessage other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (S != other.S) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (S.Length != 0) hash ^= S.GetHashCode(); + 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 (S.Length != 0) { + output.WriteRawTag(10); + output.WriteString(S); + } + 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 (S.Length != 0) { + output.WriteRawTag(10); + output.WriteString(S); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (S.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(S); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(NestedMessage other) { + if (other == null) { + return; + } + if (other.S.Length != 0) { + S = other.S; + } + _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; + case 10: { + S = input.ReadString(); + 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; + case 10: { + S = input.ReadString(); + break; + } + } + } + } + #endif + + } + + } + #endregion + + } + #endregion }
diff --git a/csharp/src/Google.Protobuf.Test/testprotos.pb b/csharp/src/Google.Protobuf.Test/testprotos.pb index 8aedcdb..bde0dae 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/Reflection/Descriptor.cs b/csharp/src/Google.Protobuf/Reflection/Descriptor.cs index df92228..0a1f4a7 100644 --- a/csharp/src/Google.Protobuf/Reflection/Descriptor.cs +++ b/csharp/src/Google.Protobuf/Reflection/Descriptor.cs
@@ -155,10 +155,9 @@ "dGF0aW9uGAEgAygLMi0uZ29vZ2xlLnByb3RvYnVmLkdlbmVyYXRlZENvZGVJ", "bmZvLkFubm90YXRpb24aTwoKQW5ub3RhdGlvbhIQCgRwYXRoGAEgAygFQgIQ", "ARITCgtzb3VyY2VfZmlsZRgCIAEoCRINCgViZWdpbhgDIAEoBRILCgNlbmQY", - "BCABKAVCjwEKE2NvbS5nb29nbGUucHJvdG9idWZCEERlc2NyaXB0b3JQcm90", - "b3NIAVo+Z2l0aHViLmNvbS9nb2xhbmcvcHJvdG9idWYvcHJvdG9jLWdlbi1n", - "by9kZXNjcmlwdG9yO2Rlc2NyaXB0b3L4AQGiAgNHUEKqAhpHb29nbGUuUHJv", - "dG9idWYuUmVmbGVjdGlvbg==")); + "BCABKAVCfgoTY29tLmdvb2dsZS5wcm90b2J1ZkIQRGVzY3JpcHRvclByb3Rv", + "c0gBWi1nb29nbGUuZ29sYW5nLm9yZy9wcm90b2J1Zi90eXBlcy9kZXNjcmlw", + "dG9ycGL4AQGiAgNHUEKqAhpHb29nbGUuUHJvdG9idWYuUmVmbGVjdGlvbg==")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] {
diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Any.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Any.cs index 2b33cd4..60ae03d 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/Any.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/Any.cs
@@ -25,10 +25,10 @@ byte[] descriptorData = global::System.Convert.FromBase64String( string.Concat( "Chlnb29nbGUvcHJvdG9idWYvYW55LnByb3RvEg9nb29nbGUucHJvdG9idWYi", - "JgoDQW55EhAKCHR5cGVfdXJsGAEgASgJEg0KBXZhbHVlGAIgASgMQm8KE2Nv", - "bS5nb29nbGUucHJvdG9idWZCCEFueVByb3RvUAFaJWdpdGh1Yi5jb20vZ29s", - "YW5nL3Byb3RvYnVmL3B0eXBlcy9hbnmiAgNHUEKqAh5Hb29nbGUuUHJvdG9i", - "dWYuV2VsbEtub3duVHlwZXNiBnByb3RvMw==")); + "JgoDQW55EhAKCHR5cGVfdXJsGAEgASgJEg0KBXZhbHVlGAIgASgMQnYKE2Nv", + "bS5nb29nbGUucHJvdG9idWZCCEFueVByb3RvUAFaLGdvb2dsZS5nb2xhbmcu", + "b3JnL3Byb3RvYnVmL3R5cGVzL2tub3duL2FueXBiogIDR1BCqgIeR29vZ2xl", + "LlByb3RvYnVmLldlbGxLbm93blR5cGVzYgZwcm90bzM=")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] { @@ -78,10 +78,13 @@ /// Example 4: Pack and unpack a message in Go /// /// foo := &pb.Foo{...} - /// any, err := ptypes.MarshalAny(foo) + /// any, err := anypb.New(foo) + /// if err != nil { + /// ... + /// } /// ... /// foo := &pb.Foo{} - /// if err := ptypes.UnmarshalAny(any, foo); err != nil { + /// if err := any.UnmarshalTo(foo); err != nil { /// ... /// } ///
diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Api.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Api.cs index 6bc0821..50d79bf 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/Api.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/Api.cs
@@ -37,10 +37,10 @@ "ChFyZXNwb25zZV90eXBlX3VybBgEIAEoCRIaChJyZXNwb25zZV9zdHJlYW1p", "bmcYBSABKAgSKAoHb3B0aW9ucxgGIAMoCzIXLmdvb2dsZS5wcm90b2J1Zi5P", "cHRpb24SJwoGc3ludGF4GAcgASgOMhcuZ29vZ2xlLnByb3RvYnVmLlN5bnRh", - "eCIjCgVNaXhpbhIMCgRuYW1lGAEgASgJEgwKBHJvb3QYAiABKAlCdQoTY29t", - "Lmdvb2dsZS5wcm90b2J1ZkIIQXBpUHJvdG9QAVorZ29vZ2xlLmdvbGFuZy5v", - "cmcvZ2VucHJvdG8vcHJvdG9idWYvYXBpO2FwaaICA0dQQqoCHkdvb2dsZS5Q", - "cm90b2J1Zi5XZWxsS25vd25UeXBlc2IGcHJvdG8z")); + "eCIjCgVNaXhpbhIMCgRuYW1lGAEgASgJEgwKBHJvb3QYAiABKAlCdgoTY29t", + "Lmdvb2dsZS5wcm90b2J1ZkIIQXBpUHJvdG9QAVosZ29vZ2xlLmdvbGFuZy5v", + "cmcvcHJvdG9idWYvdHlwZXMva25vd24vYXBpcGKiAgNHUEKqAh5Hb29nbGUu", + "UHJvdG9idWYuV2VsbEtub3duVHlwZXNiBnByb3RvMw==")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { global::Google.Protobuf.WellKnownTypes.SourceContextReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.TypeReflection.Descriptor, }, new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] {
diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs index 2d479ba..2a653a3 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs
@@ -26,10 +26,10 @@ string.Concat( "Ch5nb29nbGUvcHJvdG9idWYvZHVyYXRpb24ucHJvdG8SD2dvb2dsZS5wcm90", "b2J1ZiIqCghEdXJhdGlvbhIPCgdzZWNvbmRzGAEgASgDEg0KBW5hbm9zGAIg", - "ASgFQnwKE2NvbS5nb29nbGUucHJvdG9idWZCDUR1cmF0aW9uUHJvdG9QAVoq", - "Z2l0aHViLmNvbS9nb2xhbmcvcHJvdG9idWYvcHR5cGVzL2R1cmF0aW9u+AEB", - "ogIDR1BCqgIeR29vZ2xlLlByb3RvYnVmLldlbGxLbm93blR5cGVzYgZwcm90", - "bzM=")); + "ASgFQoMBChNjb20uZ29vZ2xlLnByb3RvYnVmQg1EdXJhdGlvblByb3RvUAFa", + "MWdvb2dsZS5nb2xhbmcub3JnL3Byb3RvYnVmL3R5cGVzL2tub3duL2R1cmF0", + "aW9ucGL4AQGiAgNHUEKqAh5Hb29nbGUuUHJvdG9idWYuV2VsbEtub3duVHlw", + "ZXNiBnByb3RvMw==")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] {
diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Empty.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Empty.cs index ce820cb..e2e3518 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/Empty.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/Empty.cs
@@ -25,10 +25,10 @@ byte[] descriptorData = global::System.Convert.FromBase64String( string.Concat( "Chtnb29nbGUvcHJvdG9idWYvZW1wdHkucHJvdG8SD2dvb2dsZS5wcm90b2J1", - "ZiIHCgVFbXB0eUJ2ChNjb20uZ29vZ2xlLnByb3RvYnVmQgpFbXB0eVByb3Rv", - "UAFaJ2dpdGh1Yi5jb20vZ29sYW5nL3Byb3RvYnVmL3B0eXBlcy9lbXB0efgB", - "AaICA0dQQqoCHkdvb2dsZS5Qcm90b2J1Zi5XZWxsS25vd25UeXBlc2IGcHJv", - "dG8z")); + "ZiIHCgVFbXB0eUJ9ChNjb20uZ29vZ2xlLnByb3RvYnVmQgpFbXB0eVByb3Rv", + "UAFaLmdvb2dsZS5nb2xhbmcub3JnL3Byb3RvYnVmL3R5cGVzL2tub3duL2Vt", + "cHR5cGL4AQGiAgNHUEKqAh5Hb29nbGUuUHJvdG9idWYuV2VsbEtub3duVHlw", + "ZXNiBnByb3RvMw==")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] {
diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs b/csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs index ee53861..d5da314 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs
@@ -25,11 +25,10 @@ byte[] descriptorData = global::System.Convert.FromBase64String( string.Concat( "CiBnb29nbGUvcHJvdG9idWYvZmllbGRfbWFzay5wcm90bxIPZ29vZ2xlLnBy", - "b3RvYnVmIhoKCUZpZWxkTWFzaxINCgVwYXRocxgBIAMoCUKMAQoTY29tLmdv", - "b2dsZS5wcm90b2J1ZkIORmllbGRNYXNrUHJvdG9QAVo5Z29vZ2xlLmdvbGFu", - "Zy5vcmcvZ2VucHJvdG8vcHJvdG9idWYvZmllbGRfbWFzaztmaWVsZF9tYXNr", - "+AEBogIDR1BCqgIeR29vZ2xlLlByb3RvYnVmLldlbGxLbm93blR5cGVzYgZw", - "cm90bzM=")); + "b3RvYnVmIhoKCUZpZWxkTWFzaxINCgVwYXRocxgBIAMoCUKFAQoTY29tLmdv", + "b2dsZS5wcm90b2J1ZkIORmllbGRNYXNrUHJvdG9QAVoyZ29vZ2xlLmdvbGFu", + "Zy5vcmcvcHJvdG9idWYvdHlwZXMva25vd24vZmllbGRtYXNrcGL4AQGiAgNH", + "UEKqAh5Hb29nbGUuUHJvdG9idWYuV2VsbEtub3duVHlwZXNiBnByb3RvMw==")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] {
diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/SourceContext.cs b/csharp/src/Google.Protobuf/WellKnownTypes/SourceContext.cs index 38240bb..5fe9b89 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/SourceContext.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/SourceContext.cs
@@ -26,10 +26,10 @@ string.Concat( "CiRnb29nbGUvcHJvdG9idWYvc291cmNlX2NvbnRleHQucHJvdG8SD2dvb2ds", "ZS5wcm90b2J1ZiIiCg1Tb3VyY2VDb250ZXh0EhEKCWZpbGVfbmFtZRgBIAEo", - "CUKVAQoTY29tLmdvb2dsZS5wcm90b2J1ZkISU291cmNlQ29udGV4dFByb3Rv", - "UAFaQWdvb2dsZS5nb2xhbmcub3JnL2dlbnByb3RvL3Byb3RvYnVmL3NvdXJj", - "ZV9jb250ZXh0O3NvdXJjZV9jb250ZXh0ogIDR1BCqgIeR29vZ2xlLlByb3Rv", - "YnVmLldlbGxLbm93blR5cGVzYgZwcm90bzM=")); + "CUKKAQoTY29tLmdvb2dsZS5wcm90b2J1ZkISU291cmNlQ29udGV4dFByb3Rv", + "UAFaNmdvb2dsZS5nb2xhbmcub3JnL3Byb3RvYnVmL3R5cGVzL2tub3duL3Nv", + "dXJjZWNvbnRleHRwYqICA0dQQqoCHkdvb2dsZS5Qcm90b2J1Zi5XZWxsS25v", + "d25UeXBlc2IGcHJvdG8z")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] {
diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs index 42d37ca..0bbb1fc 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs
@@ -35,10 +35,10 @@ "ABIwCgpsaXN0X3ZhbHVlGAYgASgLMhouZ29vZ2xlLnByb3RvYnVmLkxpc3RW", "YWx1ZUgAQgYKBGtpbmQiMwoJTGlzdFZhbHVlEiYKBnZhbHVlcxgBIAMoCzIW", "Lmdvb2dsZS5wcm90b2J1Zi5WYWx1ZSobCglOdWxsVmFsdWUSDgoKTlVMTF9W", - "QUxVRRAAQoEBChNjb20uZ29vZ2xlLnByb3RvYnVmQgtTdHJ1Y3RQcm90b1AB", - "WjFnaXRodWIuY29tL2dvbGFuZy9wcm90b2J1Zi9wdHlwZXMvc3RydWN0O3N0", - "cnVjdHBi+AEBogIDR1BCqgIeR29vZ2xlLlByb3RvYnVmLldlbGxLbm93blR5", - "cGVzYgZwcm90bzM=")); + "QUxVRRAAQn8KE2NvbS5nb29nbGUucHJvdG9idWZCC1N0cnVjdFByb3RvUAFa", + "L2dvb2dsZS5nb2xhbmcub3JnL3Byb3RvYnVmL3R5cGVzL2tub3duL3N0cnVj", + "dHBi+AEBogIDR1BCqgIeR29vZ2xlLlByb3RvYnVmLldlbGxLbm93blR5cGVz", + "YgZwcm90bzM=")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Google.Protobuf.WellKnownTypes.NullValue), }, null, new pbr::GeneratedClrTypeInfo[] {
diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs index b2f5d35..c75ef0f 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs
@@ -26,10 +26,10 @@ string.Concat( "Ch9nb29nbGUvcHJvdG9idWYvdGltZXN0YW1wLnByb3RvEg9nb29nbGUucHJv", "dG9idWYiKwoJVGltZXN0YW1wEg8KB3NlY29uZHMYASABKAMSDQoFbmFub3MY", - "AiABKAVCfgoTY29tLmdvb2dsZS5wcm90b2J1ZkIOVGltZXN0YW1wUHJvdG9Q", - "AVorZ2l0aHViLmNvbS9nb2xhbmcvcHJvdG9idWYvcHR5cGVzL3RpbWVzdGFt", - "cPgBAaICA0dQQqoCHkdvb2dsZS5Qcm90b2J1Zi5XZWxsS25vd25UeXBlc2IG", - "cHJvdG8z")); + "AiABKAVChQEKE2NvbS5nb29nbGUucHJvdG9idWZCDlRpbWVzdGFtcFByb3Rv", + "UAFaMmdvb2dsZS5nb2xhbmcub3JnL3Byb3RvYnVmL3R5cGVzL2tub3duL3Rp", + "bWVzdGFtcHBi+AEBogIDR1BCqgIeR29vZ2xlLlByb3RvYnVmLldlbGxLbm93", + "blR5cGVzYgZwcm90bzM=")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] {
diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Type.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Type.cs index c62095a..f5dfdb7 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/Type.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/Type.cs
@@ -56,10 +56,10 @@ "ASgFEigKB29wdGlvbnMYAyADKAsyFy5nb29nbGUucHJvdG9idWYuT3B0aW9u", "IjsKBk9wdGlvbhIMCgRuYW1lGAEgASgJEiMKBXZhbHVlGAIgASgLMhQuZ29v", "Z2xlLnByb3RvYnVmLkFueSouCgZTeW50YXgSEQoNU1lOVEFYX1BST1RPMhAA", - "EhEKDVNZTlRBWF9QUk9UTzMQAUJ9ChNjb20uZ29vZ2xlLnByb3RvYnVmQglU", - "eXBlUHJvdG9QAVovZ29vZ2xlLmdvbGFuZy5vcmcvZ2VucHJvdG8vcHJvdG9i", - "dWYvcHR5cGU7cHR5cGX4AQGiAgNHUEKqAh5Hb29nbGUuUHJvdG9idWYuV2Vs", - "bEtub3duVHlwZXNiBnByb3RvMw==")); + "EhEKDVNZTlRBWF9QUk9UTzMQAUJ7ChNjb20uZ29vZ2xlLnByb3RvYnVmQglU", + "eXBlUHJvdG9QAVotZ29vZ2xlLmdvbGFuZy5vcmcvcHJvdG9idWYvdHlwZXMv", + "a25vd24vdHlwZXBi+AEBogIDR1BCqgIeR29vZ2xlLlByb3RvYnVmLldlbGxL", + "bm93blR5cGVzYgZwcm90bzM=")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { global::Google.Protobuf.WellKnownTypes.AnyReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.SourceContextReflection.Descriptor, }, new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Google.Protobuf.WellKnownTypes.Syntax), }, null, new pbr::GeneratedClrTypeInfo[] {
diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Wrappers.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Wrappers.cs index 5bf47dc..01d3121 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/Wrappers.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/Wrappers.cs
@@ -30,10 +30,11 @@ "KAMiHAoLVUludDY0VmFsdWUSDQoFdmFsdWUYASABKAQiGwoKSW50MzJWYWx1", "ZRINCgV2YWx1ZRgBIAEoBSIcCgtVSW50MzJWYWx1ZRINCgV2YWx1ZRgBIAEo", "DSIaCglCb29sVmFsdWUSDQoFdmFsdWUYASABKAgiHAoLU3RyaW5nVmFsdWUS", - "DQoFdmFsdWUYASABKAkiGwoKQnl0ZXNWYWx1ZRINCgV2YWx1ZRgBIAEoDEJ8", - "ChNjb20uZ29vZ2xlLnByb3RvYnVmQg1XcmFwcGVyc1Byb3RvUAFaKmdpdGh1", - "Yi5jb20vZ29sYW5nL3Byb3RvYnVmL3B0eXBlcy93cmFwcGVyc/gBAaICA0dQ", - "QqoCHkdvb2dsZS5Qcm90b2J1Zi5XZWxsS25vd25UeXBlc2IGcHJvdG8z")); + "DQoFdmFsdWUYASABKAkiGwoKQnl0ZXNWYWx1ZRINCgV2YWx1ZRgBIAEoDEKD", + "AQoTY29tLmdvb2dsZS5wcm90b2J1ZkINV3JhcHBlcnNQcm90b1ABWjFnb29n", + "bGUuZ29sYW5nLm9yZy9wcm90b2J1Zi90eXBlcy9rbm93bi93cmFwcGVyc3Bi", + "+AEBogIDR1BCqgIeR29vZ2xlLlByb3RvYnVmLldlbGxLbm93blR5cGVzYgZw", + "cm90bzM=")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] {
diff --git a/js/gulpfile.js b/js/gulpfile.js index 2e72a88..8137b90 100644 --- a/js/gulpfile.js +++ b/js/gulpfile.js
@@ -71,13 +71,16 @@ }); }); -gulp.task('genproto_group2_closure', function (cb) { - exec(protoc + ' --experimental_allow_proto3_optional --js_out=library=testproto_libs2,binary:. -I ../src -I . -I commonjs ' + group2Protos.join(' '), - function (err, stdout, stderr) { - console.log(stdout); - console.log(stderr); - cb(err); - }); +gulp.task('genproto_group2_closure', function(cb) { + exec( + protoc + + ' --experimental_allow_proto3_optional --js_out=library=testproto_libs2,binary:. -I ../src -I . -I commonjs ' + + group2Protos.join(' '), + function(err, stdout, stderr) { + console.log(stdout); + console.log(stderr); + cb(err); + }); }); gulp.task('genproto_well_known_types_commonjs', function (cb) { @@ -98,13 +101,16 @@ }); }); -gulp.task('genproto_group2_commonjs', function (cb) { - exec('mkdir -p commonjs_out && ' + protoc + ' --experimental_allow_proto3_optional --js_out=import_style=commonjs,binary:commonjs_out -I ../src -I commonjs -I . ' + group2Protos.join(' '), - function (err, stdout, stderr) { - console.log(stdout); - console.log(stderr); - cb(err); - }); +gulp.task('genproto_group2_commonjs', function(cb) { + exec( + 'mkdir -p commonjs_out && ' + protoc + + ' --experimental_allow_proto3_optional --js_out=import_style=commonjs,binary:commonjs_out -I ../src -I commonjs -I . ' + + group2Protos.join(' '), + function(err, stdout, stderr) { + console.log(stdout); + console.log(stderr); + cb(err); + }); }); gulp.task('genproto_commonjs_wellknowntypes', function (cb) {
diff --git a/js/proto3_test.js b/js/proto3_test.js index bd7cce5..fd59ae5 100644 --- a/js/proto3_test.js +++ b/js/proto3_test.js
@@ -130,8 +130,8 @@ assertEquals(msg.getSingularBytes_asU8().length, 0); assertEquals(msg.getSingularBytes_asB64(), ''); - assertEquals(msg.getSingularForeignEnum(), - proto.jspb.test.Proto3Enum.PROTO3_FOO); + assertEquals( + msg.getSingularForeignEnum(), proto.jspb.test.Proto3Enum.PROTO3_FOO); assertEquals(msg.getSingularForeignMessage(), undefined); assertEquals(msg.getSingularForeignMessage(), undefined); @@ -201,7 +201,7 @@ assertTrue(msg.hasOptionalInt64()); assertFalse(msg.hasOptionalString()); - msg.setOptionalString(""); + msg.setOptionalString(''); assertTrue(msg.hasOptionalString()); // Now the proto will have a non-zero size, even though its values are 0. @@ -224,7 +224,7 @@ /** * Test that all fields can be set ,and read via a serialization roundtrip. */ - it('testProto3FieldSetGet', function () { + it('testProto3FieldSetGet', function() { var msg = new proto.jspb.test.TestProto3(); msg.setSingularInt32(-42); @@ -288,8 +288,8 @@ assertEquals(msg.getSingularString(), 'hello world'); assertEquals(true, bytesCompare(msg.getSingularBytes(), BYTES)); assertEquals(msg.getSingularForeignMessage().getC(), 16); - assertEquals(msg.getSingularForeignEnum(), - proto.jspb.test.Proto3Enum.PROTO3_BAR); + assertEquals( + msg.getSingularForeignEnum(), proto.jspb.test.Proto3Enum.PROTO3_BAR); assertElementsEquals(msg.getRepeatedInt32List(), [-42]); assertElementsEquals(msg.getRepeatedInt64List(), [-0x7fffffff00000000]);
diff --git a/js/proto3_test.proto b/js/proto3_test.proto index 1f6bbed..14f104e 100644 --- a/js/proto3_test.proto +++ b/js/proto3_test.proto
@@ -30,10 +30,10 @@ syntax = "proto3"; -import "testbinary.proto"; - package jspb.test; +import "testbinary.proto"; + message TestProto3 { int32 singular_int32 = 1; int64 singular_int64 = 2; @@ -71,7 +71,7 @@ optional bytes optional_bytes = 135; optional ForeignMessage optional_foreign_message = 136; - optional Proto3Enum optional_foreign_enum =137; + optional Proto3Enum optional_foreign_enum = 137; repeated int32 repeated_int32 = 31; repeated int64 repeated_int64 = 32; @@ -92,7 +92,6 @@ repeated ForeignMessage repeated_foreign_message = 49; repeated Proto3Enum repeated_foreign_enum = 52; - oneof oneof_field { uint32 oneof_uint32 = 111; ForeignMessage oneof_foreign_message = 112;
diff --git a/objectivec/GPBAny.pbobjc.h b/objectivec/GPBAny.pbobjc.h index 288d552..21b7dcf 100644 --- a/objectivec/GPBAny.pbobjc.h +++ b/objectivec/GPBAny.pbobjc.h
@@ -94,10 +94,13 @@ * Example 4: Pack and unpack a message in Go * * foo := &pb.Foo{...} - * any, err := ptypes.MarshalAny(foo) + * any, err := anypb.New(foo) + * if err != nil { + * ... + * } * ... * foo := &pb.Foo{} - * if err := ptypes.UnmarshalAny(any, foo); err != nil { + * if err := any.UnmarshalTo(foo); err != nil { * ... * } *
diff --git a/php/src/Google/Protobuf/Internal/FieldDescriptorProto.php b/php/src/Google/Protobuf/Internal/FieldDescriptorProto.php index b43d988..a65ce70 100644 --- a/php/src/Google/Protobuf/Internal/FieldDescriptorProto.php +++ b/php/src/Google/Protobuf/Internal/FieldDescriptorProto.php
@@ -252,7 +252,7 @@ */ public function setLabel($var) { - GPBUtil::checkEnum($var, \Google\Protobuf\Internal\FieldDescriptorProto_Label::class); + GPBUtil::checkEnum($var, \Google\Protobuf\Internal\FieldDescriptorProto\Label::class); $this->label = $var; $this->has_label = true; @@ -286,7 +286,7 @@ */ public function setType($var) { - GPBUtil::checkEnum($var, \Google\Protobuf\Internal\FieldDescriptorProto_Type::class); + GPBUtil::checkEnum($var, \Google\Protobuf\Internal\FieldDescriptorProto\Type::class); $this->type = $var; $this->has_type = true;
diff --git a/php/src/Google/Protobuf/Internal/FieldOptions.php b/php/src/Google/Protobuf/Internal/FieldOptions.php index 2ccc418..c57077d 100644 --- a/php/src/Google/Protobuf/Internal/FieldOptions.php +++ b/php/src/Google/Protobuf/Internal/FieldOptions.php
@@ -202,7 +202,7 @@ */ public function setCtype($var) { - GPBUtil::checkEnum($var, \Google\Protobuf\Internal\FieldOptions_CType::class); + GPBUtil::checkEnum($var, \Google\Protobuf\Internal\FieldOptions\CType::class); $this->ctype = $var; $this->has_ctype = true; @@ -292,7 +292,7 @@ */ public function setJstype($var) { - GPBUtil::checkEnum($var, \Google\Protobuf\Internal\FieldOptions_JSType::class); + GPBUtil::checkEnum($var, \Google\Protobuf\Internal\FieldOptions\JSType::class); $this->jstype = $var; $this->has_jstype = true;
diff --git a/php/src/Google/Protobuf/Internal/FileOptions.php b/php/src/Google/Protobuf/Internal/FileOptions.php index 892a6a8..666c6c9 100644 --- a/php/src/Google/Protobuf/Internal/FileOptions.php +++ b/php/src/Google/Protobuf/Internal/FileOptions.php
@@ -506,7 +506,7 @@ */ public function setOptimizeFor($var) { - GPBUtil::checkEnum($var, \Google\Protobuf\Internal\FileOptions_OptimizeMode::class); + GPBUtil::checkEnum($var, \Google\Protobuf\Internal\FileOptions\OptimizeMode::class); $this->optimize_for = $var; $this->has_optimize_for = true;
diff --git a/php/src/Google/Protobuf/Internal/MethodOptions.php b/php/src/Google/Protobuf/Internal/MethodOptions.php index 6a4c92d..f96dd3c 100644 --- a/php/src/Google/Protobuf/Internal/MethodOptions.php +++ b/php/src/Google/Protobuf/Internal/MethodOptions.php
@@ -113,7 +113,7 @@ */ public function setIdempotencyLevel($var) { - GPBUtil::checkEnum($var, \Google\Protobuf\Internal\MethodOptions_IdempotencyLevel::class); + GPBUtil::checkEnum($var, \Google\Protobuf\Internal\MethodOptions\IdempotencyLevel::class); $this->idempotency_level = $var; $this->has_idempotency_level = true;
diff --git a/python/google/protobuf/internal/json_format_test.py b/python/google/protobuf/internal/json_format_test.py index 68aa21c..6a60348 100755 --- a/python/google/protobuf/internal/json_format_test.py +++ b/python/google/protobuf/internal/json_format_test.py
@@ -636,6 +636,20 @@ parsed_message = json_format_proto3_pb2.TestListValue() self.CheckParseBack(message, parsed_message) + def testNullValue(self): + message = json_format_proto3_pb2.TestOneof() + message.oneof_null_value = 0 + self.assertEqual(json_format.MessageToJson(message), + '{\n "oneofNullValue": null\n}') + parsed_message = json_format_proto3_pb2.TestOneof() + self.CheckParseBack(message, parsed_message) + # Check old format is also accepted + new_message = json_format_proto3_pb2.TestOneof() + json_format.Parse('{\n "oneofNullValue": "NULL_VALUE"\n}', + new_message) + self.assertEqual(json_format.MessageToJson(new_message), + '{\n "oneofNullValue": null\n}') + def testAnyMessage(self): message = json_format_proto3_pb2.TestAny() value1 = json_format_proto3_pb2.MessageType()
diff --git a/python/google/protobuf/internal/text_format_test.py b/python/google/protobuf/internal/text_format_test.py index 9e84185..987116a 100755 --- a/python/google/protobuf/internal/text_format_test.py +++ b/python/google/protobuf/internal/text_format_test.py
@@ -142,6 +142,8 @@ message.repeated_float.append(1.234e10) message.repeated_float.append(1.2345e10) message.repeated_float.append(1.23456e10) + message.repeated_float.append(float('NaN')) + message.repeated_float.append(float('inf')) message.repeated_double.append(0.0) message.repeated_double.append(0.8) message.repeated_double.append(1.0) @@ -190,6 +192,8 @@ 'repeated_float: 12340000000\n' 'repeated_float: 12345000000\n' 'repeated_float: 12345600000\n' + 'repeated_float: nan\n' + 'repeated_float: inf\n' 'repeated_double: 0\n' 'repeated_double: 0.8\n' 'repeated_double: 1\n'
diff --git a/python/google/protobuf/internal/type_checkers.py b/python/google/protobuf/internal/type_checkers.py index bfde1c3..eb66f9f 100644 --- a/python/google/protobuf/internal/type_checkers.py +++ b/python/google/protobuf/internal/type_checkers.py
@@ -74,11 +74,6 @@ def ToShortestFloat(original): """Returns the shortest float that has same value in wire.""" - # Return the original value if it is not truncated. This may happen - # if someone mixes this code with an old protobuf runtime. - # TODO(jieluo): Remove it after maybe 2022. - if TruncateToFourByteFloat(original) != original: - return original # All 4 byte floats have between 6 and 9 significant digits, so we # start with 6 as the lower bound. # It has to be iterative because use '.9g' directly can not get rid
diff --git a/python/google/protobuf/json_format.py b/python/google/protobuf/json_format.py index 4d76d02..c8f5602 100644 --- a/python/google/protobuf/json_format.py +++ b/python/google/protobuf/json_format.py
@@ -286,6 +286,8 @@ elif field.cpp_type == descriptor.FieldDescriptor.CPPTYPE_ENUM: if self.use_integers_for_enums: return value + if field.enum_type.full_name == 'google.protobuf.NullValue': + return None enum_value = field.enum_type.values_by_number.get(value, None) if enum_value is not None: return enum_value.name @@ -544,6 +546,9 @@ and field.message_type.full_name == 'google.protobuf.Value'): sub_message = getattr(message, field.name) sub_message.null_value = 0 + elif (field.cpp_type == descriptor.FieldDescriptor.CPPTYPE_ENUM + and field.enum_type.full_name == 'google.protobuf.NullValue'): + setattr(message, field.name, 0) else: message.ClearField(field.name) continue
diff --git a/python/google/protobuf/text_format.py b/python/google/protobuf/text_format.py index 8387218..2a9a866 100644 --- a/python/google/protobuf/text_format.py +++ b/python/google/protobuf/text_format.py
@@ -46,19 +46,19 @@ import encodings.raw_unicode_escape # pylint: disable=unused-import import encodings.unicode_escape # pylint: disable=unused-import import io +import math import re - import six -if six.PY3: - long = int # pylint: disable=redefined-builtin,invalid-name - -# pylint: disable=g-import-not-at-top from google.protobuf.internal import decoder from google.protobuf.internal import type_checkers from google.protobuf import descriptor from google.protobuf import text_encoding +if six.PY3: + long = int # pylint: disable=redefined-builtin,invalid-name + +# pylint: disable=g-import-not-at-top __all__ = ['MessageToString', 'Parse', 'PrintMessage', 'PrintField', 'PrintFieldValue', 'Merge', 'MessageToBytes'] @@ -630,7 +630,10 @@ if self.float_format is not None: out.write('{1:{0}}'.format(self.float_format, value)) else: - out.write(str(type_checkers.ToShortestFloat(value))) + if math.isnan(value): + out.write(str(value)) + else: + out.write(str(type_checkers.ToShortestFloat(value))) elif (field.cpp_type == descriptor.FieldDescriptor.CPPTYPE_DOUBLE and self.double_format is not None): out.write('{1:{0}}'.format(self.double_format, value))
diff --git a/src/google/protobuf/any.cc b/src/google/protobuf/any.cc index a79214b..a9876fc 100644 --- a/src/google/protobuf/any.cc +++ b/src/google/protobuf/any.cc
@@ -46,7 +46,7 @@ } void AnyMetadata::PackFrom(const Message& message, - const std::string& type_url_prefix) { + StringPiece type_url_prefix) { type_url_->SetNoArena( &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString(), GetTypeUrl(message.GetDescriptor()->full_name(), type_url_prefix));
diff --git a/src/google/protobuf/any.h b/src/google/protobuf/any.h index 59dd50c..16a68ca 100644 --- a/src/google/protobuf/any.h +++ b/src/google/protobuf/any.h
@@ -82,7 +82,7 @@ InternalPackFrom(message, type_url_prefix, T::FullMessageName()); } - void PackFrom(const Message& message, const std::string& type_url_prefix); + void PackFrom(const Message& message, StringPiece type_url_prefix); // Unpacks the payload into the given message. Returns false if the message's // type doesn't match the type specified in the type URL (i.e., the full @@ -124,14 +124,14 @@ // // NOTE: this function is available publicly as: // google::protobuf::Any() // static method on the generated message type. -bool ParseAnyTypeUrl(const std::string& type_url, std::string* full_type_name); +bool ParseAnyTypeUrl(StringPiece type_url, std::string* full_type_name); // Get the proto type name and prefix from Any::type_url value. For example, // passing "type.googleapis.com/rpc.QueryOrigin" will return // "type.googleapis.com/" in *url_prefix and "rpc.QueryOrigin" in // *full_type_name. Returns false if the type_url does not have a "/" in the // type url separating the full type name. -bool ParseAnyTypeUrl(const std::string& type_url, std::string* url_prefix, +bool ParseAnyTypeUrl(StringPiece type_url, std::string* url_prefix, std::string* full_type_name); // See if message is of type google.protobuf.Any, if so, return the descriptors
diff --git a/src/google/protobuf/any.pb.cc b/src/google/protobuf/any.pb.cc index 1eba999..7eed87c 100644 --- a/src/google/protobuf/any.pb.cc +++ b/src/google/protobuf/any.pb.cc
@@ -58,10 +58,10 @@ const char descriptor_table_protodef_google_2fprotobuf_2fany_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = "\n\031google/protobuf/any.proto\022\017google.prot" "obuf\"&\n\003Any\022\020\n\010type_url\030\001 \001(\t\022\r\n\005value\030\002" - " \001(\014Bo\n\023com.google.protobufB\010AnyProtoP\001Z" - "%github.com/golang/protobuf/ptypes/any\242\002" - "\003GPB\252\002\036Google.Protobuf.WellKnownTypesb\006p" - "roto3" + " \001(\014Bv\n\023com.google.protobufB\010AnyProtoP\001Z" + ",google.golang.org/protobuf/types/known/" + "anypb\242\002\003GPB\252\002\036Google.Protobuf.WellKnownT" + "ypesb\006proto3" ; static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_google_2fprotobuf_2fany_2eproto_deps[1] = { }; @@ -70,7 +70,7 @@ }; static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_google_2fprotobuf_2fany_2eproto_once; const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fany_2eproto = { - false, false, descriptor_table_protodef_google_2fprotobuf_2fany_2eproto, "google/protobuf/any.proto", 205, + false, false, descriptor_table_protodef_google_2fprotobuf_2fany_2eproto, "google/protobuf/any.proto", 212, &descriptor_table_google_2fprotobuf_2fany_2eproto_once, descriptor_table_google_2fprotobuf_2fany_2eproto_sccs, descriptor_table_google_2fprotobuf_2fany_2eproto_deps, 1, 0, schemas, file_default_instances, TableStruct_google_2fprotobuf_2fany_2eproto::offsets, file_level_metadata_google_2fprotobuf_2fany_2eproto, 1, file_level_enum_descriptors_google_2fprotobuf_2fany_2eproto, file_level_service_descriptors_google_2fprotobuf_2fany_2eproto, @@ -91,8 +91,9 @@ return ::PROTOBUF_NAMESPACE_ID::internal::GetAnyFieldDescriptors( message, type_url_field, value_field); } -bool Any::ParseAnyTypeUrl(const string& type_url, - std::string* full_type_name) { +bool Any::ParseAnyTypeUrl( + ::PROTOBUF_NAMESPACE_ID::ConstStringParam type_url, + std::string* full_type_name) { return ::PROTOBUF_NAMESPACE_ID::internal::ParseAnyTypeUrl(type_url, full_type_name); }
diff --git a/src/google/protobuf/any.pb.h b/src/google/protobuf/any.pb.h index 426dda2..90cd342 100644 --- a/src/google/protobuf/any.pb.h +++ b/src/google/protobuf/any.pb.h
@@ -116,7 +116,7 @@ _any_metadata_.PackFrom(message); } void PackFrom(const ::PROTOBUF_NAMESPACE_ID::Message& message, - const std::string& type_url_prefix) { + ::PROTOBUF_NAMESPACE_ID::ConstStringParam type_url_prefix) { _any_metadata_.PackFrom(message, type_url_prefix); } bool UnpackTo(::PROTOBUF_NAMESPACE_ID::Message* message) const { @@ -132,7 +132,7 @@ } template <typename T, class = typename std::enable_if<!std::is_convertible<T, const ::PROTOBUF_NAMESPACE_ID::Message&>::value>::type> void PackFrom(const T& message, - const std::string& type_url_prefix) { + ::PROTOBUF_NAMESPACE_ID::ConstStringParam type_url_prefix) { _any_metadata_.PackFrom<T>(message, type_url_prefix);} template <typename T, class = typename std::enable_if<!std::is_convertible<T, const ::PROTOBUF_NAMESPACE_ID::Message&>::value>::type> bool UnpackTo(T* message) const { @@ -141,7 +141,7 @@ template<typename T> bool Is() const { return _any_metadata_.Is<T>(); } - static bool ParseAnyTypeUrl(const string& type_url, + static bool ParseAnyTypeUrl(::PROTOBUF_NAMESPACE_ID::ConstStringParam type_url, std::string* full_type_name); friend void swap(Any& a, Any& b) { a.Swap(&b);
diff --git a/src/google/protobuf/any.proto b/src/google/protobuf/any.proto index c9be854..6ed8a23 100644 --- a/src/google/protobuf/any.proto +++ b/src/google/protobuf/any.proto
@@ -33,7 +33,7 @@ package google.protobuf; option csharp_namespace = "Google.Protobuf.WellKnownTypes"; -option go_package = "github.com/golang/protobuf/ptypes/any"; +option go_package = "google.golang.org/protobuf/types/known/anypb"; option java_package = "com.google.protobuf"; option java_outer_classname = "AnyProto"; option java_multiple_files = true; @@ -77,10 +77,13 @@ // Example 4: Pack and unpack a message in Go // // foo := &pb.Foo{...} -// any, err := ptypes.MarshalAny(foo) +// any, err := anypb.New(foo) +// if err != nil { +// ... +// } // ... // foo := &pb.Foo{} -// if err := ptypes.UnmarshalAny(any, foo); err != nil { +// if err := any.UnmarshalTo(foo); err != nil { // ... // } //
diff --git a/src/google/protobuf/any_lite.cc b/src/google/protobuf/any_lite.cc index 7839381..3badb41 100644 --- a/src/google/protobuf/any_lite.cc +++ b/src/google/protobuf/any_lite.cc
@@ -100,20 +100,20 @@ HasSuffixString(type_url, type_name); } -bool ParseAnyTypeUrl(const std::string& type_url, std::string* url_prefix, +bool ParseAnyTypeUrl(StringPiece type_url, std::string* url_prefix, std::string* full_type_name) { size_t pos = type_url.find_last_of("/"); if (pos == std::string::npos || pos + 1 == type_url.size()) { return false; } if (url_prefix) { - *url_prefix = type_url.substr(0, pos + 1); + *url_prefix = std::string(type_url.substr(0, pos + 1)); } - *full_type_name = type_url.substr(pos + 1); + *full_type_name = std::string(type_url.substr(pos + 1)); return true; } -bool ParseAnyTypeUrl(const std::string& type_url, std::string* full_type_name) { +bool ParseAnyTypeUrl(StringPiece type_url, std::string* full_type_name) { return ParseAnyTypeUrl(type_url, nullptr, full_type_name); }
diff --git a/src/google/protobuf/api.pb.cc b/src/google/protobuf/api.pb.cc index 816df12..6ae678a 100644 --- a/src/google/protobuf/api.pb.cc +++ b/src/google/protobuf/api.pb.cc
@@ -144,10 +144,10 @@ "esponse_streaming\030\005 \001(\010\022(\n\007options\030\006 \003(\013" "2\027.google.protobuf.Option\022\'\n\006syntax\030\007 \001(" "\0162\027.google.protobuf.Syntax\"#\n\005Mixin\022\014\n\004n" - "ame\030\001 \001(\t\022\014\n\004root\030\002 \001(\tBu\n\023com.google.pr" - "otobufB\010ApiProtoP\001Z+google.golang.org/ge" - "nproto/protobuf/api;api\242\002\003GPB\252\002\036Google.P" - "rotobuf.WellKnownTypesb\006proto3" + "ame\030\001 \001(\t\022\014\n\004root\030\002 \001(\tBv\n\023com.google.pr" + "otobufB\010ApiProtoP\001Z,google.golang.org/pr" + "otobuf/types/known/apipb\242\002\003GPB\252\002\036Google." + "Protobuf.WellKnownTypesb\006proto3" ; static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_google_2fprotobuf_2fapi_2eproto_deps[2] = { &::descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto, @@ -160,7 +160,7 @@ }; static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_google_2fprotobuf_2fapi_2eproto_once; const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fapi_2eproto = { - false, false, descriptor_table_protodef_google_2fprotobuf_2fapi_2eproto, "google/protobuf/api.proto", 750, + false, false, descriptor_table_protodef_google_2fprotobuf_2fapi_2eproto, "google/protobuf/api.proto", 751, &descriptor_table_google_2fprotobuf_2fapi_2eproto_once, descriptor_table_google_2fprotobuf_2fapi_2eproto_sccs, descriptor_table_google_2fprotobuf_2fapi_2eproto_deps, 3, 2, schemas, file_default_instances, TableStruct_google_2fprotobuf_2fapi_2eproto::offsets, file_level_metadata_google_2fprotobuf_2fapi_2eproto, 3, file_level_enum_descriptors_google_2fprotobuf_2fapi_2eproto, file_level_service_descriptors_google_2fprotobuf_2fapi_2eproto,
diff --git a/src/google/protobuf/api.proto b/src/google/protobuf/api.proto index f37ee2f..8dd9457 100644 --- a/src/google/protobuf/api.proto +++ b/src/google/protobuf/api.proto
@@ -40,7 +40,7 @@ option java_outer_classname = "ApiProto"; option java_multiple_files = true; option objc_class_prefix = "GPB"; -option go_package = "google.golang.org/genproto/protobuf/api;api"; +option go_package = "google.golang.org/protobuf/types/known/apipb"; // Api is a light-weight descriptor for an API Interface. // @@ -52,7 +52,6 @@ // this message itself. See https://cloud.google.com/apis/design/glossary for // detailed terminology. message Api { - // The fully qualified name of this interface, including package name // followed by the interface's simple name. string name = 1; @@ -99,7 +98,6 @@ // Method represents a method of an API interface. message Method { - // The simple name of this method. string name = 1;
diff --git a/src/google/protobuf/compiler/command_line_interface.cc b/src/google/protobuf/compiler/command_line_interface.cc index 0a00c19..1ada897 100644 --- a/src/google/protobuf/compiler/command_line_interface.cc +++ b/src/google/protobuf/compiler/command_line_interface.cc
@@ -1278,8 +1278,9 @@ if (in_fallback_database) { return true; } - std::string error_str = source_tree->GetLastErrorMessage().empty() ? - strerror(errno) : source_tree->GetLastErrorMessage(); + std::string error_str = source_tree->GetLastErrorMessage().empty() + ? strerror(errno) + : source_tree->GetLastErrorMessage(); std::cerr << "Could not map to virtual file: " << *proto << ": " << error_str << std::endl; return false;
diff --git a/src/google/protobuf/compiler/cpp/cpp_map_field.cc b/src/google/protobuf/compiler/cpp/cpp_map_field.cc index 630c97e..39312b3 100644 --- a/src/google/protobuf/compiler/cpp/cpp_map_field.cc +++ b/src/google/protobuf/compiler/cpp/cpp_map_field.cc
@@ -81,13 +81,6 @@ } else { (*variables)["lite"] = "Lite"; } - - if (!IsProto3Field(descriptor) && val->type() == FieldDescriptor::TYPE_ENUM) { - const EnumValueDescriptor* default_value = val->default_value_enum(); - (*variables)["default_enum_value"] = Int32ToString(default_value->number()); - } else { - (*variables)["default_enum_value"] = "0"; - } } MapFieldGenerator::MapFieldGenerator(const FieldDescriptor* descriptor, @@ -105,8 +98,8 @@ " $map_classname$,\n" " $key_cpp$, $val_cpp$,\n" " ::$proto_ns$::internal::WireFormatLite::$key_wire_type$,\n" - " ::$proto_ns$::internal::WireFormatLite::$val_wire_type$,\n" - " $default_enum_value$ > $name$_;\n"); + " ::$proto_ns$::internal::WireFormatLite::$val_wire_type$> " + "$name$_;\n"); } void MapFieldGenerator::GenerateAccessorDeclarations(
diff --git a/src/google/protobuf/compiler/cpp/cpp_message.cc b/src/google/protobuf/compiler/cpp/cpp_message.cc index 61a2395..7c7461f 100644 --- a/src/google/protobuf/compiler/cpp/cpp_message.cc +++ b/src/google/protobuf/compiler/cpp/cpp_message.cc
@@ -268,13 +268,6 @@ "TYPE_" + ToUpper(DeclaredTypeMethodName(key->type())); vars["val_wire_type"] = "TYPE_" + ToUpper(DeclaredTypeMethodName(val->type())); - if (descriptor->file()->syntax() != FileDescriptor::SYNTAX_PROTO3 && - val->type() == FieldDescriptor::TYPE_ENUM) { - const EnumValueDescriptor* default_value = val->default_value_enum(); - vars["default_enum_value"] = Int32ToString(default_value->number()); - } else { - vars["default_enum_value"] = "0"; - } } // Does the given field have a private (internal helper only) has_$name$() @@ -631,16 +624,7 @@ MessageGenerator::~MessageGenerator() = default; size_t MessageGenerator::HasBitsSize() const { - size_t sizeof_has_bits = (max_has_bit_index_ + 31) / 32 * 4; - if (sizeof_has_bits == 0) { - // Zero-size arrays aren't technically allowed, and MSVC in particular - // doesn't like them. We still need to declare these arrays to make - // other code compile. Since this is an uncommon case, we'll just declare - // them with size 1 and waste some space. Oh well. - sizeof_has_bits = 4; - } - - return sizeof_has_bits; + return (max_has_bit_index_ + 31) / 32; } int MessageGenerator::HasBitIndex(const FieldDescriptor* field) const { @@ -1026,14 +1010,13 @@ "::$proto_ns$::internal::MapEntry$lite$<$classname$, \n" " $key_cpp$, $val_cpp$,\n" " ::$proto_ns$::internal::WireFormatLite::$key_wire_type$,\n" - " ::$proto_ns$::internal::WireFormatLite::$val_wire_type$,\n" - " $default_enum_value$ > {\n" + " ::$proto_ns$::internal::WireFormatLite::$val_wire_type$> {\n" "public:\n" " typedef ::$proto_ns$::internal::MapEntry$lite$<$classname$, \n" " $key_cpp$, $val_cpp$,\n" " ::$proto_ns$::internal::WireFormatLite::$key_wire_type$,\n" - " ::$proto_ns$::internal::WireFormatLite::$val_wire_type$,\n" - " $default_enum_value$ > SuperType;\n" + " ::$proto_ns$::internal::WireFormatLite::$val_wire_type$> " + "SuperType;\n" " $classname$();\n" " explicit $classname$(::$proto_ns$::Arena* arena);\n" " void MergeFrom(const $classname$& other);\n" @@ -1244,7 +1227,8 @@ " _any_metadata_.PackFrom(message);\n" "}\n" "void PackFrom(const ::$proto_ns$::Message& message,\n" - " const std::string& type_url_prefix) {\n" + " ::PROTOBUF_NAMESPACE_ID::ConstStringParam " + "type_url_prefix) {\n" " _any_metadata_.PackFrom(message, type_url_prefix);\n" "}\n" "bool UnpackTo(::$proto_ns$::Message* message) const {\n" @@ -1264,7 +1248,8 @@ "!std::is_convertible<T, const ::$proto_ns$::Message&>" "::value>::type>\n" "void PackFrom(const T& message,\n" - " const std::string& type_url_prefix) {\n" + " ::PROTOBUF_NAMESPACE_ID::ConstStringParam " + "type_url_prefix) {\n" " _any_metadata_.PackFrom<T>(message, type_url_prefix);" "}\n" "template <typename T, class = typename std::enable_if<" @@ -1281,7 +1266,8 @@ "}\n" "template <typename T>\n" "void PackFrom(const T& message,\n" - " const std::string& type_url_prefix) {\n" + " ::PROTOBUF_NAMESPACE_ID::ConstStringParam " + "type_url_prefix) {\n" " _any_metadata_.PackFrom(message, type_url_prefix);\n" "}\n" "template <typename T>\n" @@ -1293,7 +1279,8 @@ "template<typename T> bool Is() const {\n" " return _any_metadata_.Is<T>();\n" "}\n" - "static bool ParseAnyTypeUrl(const string& type_url,\n" + "static bool ParseAnyTypeUrl(::PROTOBUF_NAMESPACE_ID::ConstStringParam " + "type_url,\n" " std::string* full_type_name);\n"); } @@ -1515,10 +1502,9 @@ const size_t sizeof_has_bits = HasBitsSize(); const std::string has_bits_decl = - sizeof_has_bits == 0 - ? "" - : StrCat("::$proto_ns$::internal::HasBits<", - sizeof_has_bits / 4, "> _has_bits_;\n"); + sizeof_has_bits == 0 ? "" + : StrCat("::$proto_ns$::internal::HasBits<", + sizeof_has_bits, "> _has_bits_;\n"); // To minimize padding, data members are divided into three sections: // (1) members assumed to align to 8 bytes @@ -2057,8 +2043,9 @@ "}\n"); } format( - "bool $classname$::ParseAnyTypeUrl(const string& type_url,\n" - " std::string* full_type_name) {\n" + "bool $classname$::ParseAnyTypeUrl(\n" + " ::PROTOBUF_NAMESPACE_ID::ConstStringParam type_url,\n" + " std::string* full_type_name) {\n" " return ::$proto_ns$::internal::ParseAnyTypeUrl(type_url,\n" " full_type_name);\n" "}\n" @@ -3065,7 +3052,7 @@ "metadata_);\n"); if (!has_bit_indices_.empty()) { - for (int i = 0; i < HasBitsSize() / 4; ++i) { + for (int i = 0; i < HasBitsSize(); ++i) { format("swap(_has_bits_[$1$], other->_has_bits_[$1$]);\n", i); } }
diff --git a/src/google/protobuf/compiler/js/js_generator.cc b/src/google/protobuf/compiler/js/js_generator.cc index 02a8954..fd55ac1 100644 --- a/src/google/protobuf/compiler/js/js_generator.cc +++ b/src/google/protobuf/compiler/js/js_generator.cc
@@ -2687,8 +2687,7 @@ "\n" "\n", "index", JSFieldIndex(field), "oneofgroup", - (InRealOneof(field) ? (", " + JSOneofArray(options, field)) - : "")); + (InRealOneof(field) ? (", " + JSOneofArray(options, field)) : "")); if (field->is_repeated()) { GenerateRepeatedMessageHelperMethods(options, printer, field); @@ -2993,8 +2992,8 @@ "\n" "\n", "index", JSFieldIndex(field), "oneofgroup", - (InRealOneof(field) ? (", " + JSOneofArray(options, field)) : ""), - "ctor", GetMessagePath(options, field->message_type())); + (InRealOneof(field) ? (", " + JSOneofArray(options, field)) : ""), "ctor", + GetMessagePath(options, field->message_type())); } void Generator::GenerateClassExtensionFieldInfo(const GeneratorOptions& options,
diff --git a/src/google/protobuf/compiler/plugin.pb.cc b/src/google/protobuf/compiler/plugin.pb.cc index 6739215..c2e430a 100644 --- a/src/google/protobuf/compiler/plugin.pb.cc +++ b/src/google/protobuf/compiler/plugin.pb.cc
@@ -180,10 +180,9 @@ "atorResponse.File\032>\n\004File\022\014\n\004name\030\001 \001(\t\022" "\027\n\017insertion_point\030\002 \001(\t\022\017\n\007content\030\017 \001(" "\t\"8\n\007Feature\022\020\n\014FEATURE_NONE\020\000\022\033\n\027FEATUR" - "E_PROTO3_OPTIONAL\020\001Bg\n\034com.google.protob" - "uf.compilerB\014PluginProtosZ9github.com/go" - "lang/protobuf/protoc-gen-go/plugin;plugi" - "n_go" + "E_PROTO3_OPTIONAL\020\001BW\n\034com.google.protob" + "uf.compilerB\014PluginProtosZ)google.golang" + ".org/protobuf/types/pluginpb" ; static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_deps[1] = { &::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto, @@ -196,7 +195,7 @@ }; static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once; const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto = { - false, false, descriptor_table_protodef_google_2fprotobuf_2fcompiler_2fplugin_2eproto, "google/protobuf/compiler/plugin.proto", 724, + false, false, descriptor_table_protodef_google_2fprotobuf_2fcompiler_2fplugin_2eproto, "google/protobuf/compiler/plugin.proto", 708, &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once, descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_sccs, descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_deps, 4, 1, schemas, file_default_instances, TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto::offsets, file_level_metadata_google_2fprotobuf_2fcompiler_2fplugin_2eproto, 4, file_level_enum_descriptors_google_2fprotobuf_2fcompiler_2fplugin_2eproto, file_level_service_descriptors_google_2fprotobuf_2fcompiler_2fplugin_2eproto,
diff --git a/src/google/protobuf/compiler/plugin.proto b/src/google/protobuf/compiler/plugin.proto index 492b896..189db19 100644 --- a/src/google/protobuf/compiler/plugin.proto +++ b/src/google/protobuf/compiler/plugin.proto
@@ -50,7 +50,7 @@ option java_package = "com.google.protobuf.compiler"; option java_outer_classname = "PluginProtos"; -option go_package = "github.com/golang/protobuf/protoc-gen-go/plugin;plugin_go"; +option go_package = "google.golang.org/protobuf/types/pluginpb"; import "google/protobuf/descriptor.proto";
diff --git a/src/google/protobuf/descriptor.pb.cc b/src/google/protobuf/descriptor.pb.cc index 471351c..c4e26b6 100644 --- a/src/google/protobuf/descriptor.pb.cc +++ b/src/google/protobuf/descriptor.pb.cc
@@ -1156,11 +1156,10 @@ "tation\030\001 \003(\0132-.google.protobuf.Generated" "CodeInfo.Annotation\032O\n\nAnnotation\022\020\n\004pat" "h\030\001 \003(\005B\002\020\001\022\023\n\013source_file\030\002 \001(\t\022\r\n\005begi" - "n\030\003 \001(\005\022\013\n\003end\030\004 \001(\005B\217\001\n\023com.google.prot" - "obufB\020DescriptorProtosH\001Z>github.com/gol" - "ang/protobuf/protoc-gen-go/descriptor;de" - "scriptor\370\001\001\242\002\003GPB\252\002\032Google.Protobuf.Refl" - "ection" + "n\030\003 \001(\005\022\013\n\003end\030\004 \001(\005B~\n\023com.google.proto" + "bufB\020DescriptorProtosH\001Z-google.golang.o" + "rg/protobuf/types/descriptorpb\370\001\001\242\002\003GPB\252" + "\002\032Google.Protobuf.Reflection" ; static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_deps[1] = { }; @@ -1195,7 +1194,7 @@ }; static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once; const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fdescriptor_2eproto = { - false, false, descriptor_table_protodef_google_2fprotobuf_2fdescriptor_2eproto, "google/protobuf/descriptor.proto", 6046, + false, false, descriptor_table_protodef_google_2fprotobuf_2fdescriptor_2eproto, "google/protobuf/descriptor.proto", 6028, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_sccs, descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_deps, 27, 0, schemas, file_default_instances, TableStruct_google_2fprotobuf_2fdescriptor_2eproto::offsets, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto, 27, file_level_enum_descriptors_google_2fprotobuf_2fdescriptor_2eproto, file_level_service_descriptors_google_2fprotobuf_2fdescriptor_2eproto,
diff --git a/src/google/protobuf/descriptor.proto b/src/google/protobuf/descriptor.proto index d29fdec..9f0ce6c 100644 --- a/src/google/protobuf/descriptor.proto +++ b/src/google/protobuf/descriptor.proto
@@ -41,7 +41,7 @@ package google.protobuf; -option go_package = "github.com/golang/protobuf/protoc-gen-go/descriptor;descriptor"; +option go_package = "google.golang.org/protobuf/types/descriptorpb"; option java_package = "com.google.protobuf"; option java_outer_classname = "DescriptorProtos"; option csharp_namespace = "Google.Protobuf.Reflection";
diff --git a/src/google/protobuf/duration.pb.cc b/src/google/protobuf/duration.pb.cc index 2682662..b8bceca 100644 --- a/src/google/protobuf/duration.pb.cc +++ b/src/google/protobuf/duration.pb.cc
@@ -58,10 +58,10 @@ const char descriptor_table_protodef_google_2fprotobuf_2fduration_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = "\n\036google/protobuf/duration.proto\022\017google" ".protobuf\"*\n\010Duration\022\017\n\007seconds\030\001 \001(\003\022\r" - "\n\005nanos\030\002 \001(\005B|\n\023com.google.protobufB\rDu" - "rationProtoP\001Z*github.com/golang/protobu" - "f/ptypes/duration\370\001\001\242\002\003GPB\252\002\036Google.Prot" - "obuf.WellKnownTypesb\006proto3" + "\n\005nanos\030\002 \001(\005B\203\001\n\023com.google.protobufB\rD" + "urationProtoP\001Z1google.golang.org/protob" + "uf/types/known/durationpb\370\001\001\242\002\003GPB\252\002\036Goo" + "gle.Protobuf.WellKnownTypesb\006proto3" ; static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_google_2fprotobuf_2fduration_2eproto_deps[1] = { }; @@ -70,7 +70,7 @@ }; static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_google_2fprotobuf_2fduration_2eproto_once; const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fduration_2eproto = { - false, false, descriptor_table_protodef_google_2fprotobuf_2fduration_2eproto, "google/protobuf/duration.proto", 227, + false, false, descriptor_table_protodef_google_2fprotobuf_2fduration_2eproto, "google/protobuf/duration.proto", 235, &descriptor_table_google_2fprotobuf_2fduration_2eproto_once, descriptor_table_google_2fprotobuf_2fduration_2eproto_sccs, descriptor_table_google_2fprotobuf_2fduration_2eproto_deps, 1, 0, schemas, file_default_instances, TableStruct_google_2fprotobuf_2fduration_2eproto::offsets, file_level_metadata_google_2fprotobuf_2fduration_2eproto, 1, file_level_enum_descriptors_google_2fprotobuf_2fduration_2eproto, file_level_service_descriptors_google_2fprotobuf_2fduration_2eproto,
diff --git a/src/google/protobuf/duration.proto b/src/google/protobuf/duration.proto index 99cb102..81c3e36 100644 --- a/src/google/protobuf/duration.proto +++ b/src/google/protobuf/duration.proto
@@ -34,7 +34,7 @@ option csharp_namespace = "Google.Protobuf.WellKnownTypes"; option cc_enable_arenas = true; -option go_package = "github.com/golang/protobuf/ptypes/duration"; +option go_package = "google.golang.org/protobuf/types/known/durationpb"; option java_package = "com.google.protobuf"; option java_outer_classname = "DurationProto"; option java_multiple_files = true;
diff --git a/src/google/protobuf/empty.pb.cc b/src/google/protobuf/empty.pb.cc index 855db18..27f801f 100644 --- a/src/google/protobuf/empty.pb.cc +++ b/src/google/protobuf/empty.pb.cc
@@ -55,10 +55,10 @@ const char descriptor_table_protodef_google_2fprotobuf_2fempty_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = "\n\033google/protobuf/empty.proto\022\017google.pr" - "otobuf\"\007\n\005EmptyBv\n\023com.google.protobufB\n" - "EmptyProtoP\001Z\'github.com/golang/protobuf" - "/ptypes/empty\370\001\001\242\002\003GPB\252\002\036Google.Protobuf" - ".WellKnownTypesb\006proto3" + "otobuf\"\007\n\005EmptyB}\n\023com.google.protobufB\n" + "EmptyProtoP\001Z.google.golang.org/protobuf" + "/types/known/emptypb\370\001\001\242\002\003GPB\252\002\036Google.P" + "rotobuf.WellKnownTypesb\006proto3" ; static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_google_2fprotobuf_2fempty_2eproto_deps[1] = { }; @@ -67,7 +67,7 @@ }; static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_google_2fprotobuf_2fempty_2eproto_once; const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fempty_2eproto = { - false, false, descriptor_table_protodef_google_2fprotobuf_2fempty_2eproto, "google/protobuf/empty.proto", 183, + false, false, descriptor_table_protodef_google_2fprotobuf_2fempty_2eproto, "google/protobuf/empty.proto", 190, &descriptor_table_google_2fprotobuf_2fempty_2eproto_once, descriptor_table_google_2fprotobuf_2fempty_2eproto_sccs, descriptor_table_google_2fprotobuf_2fempty_2eproto_deps, 1, 0, schemas, file_default_instances, TableStruct_google_2fprotobuf_2fempty_2eproto::offsets, file_level_metadata_google_2fprotobuf_2fempty_2eproto, 1, file_level_enum_descriptors_google_2fprotobuf_2fempty_2eproto, file_level_service_descriptors_google_2fprotobuf_2fempty_2eproto,
diff --git a/src/google/protobuf/empty.proto b/src/google/protobuf/empty.proto index 03cacd2..5f992de 100644 --- a/src/google/protobuf/empty.proto +++ b/src/google/protobuf/empty.proto
@@ -33,7 +33,7 @@ package google.protobuf; option csharp_namespace = "Google.Protobuf.WellKnownTypes"; -option go_package = "github.com/golang/protobuf/ptypes/empty"; +option go_package = "google.golang.org/protobuf/types/known/emptypb"; option java_package = "com.google.protobuf"; option java_outer_classname = "EmptyProto"; option java_multiple_files = true;
diff --git a/src/google/protobuf/extension_set_unittest.cc b/src/google/protobuf/extension_set_unittest.cc index d5073ee..3e6ecef 100644 --- a/src/google/protobuf/extension_set_unittest.cc +++ b/src/google/protobuf/extension_set_unittest.cc
@@ -1105,8 +1105,6 @@ ASSERT_EQ(msg_const_iter->bb(), 1234); } - // Test range-based for as well, but only if compiled as C++11. -#if __cplusplus >= 201103L // Test one primitive field. for (auto& x : *message.MutableRepeatedExtension(unittest::repeated_int32_extension)) { @@ -1134,7 +1132,6 @@ unittest::repeated_nested_message_extension)) { ASSERT_EQ(x.bb(), 4321); } -#endif } // From b/12926163
diff --git a/src/google/protobuf/field_mask.pb.cc b/src/google/protobuf/field_mask.pb.cc index 42e077f..e735b3a 100644 --- a/src/google/protobuf/field_mask.pb.cc +++ b/src/google/protobuf/field_mask.pb.cc
@@ -57,10 +57,10 @@ const char descriptor_table_protodef_google_2fprotobuf_2ffield_5fmask_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = "\n google/protobuf/field_mask.proto\022\017goog" "le.protobuf\"\032\n\tFieldMask\022\r\n\005paths\030\001 \003(\tB" - "\214\001\n\023com.google.protobufB\016FieldMaskProtoP" - "\001Z9google.golang.org/genproto/protobuf/f" - "ield_mask;field_mask\370\001\001\242\002\003GPB\252\002\036Google.P" - "rotobuf.WellKnownTypesb\006proto3" + "\205\001\n\023com.google.protobufB\016FieldMaskProtoP" + "\001Z2google.golang.org/protobuf/types/know" + "n/fieldmaskpb\370\001\001\242\002\003GPB\252\002\036Google.Protobuf" + ".WellKnownTypesb\006proto3" ; static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto_deps[1] = { }; @@ -69,7 +69,7 @@ }; static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto_once; const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto = { - false, false, descriptor_table_protodef_google_2fprotobuf_2ffield_5fmask_2eproto, "google/protobuf/field_mask.proto", 230, + false, false, descriptor_table_protodef_google_2fprotobuf_2ffield_5fmask_2eproto, "google/protobuf/field_mask.proto", 223, &descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto_once, descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto_sccs, descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto_deps, 1, 0, schemas, file_default_instances, TableStruct_google_2fprotobuf_2ffield_5fmask_2eproto::offsets, file_level_metadata_google_2fprotobuf_2ffield_5fmask_2eproto, 1, file_level_enum_descriptors_google_2fprotobuf_2ffield_5fmask_2eproto, file_level_service_descriptors_google_2fprotobuf_2ffield_5fmask_2eproto,
diff --git a/src/google/protobuf/field_mask.proto b/src/google/protobuf/field_mask.proto index baac874..6b5104f 100644 --- a/src/google/protobuf/field_mask.proto +++ b/src/google/protobuf/field_mask.proto
@@ -37,7 +37,7 @@ option java_outer_classname = "FieldMaskProto"; option java_multiple_files = true; option objc_class_prefix = "GPB"; -option go_package = "google.golang.org/genproto/protobuf/field_mask;field_mask"; +option go_package = "google.golang.org/protobuf/types/known/fieldmaskpb"; option cc_enable_arenas = true; // `FieldMask` represents a set of symbolic field paths, for example:
diff --git a/src/google/protobuf/generated_message_reflection.cc b/src/google/protobuf/generated_message_reflection.cc index 5483eda..d8397ed 100644 --- a/src/google/protobuf/generated_message_reflection.cc +++ b/src/google/protobuf/generated_message_reflection.cc
@@ -2044,10 +2044,8 @@ void Reflection::ClearBit(Message* message, const FieldDescriptor* field) const { GOOGLE_DCHECK(!field->options().weak()); - if (!schema_.HasHasbits()) { - return; - } const uint32 index = schema_.HasBitIndex(field); + if (index == -1) return; MutableHasBits(message)[index / 32] &= ~(static_cast<uint32>(1) << (index % 32)); }
diff --git a/src/google/protobuf/generated_message_util.cc b/src/google/protobuf/generated_message_util.cc index 15eb9d6..01f65ae 100644 --- a/src/google/protobuf/generated_message_util.cc +++ b/src/google/protobuf/generated_message_util.cc
@@ -65,7 +65,7 @@ static_cast<const MessageLite*>(message)->~MessageLite(); } void DestroyString(const void* s) { - static_cast<const std::string*>(s)->~string(); + static_cast<const std::string*>(s)->~basic_string(); } ExplicitlyConstructed<std::string> fixed_address_empty_string;
diff --git a/src/google/protobuf/io/tokenizer.cc b/src/google/protobuf/io/tokenizer.cc index ff83946..6853b1a 100644 --- a/src/google/protobuf/io/tokenizer.cc +++ b/src/google/protobuf/io/tokenizer.cc
@@ -940,14 +940,15 @@ tmp = 0x00e08080 | ((code_point & 0xf000) << 4) | ((code_point & 0x0fc0) << 2) | (code_point & 0x003f); len = 3; - } else if (code_point <= 0x1fffff) { + } else if (code_point <= 0x10ffff) { tmp = 0xf0808080 | ((code_point & 0x1c0000) << 6) | ((code_point & 0x03f000) << 4) | ((code_point & 0x000fc0) << 2) | (code_point & 0x003f); len = 4; } else { - // UTF-16 is only defined for code points up to 0x10FFFF, and UTF-8 is - // normally only defined up to there as well. + // Unicode code points end at 0x10FFFF, so this is out-of-range. + // ConsumeString permits hex values up to 0x1FFFFF, and FetchUnicodePoint + // doesn't perform a range check. StringAppendF(output, "\\U%08x", code_point); return; }
diff --git a/src/google/protobuf/io/tokenizer_unittest.cc b/src/google/protobuf/io/tokenizer_unittest.cc index b14eddf..91c440c 100644 --- a/src/google/protobuf/io/tokenizer_unittest.cc +++ b/src/google/protobuf/io/tokenizer_unittest.cc
@@ -808,8 +808,11 @@ Tokenizer::ParseString("'\\ud852XX'", &output); EXPECT_EQ("\xed\xa1\x92XX", output); // Malformed escape: Demons may fly out of the nose. - Tokenizer::ParseString("\\u0", &output); + Tokenizer::ParseString("'\\u0'", &output); EXPECT_EQ("u0", output); + // Beyond the range of valid UTF-32 code units. + Tokenizer::ParseString("'\\U00110000\\U00200000\\UFFFFFFFF'", &output); + EXPECT_EQ("\\U00110000\\U00200000\\Uffffffff", output); // Test invalid strings that will never be tokenized as strings. #ifdef PROTOBUF_HAS_DEATH_TEST // death tests do not work on Windows yet
diff --git a/src/google/protobuf/map.h b/src/google/protobuf/map.h index a1722db..c3cfb43 100644 --- a/src/google/protobuf/map.h +++ b/src/google/protobuf/map.h
@@ -76,12 +76,12 @@ namespace internal { template <typename Derived, typename Key, typename T, WireFormatLite::FieldType key_wire_type, - WireFormatLite::FieldType value_wire_type, int default_enum_value> + WireFormatLite::FieldType value_wire_type> class MapFieldLite; template <typename Derived, typename Key, typename T, WireFormatLite::FieldType key_wire_type, - WireFormatLite::FieldType value_wire_type, int default_enum_value> + WireFormatLite::FieldType value_wire_type> class MapField; template <typename Key, typename T> @@ -133,8 +133,7 @@ } } -#if __cplusplus >= 201103L && !defined(GOOGLE_PROTOBUF_OS_APPLE) && \ - !defined(GOOGLE_PROTOBUF_OS_NACL) && \ +#if !defined(GOOGLE_PROTOBUF_OS_APPLE) && !defined(GOOGLE_PROTOBUF_OS_NACL) && \ !defined(GOOGLE_PROTOBUF_OS_EMSCRIPTEN) template <class NodeType, class... Args> void construct(NodeType* p, Args&&... args) { @@ -252,6 +251,76 @@ }; #endif // defined(__cpp_lib_string_view) +template <typename Key> +using TreeForMap = + std::map<KeyForTree<Key>, void*, typename TransparentSupport<Key>::less, + MapAllocator<std::pair<const KeyForTree<Key>, void*>>>; + +inline bool TableEntryIsEmpty(void* const* table, size_t b) { + return table[b] == nullptr; +} +inline bool TableEntryIsNonEmptyList(void* const* table, size_t b) { + return table[b] != nullptr && table[b] != table[b ^ 1]; +} +inline bool TableEntryIsTree(void* const* table, size_t b) { + return !TableEntryIsEmpty(table, b) && !TableEntryIsNonEmptyList(table, b); +} +inline bool TableEntryIsList(void* const* table, size_t b) { + return !TableEntryIsTree(table, b); +} + +// This captures all numeric types. +inline size_t MapValueSpaceUsedExcludingSelfLong(bool) { return 0; } +inline size_t MapValueSpaceUsedExcludingSelfLong(const std::string& str) { + return StringSpaceUsedExcludingSelfLong(str); +} +template <typename T, + typename = decltype(std::declval<const T&>().SpaceUsedLong())> +size_t MapValueSpaceUsedExcludingSelfLong(const T& message) { + return message.SpaceUsedLong() - sizeof(T); +} + +// Space used for the table, trees, and nodes. +// Does not include the indirect space used. Eg the data of a std::string. +template <typename Key> +PROTOBUF_NOINLINE size_t SpaceUsedInTable(void** table, size_t num_buckets, + size_t num_elements, + size_t sizeof_node) { + size_t size = 0; + // The size of the table. + size += sizeof(void*) * num_buckets; + // All the nodes. + size += sizeof_node * num_elements; + // For each tree, count the overhead of the those nodes. + // Two buckets at a time because we only care about trees. + for (size_t b = 0; b < num_buckets; b += 2) { + if (internal::TableEntryIsTree(table, b)) { + using Tree = TreeForMap<Key>; + Tree* tree = static_cast<Tree*>(table[b]); + // Estimated cost of the red-black tree nodes, 3 pointers plus a + // bool (plus alignment, so 4 pointers). + size += tree->size() * + (sizeof(typename Tree::value_type) + sizeof(void*) * 4); + } + } + return size; +} + +template <typename Map, + typename = typename std::enable_if< + !std::is_scalar<typename Map::key_type>::value || + !std::is_scalar<typename Map::mapped_type>::value>::type> +size_t SpaceUsedInValues(const Map* map) { + size_t size = 0; + for (const auto& v : *map) { + size += internal::MapValueSpaceUsedExcludingSelfLong(v.first) + + internal::MapValueSpaceUsedExcludingSelfLong(v.second); + } + return size; +} + +inline size_t SpaceUsedInValues(const void*) { return 0; } + } // namespace internal // This is the class for Map's internal value_type. Instead of using @@ -308,11 +377,10 @@ using size_type = size_t; using hasher = typename internal::TransparentSupport<Key>::hash; - Map() : arena_(nullptr), default_enum_value_(0) { Init(); } - explicit Map(Arena* arena) : arena_(arena), default_enum_value_(0) { Init(); } + Map() : arena_(nullptr) { Init(); } + explicit Map(Arena* arena) : arena_(arena) { Init(); } - Map(const Map& other) - : arena_(nullptr), default_enum_value_(other.default_enum_value_) { + Map(const Map& other) : arena_(nullptr) { Init(); insert(other.begin(), other.end()); } @@ -336,8 +404,7 @@ } template <class InputIt> - Map(const InputIt& first, const InputIt& last) - : arena_(nullptr), default_enum_value_(0) { + Map(const InputIt& first, const InputIt& last) : arena_(nullptr) { Init(); insert(first, last); } @@ -421,11 +488,7 @@ // The value is a void* pointing to Node. We use void* instead of Node* to // avoid code bloat. That way there is only one instantiation of the tree // class per key type. - using TreeAllocator = typename Allocator::template rebind< - std::pair<const internal::KeyForTree<Key>, void*>>::other; - using Tree = std::map<internal::KeyForTree<Key>, void*, - typename internal::TransparentSupport<Key>::less, - TreeAllocator>; + using Tree = internal::TreeForMap<Key>; using TreeIterator = typename Tree::iterator; static Node* NodeFromTreeIterator(TreeIterator it) { @@ -675,6 +738,11 @@ } } + size_t SpaceUsedInternal() const { + return internal::SpaceUsedInTable<Key>(table_, num_buckets_, + num_elements_, sizeof(Node)); + } + private: const_iterator find(const Key& k, TreeIterator* it) const { return FindHelper(k, it).first; @@ -835,9 +903,9 @@ const size_type start = index_of_first_non_null_; index_of_first_non_null_ = num_buckets_; for (size_type i = start; i < old_table_size; i++) { - if (TableEntryIsNonEmptyList(old_table, i)) { + if (internal::TableEntryIsNonEmptyList(old_table, i)) { TransferList(old_table, i); - } else if (TableEntryIsTree(old_table, i)) { + } else if (internal::TableEntryIsTree(old_table, i)) { TransferTree(old_table, i++); } } @@ -873,29 +941,16 @@ } bool TableEntryIsEmpty(size_type b) const { - return TableEntryIsEmpty(table_, b); + return internal::TableEntryIsEmpty(table_, b); } bool TableEntryIsNonEmptyList(size_type b) const { - return TableEntryIsNonEmptyList(table_, b); + return internal::TableEntryIsNonEmptyList(table_, b); } bool TableEntryIsTree(size_type b) const { - return TableEntryIsTree(table_, b); + return internal::TableEntryIsTree(table_, b); } bool TableEntryIsList(size_type b) const { - return TableEntryIsList(table_, b); - } - static bool TableEntryIsEmpty(void* const* table, size_type b) { - return table[b] == nullptr; - } - static bool TableEntryIsNonEmptyList(void* const* table, size_type b) { - return table[b] != nullptr && table[b] != table[b ^ 1]; - } - static bool TableEntryIsTree(void* const* table, size_type b) { - return !TableEntryIsEmpty(table, b) && - !TableEntryIsNonEmptyList(table, b); - } - static bool TableEntryIsList(void* const* table, size_type b) { - return !TableEntryIsTree(table, b); + return internal::TableEntryIsList(table_, b); } void TreeConvert(size_type b) { @@ -1231,7 +1286,6 @@ void swap(Map& other) { if (arena_ == other.arena_) { - std::swap(default_enum_value_, other.default_enum_value_); std::swap(elements_, other.elements_); } else { // TODO(zuguang): optimize this. The temporary copy can be allocated @@ -1247,14 +1301,13 @@ // be modified to return a const reference in the future. hasher hash_function() const { return elements_->hash_function(); } - private: - // Set default enum value only for proto2 map field whose value is enum type. - void SetDefaultEnumValue(int default_enum_value) { - default_enum_value_ = default_enum_value; + size_t SpaceUsedExcludingSelfLong() const { + return sizeof(InnerMap) + elements_->SpaceUsedInternal() + + internal::SpaceUsedInValues(this); } + private: Arena* arena_; - int default_enum_value_; InnerMap* elements_; friend class Arena; @@ -1262,8 +1315,7 @@ using DestructorSkippable_ = void; template <typename Derived, typename K, typename V, internal::WireFormatLite::FieldType key_wire_type, - internal::WireFormatLite::FieldType value_wire_type, - int default_enum_value> + internal::WireFormatLite::FieldType value_wire_type> friend class internal::MapFieldLite; };
diff --git a/src/google/protobuf/map_entry.h b/src/google/protobuf/map_entry.h index 4e6a3e3..180ff0e 100644 --- a/src/google/protobuf/map_entry.h +++ b/src/google/protobuf/map_entry.h
@@ -51,7 +51,7 @@ namespace internal { template <typename Derived, typename Key, typename Value, WireFormatLite::FieldType kKeyFieldType, - WireFormatLite::FieldType kValueFieldType, int default_enum_value> + WireFormatLite::FieldType kValueFieldType> class MapField; } } // namespace protobuf @@ -86,19 +86,17 @@ // // The in-memory types of primitive types can be inferred from its proto type, // while we need to explicitly specify the cpp type if proto type is -// TYPE_MESSAGE to infer the in-memory type. Moreover, default_enum_value is -// used to initialize enum field in proto2. +// TYPE_MESSAGE to infer the in-memory type. template <typename Derived, typename Key, typename Value, WireFormatLite::FieldType kKeyFieldType, - WireFormatLite::FieldType kValueFieldType, int default_enum_value> -class MapEntry - : public MapEntryImpl<Derived, Message, Key, Value, kKeyFieldType, - kValueFieldType, default_enum_value> { + WireFormatLite::FieldType kValueFieldType> +class MapEntry : public MapEntryImpl<Derived, Message, Key, Value, + kKeyFieldType, kValueFieldType> { public: MapEntry() : _internal_metadata_(NULL) {} explicit MapEntry(Arena* arena) : MapEntryImpl<Derived, Message, Key, Value, kKeyFieldType, - kValueFieldType, default_enum_value>(arena), + kValueFieldType>(arena), _internal_metadata_(arena) {} ~MapEntry() { Message::_internal_metadata_.Delete<UnknownFieldSet>(); @@ -107,13 +105,11 @@ typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; + typedef typename MapEntryImpl<Derived, Message, Key, Value, kKeyFieldType, + kValueFieldType>::KeyTypeHandler KeyTypeHandler; typedef typename MapEntryImpl<Derived, Message, Key, Value, kKeyFieldType, - kValueFieldType, default_enum_value>::KeyTypeHandler - KeyTypeHandler; - typedef typename MapEntryImpl< - Derived, Message, Key, Value, kKeyFieldType, kValueFieldType, - default_enum_value>::ValueTypeHandler ValueTypeHandler; + kValueFieldType>::ValueTypeHandler ValueTypeHandler; size_t SpaceUsedLong() const override { size_t size = sizeof(Derived); size += KeyTypeHandler::SpaceUsedInMapEntryLong(this->key_); @@ -126,8 +122,7 @@ private: friend class ::PROTOBUF_NAMESPACE_ID::Arena; template <typename C, typename K, typename V, - WireFormatLite::FieldType k_wire_type, WireFormatLite::FieldType, - int default_enum> + WireFormatLite::FieldType k_wire_type, WireFormatLite::FieldType> friend class internal::MapField; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MapEntry); @@ -136,26 +131,24 @@ // Specialization for the full runtime template <typename Derived, typename Key, typename Value, WireFormatLite::FieldType kKeyFieldType, - WireFormatLite::FieldType kValueFieldType, int default_enum_value> -struct MapEntryHelper<MapEntry<Derived, Key, Value, kKeyFieldType, - kValueFieldType, default_enum_value> > - : MapEntryHelper<MapEntryLite<Derived, Key, Value, kKeyFieldType, - kValueFieldType, default_enum_value> > { + WireFormatLite::FieldType kValueFieldType> +struct MapEntryHelper< + MapEntry<Derived, Key, Value, kKeyFieldType, kValueFieldType> > + : MapEntryHelper< + MapEntryLite<Derived, Key, Value, kKeyFieldType, kValueFieldType> > { explicit MapEntryHelper(const MapPair<Key, Value>& map_pair) - : MapEntryHelper<MapEntryLite<Derived, Key, Value, kKeyFieldType, - kValueFieldType, default_enum_value> >( + : MapEntryHelper< + MapEntryLite<Derived, Key, Value, kKeyFieldType, kValueFieldType> >( map_pair) {} }; template <typename Derived, typename K, typename V, - WireFormatLite::FieldType key, WireFormatLite::FieldType value, - int default_enum> -struct DeconstructMapEntry<MapEntry<Derived, K, V, key, value, default_enum> > { + WireFormatLite::FieldType key, WireFormatLite::FieldType value> +struct DeconstructMapEntry<MapEntry<Derived, K, V, key, value> > { typedef K Key; typedef V Value; static constexpr WireFormatLite::FieldType kKeyFieldType = key; static constexpr WireFormatLite::FieldType kValueFieldType = value; - static constexpr int default_enum_value = default_enum; }; } // namespace internal
diff --git a/src/google/protobuf/map_entry_lite.h b/src/google/protobuf/map_entry_lite.h index 161d08d..6b5d4e8 100644 --- a/src/google/protobuf/map_entry_lite.h +++ b/src/google/protobuf/map_entry_lite.h
@@ -55,11 +55,11 @@ namespace internal { template <typename Derived, typename Key, typename Value, WireFormatLite::FieldType kKeyFieldType, - WireFormatLite::FieldType kValueFieldType, int default_enum_value> + WireFormatLite::FieldType kValueFieldType> class MapEntry; template <typename Derived, typename Key, typename Value, WireFormatLite::FieldType kKeyFieldType, - WireFormatLite::FieldType kValueFieldType, int default_enum_value> + WireFormatLite::FieldType kValueFieldType> class MapFieldLite; } // namespace internal } // namespace protobuf @@ -93,11 +93,7 @@ template <typename T> struct MoveHelper<false, false, true, T> { // strings and similar static void Move(T* src, T* dest) { -#if __cplusplus >= 201103L *dest = std::move(*src); -#else - dest->swap(*src); -#endif } }; @@ -144,7 +140,7 @@ // the eventual code to the template code. template <typename Derived, typename Base, typename Key, typename Value, WireFormatLite::FieldType kKeyFieldType, - WireFormatLite::FieldType kValueFieldType, int default_enum_value> + WireFormatLite::FieldType kValueFieldType> class MapEntryImpl : public Base { public: typedef MapEntryFuncs<Key, Value, kKeyFieldType, kValueFieldType> Funcs; @@ -185,19 +181,16 @@ typedef Value EntryValueType; static const WireFormatLite::FieldType kEntryKeyFieldType = kKeyFieldType; static const WireFormatLite::FieldType kEntryValueFieldType = kValueFieldType; - static const int kEntryDefaultEnumValue = default_enum_value; MapEntryImpl() { KeyTypeHandler::Initialize(&key_, NULL); - ValueTypeHandler::InitializeMaybeByDefaultEnum(&value_, default_enum_value, - NULL); + ValueTypeHandler::Initialize(&value_, NULL); _has_bits_[0] = 0; } explicit MapEntryImpl(Arena* arena) : Base(arena) { KeyTypeHandler::Initialize(&key_, arena); - ValueTypeHandler::InitializeMaybeByDefaultEnum(&value_, default_enum_value, - arena); + ValueTypeHandler::Initialize(&value_, arena); _has_bits_[0] = 0; } @@ -325,8 +318,7 @@ public: void Clear() override { KeyTypeHandler::Clear(&key_, Base::GetArena()); - ValueTypeHandler::ClearMaybeByDefaultEnum(&value_, Base::GetArena(), - default_enum_value); + ValueTypeHandler::Clear(&value_, Base::GetArena()); clear_has_key(); clear_has_value(); } @@ -520,10 +512,10 @@ typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; template <typename C, typename K, typename V, WireFormatLite::FieldType, - WireFormatLite::FieldType, int> + WireFormatLite::FieldType> friend class internal::MapEntry; template <typename C, typename K, typename V, WireFormatLite::FieldType, - WireFormatLite::FieldType, int> + WireFormatLite::FieldType> friend class internal::MapFieldLite; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MapEntryImpl); @@ -531,13 +523,12 @@ template <typename T, typename Key, typename Value, WireFormatLite::FieldType kKeyFieldType, - WireFormatLite::FieldType kValueFieldType, int default_enum_value> -class MapEntryLite - : public MapEntryImpl<T, MessageLite, Key, Value, kKeyFieldType, - kValueFieldType, default_enum_value> { + WireFormatLite::FieldType kValueFieldType> +class MapEntryLite : public MapEntryImpl<T, MessageLite, Key, Value, + kKeyFieldType, kValueFieldType> { public: typedef MapEntryImpl<T, MessageLite, Key, Value, kKeyFieldType, - kValueFieldType, default_enum_value> + kValueFieldType> SuperType; MapEntryLite() {} explicit MapEntryLite(Arena* arena) : SuperType(arena) {} @@ -554,13 +545,12 @@ struct DeconstructMapEntry; template <typename T, typename K, typename V, WireFormatLite::FieldType key, - WireFormatLite::FieldType value, int default_enum> -struct DeconstructMapEntry<MapEntryLite<T, K, V, key, value, default_enum> > { + WireFormatLite::FieldType value> +struct DeconstructMapEntry<MapEntryLite<T, K, V, key, value> > { typedef K Key; typedef V Value; static const WireFormatLite::FieldType kKeyFieldType = key; static const WireFormatLite::FieldType kValueFieldType = value; - static const int default_enum_value = default_enum; }; // Helpers for deterministic serialization ============================= @@ -631,9 +621,9 @@ template <typename T, typename Key, typename Value, WireFormatLite::FieldType kKeyFieldType, - WireFormatLite::FieldType kValueFieldType, int default_enum_value> -struct MapEntryHelper<MapEntryLite<T, Key, Value, kKeyFieldType, - kValueFieldType, default_enum_value> > { + WireFormatLite::FieldType kValueFieldType> +struct MapEntryHelper< + MapEntryLite<T, Key, Value, kKeyFieldType, kValueFieldType> > { // Provide utilities to parse/serialize key/value. Provide utilities to // manipulate internal stored type. typedef MapTypeHandler<kKeyFieldType, Key> KeyTypeHandler;
diff --git a/src/google/protobuf/map_field.h b/src/google/protobuf/map_field.h index 9ea3fad..efca5ee 100644 --- a/src/google/protobuf/map_field.h +++ b/src/google/protobuf/map_field.h
@@ -425,7 +425,7 @@ // directly. template <typename Derived, typename Key, typename T, WireFormatLite::FieldType kKeyFieldType, - WireFormatLite::FieldType kValueFieldType, int default_enum_value = 0> + WireFormatLite::FieldType kValueFieldType> class MapField : public TypeDefinedMapFieldBase<Key, T> { // Provide utilities to parse/serialize key/value. Provide utilities to // manipulate internal stored type. @@ -436,8 +436,7 @@ typedef Derived EntryType; // Define abbreviation for parent MapFieldLite - typedef MapFieldLite<Derived, Key, T, kKeyFieldType, kValueFieldType, - default_enum_value> + typedef MapFieldLite<Derived, Key, T, kKeyFieldType, kValueFieldType> MapFieldLiteType; // Enum needs to be handled differently from other types because it has @@ -522,10 +521,9 @@ template <typename Derived, typename Key, typename T, WireFormatLite::FieldType key_wire_type, - WireFormatLite::FieldType value_wire_type, int default_enum_value> + WireFormatLite::FieldType value_wire_type> bool AllAreInitialized( - const MapField<Derived, Key, T, key_wire_type, value_wire_type, - default_enum_value>& field) { + const MapField<Derived, Key, T, key_wire_type, value_wire_type>& field) { const auto& t = field.GetMap(); for (typename Map<Key, T>::const_iterator it = t.begin(); it != t.end(); ++it) { @@ -536,12 +534,10 @@ template <typename T, typename Key, typename Value, WireFormatLite::FieldType kKeyFieldType, - WireFormatLite::FieldType kValueFieldType, int default_enum_value> -struct MapEntryToMapField<MapEntry<T, Key, Value, kKeyFieldType, - kValueFieldType, default_enum_value>> { - typedef MapField<T, Key, Value, kKeyFieldType, kValueFieldType, - default_enum_value> - MapFieldType; + WireFormatLite::FieldType kValueFieldType> +struct MapEntryToMapField< + MapEntry<T, Key, Value, kKeyFieldType, kValueFieldType>> { + typedef MapField<T, Key, Value, kKeyFieldType, kValueFieldType> MapFieldType; }; class PROTOBUF_EXPORT DynamicMapField @@ -675,8 +671,7 @@ private: template <typename Derived, typename K, typename V, internal::WireFormatLite::FieldType key_wire_type, - internal::WireFormatLite::FieldType value_wire_type, - int default_enum_value> + internal::WireFormatLite::FieldType value_wire_type> friend class internal::MapField; template <typename K, typename V> friend class internal::TypeDefinedMapFieldBase; @@ -778,8 +773,7 @@ friend class internal::DynamicMapField; template <typename Derived, typename Key, typename T, internal::WireFormatLite::FieldType kKeyFieldType, - internal::WireFormatLite::FieldType kValueFieldType, - int default_enum_value> + internal::WireFormatLite::FieldType kValueFieldType> friend class internal::MapField; // reinterpret_cast from heap-allocated Map<...>::iterator*. MapIterator owns
diff --git a/src/google/protobuf/map_field_inl.h b/src/google/protobuf/map_field_inl.h index 7baaa5f..6b6a87e 100644 --- a/src/google/protobuf/map_field_inl.h +++ b/src/google/protobuf/map_field_inl.h
@@ -164,18 +164,16 @@ template <typename Derived, typename Key, typename T, WireFormatLite::FieldType kKeyFieldType, - WireFormatLite::FieldType kValueFieldType, int default_enum_value> -int MapField<Derived, Key, T, kKeyFieldType, kValueFieldType, - default_enum_value>::size() const { + WireFormatLite::FieldType kValueFieldType> +int MapField<Derived, Key, T, kKeyFieldType, kValueFieldType>::size() const { MapFieldBase::SyncMapWithRepeatedField(); return static_cast<int>(impl_.GetMap().size()); } template <typename Derived, typename Key, typename T, WireFormatLite::FieldType kKeyFieldType, - WireFormatLite::FieldType kValueFieldType, int default_enum_value> -void MapField<Derived, Key, T, kKeyFieldType, kValueFieldType, - default_enum_value>::Clear() { + WireFormatLite::FieldType kValueFieldType> +void MapField<Derived, Key, T, kKeyFieldType, kValueFieldType>::Clear() { if (this->MapFieldBase::repeated_field_ != nullptr) { RepeatedPtrField<EntryType>* repeated_field = reinterpret_cast<RepeatedPtrField<EntryType>*>( @@ -192,9 +190,9 @@ template <typename Derived, typename Key, typename T, WireFormatLite::FieldType kKeyFieldType, - WireFormatLite::FieldType kValueFieldType, int default_enum_value> -void MapField<Derived, Key, T, kKeyFieldType, kValueFieldType, - default_enum_value>::SetMapIteratorValue(MapIterator* map_iter) + WireFormatLite::FieldType kValueFieldType> +void MapField<Derived, Key, T, kKeyFieldType, + kValueFieldType>::SetMapIteratorValue(MapIterator* map_iter) const { const Map<Key, T>& map = impl_.GetMap(); typename Map<Key, T>::const_iterator iter = @@ -206,9 +204,9 @@ template <typename Derived, typename Key, typename T, WireFormatLite::FieldType kKeyFieldType, - WireFormatLite::FieldType kValueFieldType, int default_enum_value> -bool MapField<Derived, Key, T, kKeyFieldType, kValueFieldType, - default_enum_value>::ContainsMapKey(const MapKey& map_key) const { + WireFormatLite::FieldType kValueFieldType> +bool MapField<Derived, Key, T, kKeyFieldType, kValueFieldType>::ContainsMapKey( + const MapKey& map_key) const { const Map<Key, T>& map = impl_.GetMap(); const Key& key = UnwrapMapKey<Key>(map_key); typename Map<Key, T>::const_iterator iter = map.find(key); @@ -217,10 +215,10 @@ template <typename Derived, typename Key, typename T, WireFormatLite::FieldType kKeyFieldType, - WireFormatLite::FieldType kValueFieldType, int default_enum_value> -bool MapField<Derived, Key, T, kKeyFieldType, kValueFieldType, - default_enum_value>::InsertOrLookupMapValue(const MapKey& map_key, - MapValueRef* val) { + WireFormatLite::FieldType kValueFieldType> +bool MapField<Derived, Key, T, kKeyFieldType, + kValueFieldType>::InsertOrLookupMapValue(const MapKey& map_key, + MapValueRef* val) { // Always use mutable map because users may change the map value by // MapValueRef. Map<Key, T>* map = MutableMap(); @@ -238,18 +236,18 @@ template <typename Derived, typename Key, typename T, WireFormatLite::FieldType kKeyFieldType, - WireFormatLite::FieldType kValueFieldType, int default_enum_value> -bool MapField<Derived, Key, T, kKeyFieldType, kValueFieldType, - default_enum_value>::DeleteMapValue(const MapKey& map_key) { + WireFormatLite::FieldType kValueFieldType> +bool MapField<Derived, Key, T, kKeyFieldType, kValueFieldType>::DeleteMapValue( + const MapKey& map_key) { const Key& key = UnwrapMapKey<Key>(map_key); return MutableMap()->erase(key); } template <typename Derived, typename Key, typename T, WireFormatLite::FieldType kKeyFieldType, - WireFormatLite::FieldType kValueFieldType, int default_enum_value> -void MapField<Derived, Key, T, kKeyFieldType, kValueFieldType, - default_enum_value>::MergeFrom(const MapFieldBase& other) { + WireFormatLite::FieldType kValueFieldType> +void MapField<Derived, Key, T, kKeyFieldType, kValueFieldType>::MergeFrom( + const MapFieldBase& other) { MapFieldBase::SyncMapWithRepeatedField(); const MapField& other_field = static_cast<const MapField&>(other); other_field.SyncMapWithRepeatedField(); @@ -259,9 +257,9 @@ template <typename Derived, typename Key, typename T, WireFormatLite::FieldType kKeyFieldType, - WireFormatLite::FieldType kValueFieldType, int default_enum_value> -void MapField<Derived, Key, T, kKeyFieldType, kValueFieldType, - default_enum_value>::Swap(MapFieldBase* other) { + WireFormatLite::FieldType kValueFieldType> +void MapField<Derived, Key, T, kKeyFieldType, kValueFieldType>::Swap( + MapFieldBase* other) { MapField* other_field = down_cast<MapField*>(other); std::swap(this->MapFieldBase::repeated_field_, other_field->repeated_field_); impl_.Swap(&other_field->impl_); @@ -274,9 +272,9 @@ template <typename Derived, typename Key, typename T, WireFormatLite::FieldType kKeyFieldType, - WireFormatLite::FieldType kValueFieldType, int default_enum_value> -void MapField<Derived, Key, T, kKeyFieldType, kValueFieldType, - default_enum_value>::SyncRepeatedFieldWithMapNoLock() const { + WireFormatLite::FieldType kValueFieldType> +void MapField<Derived, Key, T, kKeyFieldType, + kValueFieldType>::SyncRepeatedFieldWithMapNoLock() const { if (this->MapFieldBase::repeated_field_ == NULL) { if (this->MapFieldBase::arena_ == NULL) { this->MapFieldBase::repeated_field_ = new RepeatedPtrField<Message>(); @@ -311,9 +309,9 @@ template <typename Derived, typename Key, typename T, WireFormatLite::FieldType kKeyFieldType, - WireFormatLite::FieldType kValueFieldType, int default_enum_value> -void MapField<Derived, Key, T, kKeyFieldType, kValueFieldType, - default_enum_value>::SyncMapWithRepeatedFieldNoLock() const { + WireFormatLite::FieldType kValueFieldType> +void MapField<Derived, Key, T, kKeyFieldType, + kValueFieldType>::SyncMapWithRepeatedFieldNoLock() const { Map<Key, T>* map = const_cast<MapField*>(this)->impl_.MutableMap(); RepeatedPtrField<EntryType>* repeated_field = reinterpret_cast<RepeatedPtrField<EntryType>*>( @@ -334,20 +332,15 @@ template <typename Derived, typename Key, typename T, WireFormatLite::FieldType kKeyFieldType, - WireFormatLite::FieldType kValueFieldType, int default_enum_value> -size_t MapField<Derived, Key, T, kKeyFieldType, kValueFieldType, - default_enum_value>::SpaceUsedExcludingSelfNoLock() const { + WireFormatLite::FieldType kValueFieldType> +size_t MapField<Derived, Key, T, kKeyFieldType, + kValueFieldType>::SpaceUsedExcludingSelfNoLock() const { size_t size = 0; if (this->MapFieldBase::repeated_field_ != NULL) { size += this->MapFieldBase::repeated_field_->SpaceUsedExcludingSelfLong(); } - Map<Key, T>* map = const_cast<MapField*>(this)->impl_.MutableMap(); - size += sizeof(*map); - for (typename Map<Key, T>::iterator it = map->begin(); it != map->end(); - ++it) { - size += KeyTypeHandler::SpaceUsedInMapLong(it->first); - size += ValueTypeHandler::SpaceUsedInMapLong(it->second); - } + size += impl_.GetMap().SpaceUsedExcludingSelfLong(); + return size; } } // namespace internal
diff --git a/src/google/protobuf/map_field_lite.h b/src/google/protobuf/map_field_lite.h index d641d17..db0ddc9 100644 --- a/src/google/protobuf/map_field_lite.h +++ b/src/google/protobuf/map_field_lite.h
@@ -54,7 +54,7 @@ // directly. template <typename Derived, typename Key, typename T, WireFormatLite::FieldType key_wire_type, - WireFormatLite::FieldType value_wire_type, int default_enum_value = 0> + WireFormatLite::FieldType value_wire_type> class MapFieldLite { // Define message type for internal repeated field. typedef Derived EntryType; @@ -63,9 +63,9 @@ typedef Map<Key, T> MapType; typedef EntryType EntryTypeTrait; - MapFieldLite() { SetDefaultEnumValue(); } + MapFieldLite() {} - explicit MapFieldLite(Arena* arena) : map_(arena) { SetDefaultEnumValue(); } + explicit MapFieldLite(Arena* arena) : map_(arena) {} // Accessors const Map<Key, T>& GetMap() const { return map_; } @@ -82,11 +82,6 @@ } void Swap(MapFieldLite* other) { map_.swap(other->map_); } - // Set default enum value only for proto2 map field whose value is enum type. - void SetDefaultEnumValue() { - MutableMap()->SetDefaultEnumValue(default_enum_value); - } - // Used in the implementation of parsing. Caller should take the ownership iff // arena_ is NULL. EntryType* NewEntry() const { @@ -154,10 +149,9 @@ // We want the C++ compiler to inline this or not as it sees fit. template <typename Derived, typename Key, typename T, WireFormatLite::FieldType key_wire_type, - WireFormatLite::FieldType value_wire_type, int default_enum_value> -bool AllAreInitialized( - const MapFieldLite<Derived, Key, T, key_wire_type, value_wire_type, - default_enum_value>& field) { + WireFormatLite::FieldType value_wire_type> +bool AllAreInitialized(const MapFieldLite<Derived, Key, T, key_wire_type, + value_wire_type>& field) { const auto& t = field.GetMap(); for (typename Map<Key, T>::const_iterator it = t.begin(); it != t.end(); ++it) { @@ -171,13 +165,12 @@ template <typename T, typename Key, typename Value, WireFormatLite::FieldType kKeyFieldType, - WireFormatLite::FieldType kValueFieldType, int default_enum_value> -struct MapEntryToMapField<MapEntryLite<T, Key, Value, kKeyFieldType, - kValueFieldType, default_enum_value>> { - typedef MapFieldLite<MapEntryLite<T, Key, Value, kKeyFieldType, - kValueFieldType, default_enum_value>, - Key, Value, kKeyFieldType, kValueFieldType, - default_enum_value> + WireFormatLite::FieldType kValueFieldType> +struct MapEntryToMapField< + MapEntryLite<T, Key, Value, kKeyFieldType, kValueFieldType>> { + typedef MapFieldLite< + MapEntryLite<T, Key, Value, kKeyFieldType, kValueFieldType>, Key, Value, + kKeyFieldType, kValueFieldType> MapFieldType; };
diff --git a/src/google/protobuf/map_field_test.cc b/src/google/protobuf/map_field_test.cc index 5ccb7b0..f05d68d 100644 --- a/src/google/protobuf/map_field_test.cc +++ b/src/google/protobuf/map_field_test.cc
@@ -99,7 +99,7 @@ protected: typedef unittest::TestMap_MapInt32Int32Entry_DoNotUse EntryType; typedef MapField<EntryType, int32, int32, WireFormatLite::TYPE_INT32, - WireFormatLite::TYPE_INT32, false> + WireFormatLite::TYPE_INT32> MapFieldType; MapFieldBasePrimitiveTest() { @@ -203,7 +203,7 @@ protected: typedef unittest::TestMap_MapInt32Int32Entry_DoNotUse EntryType; typedef MapField<EntryType, int32, int32, WireFormatLite::TYPE_INT32, - WireFormatLite::TYPE_INT32, false> + WireFormatLite::TYPE_INT32> MapFieldType; MapFieldStateTest() : state_(GetParam()) { // Build map field
diff --git a/src/google/protobuf/map_test.cc b/src/google/protobuf/map_test.cc index ab88dd0..9256f0e 100644 --- a/src/google/protobuf/map_test.cc +++ b/src/google/protobuf/map_test.cc
@@ -980,6 +980,46 @@ EXPECT_EQ(it1.GetKey().GetInt32Value(), it2.GetKey().GetInt32Value()); } +TEST_F(MapImplTest, SpaceUsed) { + constexpr size_t kMinCap = 8; + constexpr size_t kInnerMapOverhead = sizeof(size_t) * 4 + sizeof(void*) * 2; + + Map<int32, int32> m; + // To check the current overhead of an empty map. + // Ideally this should be zero. + EXPECT_EQ(m.SpaceUsedExcludingSelfLong(), + sizeof(void*) * kMinCap + kInnerMapOverhead); + + size_t capacity = kMinCap; + for (int i = 0; i < 100; ++i) { + m[i]; + static constexpr double kMaxLoadFactor = .75; + if (m.size() >= capacity * kMaxLoadFactor) { + capacity *= 2; + } + EXPECT_EQ(m.SpaceUsedExcludingSelfLong(), + sizeof(void*) * capacity + kInnerMapOverhead + + m.size() * sizeof(std::pair<std::pair<int32, int32>, void*>)); + } + + // Test string, and non-scalar keys. + Map<std::string, int32> m2; + std::string str = "Some arbitrarily large string"; + m2[str] = 1; + EXPECT_EQ(m2.SpaceUsedExcludingSelfLong(), + sizeof(void*) * kMinCap + kInnerMapOverhead + + sizeof(std::pair<std::pair<std::string, int32>, void*>) + + internal::StringSpaceUsedExcludingSelfLong(str)); + + // Test messages, and non-scalar values. + Map<int32, TestAllTypes> m3; + m3[0].set_optional_string(str); + EXPECT_EQ(m3.SpaceUsedExcludingSelfLong(), + sizeof(void*) * kMinCap + kInnerMapOverhead + + sizeof(std::pair<std::pair<int32, TestAllTypes>, void*>) + + m3[0].SpaceUsedLong() - sizeof(m3[0])); +} + // Attempts to verify that a map with keys a and b has a random ordering. This // function returns true if it succeeds in observing both possible orderings. bool MapOrderingIsRandom(int a, int b) { @@ -2507,6 +2547,27 @@ EXPECT_TRUE(map_message.IsInitialized()); } +TEST(GeneratedMapFieldTest, SpaceUsed) { + unittest::TestRequiredMessageMap map_message; + const size_t initial = map_message.SpaceUsed(); + const size_t space_used_message = unittest::TestRequired().SpaceUsed(); + + auto& m = *map_message.mutable_map_field(); + constexpr int kNumValues = 100; + for (int i = 0; i < kNumValues; ++i) { + m[i]; + } + + // The exact value will depend on internal state, like collisions, + // so we can't predict it. But we can predict a lower bound. + size_t lower_bound = + initial + kNumValues * (space_used_message + sizeof(int32) + + /* Node::next */ sizeof(void*) + + /* table entry */ sizeof(void*)); + + EXPECT_LE(lower_bound, map_message.SpaceUsed()); +} + TEST(GeneratedMapFieldTest, MessagesMustMerge) { unittest::TestRequiredMessageMap map_message;
diff --git a/src/google/protobuf/map_type_handler.h b/src/google/protobuf/map_type_handler.h index d54aa22..aba35be 100644 --- a/src/google/protobuf/map_type_handler.h +++ b/src/google/protobuf/map_type_handler.h
@@ -59,29 +59,6 @@ typedef FalseType type; }; -// In proto2 Map, enum needs to be initialized to given default value, while -// other types' default value can be inferred from the type. -template <bool IsEnum, typename Type> -class MapValueInitializer { - public: - static inline void Initialize(Type& type, int default_enum_value); -}; - -template <typename Type> -class MapValueInitializer<true, Type> { - public: - static inline void Initialize(Type& value, int default_enum_value) { - value = static_cast<Type>(default_enum_value); - } -}; - -template <typename Type> -class MapValueInitializer<false, Type> { - public: - static inline void Initialize(Type& /* value */, - int /* default_enum_value */) {} -}; - template <typename Type, bool is_arena_constructable> class MapArenaMessageCreator { public: @@ -180,19 +157,12 @@ static inline void DeleteNoArena(const Type* x); static inline void Merge(const Type& from, Type** to, Arena* arena); static inline void Clear(Type** value, Arena* arena); - static inline void ClearMaybeByDefaultEnum(Type** value, Arena* arena, - int default_enum_value); static inline void Initialize(Type** x, Arena* arena); - static inline void InitializeMaybeByDefaultEnum(Type** x, - int default_enum_value, - Arena* arena); static inline Type* EnsureMutable(Type** value, Arena* arena); // SpaceUsedInMapEntry: Return bytes used by value in MapEntry, excluding // those already calculate in sizeof(MapField). static inline size_t SpaceUsedInMapEntryLong(const Type* value); - // Return bytes used by value in Map. - static inline size_t SpaceUsedInMapLong(const Type& value); // Assign default value to given instance. static inline void AssignDefaultValue(Type** value); // Return default instance if value is not initialized when calling const @@ -235,21 +205,13 @@ static inline void Merge(const MapEntryAccessorType& from, \ TypeOnMemory* to, Arena* arena); \ static inline void Clear(TypeOnMemory* value, Arena* arena); \ - static inline void ClearMaybeByDefaultEnum(TypeOnMemory* value, \ - Arena* arena, \ - int default_enum); \ static inline size_t SpaceUsedInMapEntryLong(const TypeOnMemory& value); \ - static inline size_t SpaceUsedInMapLong(const TypeOnMemory& value); \ - static inline size_t SpaceUsedInMapLong(ConstStringParam value); \ static inline void AssignDefaultValue(TypeOnMemory* value); \ static inline const MapEntryAccessorType& DefaultIfNotInitialized( \ const TypeOnMemory& value, const TypeOnMemory& default_value); \ static inline bool IsInitialized(const TypeOnMemory& value); \ static void DeleteNoArena(TypeOnMemory& value); \ static inline void Initialize(TypeOnMemory* value, Arena* arena); \ - static inline void InitializeMaybeByDefaultEnum(TypeOnMemory* value, \ - int default_enum_value, \ - Arena* arena); \ static inline MapEntryAccessorType* EnsureMutable(TypeOnMemory* value, \ Arena* arena); \ }; @@ -547,23 +509,11 @@ } template <typename Type> -size_t MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type>::SpaceUsedInMapLong( - const Type& value) { - return value.SpaceUsedLong(); -} - -template <typename Type> inline void MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type>::Clear( Type** value, Arena* /* arena */) { if (*value != NULL) (*value)->Clear(); } template <typename Type> -inline void -MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type>::ClearMaybeByDefaultEnum( - Type** value, Arena* /* arena */, int /* default_enum_value */) { - if (*value != NULL) (*value)->Clear(); -} -template <typename Type> inline void MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type>::Merge( const Type& from, Type** to, Arena* /* arena */) { (*to)->MergeFrom(from); @@ -588,13 +538,6 @@ } template <typename Type> -inline void MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type>:: - InitializeMaybeByDefaultEnum(Type** x, int /* default_enum_value */, - Arena* /* arena */) { - *x = NULL; -} - -template <typename Type> inline Type* MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type>::EnsureMutable( Type** value, Arena* arena) { if (*value == NULL) { @@ -635,29 +578,11 @@ return sizeof(value); \ } \ template <typename Type> \ - inline size_t \ - MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::SpaceUsedInMapLong( \ - const TypeOnMemory& value) { \ - return sizeof(value); \ - } \ - template <typename Type> \ - inline size_t \ - MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::SpaceUsedInMapLong( \ - ConstStringParam value) { \ - return sizeof(std::string); \ - } \ - template <typename Type> \ inline void MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::Clear( \ TypeOnMemory* value, Arena* arena) { \ value->ClearToEmpty(&internal::GetEmptyStringAlreadyInited(), arena); \ } \ template <typename Type> \ - inline void MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>:: \ - ClearMaybeByDefaultEnum(TypeOnMemory* value, Arena* arena, \ - int /* default_enum */) { \ - Clear(value, arena); \ - } \ - template <typename Type> \ inline void MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::Merge( \ const MapEntryAccessorType& from, TypeOnMemory* to, Arena* arena) { \ to->Set(&internal::GetEmptyStringAlreadyInited(), from, arena); \ @@ -678,12 +603,6 @@ value->UnsafeSetDefault(&internal::GetEmptyStringAlreadyInited()); \ } \ template <typename Type> \ - inline void MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>:: \ - InitializeMaybeByDefaultEnum( \ - TypeOnMemory* value, int /* default_enum_value */, Arena* arena) { \ - Initialize(value, arena); \ - } \ - template <typename Type> \ inline typename MapTypeHandler<WireFormatLite::TYPE_##FieldType, \ Type>::MapEntryAccessorType* \ MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::EnsureMutable( \ @@ -722,23 +641,11 @@ return 0; \ } \ template <typename Type> \ - inline size_t \ - MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::SpaceUsedInMapLong( \ - const TypeOnMemory& /* value */) { \ - return sizeof(Type); \ - } \ - template <typename Type> \ inline void MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::Clear( \ TypeOnMemory* value, Arena* /* arena */) { \ *value = 0; \ } \ template <typename Type> \ - inline void MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>:: \ - ClearMaybeByDefaultEnum(TypeOnMemory* value, Arena* /* arena */, \ - int default_enum_value) { \ - *value = static_cast<TypeOnMemory>(default_enum_value); \ - } \ - template <typename Type> \ inline void MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::Merge( \ const MapEntryAccessorType& from, TypeOnMemory* to, \ Arena* /* arena */) { \ @@ -758,12 +665,6 @@ *value = 0; \ } \ template <typename Type> \ - inline void MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>:: \ - InitializeMaybeByDefaultEnum( \ - TypeOnMemory* value, int default_enum_value, Arena* /* arena */) { \ - *value = static_cast<TypeOnMemory>(default_enum_value); \ - } \ - template <typename Type> \ inline typename MapTypeHandler<WireFormatLite::TYPE_##FieldType, \ Type>::MapEntryAccessorType* \ MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::EnsureMutable( \
diff --git a/src/google/protobuf/port_def.inc b/src/google/protobuf/port_def.inc index 17c3767..86d4d17 100644 --- a/src/google/protobuf/port_def.inc +++ b/src/google/protobuf/port_def.inc
@@ -444,6 +444,10 @@ #undef NO #pragma push_macro("DEBUG") #undef DEBUG +#pragma push_macro("TRUE") +#undef TRUE +#pragma push_macro("FALSE") +#undef FALSE #endif // defined(__clang__) || defined(__GNUC__) || defined(_MSC_VER) #if defined(__clang__)
diff --git a/src/google/protobuf/port_undef.inc b/src/google/protobuf/port_undef.inc index 5fea276..6b37510 100644 --- a/src/google/protobuf/port_undef.inc +++ b/src/google/protobuf/port_undef.inc
@@ -99,6 +99,8 @@ #pragma pop_macro("YES") #pragma pop_macro("NO") #pragma pop_macro("DEBUG") +#pragma pop_macro("TRUE") +#pragma pop_macro("FALSE") #endif // defined(__clang__) || defined(__GNUC__) || defined(_MSC_VER) #if defined(__clang__)
diff --git a/src/google/protobuf/proto3_arena_unittest.cc b/src/google/protobuf/proto3_arena_unittest.cc index 11f8b65..b253f70 100644 --- a/src/google/protobuf/proto3_arena_unittest.cc +++ b/src/google/protobuf/proto3_arena_unittest.cc
@@ -293,6 +293,47 @@ EXPECT_TRUE(r->GetOneofFieldDescriptor(msg, o) == nullptr); } +// It's a regression test for b/160665543. +TEST(Proto3OptionalTest, ClearNonOptionalMessageField) { + protobuf_unittest::TestProto3OptionalMessage msg; + msg.mutable_nested_message(); + const google::protobuf::Descriptor* d = msg.GetDescriptor(); + const google::protobuf::Reflection* r = msg.GetReflection(); + const google::protobuf::FieldDescriptor* f = d->FindFieldByName("nested_message"); + r->ClearField(&msg, f); +} + +TEST(Proto3OptionalTest, ClearOptionalMessageField) { + protobuf_unittest::TestProto3OptionalMessage msg; + msg.mutable_optional_nested_message(); + const google::protobuf::Descriptor* d = msg.GetDescriptor(); + const google::protobuf::Reflection* r = msg.GetReflection(); + const google::protobuf::FieldDescriptor* f = + d->FindFieldByName("optional_nested_message"); + r->ClearField(&msg, f); +} + +TEST(Proto3OptionalTest, SwapNonOptionalMessageField) { + protobuf_unittest::TestProto3OptionalMessage msg1; + protobuf_unittest::TestProto3OptionalMessage msg2; + msg1.mutable_nested_message(); + const google::protobuf::Descriptor* d = msg1.GetDescriptor(); + const google::protobuf::Reflection* r = msg1.GetReflection(); + const google::protobuf::FieldDescriptor* f = d->FindFieldByName("nested_message"); + r->SwapFields(&msg1, &msg2, {f}); +} + +TEST(Proto3OptionalTest, SwapOptionalMessageField) { + protobuf_unittest::TestProto3OptionalMessage msg1; + protobuf_unittest::TestProto3OptionalMessage msg2; + msg1.mutable_optional_nested_message(); + const google::protobuf::Descriptor* d = msg1.GetDescriptor(); + const google::protobuf::Reflection* r = msg1.GetReflection(); + const google::protobuf::FieldDescriptor* f = + d->FindFieldByName("optional_nested_message"); + r->SwapFields(&msg1, &msg2, {f}); +} + void SetAllFieldsZero(protobuf_unittest::TestProto3Optional* msg) { msg->set_optional_int32(0); msg->set_optional_int64(0);
diff --git a/src/google/protobuf/source_context.pb.cc b/src/google/protobuf/source_context.pb.cc index 9f09bec..059456f 100644 --- a/src/google/protobuf/source_context.pb.cc +++ b/src/google/protobuf/source_context.pb.cc
@@ -57,11 +57,10 @@ const char descriptor_table_protodef_google_2fprotobuf_2fsource_5fcontext_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = "\n$google/protobuf/source_context.proto\022\017" "google.protobuf\"\"\n\rSourceContext\022\021\n\tfile" - "_name\030\001 \001(\tB\225\001\n\023com.google.protobufB\022Sou" - "rceContextProtoP\001ZAgoogle.golang.org/gen" - "proto/protobuf/source_context;source_con" - "text\242\002\003GPB\252\002\036Google.Protobuf.WellKnownTy" - "pesb\006proto3" + "_name\030\001 \001(\tB\212\001\n\023com.google.protobufB\022Sou" + "rceContextProtoP\001Z6google.golang.org/pro" + "tobuf/types/known/sourcecontextpb\242\002\003GPB\252" + "\002\036Google.Protobuf.WellKnownTypesb\006proto3" ; static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto_deps[1] = { }; @@ -70,7 +69,7 @@ }; static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto_once; const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto = { - false, false, descriptor_table_protodef_google_2fprotobuf_2fsource_5fcontext_2eproto, "google/protobuf/source_context.proto", 251, + false, false, descriptor_table_protodef_google_2fprotobuf_2fsource_5fcontext_2eproto, "google/protobuf/source_context.proto", 240, &descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto_once, descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto_sccs, descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto_deps, 1, 0, schemas, file_default_instances, TableStruct_google_2fprotobuf_2fsource_5fcontext_2eproto::offsets, file_level_metadata_google_2fprotobuf_2fsource_5fcontext_2eproto, 1, file_level_enum_descriptors_google_2fprotobuf_2fsource_5fcontext_2eproto, file_level_service_descriptors_google_2fprotobuf_2fsource_5fcontext_2eproto,
diff --git a/src/google/protobuf/source_context.proto b/src/google/protobuf/source_context.proto index f3b2c96..06bfc43 100644 --- a/src/google/protobuf/source_context.proto +++ b/src/google/protobuf/source_context.proto
@@ -37,7 +37,7 @@ option java_outer_classname = "SourceContextProto"; option java_multiple_files = true; option objc_class_prefix = "GPB"; -option go_package = "google.golang.org/genproto/protobuf/source_context;source_context"; +option go_package = "google.golang.org/protobuf/types/known/sourcecontextpb"; // `SourceContext` represents information about the source of a // protobuf element, like the file in which it is defined.
diff --git a/src/google/protobuf/struct.pb.cc b/src/google/protobuf/struct.pb.cc index 027fef6..54c9283 100644 --- a/src/google/protobuf/struct.pb.cc +++ b/src/google/protobuf/struct.pb.cc
@@ -136,11 +136,10 @@ "\000\0220\n\nlist_value\030\006 \001(\0132\032.google.protobuf." "ListValueH\000B\006\n\004kind\"3\n\tListValue\022&\n\006valu" "es\030\001 \003(\0132\026.google.protobuf.Value*\033\n\tNull" - "Value\022\016\n\nNULL_VALUE\020\000B\201\001\n\023com.google.pro" - "tobufB\013StructProtoP\001Z1github.com/golang/" - "protobuf/ptypes/struct;structpb\370\001\001\242\002\003GPB" - "\252\002\036Google.Protobuf.WellKnownTypesb\006proto" - "3" + "Value\022\016\n\nNULL_VALUE\020\000B\177\n\023com.google.prot" + "obufB\013StructProtoP\001Z/google.golang.org/p" + "rotobuf/types/known/structpb\370\001\001\242\002\003GPB\252\002\036" + "Google.Protobuf.WellKnownTypesb\006proto3" ; static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_google_2fprotobuf_2fstruct_2eproto_deps[1] = { }; @@ -149,7 +148,7 @@ }; static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_google_2fprotobuf_2fstruct_2eproto_once; const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fstruct_2eproto = { - false, false, descriptor_table_protodef_google_2fprotobuf_2fstruct_2eproto, "google/protobuf/struct.proto", 641, + false, false, descriptor_table_protodef_google_2fprotobuf_2fstruct_2eproto, "google/protobuf/struct.proto", 638, &descriptor_table_google_2fprotobuf_2fstruct_2eproto_once, descriptor_table_google_2fprotobuf_2fstruct_2eproto_sccs, descriptor_table_google_2fprotobuf_2fstruct_2eproto_deps, 1, 0, schemas, file_default_instances, TableStruct_google_2fprotobuf_2fstruct_2eproto::offsets, file_level_metadata_google_2fprotobuf_2fstruct_2eproto, 4, file_level_enum_descriptors_google_2fprotobuf_2fstruct_2eproto, file_level_service_descriptors_google_2fprotobuf_2fstruct_2eproto,
diff --git a/src/google/protobuf/struct.pb.h b/src/google/protobuf/struct.pb.h index e5d3604..772f1a4 100644 --- a/src/google/protobuf/struct.pb.h +++ b/src/google/protobuf/struct.pb.h
@@ -109,14 +109,12 @@ class Struct_FieldsEntry_DoNotUse : public ::PROTOBUF_NAMESPACE_ID::internal::MapEntry<Struct_FieldsEntry_DoNotUse, std::string, PROTOBUF_NAMESPACE_ID::Value, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_STRING, - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_MESSAGE, - 0 > { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_MESSAGE> { public: typedef ::PROTOBUF_NAMESPACE_ID::internal::MapEntry<Struct_FieldsEntry_DoNotUse, std::string, PROTOBUF_NAMESPACE_ID::Value, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_STRING, - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_MESSAGE, - 0 > SuperType; + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_MESSAGE> SuperType; Struct_FieldsEntry_DoNotUse(); explicit Struct_FieldsEntry_DoNotUse(::PROTOBUF_NAMESPACE_ID::Arena* arena); void MergeFrom(const Struct_FieldsEntry_DoNotUse& other); @@ -282,8 +280,7 @@ Struct_FieldsEntry_DoNotUse, std::string, PROTOBUF_NAMESPACE_ID::Value, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_STRING, - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_MESSAGE, - 0 > fields_; + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_MESSAGE> fields_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; friend struct ::TableStruct_google_2fprotobuf_2fstruct_2eproto; };
diff --git a/src/google/protobuf/struct.proto b/src/google/protobuf/struct.proto index ed990e3..545215c 100644 --- a/src/google/protobuf/struct.proto +++ b/src/google/protobuf/struct.proto
@@ -34,7 +34,7 @@ option csharp_namespace = "Google.Protobuf.WellKnownTypes"; option cc_enable_arenas = true; -option go_package = "github.com/golang/protobuf/ptypes/struct;structpb"; +option go_package = "google.golang.org/protobuf/types/known/structpb"; option java_package = "com.google.protobuf"; option java_outer_classname = "StructProto"; option java_multiple_files = true;
diff --git a/src/google/protobuf/test_messages_proto3.proto b/src/google/protobuf/test_messages_proto3.proto index a10f44d..4e409dc 100644 --- a/src/google/protobuf/test_messages_proto3.proto +++ b/src/google/protobuf/test_messages_proto3.proto
@@ -203,6 +203,7 @@ float oneof_float = 117; double oneof_double = 118; NestedEnum oneof_enum = 119; + google.protobuf.NullValue oneof_null_value = 120; } // Well-known types @@ -232,6 +233,7 @@ google.protobuf.Struct optional_struct = 304; google.protobuf.Any optional_any = 305; google.protobuf.Value optional_value = 306; + google.protobuf.NullValue optional_null_value = 307; repeated google.protobuf.Duration repeated_duration = 311; repeated google.protobuf.Timestamp repeated_timestamp = 312;
diff --git a/src/google/protobuf/timestamp.pb.cc b/src/google/protobuf/timestamp.pb.cc index 8b27210..1458bc0 100644 --- a/src/google/protobuf/timestamp.pb.cc +++ b/src/google/protobuf/timestamp.pb.cc
@@ -58,10 +58,10 @@ const char descriptor_table_protodef_google_2fprotobuf_2ftimestamp_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = "\n\037google/protobuf/timestamp.proto\022\017googl" "e.protobuf\"+\n\tTimestamp\022\017\n\007seconds\030\001 \001(\003" - "\022\r\n\005nanos\030\002 \001(\005B~\n\023com.google.protobufB\016" - "TimestampProtoP\001Z+github.com/golang/prot" - "obuf/ptypes/timestamp\370\001\001\242\002\003GPB\252\002\036Google." - "Protobuf.WellKnownTypesb\006proto3" + "\022\r\n\005nanos\030\002 \001(\005B\205\001\n\023com.google.protobufB" + "\016TimestampProtoP\001Z2google.golang.org/pro" + "tobuf/types/known/timestamppb\370\001\001\242\002\003GPB\252\002" + "\036Google.Protobuf.WellKnownTypesb\006proto3" ; static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_google_2fprotobuf_2ftimestamp_2eproto_deps[1] = { }; @@ -70,7 +70,7 @@ }; static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_google_2fprotobuf_2ftimestamp_2eproto_once; const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2ftimestamp_2eproto = { - false, false, descriptor_table_protodef_google_2fprotobuf_2ftimestamp_2eproto, "google/protobuf/timestamp.proto", 231, + false, false, descriptor_table_protodef_google_2fprotobuf_2ftimestamp_2eproto, "google/protobuf/timestamp.proto", 239, &descriptor_table_google_2fprotobuf_2ftimestamp_2eproto_once, descriptor_table_google_2fprotobuf_2ftimestamp_2eproto_sccs, descriptor_table_google_2fprotobuf_2ftimestamp_2eproto_deps, 1, 0, schemas, file_default_instances, TableStruct_google_2fprotobuf_2ftimestamp_2eproto::offsets, file_level_metadata_google_2fprotobuf_2ftimestamp_2eproto, 1, file_level_enum_descriptors_google_2fprotobuf_2ftimestamp_2eproto, file_level_service_descriptors_google_2fprotobuf_2ftimestamp_2eproto,
diff --git a/src/google/protobuf/timestamp.proto b/src/google/protobuf/timestamp.proto index cd35786..a343d81 100644 --- a/src/google/protobuf/timestamp.proto +++ b/src/google/protobuf/timestamp.proto
@@ -34,7 +34,7 @@ option csharp_namespace = "Google.Protobuf.WellKnownTypes"; option cc_enable_arenas = true; -option go_package = "github.com/golang/protobuf/ptypes/timestamp"; +option go_package = "google.golang.org/protobuf/types/known/timestamppb"; option java_package = "com.google.protobuf"; option java_outer_classname = "TimestampProto"; option java_multiple_files = true;
diff --git a/src/google/protobuf/type.pb.cc b/src/google/protobuf/type.pb.cc index 8da70ec..8da9559 100644 --- a/src/google/protobuf/type.pb.cc +++ b/src/google/protobuf/type.pb.cc
@@ -230,10 +230,10 @@ "\003 \003(\0132\027.google.protobuf.Option\";\n\006Option" "\022\014\n\004name\030\001 \001(\t\022#\n\005value\030\002 \001(\0132\024.google.p" "rotobuf.Any*.\n\006Syntax\022\021\n\rSYNTAX_PROTO2\020\000" - "\022\021\n\rSYNTAX_PROTO3\020\001B}\n\023com.google.protob" - "ufB\tTypeProtoP\001Z/google.golang.org/genpr" - "oto/protobuf/ptype;ptype\370\001\001\242\002\003GPB\252\002\036Goog" - "le.Protobuf.WellKnownTypesb\006proto3" + "\022\021\n\rSYNTAX_PROTO3\020\001B{\n\023com.google.protob" + "ufB\tTypeProtoP\001Z-google.golang.org/proto" + "buf/types/known/typepb\370\001\001\242\002\003GPB\252\002\036Google" + ".Protobuf.WellKnownTypesb\006proto3" ; static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_google_2fprotobuf_2ftype_2eproto_deps[2] = { &::descriptor_table_google_2fprotobuf_2fany_2eproto, @@ -248,7 +248,7 @@ }; static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_google_2fprotobuf_2ftype_2eproto_once; const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2ftype_2eproto = { - false, false, descriptor_table_protodef_google_2fprotobuf_2ftype_2eproto, "google/protobuf/type.proto", 1594, + false, false, descriptor_table_protodef_google_2fprotobuf_2ftype_2eproto, "google/protobuf/type.proto", 1592, &descriptor_table_google_2fprotobuf_2ftype_2eproto_once, descriptor_table_google_2fprotobuf_2ftype_2eproto_sccs, descriptor_table_google_2fprotobuf_2ftype_2eproto_deps, 5, 2, schemas, file_default_instances, TableStruct_google_2fprotobuf_2ftype_2eproto::offsets, file_level_metadata_google_2fprotobuf_2ftype_2eproto, 5, file_level_enum_descriptors_google_2fprotobuf_2ftype_2eproto, file_level_service_descriptors_google_2fprotobuf_2ftype_2eproto,
diff --git a/src/google/protobuf/type.proto b/src/google/protobuf/type.proto index e4b1d3a..d3f6a68 100644 --- a/src/google/protobuf/type.proto +++ b/src/google/protobuf/type.proto
@@ -41,7 +41,7 @@ option java_outer_classname = "TypeProto"; option java_multiple_files = true; option objc_class_prefix = "GPB"; -option go_package = "google.golang.org/genproto/protobuf/ptype;ptype"; +option go_package = "google.golang.org/protobuf/types/known/typepb"; // A protocol buffer message type. message Type { @@ -113,7 +113,7 @@ CARDINALITY_REQUIRED = 2; // For repeated fields. CARDINALITY_REPEATED = 3; - }; + } // The field type. Kind kind = 1;
diff --git a/src/google/protobuf/unittest_proto3_optional.proto b/src/google/protobuf/unittest_proto3_optional.proto index 3c47f12..e760021 100644 --- a/src/google/protobuf/unittest_proto3_optional.proto +++ b/src/google/protobuf/unittest_proto3_optional.proto
@@ -77,3 +77,12 @@ int32 singular_int32 = 22; int64 singular_int64 = 23; } + +message TestProto3OptionalMessage { + message NestedMessage { + string s = 1; + } + + NestedMessage nested_message = 1; + optional NestedMessage optional_nested_message = 2; +}
diff --git a/src/google/protobuf/util/internal/datapiece.cc b/src/google/protobuf/util/internal/datapiece.cc index 6ce7dbc..e76268a 100644 --- a/src/google/protobuf/util/internal/datapiece.cc +++ b/src/google/protobuf/util/internal/datapiece.cc
@@ -37,6 +37,7 @@ #include <google/protobuf/type.pb.h> #include <google/protobuf/descriptor.h> #include <google/protobuf/util/internal/utility.h> +#include <google/protobuf/stubs/status.h> #include <google/protobuf/stubs/strutil.h> #include <google/protobuf/stubs/mathutil.h>
diff --git a/src/google/protobuf/util/internal/field_mask_utility.cc b/src/google/protobuf/util/internal/field_mask_utility.cc index 40e193e..0beff99 100644 --- a/src/google/protobuf/util/internal/field_mask_utility.cc +++ b/src/google/protobuf/util/internal/field_mask_utility.cc
@@ -31,6 +31,7 @@ #include <google/protobuf/util/internal/field_mask_utility.h> #include <google/protobuf/util/internal/utility.h> +#include <google/protobuf/stubs/status.h> #include <google/protobuf/stubs/strutil.h> #include <google/protobuf/stubs/status_macros.h> @@ -107,7 +108,7 @@ } util::Status DecodeCompactFieldMaskPaths(StringPiece paths, - PathSinkCallback path_sink) { + PathSinkCallback path_sink) { std::stack<std::string> prefix; int length = paths.length(); int previous_position = 0;
diff --git a/src/google/protobuf/util/internal/field_mask_utility.h b/src/google/protobuf/util/internal/field_mask_utility.h index 7335af5..bc41321 100644 --- a/src/google/protobuf/util/internal/field_mask_utility.h +++ b/src/google/protobuf/util/internal/field_mask_utility.h
@@ -38,6 +38,7 @@ #include <google/protobuf/stubs/callback.h> #include <google/protobuf/stubs/common.h> +#include <google/protobuf/stubs/status.h> #include <google/protobuf/stubs/strutil.h> #include <google/protobuf/stubs/status.h> @@ -63,7 +64,7 @@ // Note that we also support Apiary style FieldMask form. The above example in // the Apiary style will look like "a.b,a.c(d,e)". util::Status DecodeCompactFieldMaskPaths(StringPiece paths, - PathSinkCallback path_sink); + PathSinkCallback path_sink); } // namespace converter } // namespace util
diff --git a/src/google/protobuf/util/internal/json_objectwriter.cc b/src/google/protobuf/util/internal/json_objectwriter.cc index a98e7ba..32ce2dc 100644 --- a/src/google/protobuf/util/internal/json_objectwriter.cc +++ b/src/google/protobuf/util/internal/json_objectwriter.cc
@@ -148,7 +148,7 @@ std::string base64; if (use_websafe_base64_for_bytes_) - WebSafeBase64EscapeWithPadding(value.ToString(), &base64); + WebSafeBase64EscapeWithPadding(std::string(value), &base64); else Base64Escape(value, &base64);
diff --git a/src/google/protobuf/util/internal/protostream_objectsource_test.cc b/src/google/protobuf/util/internal/protostream_objectsource_test.cc index b2daf3a..ab27349 100644 --- a/src/google/protobuf/util/internal/protostream_objectsource_test.cc +++ b/src/google/protobuf/util/internal/protostream_objectsource_test.cc
@@ -49,6 +49,7 @@ #include <google/protobuf/util/internal/constants.h> #include <gtest/gtest.h> #include <google/protobuf/stubs/casts.h> +#include <google/protobuf/stubs/status.h> namespace google {
diff --git a/src/google/protobuf/util/internal/protostream_objectwriter.cc b/src/google/protobuf/util/internal/protostream_objectwriter.cc index 527d5e7..7086163 100644 --- a/src/google/protobuf/util/internal/protostream_objectwriter.cc +++ b/src/google/protobuf/util/internal/protostream_objectwriter.cc
@@ -42,6 +42,7 @@ #include <google/protobuf/util/internal/constants.h> #include <google/protobuf/util/internal/utility.h> #include <google/protobuf/stubs/strutil.h> +#include <google/protobuf/stubs/status.h> #include <google/protobuf/stubs/time.h> #include <google/protobuf/stubs/map_util.h> #include <google/protobuf/stubs/statusor.h>
diff --git a/src/google/protobuf/util/internal/protostream_objectwriter_test.cc b/src/google/protobuf/util/internal/protostream_objectwriter_test.cc index 983043f..564050f 100644 --- a/src/google/protobuf/util/internal/protostream_objectwriter_test.cc +++ b/src/google/protobuf/util/internal/protostream_objectwriter_test.cc
@@ -93,12 +93,6 @@ } } // namespace -#if __cplusplus >= 201103L -using std::get; -#else -using std::tr1::get; -#endif - class BaseProtoStreamObjectWriterTest : public ::testing::TestWithParam<testing::TypeInfoSource> { protected: @@ -171,7 +165,7 @@ MATCHER_P(HasObjectLocation, expected, "Verifies the expected object location") { - std::string actual = get<0>(arg).ToString(); + std::string actual = std::get<0>(arg).ToString(); if (actual == expected) return true; *result_listener << "actual location is: " << actual; return false;
diff --git a/src/google/protobuf/util/internal/type_info.cc b/src/google/protobuf/util/internal/type_info.cc index e8b2103..e91afa0 100644 --- a/src/google/protobuf/util/internal/type_info.cc +++ b/src/google/protobuf/util/internal/type_info.cc
@@ -36,6 +36,7 @@ #include <google/protobuf/stubs/common.h> #include <google/protobuf/type.pb.h> #include <google/protobuf/util/internal/utility.h> +#include <google/protobuf/stubs/status.h> #include <google/protobuf/stubs/strutil.h> #include <google/protobuf/stubs/map_util.h> #include <google/protobuf/stubs/status.h>
diff --git a/src/google/protobuf/util/json_format_proto3.proto b/src/google/protobuf/util/json_format_proto3.proto index b62487a..0eec9da 100644 --- a/src/google/protobuf/util/json_format_proto3.proto +++ b/src/google/protobuf/util/json_format_proto3.proto
@@ -91,6 +91,7 @@ bytes oneof_bytes_value = 3; EnumType oneof_enum_value = 4; MessageType oneof_message_value = 5; + google.protobuf.NullValue oneof_null_value = 6; } }
diff --git a/src/google/protobuf/wire_format_lite.cc b/src/google/protobuf/wire_format_lite.cc index 47ad0f1..dc25608 100644 --- a/src/google/protobuf/wire_format_lite.cc +++ b/src/google/protobuf/wire_format_lite.cc
@@ -603,7 +603,6 @@ // efficient SSE code. template <bool ZigZag, bool SignExtended, typename T> static size_t VarintSize(const T* data, const int n) { -#if __cplusplus >= 201103L static_assert(sizeof(T) == 4, "This routine only works for 32 bit integers"); // is_unsigned<T> => !ZigZag static_assert( @@ -615,7 +614,6 @@ "Cannot SignExtended unsigned types"); static_assert(!(SignExtended && ZigZag), "Cannot SignExtended and ZigZag on the same type"); -#endif uint32 sum = n; uint32 msb_sum = 0; for (int i = 0; i < n; i++) { @@ -640,12 +638,10 @@ template <bool ZigZag, typename T> static size_t VarintSize64(const T* data, const int n) { -#if __cplusplus >= 201103L static_assert(sizeof(T) == 8, "This routine only works for 64 bit integers"); // is_unsigned<T> => !ZigZag static_assert(!ZigZag || !std::is_unsigned<T>::value, "Cannot ZigZag encode unsigned types"); -#endif uint64 sum = n; for (int i = 0; i < n; i++) { uint64 x = data[i];
diff --git a/src/google/protobuf/wrappers.pb.cc b/src/google/protobuf/wrappers.pb.cc index be039b4..e9f53a5 100644 --- a/src/google/protobuf/wrappers.pb.cc +++ b/src/google/protobuf/wrappers.pb.cc
@@ -270,11 +270,11 @@ "e\030\001 \001(\004\"\033\n\nInt32Value\022\r\n\005value\030\001 \001(\005\"\034\n\013" "UInt32Value\022\r\n\005value\030\001 \001(\r\"\032\n\tBoolValue\022" "\r\n\005value\030\001 \001(\010\"\034\n\013StringValue\022\r\n\005value\030\001" - " \001(\t\"\033\n\nBytesValue\022\r\n\005value\030\001 \001(\014B|\n\023com" - ".google.protobufB\rWrappersProtoP\001Z*githu" - "b.com/golang/protobuf/ptypes/wrappers\370\001\001" - "\242\002\003GPB\252\002\036Google.Protobuf.WellKnownTypesb" - "\006proto3" + " \001(\t\"\033\n\nBytesValue\022\r\n\005value\030\001 \001(\014B\203\001\n\023co" + "m.google.protobufB\rWrappersProtoP\001Z1goog" + "le.golang.org/protobuf/types/known/wrapp" + "erspb\370\001\001\242\002\003GPB\252\002\036Google.Protobuf.WellKno" + "wnTypesb\006proto3" ; static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_google_2fprotobuf_2fwrappers_2eproto_deps[1] = { }; @@ -291,7 +291,7 @@ }; static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_google_2fprotobuf_2fwrappers_2eproto_once; const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fwrappers_2eproto = { - false, false, descriptor_table_protodef_google_2fprotobuf_2fwrappers_2eproto, "google/protobuf/wrappers.proto", 447, + false, false, descriptor_table_protodef_google_2fprotobuf_2fwrappers_2eproto, "google/protobuf/wrappers.proto", 455, &descriptor_table_google_2fprotobuf_2fwrappers_2eproto_once, descriptor_table_google_2fprotobuf_2fwrappers_2eproto_sccs, descriptor_table_google_2fprotobuf_2fwrappers_2eproto_deps, 9, 0, schemas, file_default_instances, TableStruct_google_2fprotobuf_2fwrappers_2eproto::offsets, file_level_metadata_google_2fprotobuf_2fwrappers_2eproto, 9, file_level_enum_descriptors_google_2fprotobuf_2fwrappers_2eproto, file_level_service_descriptors_google_2fprotobuf_2fwrappers_2eproto,
diff --git a/src/google/protobuf/wrappers.proto b/src/google/protobuf/wrappers.proto index 9ee41e3..d49dd53 100644 --- a/src/google/protobuf/wrappers.proto +++ b/src/google/protobuf/wrappers.proto
@@ -44,7 +44,7 @@ option csharp_namespace = "Google.Protobuf.WellKnownTypes"; option cc_enable_arenas = true; -option go_package = "github.com/golang/protobuf/ptypes/wrappers"; +option go_package = "google.golang.org/protobuf/types/known/wrapperspb"; option java_package = "com.google.protobuf"; option java_outer_classname = "WrappersProto"; option java_multiple_files = true;