Merge pull request #7698 from haberman/sync-stage

Integrate from Piper for C++, Java, and Python
pull/7830/head
Joshua Haberman 5 years ago committed by GitHub
commit 214c77e1b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      BUILD
  2. 35
      CHANGES.txt
  3. 2
      cmake/README.md
  4. 1
      cmake/libprotobuf-lite.cmake
  5. 23
      conformance/binary_json_conformance_suite.cc
  6. 2
      conformance/failure_list_php_c.txt
  7. 2
      conformance/failure_list_php_c_32.txt
  8. 3
      conformance/failure_list_ruby.txt
  9. 261
      csharp/src/Google.Protobuf.Test.TestProtos/TestMessagesProto3.cs
  10. 418
      csharp/src/Google.Protobuf.Test.TestProtos/UnittestProto3Optional.cs
  11. 7
      csharp/src/Google.Protobuf/Reflection/Descriptor.cs
  12. 15
      csharp/src/Google.Protobuf/WellKnownTypes/Any.cs
  13. 8
      csharp/src/Google.Protobuf/WellKnownTypes/Api.cs
  14. 8
      csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs
  15. 8
      csharp/src/Google.Protobuf/WellKnownTypes/Empty.cs
  16. 9
      csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs
  17. 8
      csharp/src/Google.Protobuf/WellKnownTypes/SourceContext.cs
  18. 8
      csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs
  19. 18
      csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs
  20. 8
      csharp/src/Google.Protobuf/WellKnownTypes/Type.cs
  21. 9
      csharp/src/Google.Protobuf/WellKnownTypes/Wrappers.cs
  22. 31
      java/core/src/main/java/com/google/protobuf/DynamicMessage.java
  23. 6
      java/core/src/main/java/com/google/protobuf/MessageSchema.java
  24. 2
      java/core/src/main/java/com/google/protobuf/TextFormat.java
  25. 14
      java/core/src/test/java/com/google/protobuf/TextFormatTest.java
  26. 40
      java/lite/src/test/java/com/google/protobuf/LiteTest.java
  27. 11
      java/util/src/main/java/com/google/protobuf/util/JsonFormat.java
  28. 34
      js/gulpfile.js
  29. 12
      js/proto3_test.js
  30. 7
      js/proto3_test.proto
  31. 7
      objectivec/GPBAny.pbobjc.h
  32. 11
      objectivec/GPBTimestamp.pbobjc.h
  33. 4
      python/google/protobuf/internal/enum_type_wrapper.py
  34. 14
      python/google/protobuf/internal/json_format_test.py
  35. 4
      python/google/protobuf/internal/text_format_test.py
  36. 5
      python/google/protobuf/internal/type_checkers.py
  37. 5
      python/google/protobuf/json_format.py
  38. 15
      python/google/protobuf/text_format.py
  39. 1
      src/Makefile.am
  40. 14
      src/google/protobuf/any.cc
  41. 6
      src/google/protobuf/any.h
  42. 18
      src/google/protobuf/any.pb.cc
  43. 7
      src/google/protobuf/any.pb.h
  44. 9
      src/google/protobuf/any.proto
  45. 40
      src/google/protobuf/any_lite.cc
  46. 21
      src/google/protobuf/api.pb.cc
  47. 7
      src/google/protobuf/api.pb.h
  48. 4
      src/google/protobuf/api.proto
  49. 16
      src/google/protobuf/arena.cc
  50. 1
      src/google/protobuf/arena_impl.h
  51. 1
      src/google/protobuf/arena_unittest.cc
  52. 99
      src/google/protobuf/arenastring.h
  53. 6
      src/google/protobuf/compiler/code_generator.cc
  54. 10
      src/google/protobuf/compiler/code_generator.h
  55. 211
      src/google/protobuf/compiler/command_line_interface.cc
  56. 39
      src/google/protobuf/compiler/command_line_interface_unittest.cc
  57. 20
      src/google/protobuf/compiler/cpp/cpp_file.cc
  58. 12
      src/google/protobuf/compiler/cpp/cpp_helpers.cc
  59. 26
      src/google/protobuf/compiler/cpp/cpp_helpers.h
  60. 11
      src/google/protobuf/compiler/cpp/cpp_map_field.cc
  61. 472
      src/google/protobuf/compiler/cpp/cpp_message.cc
  62. 9
      src/google/protobuf/compiler/cpp/cpp_message.h
  63. 308
      src/google/protobuf/compiler/cpp/cpp_message_field.cc
  64. 581
      src/google/protobuf/compiler/cpp/cpp_string_field.cc
  65. 2
      src/google/protobuf/compiler/importer.cc
  66. 7
      src/google/protobuf/compiler/js/js_generator.cc
  67. 88
      src/google/protobuf/compiler/mock_code_generator.cc
  68. 4
      src/google/protobuf/compiler/mock_code_generator.h
  69. 10
      src/google/protobuf/compiler/plugin.cc
  70. 100
      src/google/protobuf/compiler/plugin.pb.cc
  71. 107
      src/google/protobuf/compiler/plugin.pb.h
  72. 7
      src/google/protobuf/compiler/plugin.proto
  73. 4
      src/google/protobuf/descriptor.cc
  74. 6
      src/google/protobuf/descriptor.h
  75. 112
      src/google/protobuf/descriptor.pb.cc
  76. 67
      src/google/protobuf/descriptor.pb.h
  77. 2
      src/google/protobuf/descriptor.proto
  78. 2
      src/google/protobuf/descriptor_unittest.cc
  79. 13
      src/google/protobuf/duration.pb.cc
  80. 1
      src/google/protobuf/duration.pb.h
  81. 2
      src/google/protobuf/duration.proto
  82. 7
      src/google/protobuf/dynamic_message.cc
  83. 13
      src/google/protobuf/empty.pb.cc
  84. 1
      src/google/protobuf/empty.pb.h
  85. 2
      src/google/protobuf/empty.proto
  86. 30
      src/google/protobuf/extension_set.cc
  87. 3
      src/google/protobuf/extension_set_unittest.cc
  88. 13
      src/google/protobuf/field_mask.pb.cc
  89. 1
      src/google/protobuf/field_mask.pb.h
  90. 2
      src/google/protobuf/field_mask.proto
  91. 94
      src/google/protobuf/generated_message_reflection.cc
  92. 14
      src/google/protobuf/generated_message_reflection.h
  93. 1
      src/google/protobuf/generated_message_reflection_unittest.cc
  94. 2
      src/google/protobuf/generated_message_util.cc
  95. 7
      src/google/protobuf/io/tokenizer.cc
  96. 5
      src/google/protobuf/io/tokenizer_unittest.cc
  97. 1
      src/google/protobuf/io/zero_copy_stream_impl.h
  98. 28
      src/google/protobuf/io/zero_copy_stream_impl_lite.cc
  99. 2
      src/google/protobuf/io/zero_copy_stream_impl_lite.h
  100. 15
      src/google/protobuf/io/zero_copy_stream_unittest.cc
  101. Some files were not shown because too many files have changed in this diff Show More

@ -175,6 +175,7 @@ cc_library(
"src/google/protobuf/io/zero_copy_stream.cc", "src/google/protobuf/io/zero_copy_stream.cc",
"src/google/protobuf/io/zero_copy_stream_impl.cc", "src/google/protobuf/io/zero_copy_stream_impl.cc",
"src/google/protobuf/io/zero_copy_stream_impl_lite.cc", "src/google/protobuf/io/zero_copy_stream_impl_lite.cc",
"src/google/protobuf/map.cc",
"src/google/protobuf/message_lite.cc", "src/google/protobuf/message_lite.cc",
"src/google/protobuf/parse_context.cc", "src/google/protobuf/parse_context.cc",
"src/google/protobuf/repeated_field.cc", "src/google/protobuf/repeated_field.cc",

@ -1,3 +1,38 @@
Unreleased Changes
Protocol Compiler
* The proto compiler no longer requires a .proto filename when it is not
generating code.
C++
* Arenas are now unconditionally enabled. cc_enable_arenas no longer has
any effect.
* Fix a memory corruption bug in reflection when mixing optional and
non-optional fields.
* Make SpaceUsed() calculation more thorough for map fields.
* Add stack overflow protection for text format with unknown field values.
* FieldPath::FollowAll() now returns a bool to signal if an out-of-bounds
error was encountered.
* Performance improvements for Map.
* Minor formatting fix when dumping a descriptor to .proto format with
DebugString.
* UBSAN fix in RepeatedField (#2073).
* When running under ASAN, skip a test that makes huge allocations.
* Fixed a crash that could happen when creating more than 256 extensions in
a single message.
Java
* Bugfix in mergeFrom() when a oneof has multiple message fields.
Python
* Print google.protobuf.NullValue as null instead of "NULL_VALUE" when it is
used outside WKT Value/Struct.
* Fix bug occurring when attempting to deep copy an enum type in python 3.
Go:
* Update go_package options to reference google.golang.org/protobuf module.
2020-07-14 version 3.13.0-rc1 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript) 2020-07-14 version 3.13.0-rc1 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
C++: C++:

@ -66,7 +66,7 @@ Remember to update any submodules if you are using git clone (you can skip this
step if you are using a release .tar.gz or .zip package): step if you are using a release .tar.gz or .zip package):
```console ```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: Now go to *cmake* folder in protobuf sources:

@ -12,6 +12,7 @@ set(libprotobuf_lite_files
${protobuf_source_dir}/src/google/protobuf/io/zero_copy_stream.cc ${protobuf_source_dir}/src/google/protobuf/io/zero_copy_stream.cc
${protobuf_source_dir}/src/google/protobuf/io/zero_copy_stream_impl.cc ${protobuf_source_dir}/src/google/protobuf/io/zero_copy_stream_impl.cc
${protobuf_source_dir}/src/google/protobuf/io/zero_copy_stream_impl_lite.cc ${protobuf_source_dir}/src/google/protobuf/io/zero_copy_stream_impl_lite.cc
${protobuf_source_dir}/src/google/protobuf/map.cc
${protobuf_source_dir}/src/google/protobuf/message_lite.cc ${protobuf_source_dir}/src/google/protobuf/message_lite.cc
${protobuf_source_dir}/src/google/protobuf/parse_context.cc ${protobuf_source_dir}/src/google/protobuf/parse_context.cc
${protobuf_source_dir}/src/google/protobuf/repeated_field.cc ${protobuf_source_dir}/src/google/protobuf/repeated_field.cc

@ -3051,6 +3051,29 @@ void BinaryAndJsonConformanceSuite::RunJsonTestsForValue() {
} }
] ]
)"); )");
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() { void BinaryAndJsonConformanceSuite::RunJsonTestsForAny() {

@ -1,2 +1,4 @@
Recommended.Proto2.JsonInput.FieldNameExtension.Validator Recommended.Proto2.JsonInput.FieldNameExtension.Validator
Recommended.Proto3.JsonInput.NullValueInOtherOneofNewFormat.Validator
Recommended.Proto3.JsonInput.NullValueInOtherOneofOldFormat.Validator
Required.Proto2.JsonInput.StoresDefaultPrimitive.Validator Required.Proto2.JsonInput.StoresDefaultPrimitive.Validator

@ -1,2 +1,4 @@
Recommended.Proto2.JsonInput.FieldNameExtension.Validator Recommended.Proto2.JsonInput.FieldNameExtension.Validator
Recommended.Proto3.JsonInput.NullValueInOtherOneofNewFormat.Validator
Recommended.Proto3.JsonInput.NullValueInOtherOneofOldFormat.Validator
Required.Proto2.JsonInput.StoresDefaultPrimitive.Validator Required.Proto2.JsonInput.StoresDefaultPrimitive.Validator

@ -8,6 +8,9 @@ Recommended.Proto3.JsonInput.DurationHas3FractionalDigits.Validator
Recommended.Proto3.JsonInput.DurationHas6FractionalDigits.Validator Recommended.Proto3.JsonInput.DurationHas6FractionalDigits.Validator
Recommended.Proto3.JsonInput.FieldMaskInvalidCharacter Recommended.Proto3.JsonInput.FieldMaskInvalidCharacter
Recommended.Proto3.JsonInput.MapFieldValueIsNull Recommended.Proto3.JsonInput.MapFieldValueIsNull
Recommended.Proto3.JsonInput.NullValueInNormalMessage.Validator
Recommended.Proto3.JsonInput.NullValueInOtherOneofNewFormat.Validator
Recommended.Proto3.JsonInput.NullValueInOtherOneofOldFormat.Validator
Recommended.Proto3.JsonInput.RepeatedFieldMessageElementIsNull Recommended.Proto3.JsonInput.RepeatedFieldMessageElementIsNull
Recommended.Proto3.JsonInput.RepeatedFieldPrimitiveElementIsNull Recommended.Proto3.JsonInput.RepeatedFieldPrimitiveElementIsNull
Recommended.Proto3.JsonInput.StringEndsWithEscapeChar Recommended.Proto3.JsonInput.StringEndsWithEscapeChar

@ -29,7 +29,7 @@ namespace ProtobufTestMessages.Proto3 {
"dWYvYW55LnByb3RvGh5nb29nbGUvcHJvdG9idWYvZHVyYXRpb24ucHJvdG8a", "dWYvYW55LnByb3RvGh5nb29nbGUvcHJvdG9idWYvZHVyYXRpb24ucHJvdG8a",
"IGdvb2dsZS9wcm90b2J1Zi9maWVsZF9tYXNrLnByb3RvGhxnb29nbGUvcHJv", "IGdvb2dsZS9wcm90b2J1Zi9maWVsZF9tYXNrLnByb3RvGhxnb29nbGUvcHJv",
"dG9idWYvc3RydWN0LnByb3RvGh9nb29nbGUvcHJvdG9idWYvdGltZXN0YW1w", "dG9idWYvc3RydWN0LnByb3RvGh9nb29nbGUvcHJvdG9idWYvdGltZXN0YW1w",
"LnByb3RvGh5nb29nbGUvcHJvdG9idWYvd3JhcHBlcnMucHJvdG8iv0QKElRl", "LnByb3RvGh5nb29nbGUvcHJvdG9idWYvd3JhcHBlcnMucHJvdG8isUUKElRl",
"c3RBbGxUeXBlc1Byb3RvMxIWCg5vcHRpb25hbF9pbnQzMhgBIAEoBRIWCg5v", "c3RBbGxUeXBlc1Byb3RvMxIWCg5vcHRpb25hbF9pbnQzMhgBIAEoBRIWCg5v",
"cHRpb25hbF9pbnQ2NBgCIAEoAxIXCg9vcHRpb25hbF91aW50MzIYAyABKA0S", "cHRpb25hbF9pbnQ2NBgCIAEoAxIXCg9vcHRpb25hbF91aW50MzIYAyABKA0S",
"FwoPb3B0aW9uYWxfdWludDY0GAQgASgEEhcKD29wdGlvbmFsX3NpbnQzMhgF", "FwoPb3B0aW9uYWxfdWludDY0GAQgASgEEhcKD29wdGlvbmFsX3NpbnQzMhgF",
@ -140,99 +140,101 @@ namespace ProtobufTestMessages.Proto3 {
"IAEoBEgAEhUKC29uZW9mX2Zsb2F0GHUgASgCSAASFgoMb25lb2ZfZG91Ymxl", "IAEoBEgAEhUKC29uZW9mX2Zsb2F0GHUgASgCSAASFgoMb25lb2ZfZG91Ymxl",
"GHYgASgBSAASUgoKb25lb2ZfZW51bRh3IAEoDjI8LnByb3RvYnVmX3Rlc3Rf", "GHYgASgBSAASUgoKb25lb2ZfZW51bRh3IAEoDjI8LnByb3RvYnVmX3Rlc3Rf",
"bWVzc2FnZXMucHJvdG8zLlRlc3RBbGxUeXBlc1Byb3RvMy5OZXN0ZWRFbnVt", "bWVzc2FnZXMucHJvdG8zLlRlc3RBbGxUeXBlc1Byb3RvMy5OZXN0ZWRFbnVt",
"SAASOgoVb3B0aW9uYWxfYm9vbF93cmFwcGVyGMkBIAEoCzIaLmdvb2dsZS5w", "SAASNgoQb25lb2ZfbnVsbF92YWx1ZRh4IAEoDjIaLmdvb2dsZS5wcm90b2J1",
"cm90b2J1Zi5Cb29sVmFsdWUSPAoWb3B0aW9uYWxfaW50MzJfd3JhcHBlchjK", "Zi5OdWxsVmFsdWVIABI6ChVvcHRpb25hbF9ib29sX3dyYXBwZXIYyQEgASgL",
"ASABKAsyGy5nb29nbGUucHJvdG9idWYuSW50MzJWYWx1ZRI8ChZvcHRpb25h", "MhouZ29vZ2xlLnByb3RvYnVmLkJvb2xWYWx1ZRI8ChZvcHRpb25hbF9pbnQz",
"bF9pbnQ2NF93cmFwcGVyGMsBIAEoCzIbLmdvb2dsZS5wcm90b2J1Zi5JbnQ2", "Ml93cmFwcGVyGMoBIAEoCzIbLmdvb2dsZS5wcm90b2J1Zi5JbnQzMlZhbHVl",
"NFZhbHVlEj4KF29wdGlvbmFsX3VpbnQzMl93cmFwcGVyGMwBIAEoCzIcLmdv", "EjwKFm9wdGlvbmFsX2ludDY0X3dyYXBwZXIYywEgASgLMhsuZ29vZ2xlLnBy",
"b2dsZS5wcm90b2J1Zi5VSW50MzJWYWx1ZRI+ChdvcHRpb25hbF91aW50NjRf", "b3RvYnVmLkludDY0VmFsdWUSPgoXb3B0aW9uYWxfdWludDMyX3dyYXBwZXIY",
"d3JhcHBlchjNASABKAsyHC5nb29nbGUucHJvdG9idWYuVUludDY0VmFsdWUS", "zAEgASgLMhwuZ29vZ2xlLnByb3RvYnVmLlVJbnQzMlZhbHVlEj4KF29wdGlv",
"PAoWb3B0aW9uYWxfZmxvYXRfd3JhcHBlchjOASABKAsyGy5nb29nbGUucHJv", "bmFsX3VpbnQ2NF93cmFwcGVyGM0BIAEoCzIcLmdvb2dsZS5wcm90b2J1Zi5V",
"dG9idWYuRmxvYXRWYWx1ZRI+ChdvcHRpb25hbF9kb3VibGVfd3JhcHBlchjP", "SW50NjRWYWx1ZRI8ChZvcHRpb25hbF9mbG9hdF93cmFwcGVyGM4BIAEoCzIb",
"ASABKAsyHC5nb29nbGUucHJvdG9idWYuRG91YmxlVmFsdWUSPgoXb3B0aW9u", "Lmdvb2dsZS5wcm90b2J1Zi5GbG9hdFZhbHVlEj4KF29wdGlvbmFsX2RvdWJs",
"YWxfc3RyaW5nX3dyYXBwZXIY0AEgASgLMhwuZ29vZ2xlLnByb3RvYnVmLlN0", "ZV93cmFwcGVyGM8BIAEoCzIcLmdvb2dsZS5wcm90b2J1Zi5Eb3VibGVWYWx1",
"cmluZ1ZhbHVlEjwKFm9wdGlvbmFsX2J5dGVzX3dyYXBwZXIY0QEgASgLMhsu", "ZRI+ChdvcHRpb25hbF9zdHJpbmdfd3JhcHBlchjQASABKAsyHC5nb29nbGUu",
"Z29vZ2xlLnByb3RvYnVmLkJ5dGVzVmFsdWUSOgoVcmVwZWF0ZWRfYm9vbF93", "cHJvdG9idWYuU3RyaW5nVmFsdWUSPAoWb3B0aW9uYWxfYnl0ZXNfd3JhcHBl",
"cmFwcGVyGNMBIAMoCzIaLmdvb2dsZS5wcm90b2J1Zi5Cb29sVmFsdWUSPAoW", "chjRASABKAsyGy5nb29nbGUucHJvdG9idWYuQnl0ZXNWYWx1ZRI6ChVyZXBl",
"cmVwZWF0ZWRfaW50MzJfd3JhcHBlchjUASADKAsyGy5nb29nbGUucHJvdG9i", "YXRlZF9ib29sX3dyYXBwZXIY0wEgAygLMhouZ29vZ2xlLnByb3RvYnVmLkJv",
"dWYuSW50MzJWYWx1ZRI8ChZyZXBlYXRlZF9pbnQ2NF93cmFwcGVyGNUBIAMo", "b2xWYWx1ZRI8ChZyZXBlYXRlZF9pbnQzMl93cmFwcGVyGNQBIAMoCzIbLmdv",
"CzIbLmdvb2dsZS5wcm90b2J1Zi5JbnQ2NFZhbHVlEj4KF3JlcGVhdGVkX3Vp", "b2dsZS5wcm90b2J1Zi5JbnQzMlZhbHVlEjwKFnJlcGVhdGVkX2ludDY0X3dy",
"bnQzMl93cmFwcGVyGNYBIAMoCzIcLmdvb2dsZS5wcm90b2J1Zi5VSW50MzJW", "YXBwZXIY1QEgAygLMhsuZ29vZ2xlLnByb3RvYnVmLkludDY0VmFsdWUSPgoX",
"YWx1ZRI+ChdyZXBlYXRlZF91aW50NjRfd3JhcHBlchjXASADKAsyHC5nb29n", "cmVwZWF0ZWRfdWludDMyX3dyYXBwZXIY1gEgAygLMhwuZ29vZ2xlLnByb3Rv",
"bGUucHJvdG9idWYuVUludDY0VmFsdWUSPAoWcmVwZWF0ZWRfZmxvYXRfd3Jh", "YnVmLlVJbnQzMlZhbHVlEj4KF3JlcGVhdGVkX3VpbnQ2NF93cmFwcGVyGNcB",
"cHBlchjYASADKAsyGy5nb29nbGUucHJvdG9idWYuRmxvYXRWYWx1ZRI+Chdy", "IAMoCzIcLmdvb2dsZS5wcm90b2J1Zi5VSW50NjRWYWx1ZRI8ChZyZXBlYXRl",
"ZXBlYXRlZF9kb3VibGVfd3JhcHBlchjZASADKAsyHC5nb29nbGUucHJvdG9i", "ZF9mbG9hdF93cmFwcGVyGNgBIAMoCzIbLmdvb2dsZS5wcm90b2J1Zi5GbG9h",
"dWYuRG91YmxlVmFsdWUSPgoXcmVwZWF0ZWRfc3RyaW5nX3dyYXBwZXIY2gEg", "dFZhbHVlEj4KF3JlcGVhdGVkX2RvdWJsZV93cmFwcGVyGNkBIAMoCzIcLmdv",
"AygLMhwuZ29vZ2xlLnByb3RvYnVmLlN0cmluZ1ZhbHVlEjwKFnJlcGVhdGVk", "b2dsZS5wcm90b2J1Zi5Eb3VibGVWYWx1ZRI+ChdyZXBlYXRlZF9zdHJpbmdf",
"X2J5dGVzX3dyYXBwZXIY2wEgAygLMhsuZ29vZ2xlLnByb3RvYnVmLkJ5dGVz", "d3JhcHBlchjaASADKAsyHC5nb29nbGUucHJvdG9idWYuU3RyaW5nVmFsdWUS",
"VmFsdWUSNQoRb3B0aW9uYWxfZHVyYXRpb24YrQIgASgLMhkuZ29vZ2xlLnBy", "PAoWcmVwZWF0ZWRfYnl0ZXNfd3JhcHBlchjbASADKAsyGy5nb29nbGUucHJv",
"b3RvYnVmLkR1cmF0aW9uEjcKEm9wdGlvbmFsX3RpbWVzdGFtcBiuAiABKAsy", "dG9idWYuQnl0ZXNWYWx1ZRI1ChFvcHRpb25hbF9kdXJhdGlvbhitAiABKAsy",
"Gi5nb29nbGUucHJvdG9idWYuVGltZXN0YW1wEjgKE29wdGlvbmFsX2ZpZWxk", "GS5nb29nbGUucHJvdG9idWYuRHVyYXRpb24SNwoSb3B0aW9uYWxfdGltZXN0",
"X21hc2sYrwIgASgLMhouZ29vZ2xlLnByb3RvYnVmLkZpZWxkTWFzaxIxCg9v", "YW1wGK4CIAEoCzIaLmdvb2dsZS5wcm90b2J1Zi5UaW1lc3RhbXASOAoTb3B0",
"cHRpb25hbF9zdHJ1Y3QYsAIgASgLMhcuZ29vZ2xlLnByb3RvYnVmLlN0cnVj", "aW9uYWxfZmllbGRfbWFzaxivAiABKAsyGi5nb29nbGUucHJvdG9idWYuRmll",
"dBIrCgxvcHRpb25hbF9hbnkYsQIgASgLMhQuZ29vZ2xlLnByb3RvYnVmLkFu", "bGRNYXNrEjEKD29wdGlvbmFsX3N0cnVjdBiwAiABKAsyFy5nb29nbGUucHJv",
"eRIvCg5vcHRpb25hbF92YWx1ZRiyAiABKAsyFi5nb29nbGUucHJvdG9idWYu", "dG9idWYuU3RydWN0EisKDG9wdGlvbmFsX2FueRixAiABKAsyFC5nb29nbGUu",
"VmFsdWUSNQoRcmVwZWF0ZWRfZHVyYXRpb24YtwIgAygLMhkuZ29vZ2xlLnBy", "cHJvdG9idWYuQW55Ei8KDm9wdGlvbmFsX3ZhbHVlGLICIAEoCzIWLmdvb2ds",
"b3RvYnVmLkR1cmF0aW9uEjcKEnJlcGVhdGVkX3RpbWVzdGFtcBi4AiADKAsy", "ZS5wcm90b2J1Zi5WYWx1ZRI4ChNvcHRpb25hbF9udWxsX3ZhbHVlGLMCIAEo",
"Gi5nb29nbGUucHJvdG9idWYuVGltZXN0YW1wEjcKEnJlcGVhdGVkX2ZpZWxk", "DjIaLmdvb2dsZS5wcm90b2J1Zi5OdWxsVmFsdWUSNQoRcmVwZWF0ZWRfZHVy",
"bWFzaxi5AiADKAsyGi5nb29nbGUucHJvdG9idWYuRmllbGRNYXNrEjEKD3Jl", "YXRpb24YtwIgAygLMhkuZ29vZ2xlLnByb3RvYnVmLkR1cmF0aW9uEjcKEnJl",
"cGVhdGVkX3N0cnVjdBjEAiADKAsyFy5nb29nbGUucHJvdG9idWYuU3RydWN0", "cGVhdGVkX3RpbWVzdGFtcBi4AiADKAsyGi5nb29nbGUucHJvdG9idWYuVGlt",
"EisKDHJlcGVhdGVkX2FueRi7AiADKAsyFC5nb29nbGUucHJvdG9idWYuQW55", "ZXN0YW1wEjcKEnJlcGVhdGVkX2ZpZWxkbWFzaxi5AiADKAsyGi5nb29nbGUu",
"Ei8KDnJlcGVhdGVkX3ZhbHVlGLwCIAMoCzIWLmdvb2dsZS5wcm90b2J1Zi5W", "cHJvdG9idWYuRmllbGRNYXNrEjEKD3JlcGVhdGVkX3N0cnVjdBjEAiADKAsy",
"YWx1ZRI4ChNyZXBlYXRlZF9saXN0X3ZhbHVlGL0CIAMoCzIaLmdvb2dsZS5w", "Fy5nb29nbGUucHJvdG9idWYuU3RydWN0EisKDHJlcGVhdGVkX2FueRi7AiAD",
"cm90b2J1Zi5MaXN0VmFsdWUSEwoKZmllbGRuYW1lMRiRAyABKAUSFAoLZmll", "KAsyFC5nb29nbGUucHJvdG9idWYuQW55Ei8KDnJlcGVhdGVkX3ZhbHVlGLwC",
"bGRfbmFtZTIYkgMgASgFEhUKDF9maWVsZF9uYW1lMxiTAyABKAUSFgoNZmll", "IAMoCzIWLmdvb2dsZS5wcm90b2J1Zi5WYWx1ZRI4ChNyZXBlYXRlZF9saXN0",
"bGRfX25hbWU0XxiUAyABKAUSFAoLZmllbGQwbmFtZTUYlQMgASgFEhYKDWZp", "X3ZhbHVlGL0CIAMoCzIaLmdvb2dsZS5wcm90b2J1Zi5MaXN0VmFsdWUSEwoK",
"ZWxkXzBfbmFtZTYYlgMgASgFEhMKCmZpZWxkTmFtZTcYlwMgASgFEhMKCkZp", "ZmllbGRuYW1lMRiRAyABKAUSFAoLZmllbGRfbmFtZTIYkgMgASgFEhUKDF9m",
"ZWxkTmFtZTgYmAMgASgFEhQKC2ZpZWxkX05hbWU5GJkDIAEoBRIVCgxGaWVs", "aWVsZF9uYW1lMxiTAyABKAUSFgoNZmllbGRfX25hbWU0XxiUAyABKAUSFAoL",
"ZF9OYW1lMTAYmgMgASgFEhUKDEZJRUxEX05BTUUxMRibAyABKAUSFQoMRklF", "ZmllbGQwbmFtZTUYlQMgASgFEhYKDWZpZWxkXzBfbmFtZTYYlgMgASgFEhMK",
"TERfbmFtZTEyGJwDIAEoBRIXCg5fX2ZpZWxkX25hbWUxMxidAyABKAUSFwoO", "CmZpZWxkTmFtZTcYlwMgASgFEhMKCkZpZWxkTmFtZTgYmAMgASgFEhQKC2Zp",
"X19GaWVsZF9uYW1lMTQYngMgASgFEhYKDWZpZWxkX19uYW1lMTUYnwMgASgF", "ZWxkX05hbWU5GJkDIAEoBRIVCgxGaWVsZF9OYW1lMTAYmgMgASgFEhUKDEZJ",
"EhYKDWZpZWxkX19OYW1lMTYYoAMgASgFEhcKDmZpZWxkX25hbWUxN19fGKED", "RUxEX05BTUUxMRibAyABKAUSFQoMRklFTERfbmFtZTEyGJwDIAEoBRIXCg5f",
"IAEoBRIXCg5GaWVsZF9uYW1lMThfXxiiAyABKAUaYgoNTmVzdGVkTWVzc2Fn", "X2ZpZWxkX25hbWUxMxidAyABKAUSFwoOX19GaWVsZF9uYW1lMTQYngMgASgF",
"ZRIJCgFhGAEgASgFEkYKC2NvcmVjdXJzaXZlGAIgASgLMjEucHJvdG9idWZf", "EhYKDWZpZWxkX19uYW1lMTUYnwMgASgFEhYKDWZpZWxkX19OYW1lMTYYoAMg",
"dGVzdF9tZXNzYWdlcy5wcm90bzMuVGVzdEFsbFR5cGVzUHJvdG8zGjQKEk1h", "ASgFEhcKDmZpZWxkX25hbWUxN19fGKEDIAEoBRIXCg5GaWVsZF9uYW1lMThf",
"cEludDMySW50MzJFbnRyeRILCgNrZXkYASABKAUSDQoFdmFsdWUYAiABKAU6", "XxiiAyABKAUaYgoNTmVzdGVkTWVzc2FnZRIJCgFhGAEgASgFEkYKC2NvcmVj",
"AjgBGjQKEk1hcEludDY0SW50NjRFbnRyeRILCgNrZXkYASABKAMSDQoFdmFs", "dXJzaXZlGAIgASgLMjEucHJvdG9idWZfdGVzdF9tZXNzYWdlcy5wcm90bzMu",
"dWUYAiABKAM6AjgBGjYKFE1hcFVpbnQzMlVpbnQzMkVudHJ5EgsKA2tleRgB", "VGVzdEFsbFR5cGVzUHJvdG8zGjQKEk1hcEludDMySW50MzJFbnRyeRILCgNr",
"IAEoDRINCgV2YWx1ZRgCIAEoDToCOAEaNgoUTWFwVWludDY0VWludDY0RW50", "ZXkYASABKAUSDQoFdmFsdWUYAiABKAU6AjgBGjQKEk1hcEludDY0SW50NjRF",
"cnkSCwoDa2V5GAEgASgEEg0KBXZhbHVlGAIgASgEOgI4ARo2ChRNYXBTaW50", "bnRyeRILCgNrZXkYASABKAMSDQoFdmFsdWUYAiABKAM6AjgBGjYKFE1hcFVp",
"MzJTaW50MzJFbnRyeRILCgNrZXkYASABKBESDQoFdmFsdWUYAiABKBE6AjgB", "bnQzMlVpbnQzMkVudHJ5EgsKA2tleRgBIAEoDRINCgV2YWx1ZRgCIAEoDToC",
"GjYKFE1hcFNpbnQ2NFNpbnQ2NEVudHJ5EgsKA2tleRgBIAEoEhINCgV2YWx1", "OAEaNgoUTWFwVWludDY0VWludDY0RW50cnkSCwoDa2V5GAEgASgEEg0KBXZh",
"ZRgCIAEoEjoCOAEaOAoWTWFwRml4ZWQzMkZpeGVkMzJFbnRyeRILCgNrZXkY", "bHVlGAIgASgEOgI4ARo2ChRNYXBTaW50MzJTaW50MzJFbnRyeRILCgNrZXkY",
"ASABKAcSDQoFdmFsdWUYAiABKAc6AjgBGjgKFk1hcEZpeGVkNjRGaXhlZDY0", "ASABKBESDQoFdmFsdWUYAiABKBE6AjgBGjYKFE1hcFNpbnQ2NFNpbnQ2NEVu",
"RW50cnkSCwoDa2V5GAEgASgGEg0KBXZhbHVlGAIgASgGOgI4ARo6ChhNYXBT", "dHJ5EgsKA2tleRgBIAEoEhINCgV2YWx1ZRgCIAEoEjoCOAEaOAoWTWFwRml4",
"Zml4ZWQzMlNmaXhlZDMyRW50cnkSCwoDa2V5GAEgASgPEg0KBXZhbHVlGAIg", "ZWQzMkZpeGVkMzJFbnRyeRILCgNrZXkYASABKAcSDQoFdmFsdWUYAiABKAc6",
"ASgPOgI4ARo6ChhNYXBTZml4ZWQ2NFNmaXhlZDY0RW50cnkSCwoDa2V5GAEg", "AjgBGjgKFk1hcEZpeGVkNjRGaXhlZDY0RW50cnkSCwoDa2V5GAEgASgGEg0K",
"ASgQEg0KBXZhbHVlGAIgASgQOgI4ARo0ChJNYXBJbnQzMkZsb2F0RW50cnkS", "BXZhbHVlGAIgASgGOgI4ARo6ChhNYXBTZml4ZWQzMlNmaXhlZDMyRW50cnkS",
"CwoDa2V5GAEgASgFEg0KBXZhbHVlGAIgASgCOgI4ARo1ChNNYXBJbnQzMkRv", "CwoDa2V5GAEgASgPEg0KBXZhbHVlGAIgASgPOgI4ARo6ChhNYXBTZml4ZWQ2",
"dWJsZUVudHJ5EgsKA2tleRgBIAEoBRINCgV2YWx1ZRgCIAEoAToCOAEaMgoQ", "NFNmaXhlZDY0RW50cnkSCwoDa2V5GAEgASgQEg0KBXZhbHVlGAIgASgQOgI4",
"TWFwQm9vbEJvb2xFbnRyeRILCgNrZXkYASABKAgSDQoFdmFsdWUYAiABKAg6", "ARo0ChJNYXBJbnQzMkZsb2F0RW50cnkSCwoDa2V5GAEgASgFEg0KBXZhbHVl",
"AjgBGjYKFE1hcFN0cmluZ1N0cmluZ0VudHJ5EgsKA2tleRgBIAEoCRINCgV2", "GAIgASgCOgI4ARo1ChNNYXBJbnQzMkRvdWJsZUVudHJ5EgsKA2tleRgBIAEo",
"YWx1ZRgCIAEoCToCOAEaNQoTTWFwU3RyaW5nQnl0ZXNFbnRyeRILCgNrZXkY", "BRINCgV2YWx1ZRgCIAEoAToCOAEaMgoQTWFwQm9vbEJvb2xFbnRyeRILCgNr",
"ASABKAkSDQoFdmFsdWUYAiABKAw6AjgBGn4KG01hcFN0cmluZ05lc3RlZE1l", "ZXkYASABKAgSDQoFdmFsdWUYAiABKAg6AjgBGjYKFE1hcFN0cmluZ1N0cmlu",
"c3NhZ2VFbnRyeRILCgNrZXkYASABKAkSTgoFdmFsdWUYAiABKAsyPy5wcm90", "Z0VudHJ5EgsKA2tleRgBIAEoCRINCgV2YWx1ZRgCIAEoCToCOAEaNQoTTWFw",
"b2J1Zl90ZXN0X21lc3NhZ2VzLnByb3RvMy5UZXN0QWxsVHlwZXNQcm90bzMu", "U3RyaW5nQnl0ZXNFbnRyeRILCgNrZXkYASABKAkSDQoFdmFsdWUYAiABKAw6",
"TmVzdGVkTWVzc2FnZToCOAEabQocTWFwU3RyaW5nRm9yZWlnbk1lc3NhZ2VF", "AjgBGn4KG01hcFN0cmluZ05lc3RlZE1lc3NhZ2VFbnRyeRILCgNrZXkYASAB",
"bnRyeRILCgNrZXkYASABKAkSPAoFdmFsdWUYAiABKAsyLS5wcm90b2J1Zl90", "KAkSTgoFdmFsdWUYAiABKAsyPy5wcm90b2J1Zl90ZXN0X21lc3NhZ2VzLnBy",
"ZXN0X21lc3NhZ2VzLnByb3RvMy5Gb3JlaWduTWVzc2FnZToCOAEaeAoYTWFw", "b3RvMy5UZXN0QWxsVHlwZXNQcm90bzMuTmVzdGVkTWVzc2FnZToCOAEabQoc",
"U3RyaW5nTmVzdGVkRW51bUVudHJ5EgsKA2tleRgBIAEoCRJLCgV2YWx1ZRgC", "TWFwU3RyaW5nRm9yZWlnbk1lc3NhZ2VFbnRyeRILCgNrZXkYASABKAkSPAoF",
"IAEoDjI8LnByb3RvYnVmX3Rlc3RfbWVzc2FnZXMucHJvdG8zLlRlc3RBbGxU", "dmFsdWUYAiABKAsyLS5wcm90b2J1Zl90ZXN0X21lc3NhZ2VzLnByb3RvMy5G",
"eXBlc1Byb3RvMy5OZXN0ZWRFbnVtOgI4ARpnChlNYXBTdHJpbmdGb3JlaWdu", "b3JlaWduTWVzc2FnZToCOAEaeAoYTWFwU3RyaW5nTmVzdGVkRW51bUVudHJ5",
"RW51bUVudHJ5EgsKA2tleRgBIAEoCRI5CgV2YWx1ZRgCIAEoDjIqLnByb3Rv", "EgsKA2tleRgBIAEoCRJLCgV2YWx1ZRgCIAEoDjI8LnByb3RvYnVmX3Rlc3Rf",
"YnVmX3Rlc3RfbWVzc2FnZXMucHJvdG8zLkZvcmVpZ25FbnVtOgI4ASI5CgpO", "bWVzc2FnZXMucHJvdG8zLlRlc3RBbGxUeXBlc1Byb3RvMy5OZXN0ZWRFbnVt",
"ZXN0ZWRFbnVtEgcKA0ZPTxAAEgcKA0JBUhABEgcKA0JBWhACEhAKA05FRxD/", "OgI4ARpnChlNYXBTdHJpbmdGb3JlaWduRW51bUVudHJ5EgsKA2tleRgBIAEo",
"//////////8BIlkKC0FsaWFzZWRFbnVtEg0KCUFMSUFTX0ZPTxAAEg0KCUFM", "CRI5CgV2YWx1ZRgCIAEoDjIqLnByb3RvYnVmX3Rlc3RfbWVzc2FnZXMucHJv",
"SUFTX0JBUhABEg0KCUFMSUFTX0JBWhACEgcKA1FVWBACEgcKA3F1eBACEgcK", "dG8zLkZvcmVpZ25FbnVtOgI4ASI5CgpOZXN0ZWRFbnVtEgcKA0ZPTxAAEgcK",
"A2JBehACGgIQAUINCgtvbmVvZl9maWVsZEoGCPUDEP8DIhsKDkZvcmVpZ25N", "A0JBUhABEgcKA0JBWhACEhAKA05FRxD///////////8BIlkKC0FsaWFzZWRF",
"ZXNzYWdlEgkKAWMYASABKAUqQAoLRm9yZWlnbkVudW0SDwoLRk9SRUlHTl9G", "bnVtEg0KCUFMSUFTX0ZPTxAAEg0KCUFMSUFTX0JBUhABEg0KCUFMSUFTX0JB",
"T08QABIPCgtGT1JFSUdOX0JBUhABEg8KC0ZPUkVJR05fQkFaEAJCOAooY29t", "WhACEgcKA1FVWBACEgcKA3F1eBACEgcKA2JBehACGgIQAUINCgtvbmVvZl9m",
"Lmdvb2dsZS5wcm90b2J1Zl90ZXN0X21lc3NhZ2VzLnByb3RvM0gB+AEBogIG", "aWVsZEoGCPUDEP8DIhsKDkZvcmVpZ25NZXNzYWdlEgkKAWMYASABKAUqQAoL",
"UHJvdG8zYgZwcm90bzM=")); "Rm9yZWlnbkVudW0SDwoLRk9SRUlHTl9GT08QABIPCgtGT1JFSUdOX0JBUhAB",
"Eg8KC0ZPUkVJR05fQkFaEAJCOAooY29tLmdvb2dsZS5wcm90b2J1Zl90ZXN0",
"X21lc3NhZ2VzLnByb3RvM0gB+AEBogIGUHJvdG8zYgZwcm90bzM="));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, 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::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(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, }), 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) new pbr::GeneratedClrTypeInfo(typeof(global::ProtobufTestMessages.Proto3.ForeignMessage), global::ProtobufTestMessages.Proto3.ForeignMessage.Parser, new[]{ "C" }, null, null, null, null)
})); }));
@ -403,6 +405,7 @@ namespace ProtobufTestMessages.Proto3 {
optionalStruct_ = other.optionalStruct_ != null ? other.optionalStruct_.Clone() : null; optionalStruct_ = other.optionalStruct_ != null ? other.optionalStruct_.Clone() : null;
optionalAny_ = other.optionalAny_ != null ? other.optionalAny_.Clone() : null; optionalAny_ = other.optionalAny_ != null ? other.optionalAny_.Clone() : null;
optionalValue_ = other.optionalValue_ != null ? other.optionalValue_.Clone() : null; optionalValue_ = other.optionalValue_ != null ? other.optionalValue_.Clone() : null;
optionalNullValue_ = other.optionalNullValue_;
repeatedDuration_ = other.repeatedDuration_.Clone(); repeatedDuration_ = other.repeatedDuration_.Clone();
repeatedTimestamp_ = other.repeatedTimestamp_.Clone(); repeatedTimestamp_ = other.repeatedTimestamp_.Clone();
repeatedFieldmask_ = other.repeatedFieldmask_.Clone(); repeatedFieldmask_ = other.repeatedFieldmask_.Clone();
@ -456,6 +459,9 @@ namespace ProtobufTestMessages.Proto3 {
case OneofFieldOneofCase.OneofEnum: case OneofFieldOneofCase.OneofEnum:
OneofEnum = other.OneofEnum; OneofEnum = other.OneofEnum;
break; break;
case OneofFieldOneofCase.OneofNullValue:
OneofNullValue = other.OneofNullValue;
break;
} }
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
@ -1513,6 +1519,17 @@ namespace ProtobufTestMessages.Proto3 {
} }
} }
/// <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> /// <summary>Field number for the "optional_bool_wrapper" field.</summary>
public const int OptionalBoolWrapperFieldNumber = 201; public const int OptionalBoolWrapperFieldNumber = 201;
private static readonly pb::FieldCodec<bool?> _single_optionalBoolWrapper_codec = pb::FieldCodec.ForStructWrapper<bool>(1610); private static readonly pb::FieldCodec<bool?> _single_optionalBoolWrapper_codec = pb::FieldCodec.ForStructWrapper<bool>(1610);
@ -1789,6 +1806,17 @@ namespace ProtobufTestMessages.Proto3 {
} }
} }
/// <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> /// <summary>Field number for the "repeated_duration" field.</summary>
public const int RepeatedDurationFieldNumber = 311; public const int RepeatedDurationFieldNumber = 311;
private static readonly pb::FieldCodec<global::Google.Protobuf.WellKnownTypes.Duration> _repeated_repeatedDuration_codec private static readonly pb::FieldCodec<global::Google.Protobuf.WellKnownTypes.Duration> _repeated_repeatedDuration_codec
@ -2074,6 +2102,7 @@ namespace ProtobufTestMessages.Proto3 {
OneofFloat = 117, OneofFloat = 117,
OneofDouble = 118, OneofDouble = 118,
OneofEnum = 119, OneofEnum = 119,
OneofNullValue = 120,
} }
private OneofFieldOneofCase oneofFieldCase_ = OneofFieldOneofCase.None; private OneofFieldOneofCase oneofFieldCase_ = OneofFieldOneofCase.None;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@ -2200,6 +2229,7 @@ namespace ProtobufTestMessages.Proto3 {
if (!pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.Equals(OneofFloat, other.OneofFloat)) return false; if (!pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.Equals(OneofFloat, other.OneofFloat)) return false;
if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(OneofDouble, other.OneofDouble)) return false; if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(OneofDouble, other.OneofDouble)) return false;
if (OneofEnum != other.OneofEnum) return false; if (OneofEnum != other.OneofEnum) return false;
if (OneofNullValue != other.OneofNullValue) return false;
if (OptionalBoolWrapper != other.OptionalBoolWrapper) return false; if (OptionalBoolWrapper != other.OptionalBoolWrapper) return false;
if (OptionalInt32Wrapper != other.OptionalInt32Wrapper) return false; if (OptionalInt32Wrapper != other.OptionalInt32Wrapper) return false;
if (OptionalInt64Wrapper != other.OptionalInt64Wrapper) return false; if (OptionalInt64Wrapper != other.OptionalInt64Wrapper) return false;
@ -2224,6 +2254,7 @@ namespace ProtobufTestMessages.Proto3 {
if (!object.Equals(OptionalStruct, other.OptionalStruct)) return false; if (!object.Equals(OptionalStruct, other.OptionalStruct)) return false;
if (!object.Equals(OptionalAny, other.OptionalAny)) return false; if (!object.Equals(OptionalAny, other.OptionalAny)) return false;
if (!object.Equals(OptionalValue, other.OptionalValue)) return false; if (!object.Equals(OptionalValue, other.OptionalValue)) return false;
if (OptionalNullValue != other.OptionalNullValue) return false;
if(!repeatedDuration_.Equals(other.repeatedDuration_)) return false; if(!repeatedDuration_.Equals(other.repeatedDuration_)) return false;
if(!repeatedTimestamp_.Equals(other.repeatedTimestamp_)) return false; if(!repeatedTimestamp_.Equals(other.repeatedTimestamp_)) return false;
if(!repeatedFieldmask_.Equals(other.repeatedFieldmask_)) return false; if(!repeatedFieldmask_.Equals(other.repeatedFieldmask_)) return false;
@ -2356,6 +2387,7 @@ namespace ProtobufTestMessages.Proto3 {
if (oneofFieldCase_ == OneofFieldOneofCase.OneofFloat) hash ^= pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.GetHashCode(OneofFloat); if (oneofFieldCase_ == OneofFieldOneofCase.OneofFloat) hash ^= pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.GetHashCode(OneofFloat);
if (oneofFieldCase_ == OneofFieldOneofCase.OneofDouble) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(OneofDouble); if (oneofFieldCase_ == OneofFieldOneofCase.OneofDouble) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(OneofDouble);
if (oneofFieldCase_ == OneofFieldOneofCase.OneofEnum) hash ^= OneofEnum.GetHashCode(); if (oneofFieldCase_ == OneofFieldOneofCase.OneofEnum) hash ^= OneofEnum.GetHashCode();
if (oneofFieldCase_ == OneofFieldOneofCase.OneofNullValue) hash ^= OneofNullValue.GetHashCode();
if (optionalBoolWrapper_ != null) hash ^= OptionalBoolWrapper.GetHashCode(); if (optionalBoolWrapper_ != null) hash ^= OptionalBoolWrapper.GetHashCode();
if (optionalInt32Wrapper_ != null) hash ^= OptionalInt32Wrapper.GetHashCode(); if (optionalInt32Wrapper_ != null) hash ^= OptionalInt32Wrapper.GetHashCode();
if (optionalInt64Wrapper_ != null) hash ^= OptionalInt64Wrapper.GetHashCode(); if (optionalInt64Wrapper_ != null) hash ^= OptionalInt64Wrapper.GetHashCode();
@ -2380,6 +2412,7 @@ namespace ProtobufTestMessages.Proto3 {
if (optionalStruct_ != null) hash ^= OptionalStruct.GetHashCode(); if (optionalStruct_ != null) hash ^= OptionalStruct.GetHashCode();
if (optionalAny_ != null) hash ^= OptionalAny.GetHashCode(); if (optionalAny_ != null) hash ^= OptionalAny.GetHashCode();
if (optionalValue_ != null) hash ^= OptionalValue.GetHashCode(); if (optionalValue_ != null) hash ^= OptionalValue.GetHashCode();
if (OptionalNullValue != global::Google.Protobuf.WellKnownTypes.NullValue.NullValue) hash ^= OptionalNullValue.GetHashCode();
hash ^= repeatedDuration_.GetHashCode(); hash ^= repeatedDuration_.GetHashCode();
hash ^= repeatedTimestamp_.GetHashCode(); hash ^= repeatedTimestamp_.GetHashCode();
hash ^= repeatedFieldmask_.GetHashCode(); hash ^= repeatedFieldmask_.GetHashCode();
@ -2618,6 +2651,10 @@ namespace ProtobufTestMessages.Proto3 {
output.WriteRawTag(184, 7); output.WriteRawTag(184, 7);
output.WriteEnum((int) OneofEnum); output.WriteEnum((int) OneofEnum);
} }
if (oneofFieldCase_ == OneofFieldOneofCase.OneofNullValue) {
output.WriteRawTag(192, 7);
output.WriteEnum((int) OneofNullValue);
}
if (optionalBoolWrapper_ != null) { if (optionalBoolWrapper_ != null) {
_single_optionalBoolWrapper_codec.WriteTagAndValue(output, OptionalBoolWrapper); _single_optionalBoolWrapper_codec.WriteTagAndValue(output, OptionalBoolWrapper);
} }
@ -2678,6 +2715,10 @@ namespace ProtobufTestMessages.Proto3 {
output.WriteRawTag(146, 19); output.WriteRawTag(146, 19);
output.WriteMessage(OptionalValue); 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); repeatedDuration_.WriteTo(output, _repeated_repeatedDuration_codec);
repeatedTimestamp_.WriteTo(output, _repeated_repeatedTimestamp_codec); repeatedTimestamp_.WriteTo(output, _repeated_repeatedTimestamp_codec);
repeatedFieldmask_.WriteTo(output, _repeated_repeatedFieldmask_codec); repeatedFieldmask_.WriteTo(output, _repeated_repeatedFieldmask_codec);
@ -2962,6 +3003,10 @@ namespace ProtobufTestMessages.Proto3 {
output.WriteRawTag(184, 7); output.WriteRawTag(184, 7);
output.WriteEnum((int) OneofEnum); output.WriteEnum((int) OneofEnum);
} }
if (oneofFieldCase_ == OneofFieldOneofCase.OneofNullValue) {
output.WriteRawTag(192, 7);
output.WriteEnum((int) OneofNullValue);
}
if (optionalBoolWrapper_ != null) { if (optionalBoolWrapper_ != null) {
_single_optionalBoolWrapper_codec.WriteTagAndValue(ref output, OptionalBoolWrapper); _single_optionalBoolWrapper_codec.WriteTagAndValue(ref output, OptionalBoolWrapper);
} }
@ -3022,6 +3067,10 @@ namespace ProtobufTestMessages.Proto3 {
output.WriteRawTag(146, 19); output.WriteRawTag(146, 19);
output.WriteMessage(OptionalValue); 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); repeatedDuration_.WriteTo(ref output, _repeated_repeatedDuration_codec);
repeatedTimestamp_.WriteTo(ref output, _repeated_repeatedTimestamp_codec); repeatedTimestamp_.WriteTo(ref output, _repeated_repeatedTimestamp_codec);
repeatedFieldmask_.WriteTo(ref output, _repeated_repeatedFieldmask_codec); repeatedFieldmask_.WriteTo(ref output, _repeated_repeatedFieldmask_codec);
@ -3274,6 +3323,9 @@ namespace ProtobufTestMessages.Proto3 {
if (oneofFieldCase_ == OneofFieldOneofCase.OneofEnum) { if (oneofFieldCase_ == OneofFieldOneofCase.OneofEnum) {
size += 2 + pb::CodedOutputStream.ComputeEnumSize((int) OneofEnum); size += 2 + pb::CodedOutputStream.ComputeEnumSize((int) OneofEnum);
} }
if (oneofFieldCase_ == OneofFieldOneofCase.OneofNullValue) {
size += 2 + pb::CodedOutputStream.ComputeEnumSize((int) OneofNullValue);
}
if (optionalBoolWrapper_ != null) { if (optionalBoolWrapper_ != null) {
size += _single_optionalBoolWrapper_codec.CalculateSizeWithTag(OptionalBoolWrapper); size += _single_optionalBoolWrapper_codec.CalculateSizeWithTag(OptionalBoolWrapper);
} }
@ -3328,6 +3380,9 @@ namespace ProtobufTestMessages.Proto3 {
if (optionalValue_ != null) { if (optionalValue_ != null) {
size += 2 + pb::CodedOutputStream.ComputeMessageSize(OptionalValue); 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 += repeatedDuration_.CalculateSize(_repeated_repeatedDuration_codec);
size += repeatedTimestamp_.CalculateSize(_repeated_repeatedTimestamp_codec); size += repeatedTimestamp_.CalculateSize(_repeated_repeatedTimestamp_codec);
size += repeatedFieldmask_.CalculateSize(_repeated_repeatedFieldmask_codec); size += repeatedFieldmask_.CalculateSize(_repeated_repeatedFieldmask_codec);
@ -3636,6 +3691,9 @@ namespace ProtobufTestMessages.Proto3 {
} }
OptionalValue.MergeFrom(other.OptionalValue); OptionalValue.MergeFrom(other.OptionalValue);
} }
if (other.OptionalNullValue != global::Google.Protobuf.WellKnownTypes.NullValue.NullValue) {
OptionalNullValue = other.OptionalNullValue;
}
repeatedDuration_.Add(other.repeatedDuration_); repeatedDuration_.Add(other.repeatedDuration_);
repeatedTimestamp_.Add(other.repeatedTimestamp_); repeatedTimestamp_.Add(other.repeatedTimestamp_);
repeatedFieldmask_.Add(other.repeatedFieldmask_); repeatedFieldmask_.Add(other.repeatedFieldmask_);
@ -3728,6 +3786,9 @@ namespace ProtobufTestMessages.Proto3 {
case OneofFieldOneofCase.OneofEnum: case OneofFieldOneofCase.OneofEnum:
OneofEnum = other.OneofEnum; OneofEnum = other.OneofEnum;
break; break;
case OneofFieldOneofCase.OneofNullValue:
OneofNullValue = other.OneofNullValue;
break;
} }
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
@ -4202,6 +4263,11 @@ namespace ProtobufTestMessages.Proto3 {
oneofFieldCase_ = OneofFieldOneofCase.OneofEnum; oneofFieldCase_ = OneofFieldOneofCase.OneofEnum;
break; break;
} }
case 960: {
oneofField_ = input.ReadEnum();
oneofFieldCase_ = OneofFieldOneofCase.OneofNullValue;
break;
}
case 1610: { case 1610: {
bool? value = _single_optionalBoolWrapper_codec.Read(input); bool? value = _single_optionalBoolWrapper_codec.Read(input);
if (optionalBoolWrapper_ == null || value != false) { if (optionalBoolWrapper_ == null || value != false) {
@ -4343,6 +4409,10 @@ namespace ProtobufTestMessages.Proto3 {
input.ReadMessage(OptionalValue); input.ReadMessage(OptionalValue);
break; break;
} }
case 2456: {
OptionalNullValue = (global::Google.Protobuf.WellKnownTypes.NullValue) input.ReadEnum();
break;
}
case 2490: { case 2490: {
repeatedDuration_.AddEntriesFrom(input, _repeated_repeatedDuration_codec); repeatedDuration_.AddEntriesFrom(input, _repeated_repeatedDuration_codec);
break; break;
@ -4915,6 +4985,11 @@ namespace ProtobufTestMessages.Proto3 {
oneofFieldCase_ = OneofFieldOneofCase.OneofEnum; oneofFieldCase_ = OneofFieldOneofCase.OneofEnum;
break; break;
} }
case 960: {
oneofField_ = input.ReadEnum();
oneofFieldCase_ = OneofFieldOneofCase.OneofNullValue;
break;
}
case 1610: { case 1610: {
bool? value = _single_optionalBoolWrapper_codec.Read(ref input); bool? value = _single_optionalBoolWrapper_codec.Read(ref input);
if (optionalBoolWrapper_ == null || value != false) { if (optionalBoolWrapper_ == null || value != false) {
@ -5056,6 +5131,10 @@ namespace ProtobufTestMessages.Proto3 {
input.ReadMessage(OptionalValue); input.ReadMessage(OptionalValue);
break; break;
} }
case 2456: {
OptionalNullValue = (global::Google.Protobuf.WellKnownTypes.NullValue) input.ReadEnum();
break;
}
case 2490: { case 2490: {
repeatedDuration_.AddEntriesFrom(ref input, _repeated_repeatedDuration_codec); repeatedDuration_.AddEntriesFrom(ref input, _repeated_repeatedDuration_codec);
break; break;

@ -55,12 +55,19 @@ namespace ProtobufUnittest {
"X2Jvb2xCEgoQX29wdGlvbmFsX3N0cmluZ0IRCg9fb3B0aW9uYWxfYnl0ZXNC", "X2Jvb2xCEgoQX29wdGlvbmFsX3N0cmluZ0IRCg9fb3B0aW9uYWxfYnl0ZXNC",
"EAoOX29wdGlvbmFsX2NvcmRCGgoYX29wdGlvbmFsX25lc3RlZF9tZXNzYWdl", "EAoOX29wdGlvbmFsX2NvcmRCGgoYX29wdGlvbmFsX25lc3RlZF9tZXNzYWdl",
"QhYKFF9sYXp5X25lc3RlZF9tZXNzYWdlQhcKFV9vcHRpb25hbF9uZXN0ZWRf", "QhYKFF9sYXp5X25lc3RlZF9tZXNzYWdlQhcKFV9vcHRpb25hbF9uZXN0ZWRf",
"ZW51bUIlCiFjb20uZ29vZ2xlLnByb3RvYnVmLnRlc3RpbmcucHJvdG9QAWIG", "ZW51bSKJAgoZVGVzdFByb3RvM09wdGlvbmFsTWVzc2FnZRJSCg5uZXN0ZWRf",
"cHJvdG8z")); "bWVzc2FnZRgBIAEoCzI6LnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RQcm90bzNP",
"cHRpb25hbE1lc3NhZ2UuTmVzdGVkTWVzc2FnZRJgChdvcHRpb25hbF9uZXN0",
"ZWRfbWVzc2FnZRgCIAEoCzI6LnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RQcm90",
"bzNPcHRpb25hbE1lc3NhZ2UuTmVzdGVkTWVzc2FnZUgAiAEBGhoKDU5lc3Rl",
"ZE1lc3NhZ2USCQoBcxgBIAEoCUIaChhfb3B0aW9uYWxfbmVzdGVkX21lc3Nh",
"Z2VCJQohY29tLmdvb2dsZS5wcm90b2J1Zi50ZXN0aW5nLnByb3RvUAFiBnBy",
"b3RvMw=="));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { }, new pbr::FileDescriptor[] { },
new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] { 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 #endregion
@ -1377,6 +1384,411 @@ namespace ProtobufUnittest {
} }
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 #endregion
} }

@ -155,10 +155,9 @@ namespace Google.Protobuf.Reflection {
"dGF0aW9uGAEgAygLMi0uZ29vZ2xlLnByb3RvYnVmLkdlbmVyYXRlZENvZGVJ", "dGF0aW9uGAEgAygLMi0uZ29vZ2xlLnByb3RvYnVmLkdlbmVyYXRlZENvZGVJ",
"bmZvLkFubm90YXRpb24aTwoKQW5ub3RhdGlvbhIQCgRwYXRoGAEgAygFQgIQ", "bmZvLkFubm90YXRpb24aTwoKQW5ub3RhdGlvbhIQCgRwYXRoGAEgAygFQgIQ",
"ARITCgtzb3VyY2VfZmlsZRgCIAEoCRINCgViZWdpbhgDIAEoBRILCgNlbmQY", "ARITCgtzb3VyY2VfZmlsZRgCIAEoCRINCgViZWdpbhgDIAEoBRILCgNlbmQY",
"BCABKAVCjwEKE2NvbS5nb29nbGUucHJvdG9idWZCEERlc2NyaXB0b3JQcm90", "BCABKAVCfgoTY29tLmdvb2dsZS5wcm90b2J1ZkIQRGVzY3JpcHRvclByb3Rv",
"b3NIAVo+Z2l0aHViLmNvbS9nb2xhbmcvcHJvdG9idWYvcHJvdG9jLWdlbi1n", "c0gBWi1nb29nbGUuZ29sYW5nLm9yZy9wcm90b2J1Zi90eXBlcy9kZXNjcmlw",
"by9kZXNjcmlwdG9yO2Rlc2NyaXB0b3L4AQGiAgNHUEKqAhpHb29nbGUuUHJv", "dG9ycGL4AQGiAgNHUEKqAhpHb29nbGUuUHJvdG9idWYuUmVmbGVjdGlvbg=="));
"dG9idWYuUmVmbGVjdGlvbg=="));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { }, new pbr::FileDescriptor[] { },
new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] {

@ -25,10 +25,10 @@ namespace Google.Protobuf.WellKnownTypes {
byte[] descriptorData = global::System.Convert.FromBase64String( byte[] descriptorData = global::System.Convert.FromBase64String(
string.Concat( string.Concat(
"Chlnb29nbGUvcHJvdG9idWYvYW55LnByb3RvEg9nb29nbGUucHJvdG9idWYi", "Chlnb29nbGUvcHJvdG9idWYvYW55LnByb3RvEg9nb29nbGUucHJvdG9idWYi",
"JgoDQW55EhAKCHR5cGVfdXJsGAEgASgJEg0KBXZhbHVlGAIgASgMQm8KE2Nv", "JgoDQW55EhAKCHR5cGVfdXJsGAEgASgJEg0KBXZhbHVlGAIgASgMQnYKE2Nv",
"bS5nb29nbGUucHJvdG9idWZCCEFueVByb3RvUAFaJWdpdGh1Yi5jb20vZ29s", "bS5nb29nbGUucHJvdG9idWZCCEFueVByb3RvUAFaLGdvb2dsZS5nb2xhbmcu",
"YW5nL3Byb3RvYnVmL3B0eXBlcy9hbnmiAgNHUEKqAh5Hb29nbGUuUHJvdG9i", "b3JnL3Byb3RvYnVmL3R5cGVzL2tub3duL2FueXBiogIDR1BCqgIeR29vZ2xl",
"dWYuV2VsbEtub3duVHlwZXNiBnByb3RvMw==")); "LlByb3RvYnVmLldlbGxLbm93blR5cGVzYgZwcm90bzM="));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { }, new pbr::FileDescriptor[] { },
new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] {
@ -78,10 +78,13 @@ namespace Google.Protobuf.WellKnownTypes {
/// Example 4: Pack and unpack a message in Go /// Example 4: Pack and unpack a message in Go
/// ///
/// foo := &amp;pb.Foo{...} /// foo := &amp;pb.Foo{...}
/// any, err := ptypes.MarshalAny(foo) /// any, err := anypb.New(foo)
/// if err != nil {
/// ...
/// }
/// ... /// ...
/// foo := &amp;pb.Foo{} /// foo := &amp;pb.Foo{}
/// if err := ptypes.UnmarshalAny(any, foo); err != nil { /// if err := any.UnmarshalTo(foo); err != nil {
/// ... /// ...
/// } /// }
/// ///

@ -37,10 +37,10 @@ namespace Google.Protobuf.WellKnownTypes {
"ChFyZXNwb25zZV90eXBlX3VybBgEIAEoCRIaChJyZXNwb25zZV9zdHJlYW1p", "ChFyZXNwb25zZV90eXBlX3VybBgEIAEoCRIaChJyZXNwb25zZV9zdHJlYW1p",
"bmcYBSABKAgSKAoHb3B0aW9ucxgGIAMoCzIXLmdvb2dsZS5wcm90b2J1Zi5P", "bmcYBSABKAgSKAoHb3B0aW9ucxgGIAMoCzIXLmdvb2dsZS5wcm90b2J1Zi5P",
"cHRpb24SJwoGc3ludGF4GAcgASgOMhcuZ29vZ2xlLnByb3RvYnVmLlN5bnRh", "cHRpb24SJwoGc3ludGF4GAcgASgOMhcuZ29vZ2xlLnByb3RvYnVmLlN5bnRh",
"eCIjCgVNaXhpbhIMCgRuYW1lGAEgASgJEgwKBHJvb3QYAiABKAlCdQoTY29t", "eCIjCgVNaXhpbhIMCgRuYW1lGAEgASgJEgwKBHJvb3QYAiABKAlCdgoTY29t",
"Lmdvb2dsZS5wcm90b2J1ZkIIQXBpUHJvdG9QAVorZ29vZ2xlLmdvbGFuZy5v", "Lmdvb2dsZS5wcm90b2J1ZkIIQXBpUHJvdG9QAVosZ29vZ2xlLmdvbGFuZy5v",
"cmcvZ2VucHJvdG8vcHJvdG9idWYvYXBpO2FwaaICA0dQQqoCHkdvb2dsZS5Q", "cmcvcHJvdG9idWYvdHlwZXMva25vd24vYXBpcGKiAgNHUEKqAh5Hb29nbGUu",
"cm90b2J1Zi5XZWxsS25vd25UeXBlc2IGcHJvdG8z")); "UHJvdG9idWYuV2VsbEtub3duVHlwZXNiBnByb3RvMw=="));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { global::Google.Protobuf.WellKnownTypes.SourceContextReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.TypeReflection.Descriptor, }, new pbr::FileDescriptor[] { global::Google.Protobuf.WellKnownTypes.SourceContextReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.TypeReflection.Descriptor, },
new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] {

@ -26,10 +26,10 @@ namespace Google.Protobuf.WellKnownTypes {
string.Concat( string.Concat(
"Ch5nb29nbGUvcHJvdG9idWYvZHVyYXRpb24ucHJvdG8SD2dvb2dsZS5wcm90", "Ch5nb29nbGUvcHJvdG9idWYvZHVyYXRpb24ucHJvdG8SD2dvb2dsZS5wcm90",
"b2J1ZiIqCghEdXJhdGlvbhIPCgdzZWNvbmRzGAEgASgDEg0KBW5hbm9zGAIg", "b2J1ZiIqCghEdXJhdGlvbhIPCgdzZWNvbmRzGAEgASgDEg0KBW5hbm9zGAIg",
"ASgFQnwKE2NvbS5nb29nbGUucHJvdG9idWZCDUR1cmF0aW9uUHJvdG9QAVoq", "ASgFQoMBChNjb20uZ29vZ2xlLnByb3RvYnVmQg1EdXJhdGlvblByb3RvUAFa",
"Z2l0aHViLmNvbS9nb2xhbmcvcHJvdG9idWYvcHR5cGVzL2R1cmF0aW9u+AEB", "MWdvb2dsZS5nb2xhbmcub3JnL3Byb3RvYnVmL3R5cGVzL2tub3duL2R1cmF0",
"ogIDR1BCqgIeR29vZ2xlLlByb3RvYnVmLldlbGxLbm93blR5cGVzYgZwcm90", "aW9ucGL4AQGiAgNHUEKqAh5Hb29nbGUuUHJvdG9idWYuV2VsbEtub3duVHlw",
"bzM=")); "ZXNiBnByb3RvMw=="));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { }, new pbr::FileDescriptor[] { },
new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] {

@ -25,10 +25,10 @@ namespace Google.Protobuf.WellKnownTypes {
byte[] descriptorData = global::System.Convert.FromBase64String( byte[] descriptorData = global::System.Convert.FromBase64String(
string.Concat( string.Concat(
"Chtnb29nbGUvcHJvdG9idWYvZW1wdHkucHJvdG8SD2dvb2dsZS5wcm90b2J1", "Chtnb29nbGUvcHJvdG9idWYvZW1wdHkucHJvdG8SD2dvb2dsZS5wcm90b2J1",
"ZiIHCgVFbXB0eUJ2ChNjb20uZ29vZ2xlLnByb3RvYnVmQgpFbXB0eVByb3Rv", "ZiIHCgVFbXB0eUJ9ChNjb20uZ29vZ2xlLnByb3RvYnVmQgpFbXB0eVByb3Rv",
"UAFaJ2dpdGh1Yi5jb20vZ29sYW5nL3Byb3RvYnVmL3B0eXBlcy9lbXB0efgB", "UAFaLmdvb2dsZS5nb2xhbmcub3JnL3Byb3RvYnVmL3R5cGVzL2tub3duL2Vt",
"AaICA0dQQqoCHkdvb2dsZS5Qcm90b2J1Zi5XZWxsS25vd25UeXBlc2IGcHJv", "cHR5cGL4AQGiAgNHUEKqAh5Hb29nbGUuUHJvdG9idWYuV2VsbEtub3duVHlw",
"dG8z")); "ZXNiBnByb3RvMw=="));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { }, new pbr::FileDescriptor[] { },
new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] {

@ -25,11 +25,10 @@ namespace Google.Protobuf.WellKnownTypes {
byte[] descriptorData = global::System.Convert.FromBase64String( byte[] descriptorData = global::System.Convert.FromBase64String(
string.Concat( string.Concat(
"CiBnb29nbGUvcHJvdG9idWYvZmllbGRfbWFzay5wcm90bxIPZ29vZ2xlLnBy", "CiBnb29nbGUvcHJvdG9idWYvZmllbGRfbWFzay5wcm90bxIPZ29vZ2xlLnBy",
"b3RvYnVmIhoKCUZpZWxkTWFzaxINCgVwYXRocxgBIAMoCUKMAQoTY29tLmdv", "b3RvYnVmIhoKCUZpZWxkTWFzaxINCgVwYXRocxgBIAMoCUKFAQoTY29tLmdv",
"b2dsZS5wcm90b2J1ZkIORmllbGRNYXNrUHJvdG9QAVo5Z29vZ2xlLmdvbGFu", "b2dsZS5wcm90b2J1ZkIORmllbGRNYXNrUHJvdG9QAVoyZ29vZ2xlLmdvbGFu",
"Zy5vcmcvZ2VucHJvdG8vcHJvdG9idWYvZmllbGRfbWFzaztmaWVsZF9tYXNr", "Zy5vcmcvcHJvdG9idWYvdHlwZXMva25vd24vZmllbGRtYXNrcGL4AQGiAgNH",
"+AEBogIDR1BCqgIeR29vZ2xlLlByb3RvYnVmLldlbGxLbm93blR5cGVzYgZw", "UEKqAh5Hb29nbGUuUHJvdG9idWYuV2VsbEtub3duVHlwZXNiBnByb3RvMw=="));
"cm90bzM="));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { }, new pbr::FileDescriptor[] { },
new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] {

@ -26,10 +26,10 @@ namespace Google.Protobuf.WellKnownTypes {
string.Concat( string.Concat(
"CiRnb29nbGUvcHJvdG9idWYvc291cmNlX2NvbnRleHQucHJvdG8SD2dvb2ds", "CiRnb29nbGUvcHJvdG9idWYvc291cmNlX2NvbnRleHQucHJvdG8SD2dvb2ds",
"ZS5wcm90b2J1ZiIiCg1Tb3VyY2VDb250ZXh0EhEKCWZpbGVfbmFtZRgBIAEo", "ZS5wcm90b2J1ZiIiCg1Tb3VyY2VDb250ZXh0EhEKCWZpbGVfbmFtZRgBIAEo",
"CUKVAQoTY29tLmdvb2dsZS5wcm90b2J1ZkISU291cmNlQ29udGV4dFByb3Rv", "CUKKAQoTY29tLmdvb2dsZS5wcm90b2J1ZkISU291cmNlQ29udGV4dFByb3Rv",
"UAFaQWdvb2dsZS5nb2xhbmcub3JnL2dlbnByb3RvL3Byb3RvYnVmL3NvdXJj", "UAFaNmdvb2dsZS5nb2xhbmcub3JnL3Byb3RvYnVmL3R5cGVzL2tub3duL3Nv",
"ZV9jb250ZXh0O3NvdXJjZV9jb250ZXh0ogIDR1BCqgIeR29vZ2xlLlByb3Rv", "dXJjZWNvbnRleHRwYqICA0dQQqoCHkdvb2dsZS5Qcm90b2J1Zi5XZWxsS25v",
"YnVmLldlbGxLbm93blR5cGVzYgZwcm90bzM=")); "d25UeXBlc2IGcHJvdG8z"));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { }, new pbr::FileDescriptor[] { },
new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] {

@ -35,10 +35,10 @@ namespace Google.Protobuf.WellKnownTypes {
"ABIwCgpsaXN0X3ZhbHVlGAYgASgLMhouZ29vZ2xlLnByb3RvYnVmLkxpc3RW", "ABIwCgpsaXN0X3ZhbHVlGAYgASgLMhouZ29vZ2xlLnByb3RvYnVmLkxpc3RW",
"YWx1ZUgAQgYKBGtpbmQiMwoJTGlzdFZhbHVlEiYKBnZhbHVlcxgBIAMoCzIW", "YWx1ZUgAQgYKBGtpbmQiMwoJTGlzdFZhbHVlEiYKBnZhbHVlcxgBIAMoCzIW",
"Lmdvb2dsZS5wcm90b2J1Zi5WYWx1ZSobCglOdWxsVmFsdWUSDgoKTlVMTF9W", "Lmdvb2dsZS5wcm90b2J1Zi5WYWx1ZSobCglOdWxsVmFsdWUSDgoKTlVMTF9W",
"QUxVRRAAQoEBChNjb20uZ29vZ2xlLnByb3RvYnVmQgtTdHJ1Y3RQcm90b1AB", "QUxVRRAAQn8KE2NvbS5nb29nbGUucHJvdG9idWZCC1N0cnVjdFByb3RvUAFa",
"WjFnaXRodWIuY29tL2dvbGFuZy9wcm90b2J1Zi9wdHlwZXMvc3RydWN0O3N0", "L2dvb2dsZS5nb2xhbmcub3JnL3Byb3RvYnVmL3R5cGVzL2tub3duL3N0cnVj",
"cnVjdHBi+AEBogIDR1BCqgIeR29vZ2xlLlByb3RvYnVmLldlbGxLbm93blR5", "dHBi+AEBogIDR1BCqgIeR29vZ2xlLlByb3RvYnVmLldlbGxLbm93blR5cGVz",
"cGVzYgZwcm90bzM=")); "YgZwcm90bzM="));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { }, new pbr::FileDescriptor[] { },
new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Google.Protobuf.WellKnownTypes.NullValue), }, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Google.Protobuf.WellKnownTypes.NullValue), }, null, new pbr::GeneratedClrTypeInfo[] {

@ -26,10 +26,10 @@ namespace Google.Protobuf.WellKnownTypes {
string.Concat( string.Concat(
"Ch9nb29nbGUvcHJvdG9idWYvdGltZXN0YW1wLnByb3RvEg9nb29nbGUucHJv", "Ch9nb29nbGUvcHJvdG9idWYvdGltZXN0YW1wLnByb3RvEg9nb29nbGUucHJv",
"dG9idWYiKwoJVGltZXN0YW1wEg8KB3NlY29uZHMYASABKAMSDQoFbmFub3MY", "dG9idWYiKwoJVGltZXN0YW1wEg8KB3NlY29uZHMYASABKAMSDQoFbmFub3MY",
"AiABKAVCfgoTY29tLmdvb2dsZS5wcm90b2J1ZkIOVGltZXN0YW1wUHJvdG9Q", "AiABKAVChQEKE2NvbS5nb29nbGUucHJvdG9idWZCDlRpbWVzdGFtcFByb3Rv",
"AVorZ2l0aHViLmNvbS9nb2xhbmcvcHJvdG9idWYvcHR5cGVzL3RpbWVzdGFt", "UAFaMmdvb2dsZS5nb2xhbmcub3JnL3Byb3RvYnVmL3R5cGVzL2tub3duL3Rp",
"cPgBAaICA0dQQqoCHkdvb2dsZS5Qcm90b2J1Zi5XZWxsS25vd25UeXBlc2IG", "bWVzdGFtcHBi+AEBogIDR1BCqgIeR29vZ2xlLlByb3RvYnVmLldlbGxLbm93",
"cHJvdG8z")); "blR5cGVzYgZwcm90bzM="));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { }, new pbr::FileDescriptor[] { },
new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] {
@ -91,7 +91,15 @@ namespace Google.Protobuf.WellKnownTypes {
/// Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000) /// Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
/// .setNanos((int) ((millis % 1000) * 1000000)).build(); /// .setNanos((int) ((millis % 1000) * 1000000)).build();
/// ///
/// Example 5: Compute Timestamp from current time in Python. /// Example 5: Compute Timestamp from Java `Instant.now()`.
///
/// Instant now = Instant.now();
///
/// Timestamp timestamp =
/// Timestamp.newBuilder().setSeconds(now.getEpochSecond())
/// .setNanos(now.getNano()).build();
///
/// Example 6: Compute Timestamp from current time in Python.
/// ///
/// timestamp = Timestamp() /// timestamp = Timestamp()
/// timestamp.GetCurrentTime() /// timestamp.GetCurrentTime()

@ -56,10 +56,10 @@ namespace Google.Protobuf.WellKnownTypes {
"ASgFEigKB29wdGlvbnMYAyADKAsyFy5nb29nbGUucHJvdG9idWYuT3B0aW9u", "ASgFEigKB29wdGlvbnMYAyADKAsyFy5nb29nbGUucHJvdG9idWYuT3B0aW9u",
"IjsKBk9wdGlvbhIMCgRuYW1lGAEgASgJEiMKBXZhbHVlGAIgASgLMhQuZ29v", "IjsKBk9wdGlvbhIMCgRuYW1lGAEgASgJEiMKBXZhbHVlGAIgASgLMhQuZ29v",
"Z2xlLnByb3RvYnVmLkFueSouCgZTeW50YXgSEQoNU1lOVEFYX1BST1RPMhAA", "Z2xlLnByb3RvYnVmLkFueSouCgZTeW50YXgSEQoNU1lOVEFYX1BST1RPMhAA",
"EhEKDVNZTlRBWF9QUk9UTzMQAUJ9ChNjb20uZ29vZ2xlLnByb3RvYnVmQglU", "EhEKDVNZTlRBWF9QUk9UTzMQAUJ7ChNjb20uZ29vZ2xlLnByb3RvYnVmQglU",
"eXBlUHJvdG9QAVovZ29vZ2xlLmdvbGFuZy5vcmcvZ2VucHJvdG8vcHJvdG9i", "eXBlUHJvdG9QAVotZ29vZ2xlLmdvbGFuZy5vcmcvcHJvdG9idWYvdHlwZXMv",
"dWYvcHR5cGU7cHR5cGX4AQGiAgNHUEKqAh5Hb29nbGUuUHJvdG9idWYuV2Vs", "a25vd24vdHlwZXBi+AEBogIDR1BCqgIeR29vZ2xlLlByb3RvYnVmLldlbGxL",
"bEtub3duVHlwZXNiBnByb3RvMw==")); "bm93blR5cGVzYgZwcm90bzM="));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { global::Google.Protobuf.WellKnownTypes.AnyReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.SourceContextReflection.Descriptor, }, 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[] { new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Google.Protobuf.WellKnownTypes.Syntax), }, null, new pbr::GeneratedClrTypeInfo[] {

@ -30,10 +30,11 @@ namespace Google.Protobuf.WellKnownTypes {
"KAMiHAoLVUludDY0VmFsdWUSDQoFdmFsdWUYASABKAQiGwoKSW50MzJWYWx1", "KAMiHAoLVUludDY0VmFsdWUSDQoFdmFsdWUYASABKAQiGwoKSW50MzJWYWx1",
"ZRINCgV2YWx1ZRgBIAEoBSIcCgtVSW50MzJWYWx1ZRINCgV2YWx1ZRgBIAEo", "ZRINCgV2YWx1ZRgBIAEoBSIcCgtVSW50MzJWYWx1ZRINCgV2YWx1ZRgBIAEo",
"DSIaCglCb29sVmFsdWUSDQoFdmFsdWUYASABKAgiHAoLU3RyaW5nVmFsdWUS", "DSIaCglCb29sVmFsdWUSDQoFdmFsdWUYASABKAgiHAoLU3RyaW5nVmFsdWUS",
"DQoFdmFsdWUYASABKAkiGwoKQnl0ZXNWYWx1ZRINCgV2YWx1ZRgBIAEoDEJ8", "DQoFdmFsdWUYASABKAkiGwoKQnl0ZXNWYWx1ZRINCgV2YWx1ZRgBIAEoDEKD",
"ChNjb20uZ29vZ2xlLnByb3RvYnVmQg1XcmFwcGVyc1Byb3RvUAFaKmdpdGh1", "AQoTY29tLmdvb2dsZS5wcm90b2J1ZkINV3JhcHBlcnNQcm90b1ABWjFnb29n",
"Yi5jb20vZ29sYW5nL3Byb3RvYnVmL3B0eXBlcy93cmFwcGVyc/gBAaICA0dQ", "bGUuZ29sYW5nLm9yZy9wcm90b2J1Zi90eXBlcy9rbm93bi93cmFwcGVyc3Bi",
"QqoCHkdvb2dsZS5Qcm90b2J1Zi5XZWxsS25vd25UeXBlc2IGcHJvdG8z")); "+AEBogIDR1BCqgIeR29vZ2xlLlByb3RvYnVmLldlbGxLbm93blR5cGVzYgZw",
"cm90bzM="));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { }, new pbr::FileDescriptor[] { },
new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] {

@ -328,20 +328,6 @@ public final class DynamicMessage extends AbstractMessage {
this.fields = FieldSet.newFieldSet(); this.fields = FieldSet.newFieldSet();
this.unknownFields = UnknownFieldSet.getDefaultInstance(); this.unknownFields = UnknownFieldSet.getDefaultInstance();
this.oneofCases = new FieldDescriptor[type.toProto().getOneofDeclCount()]; this.oneofCases = new FieldDescriptor[type.toProto().getOneofDeclCount()];
// A MapEntry has all of its fields present at all times.
if (type.getOptions().getMapEntry()) {
populateMapEntry();
}
}
private void populateMapEntry() {
for (FieldDescriptor field : type.getFields()) {
if (field.getJavaType() == FieldDescriptor.JavaType.MESSAGE) {
fields.setField(field, getDefaultInstance(field.getMessageType()));
} else {
fields.setField(field, field.getDefaultValue());
}
}
} }
// --------------------------------------------------------------- // ---------------------------------------------------------------
@ -354,10 +340,6 @@ public final class DynamicMessage extends AbstractMessage {
} else { } else {
fields.clear(); fields.clear();
} }
// A MapEntry has all of its fields present at all times.
if (type.getOptions().getMapEntry()) {
populateMapEntry();
}
unknownFields = UnknownFieldSet.getDefaultInstance(); unknownFields = UnknownFieldSet.getDefaultInstance();
return this; return this;
} }
@ -423,6 +405,19 @@ public final class DynamicMessage extends AbstractMessage {
@Override @Override
public DynamicMessage buildPartial() { public DynamicMessage buildPartial() {
// Set default values for all fields in a MapEntry.
if (type.getOptions().getMapEntry()) {
for (FieldDescriptor field : type.getFields()) {
if (field.isOptional() && !fields.hasField(field)) {
if (field.getJavaType() == FieldDescriptor.JavaType.MESSAGE) {
fields.setField(field, getDefaultInstance(field.getMessageType()));
} else {
fields.setField(field, field.getDefaultValue());
}
}
}
}
fields.makeImmutable(); fields.makeImmutable();
DynamicMessage result = DynamicMessage result =
new DynamicMessage( new DynamicMessage(

@ -1402,8 +1402,10 @@ final class MessageSchema<T> implements Schema<T> {
if (!isOneofPresent(other, number, pos)) { if (!isOneofPresent(other, number, pos)) {
return; return;
} }
Object mine = null;
Object mine = UnsafeUtil.getObject(message, offset); if (isOneofPresent(message, number, pos)) {
mine = UnsafeUtil.getObject(message, offset);
}
Object theirs = UnsafeUtil.getObject(other, offset); Object theirs = UnsafeUtil.getObject(other, offset);
if (mine != null && theirs != null) { if (mine != null && theirs != null) {
Object merged = Internal.mergeMessage(mine, theirs); Object merged = Internal.mergeMessage(mine, theirs);

@ -1661,7 +1661,7 @@ public final class TextFormat {
throws IOException { throws IOException {
// Read the entire input to a String then parse that. // Read the entire input to a String then parse that.
// If StreamTokenizer were not quite so crippled, or if there were a kind // If StreamTokenizer was not so limited, or if there were a kind
// of Reader that could read in chunks that match some particular regex, // of Reader that could read in chunks that match some particular regex,
// or if we wanted to write a custom Reader to tokenize our stream, then // or if we wanted to write a custom Reader to tokenize our stream, then
// we would not have to read to one big String. Alas, none of these is // we would not have to read to one big String. Alas, none of these is

@ -1478,11 +1478,23 @@ public class TextFormatTest extends TestCase {
// With overwrite forbidden, same behavior. // With overwrite forbidden, same behavior.
// TODO(b/29122459): Expect parse exception here. // TODO(b/29122459): Expect parse exception here.
TestMap.Builder builder = TestMap.newBuilder(); TestMap.Builder builder = TestMap.newBuilder();
defaultParser.merge(text, builder); parserWithOverwriteForbidden.merge(text, builder);
TestMap map = builder.build(); TestMap map = builder.build();
assertEquals(2, map.getInt32ToInt32Field().size()); assertEquals(2, map.getInt32ToInt32Field().size());
assertEquals(30, map.getInt32ToInt32Field().get(1).intValue()); assertEquals(30, map.getInt32ToInt32Field().get(1).intValue());
} }
{
// With overwrite forbidden and a dynamic message, same behavior.
// TODO(b/29122459): Expect parse exception here.
Message.Builder builder = DynamicMessage.newBuilder(TestMap.getDescriptor());
parserWithOverwriteForbidden.merge(text, builder);
TestMap map =
TestMap.parseFrom(
builder.build().toByteString(), ExtensionRegistryLite.getEmptyRegistry());
assertEquals(2, map.getInt32ToInt32Field().size());
assertEquals(30, map.getInt32ToInt32Field().get(1).intValue());
}
} }
// ======================================================================= // =======================================================================

@ -42,6 +42,7 @@ import com.google.protobuf.UnittestLite.TestAllExtensionsLite;
import com.google.protobuf.UnittestLite.TestAllTypesLite; import com.google.protobuf.UnittestLite.TestAllTypesLite;
import com.google.protobuf.UnittestLite.TestAllTypesLite.NestedEnum; import com.google.protobuf.UnittestLite.TestAllTypesLite.NestedEnum;
import com.google.protobuf.UnittestLite.TestAllTypesLite.NestedMessage; import com.google.protobuf.UnittestLite.TestAllTypesLite.NestedMessage;
import com.google.protobuf.UnittestLite.TestAllTypesLite.NestedMessage2;
import com.google.protobuf.UnittestLite.TestAllTypesLite.OneofFieldCase; import com.google.protobuf.UnittestLite.TestAllTypesLite.OneofFieldCase;
import com.google.protobuf.UnittestLite.TestAllTypesLite.OptionalGroup; import com.google.protobuf.UnittestLite.TestAllTypesLite.OptionalGroup;
import com.google.protobuf.UnittestLite.TestAllTypesLite.RepeatedGroup; import com.google.protobuf.UnittestLite.TestAllTypesLite.RepeatedGroup;
@ -1354,6 +1355,45 @@ public class LiteTest extends TestCase {
assertEquals(message.getSerializedSize() * 2, result.getSerializedSize()); assertEquals(message.getSerializedSize() * 2, result.getSerializedSize());
} }
public void testMergeFrom_differentFieldsSetWithinOneField() throws Exception {
TestAllTypesLite result =
TestAllTypesLite.newBuilder()
.setOneofNestedMessage(NestedMessage.newBuilder().setBb(2))
.mergeFrom(
TestAllTypesLite.newBuilder()
.setOneofNestedMessage2(NestedMessage2.newBuilder().setDd(3))
.build())
.build();
assertToStringEquals("oneof_nested_message2 {\n dd: 3\n}", result);
}
public void testMergeFrom_differentFieldsOfSameTypeSetWithinOneField() throws Exception {
TestAllTypesLite result =
TestAllTypesLite.newBuilder()
.setOneofNestedMessage(NestedMessage.newBuilder().setBb(2))
.mergeFrom(
TestAllTypesLite.newBuilder()
.setOneofLazyNestedMessage(NestedMessage.newBuilder().setCc(3))
.build())
.build();
assertToStringEquals("oneof_lazy_nested_message {\n cc: 3\n}", result);
}
public void testMergeFrom_sameFieldSetWithinOneofField() throws Exception {
TestAllTypesLite result =
TestAllTypesLite.newBuilder()
.setOneofNestedMessage(NestedMessage.newBuilder().setBb(2))
.mergeFrom(
TestAllTypesLite.newBuilder()
.setOneofNestedMessage(NestedMessage.newBuilder().setCc(4))
.build())
.build();
assertToStringEquals("oneof_nested_message {\n bb: 2\n cc: 4\n}", result);
}
public void testToStringDefaultInstance() throws Exception { public void testToStringDefaultInstance() throws Exception {
assertToStringEquals("", TestAllTypesLite.getDefaultInstance()); assertToStringEquals("", TestAllTypesLite.getDefaultInstance());
} }

@ -328,14 +328,13 @@ public class JsonFormat {
/** /**
* Create a new {@link Printer} that will sort the map keys in the JSON output. * Create a new {@link Printer} that will sort the map keys in the JSON output.
* *
* Use of this modifier is discouraged, the generated JSON messages are equivalent * <p>Use of this modifier is discouraged, the generated JSON messages are equivalent with and
* with and without this option set, but there are some corner caseuse cases that * without this option set, but there are some corner use cases that demand a stable output,
* demand a stable output, while order of map keys is otherwise arbitrary. * while order of map keys is otherwise arbitrary.
* *
* The generated order is not well-defined and should not be depended on, but * <p>The generated order is not well-defined and should not be depended on, but it's stable.
* it's stable.
* *
* This new Printer clones all other configurations from the current {@link Printer}. * <p>This new Printer clones all other configurations from the current {@link Printer}.
*/ */
public Printer sortingMapKeys() { public Printer sortingMapKeys() {
return new Printer( return new Printer(

@ -71,13 +71,16 @@ gulp.task('genproto_group1_closure', function (cb) {
}); });
}); });
gulp.task('genproto_group2_closure', function (cb) { 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(' '), exec(
function (err, stdout, stderr) { protoc +
console.log(stdout); ' --experimental_allow_proto3_optional --js_out=library=testproto_libs2,binary:. -I ../src -I . -I commonjs ' +
console.log(stderr); group2Protos.join(' '),
cb(err); function(err, stdout, stderr) {
}); console.log(stdout);
console.log(stderr);
cb(err);
});
}); });
gulp.task('genproto_well_known_types_commonjs', function (cb) { gulp.task('genproto_well_known_types_commonjs', function (cb) {
@ -98,13 +101,16 @@ gulp.task('genproto_group1_commonjs', function (cb) {
}); });
}); });
gulp.task('genproto_group2_commonjs', function (cb) { 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(' '), exec(
function (err, stdout, stderr) { 'mkdir -p commonjs_out && ' + protoc +
console.log(stdout); ' --experimental_allow_proto3_optional --js_out=import_style=commonjs,binary:commonjs_out -I ../src -I commonjs -I . ' +
console.log(stderr); group2Protos.join(' '),
cb(err); function(err, stdout, stderr) {
}); console.log(stdout);
console.log(stderr);
cb(err);
});
}); });
gulp.task('genproto_commonjs_wellknowntypes', function (cb) { gulp.task('genproto_commonjs_wellknowntypes', function (cb) {

@ -130,8 +130,8 @@ describe('proto3Test', function() {
assertEquals(msg.getSingularBytes_asU8().length, 0); assertEquals(msg.getSingularBytes_asU8().length, 0);
assertEquals(msg.getSingularBytes_asB64(), ''); assertEquals(msg.getSingularBytes_asB64(), '');
assertEquals(msg.getSingularForeignEnum(), assertEquals(
proto.jspb.test.Proto3Enum.PROTO3_FOO); msg.getSingularForeignEnum(), proto.jspb.test.Proto3Enum.PROTO3_FOO);
assertEquals(msg.getSingularForeignMessage(), undefined); assertEquals(msg.getSingularForeignMessage(), undefined);
assertEquals(msg.getSingularForeignMessage(), undefined); assertEquals(msg.getSingularForeignMessage(), undefined);
@ -201,7 +201,7 @@ describe('proto3Test', function() {
assertTrue(msg.hasOptionalInt64()); assertTrue(msg.hasOptionalInt64());
assertFalse(msg.hasOptionalString()); assertFalse(msg.hasOptionalString());
msg.setOptionalString(""); msg.setOptionalString('');
assertTrue(msg.hasOptionalString()); assertTrue(msg.hasOptionalString());
// Now the proto will have a non-zero size, even though its values are 0. // Now the proto will have a non-zero size, even though its values are 0.
@ -224,7 +224,7 @@ describe('proto3Test', function() {
/** /**
* Test that all fields can be set ,and read via a serialization roundtrip. * 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(); var msg = new proto.jspb.test.TestProto3();
msg.setSingularInt32(-42); msg.setSingularInt32(-42);
@ -288,8 +288,8 @@ describe('proto3Test', function() {
assertEquals(msg.getSingularString(), 'hello world'); assertEquals(msg.getSingularString(), 'hello world');
assertEquals(true, bytesCompare(msg.getSingularBytes(), BYTES)); assertEquals(true, bytesCompare(msg.getSingularBytes(), BYTES));
assertEquals(msg.getSingularForeignMessage().getC(), 16); assertEquals(msg.getSingularForeignMessage().getC(), 16);
assertEquals(msg.getSingularForeignEnum(), assertEquals(
proto.jspb.test.Proto3Enum.PROTO3_BAR); msg.getSingularForeignEnum(), proto.jspb.test.Proto3Enum.PROTO3_BAR);
assertElementsEquals(msg.getRepeatedInt32List(), [-42]); assertElementsEquals(msg.getRepeatedInt32List(), [-42]);
assertElementsEquals(msg.getRepeatedInt64List(), [-0x7fffffff00000000]); assertElementsEquals(msg.getRepeatedInt64List(), [-0x7fffffff00000000]);

@ -30,10 +30,10 @@
syntax = "proto3"; syntax = "proto3";
import "testbinary.proto";
package jspb.test; package jspb.test;
import "testbinary.proto";
message TestProto3 { message TestProto3 {
int32 singular_int32 = 1; int32 singular_int32 = 1;
int64 singular_int64 = 2; int64 singular_int64 = 2;
@ -71,7 +71,7 @@ message TestProto3 {
optional bytes optional_bytes = 135; optional bytes optional_bytes = 135;
optional ForeignMessage optional_foreign_message = 136; optional ForeignMessage optional_foreign_message = 136;
optional Proto3Enum optional_foreign_enum =137; optional Proto3Enum optional_foreign_enum = 137;
repeated int32 repeated_int32 = 31; repeated int32 repeated_int32 = 31;
repeated int64 repeated_int64 = 32; repeated int64 repeated_int64 = 32;
@ -92,7 +92,6 @@ message TestProto3 {
repeated ForeignMessage repeated_foreign_message = 49; repeated ForeignMessage repeated_foreign_message = 49;
repeated Proto3Enum repeated_foreign_enum = 52; repeated Proto3Enum repeated_foreign_enum = 52;
oneof oneof_field { oneof oneof_field {
uint32 oneof_uint32 = 111; uint32 oneof_uint32 = 111;
ForeignMessage oneof_foreign_message = 112; ForeignMessage oneof_foreign_message = 112;

@ -94,10 +94,13 @@ typedef GPB_ENUM(GPBAny_FieldNumber) {
* Example 4: Pack and unpack a message in Go * Example 4: Pack and unpack a message in Go
* *
* foo := &pb.Foo{...} * foo := &pb.Foo{...}
* any, err := ptypes.MarshalAny(foo) * any, err := anypb.New(foo)
* if err != nil {
* ...
* }
* ... * ...
* foo := &pb.Foo{} * foo := &pb.Foo{}
* if err := ptypes.UnmarshalAny(any, foo); err != nil { * if err := any.UnmarshalTo(foo); err != nil {
* ... * ...
* } * }
* *

@ -107,7 +107,16 @@ typedef GPB_ENUM(GPBTimestamp_FieldNumber) {
* .setNanos((int) ((millis % 1000) * 1000000)).build(); * .setNanos((int) ((millis % 1000) * 1000000)).build();
* *
* *
* Example 5: Compute Timestamp from current time in Python. * Example 5: Compute Timestamp from Java `Instant.now()`.
*
* Instant now = Instant.now();
*
* Timestamp timestamp =
* Timestamp.newBuilder().setSeconds(now.getEpochSecond())
* .setNanos(now.getNano()).build();
*
*
* Example 6: Compute Timestamp from current time in Python.
* *
* timestamp = Timestamp() * timestamp = Timestamp()
* timestamp.GetCurrentTime() * timestamp.GetCurrentTime()

@ -108,7 +108,9 @@ class EnumTypeWrapper(object):
def __getattr__(self, name): def __getattr__(self, name):
"""Returns the value corresponding to the given enum name.""" """Returns the value corresponding to the given enum name."""
try: try:
return self._enum_type.values_by_name[name].number return super(
EnumTypeWrapper,
self).__getattribute__('_enum_type').values_by_name[name].number
except KeyError: except KeyError:
pass # fall out to break exception chaining pass # fall out to break exception chaining
raise AttributeError('Enum {} has no value defined for name {!r}'.format( raise AttributeError('Enum {} has no value defined for name {!r}'.format(

@ -636,6 +636,20 @@ class JsonFormatTest(JsonFormatBase):
parsed_message = json_format_proto3_pb2.TestListValue() parsed_message = json_format_proto3_pb2.TestListValue()
self.CheckParseBack(message, parsed_message) 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): def testAnyMessage(self):
message = json_format_proto3_pb2.TestAny() message = json_format_proto3_pb2.TestAny()
value1 = json_format_proto3_pb2.MessageType() value1 = json_format_proto3_pb2.MessageType()

@ -142,6 +142,8 @@ class TextFormatMessageToStringTests(TextFormatBase):
message.repeated_float.append(1.234e10) message.repeated_float.append(1.234e10)
message.repeated_float.append(1.2345e10) message.repeated_float.append(1.2345e10)
message.repeated_float.append(1.23456e10) 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.0)
message.repeated_double.append(0.8) message.repeated_double.append(0.8)
message.repeated_double.append(1.0) message.repeated_double.append(1.0)
@ -190,6 +192,8 @@ class TextFormatMessageToStringTests(TextFormatBase):
'repeated_float: 12340000000\n' 'repeated_float: 12340000000\n'
'repeated_float: 12345000000\n' 'repeated_float: 12345000000\n'
'repeated_float: 12345600000\n' 'repeated_float: 12345600000\n'
'repeated_float: nan\n'
'repeated_float: inf\n'
'repeated_double: 0\n' 'repeated_double: 0\n'
'repeated_double: 0.8\n' 'repeated_double: 0.8\n'
'repeated_double: 1\n' 'repeated_double: 1\n'

@ -74,11 +74,6 @@ def TruncateToFourByteFloat(original):
def ToShortestFloat(original): def ToShortestFloat(original):
"""Returns the shortest float that has same value in wire.""" """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 # All 4 byte floats have between 6 and 9 significant digits, so we
# start with 6 as the lower bound. # start with 6 as the lower bound.
# It has to be iterative because use '.9g' directly can not get rid # It has to be iterative because use '.9g' directly can not get rid

@ -286,6 +286,8 @@ class _Printer(object):
elif field.cpp_type == descriptor.FieldDescriptor.CPPTYPE_ENUM: elif field.cpp_type == descriptor.FieldDescriptor.CPPTYPE_ENUM:
if self.use_integers_for_enums: if self.use_integers_for_enums:
return value return value
if field.enum_type.full_name == 'google.protobuf.NullValue':
return None
enum_value = field.enum_type.values_by_number.get(value, None) enum_value = field.enum_type.values_by_number.get(value, None)
if enum_value is not None: if enum_value is not None:
return enum_value.name return enum_value.name
@ -544,6 +546,9 @@ class _Parser(object):
and field.message_type.full_name == 'google.protobuf.Value'): and field.message_type.full_name == 'google.protobuf.Value'):
sub_message = getattr(message, field.name) sub_message = getattr(message, field.name)
sub_message.null_value = 0 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: else:
message.ClearField(field.name) message.ClearField(field.name)
continue continue

@ -46,19 +46,19 @@ __author__ = 'kenton@google.com (Kenton Varda)'
import encodings.raw_unicode_escape # pylint: disable=unused-import import encodings.raw_unicode_escape # pylint: disable=unused-import
import encodings.unicode_escape # pylint: disable=unused-import import encodings.unicode_escape # pylint: disable=unused-import
import io import io
import math
import re import re
import six 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 decoder
from google.protobuf.internal import type_checkers from google.protobuf.internal import type_checkers
from google.protobuf import descriptor from google.protobuf import descriptor
from google.protobuf import text_encoding 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', __all__ = ['MessageToString', 'Parse', 'PrintMessage', 'PrintField',
'PrintFieldValue', 'Merge', 'MessageToBytes'] 'PrintFieldValue', 'Merge', 'MessageToBytes']
@ -630,7 +630,10 @@ class _Printer(object):
if self.float_format is not None: if self.float_format is not None:
out.write('{1:{0}}'.format(self.float_format, value)) out.write('{1:{0}}'.format(self.float_format, value))
else: 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 elif (field.cpp_type == descriptor.FieldDescriptor.CPPTYPE_DOUBLE and
self.double_format is not None): self.double_format is not None):
out.write('{1:{0}}'.format(self.double_format, value)) out.write('{1:{0}}'.format(self.double_format, value))

@ -208,6 +208,7 @@ libprotobuf_lite_la_SOURCES = \
google/protobuf/generated_message_table_driven_lite.h \ google/protobuf/generated_message_table_driven_lite.h \
google/protobuf/generated_message_table_driven_lite.cc \ google/protobuf/generated_message_table_driven_lite.cc \
google/protobuf/implicit_weak_message.cc \ google/protobuf/implicit_weak_message.cc \
google/protobuf/map.cc \
google/protobuf/message_lite.cc \ google/protobuf/message_lite.cc \
google/protobuf/parse_context.cc \ google/protobuf/parse_context.cc \
google/protobuf/repeated_field.cc \ google/protobuf/repeated_field.cc \

@ -46,19 +46,21 @@ void AnyMetadata::PackFrom(const Message& message) {
} }
void AnyMetadata::PackFrom(const Message& message, void AnyMetadata::PackFrom(const Message& message,
const std::string& type_url_prefix) { StringPiece type_url_prefix) {
type_url_->SetNoArena( type_url_->Set(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString(), &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString(),
GetTypeUrl(message.GetDescriptor()->full_name(), type_url_prefix)); GetTypeUrl(message.GetDescriptor()->full_name(), type_url_prefix),
message.SerializeToString(value_->MutableNoArena( nullptr);
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())); message.SerializeToString(value_->Mutable(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
nullptr));
} }
bool AnyMetadata::UnpackTo(Message* message) const { bool AnyMetadata::UnpackTo(Message* message) const {
if (!InternalIs(message->GetDescriptor()->full_name())) { if (!InternalIs(message->GetDescriptor()->full_name())) {
return false; return false;
} }
return message->ParseFromString(value_->GetNoArena()); return message->ParseFromString(value_->Get());
} }
bool GetAnyFieldDescriptors(const Message& message, bool GetAnyFieldDescriptors(const Message& message,

@ -82,7 +82,7 @@ class PROTOBUF_EXPORT AnyMetadata {
InternalPackFrom(message, type_url_prefix, T::FullMessageName()); 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 // 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 // type doesn't match the type specified in the type URL (i.e., the full
@ -124,14 +124,14 @@ class PROTOBUF_EXPORT AnyMetadata {
// //
// NOTE: this function is available publicly as: // NOTE: this function is available publicly as:
// google::protobuf::Any() // static method on the generated message type. // 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, // Get the proto type name and prefix from Any::type_url value. For example,
// passing "type.googleapis.com/rpc.QueryOrigin" will return // passing "type.googleapis.com/rpc.QueryOrigin" will return
// "type.googleapis.com/" in *url_prefix and "rpc.QueryOrigin" in // "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 // *full_type_name. Returns false if the type_url does not have a "/" in the
// type url separating the full type name. // 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); std::string* full_type_name);
// See if message is of type google.protobuf.Any, if so, return the descriptors // See if message is of type google.protobuf.Any, if so, return the descriptors

@ -28,7 +28,6 @@ static void InitDefaultsscc_info_Any_google_2fprotobuf_2fany_2eproto() {
new (ptr) PROTOBUF_NAMESPACE_ID::Any(); new (ptr) PROTOBUF_NAMESPACE_ID::Any();
::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
} }
PROTOBUF_NAMESPACE_ID::Any::InitAsDefaultInstance();
} }
PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_Any_google_2fprotobuf_2fany_2eproto = PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_Any_google_2fprotobuf_2fany_2eproto =
@ -58,10 +57,10 @@ static ::PROTOBUF_NAMESPACE_ID::Message const * const file_default_instances[] =
const char descriptor_table_protodef_google_2fprotobuf_2fany_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = const char descriptor_table_protodef_google_2fprotobuf_2fany_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) =
"\n\031google/protobuf/any.proto\022\017google.prot" "\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" "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" " \001(\014Bv\n\023com.google.protobufB\010AnyProtoP\001Z"
"%github.com/golang/protobuf/ptypes/any\242\002" ",google.golang.org/protobuf/types/known/"
"\003GPB\252\002\036Google.Protobuf.WellKnownTypesb\006p" "anypb\242\002\003GPB\252\002\036Google.Protobuf.WellKnownT"
"roto3" "ypesb\006proto3"
; ;
static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_google_2fprotobuf_2fany_2eproto_deps[1] = { static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_google_2fprotobuf_2fany_2eproto_deps[1] = {
}; };
@ -70,7 +69,7 @@ static ::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase*const descriptor_table_goo
}; };
static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_google_2fprotobuf_2fany_2eproto_once; 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 = { 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, &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, 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, file_level_metadata_google_2fprotobuf_2fany_2eproto, 1, file_level_enum_descriptors_google_2fprotobuf_2fany_2eproto, file_level_service_descriptors_google_2fprotobuf_2fany_2eproto,
@ -82,8 +81,6 @@ PROTOBUF_NAMESPACE_OPEN
// =================================================================== // ===================================================================
void Any::InitAsDefaultInstance() {
}
bool Any::GetAnyFieldDescriptors( bool Any::GetAnyFieldDescriptors(
const ::PROTOBUF_NAMESPACE_ID::Message& message, const ::PROTOBUF_NAMESPACE_ID::Message& message,
const ::PROTOBUF_NAMESPACE_ID::FieldDescriptor** type_url_field, const ::PROTOBUF_NAMESPACE_ID::FieldDescriptor** type_url_field,
@ -91,8 +88,9 @@ bool Any::GetAnyFieldDescriptors(
return ::PROTOBUF_NAMESPACE_ID::internal::GetAnyFieldDescriptors( return ::PROTOBUF_NAMESPACE_ID::internal::GetAnyFieldDescriptors(
message, type_url_field, value_field); message, type_url_field, value_field);
} }
bool Any::ParseAnyTypeUrl(const string& type_url, bool Any::ParseAnyTypeUrl(
std::string* full_type_name) { ::PROTOBUF_NAMESPACE_ID::ConstStringParam type_url,
std::string* full_type_name) {
return ::PROTOBUF_NAMESPACE_ID::internal::ParseAnyTypeUrl(type_url, return ::PROTOBUF_NAMESPACE_ID::internal::ParseAnyTypeUrl(type_url,
full_type_name); full_type_name);
} }

@ -102,7 +102,6 @@ class PROTOBUF_EXPORT Any PROTOBUF_FINAL :
} }
static const Any& default_instance(); static const Any& default_instance();
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
static inline const Any* internal_default_instance() { static inline const Any* internal_default_instance() {
return reinterpret_cast<const Any*>( return reinterpret_cast<const Any*>(
&_Any_default_instance_); &_Any_default_instance_);
@ -116,7 +115,7 @@ class PROTOBUF_EXPORT Any PROTOBUF_FINAL :
_any_metadata_.PackFrom(message); _any_metadata_.PackFrom(message);
} }
void PackFrom(const ::PROTOBUF_NAMESPACE_ID::Message& 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); _any_metadata_.PackFrom(message, type_url_prefix);
} }
bool UnpackTo(::PROTOBUF_NAMESPACE_ID::Message* message) const { bool UnpackTo(::PROTOBUF_NAMESPACE_ID::Message* message) const {
@ -132,7 +131,7 @@ class PROTOBUF_EXPORT Any PROTOBUF_FINAL :
} }
template <typename T, class = typename std::enable_if<!std::is_convertible<T, const ::PROTOBUF_NAMESPACE_ID::Message&>::value>::type> template <typename T, class = typename std::enable_if<!std::is_convertible<T, const ::PROTOBUF_NAMESPACE_ID::Message&>::value>::type>
void PackFrom(const T& message, 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);} _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> template <typename T, class = typename std::enable_if<!std::is_convertible<T, const ::PROTOBUF_NAMESPACE_ID::Message&>::value>::type>
bool UnpackTo(T* message) const { bool UnpackTo(T* message) const {
@ -141,7 +140,7 @@ class PROTOBUF_EXPORT Any PROTOBUF_FINAL :
template<typename T> bool Is() const { template<typename T> bool Is() const {
return _any_metadata_.Is<T>(); 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); std::string* full_type_name);
friend void swap(Any& a, Any& b) { friend void swap(Any& a, Any& b) {
a.Swap(&b); a.Swap(&b);

@ -33,7 +33,7 @@ syntax = "proto3";
package google.protobuf; package google.protobuf;
option csharp_namespace = "Google.Protobuf.WellKnownTypes"; 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_package = "com.google.protobuf";
option java_outer_classname = "AnyProto"; option java_outer_classname = "AnyProto";
option java_multiple_files = true; option java_multiple_files = true;
@ -77,10 +77,13 @@ option objc_class_prefix = "GPB";
// Example 4: Pack and unpack a message in Go // Example 4: Pack and unpack a message in Go
// //
// foo := &pb.Foo{...} // foo := &pb.Foo{...}
// any, err := ptypes.MarshalAny(foo) // any, err := anypb.New(foo)
// if err != nil {
// ...
// }
// ... // ...
// foo := &pb.Foo{} // foo := &pb.Foo{}
// if err := ptypes.UnmarshalAny(any, foo); err != nil { // if err := any.UnmarshalTo(foo); err != nil {
// ... // ...
// } // }
// //

@ -59,10 +59,10 @@ AnyMetadata::AnyMetadata(UrlType* type_url, ValueType* value)
void AnyMetadata::InternalPackFrom(const MessageLite& message, void AnyMetadata::InternalPackFrom(const MessageLite& message,
StringPiece type_url_prefix, StringPiece type_url_prefix,
StringPiece type_name) { StringPiece type_name) {
type_url_->SetNoArena(&::google::protobuf::internal::GetEmptyString(), type_url_->Set(&::google::protobuf::internal::GetEmptyString(),
GetTypeUrl(type_name, type_url_prefix)); GetTypeUrl(type_name, type_url_prefix), nullptr);
message.SerializeToString(value_->MutableNoArena( message.SerializeToString(value_->Mutable(
&::google::protobuf::internal::GetEmptyStringAlreadyInited())); &::google::protobuf::internal::GetEmptyStringAlreadyInited(), nullptr));
} }
bool AnyMetadata::InternalUnpackTo(StringPiece type_name, bool AnyMetadata::InternalUnpackTo(StringPiece type_name,
@ -70,50 +70,30 @@ bool AnyMetadata::InternalUnpackTo(StringPiece type_name,
if (!InternalIs(type_name)) { if (!InternalIs(type_name)) {
return false; return false;
} }
return message->ParseFromString(value_->GetNoArena()); return message->ParseFromString(value_->Get());
} }
namespace {
// The type URL could be stored in either an ArenaStringPtr or a
// StringPieceField, so we provide these helpers to get a string_view from
// either type. We use a template function as a way to avoid depending on
// StringPieceField.
template <typename T>
StringPiece Get(const T* ptr) {
return ptr->Get();
}
template <>
// NOLINTNEXTLINE: clang-diagnostic-unused-function
StringPiece Get(const ArenaStringPtr* ptr) {
return ptr->GetNoArena();
}
} // namespace
bool AnyMetadata::InternalIs(StringPiece type_name) const { bool AnyMetadata::InternalIs(StringPiece type_name) const {
StringPiece type_url = Get(type_url_); StringPiece type_url = type_url_->Get();
return type_url.size() >= type_name.size() + 1 && return type_url.size() >= type_name.size() + 1 &&
type_url[type_url.size() - type_name.size() - 1] == '/' && type_url[type_url.size() - type_name.size() - 1] == '/' &&
HasSuffixString(type_url, type_name); 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) { std::string* full_type_name) {
size_t pos = type_url.find_last_of("/"); size_t pos = type_url.find_last_of("/");
if (pos == std::string::npos || pos + 1 == type_url.size()) { if (pos == std::string::npos || pos + 1 == type_url.size()) {
return false; return false;
} }
if (url_prefix) { 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; 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); return ParseAnyTypeUrl(type_url, nullptr, full_type_name);
} }

@ -40,7 +40,6 @@ static void InitDefaultsscc_info_Api_google_2fprotobuf_2fapi_2eproto() {
new (ptr) PROTOBUF_NAMESPACE_ID::Api(); new (ptr) PROTOBUF_NAMESPACE_ID::Api();
::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
} }
PROTOBUF_NAMESPACE_ID::Api::InitAsDefaultInstance();
} }
PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<4> scc_info_Api_google_2fprotobuf_2fapi_2eproto = PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<4> scc_info_Api_google_2fprotobuf_2fapi_2eproto =
@ -58,7 +57,6 @@ static void InitDefaultsscc_info_Method_google_2fprotobuf_2fapi_2eproto() {
new (ptr) PROTOBUF_NAMESPACE_ID::Method(); new (ptr) PROTOBUF_NAMESPACE_ID::Method();
::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
} }
PROTOBUF_NAMESPACE_ID::Method::InitAsDefaultInstance();
} }
PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_Method_google_2fprotobuf_2fapi_2eproto = PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_Method_google_2fprotobuf_2fapi_2eproto =
@ -73,7 +71,6 @@ static void InitDefaultsscc_info_Mixin_google_2fprotobuf_2fapi_2eproto() {
new (ptr) PROTOBUF_NAMESPACE_ID::Mixin(); new (ptr) PROTOBUF_NAMESPACE_ID::Mixin();
::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
} }
PROTOBUF_NAMESPACE_ID::Mixin::InitAsDefaultInstance();
} }
PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_Mixin_google_2fprotobuf_2fapi_2eproto = PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_Mixin_google_2fprotobuf_2fapi_2eproto =
@ -144,10 +141,10 @@ const char descriptor_table_protodef_google_2fprotobuf_2fapi_2eproto[] PROTOBUF_
"esponse_streaming\030\005 \001(\010\022(\n\007options\030\006 \003(\013" "esponse_streaming\030\005 \001(\010\022(\n\007options\030\006 \003(\013"
"2\027.google.protobuf.Option\022\'\n\006syntax\030\007 \001(" "2\027.google.protobuf.Option\022\'\n\006syntax\030\007 \001("
"\0162\027.google.protobuf.Syntax\"#\n\005Mixin\022\014\n\004n" "\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" "ame\030\001 \001(\t\022\014\n\004root\030\002 \001(\tBv\n\023com.google.pr"
"otobufB\010ApiProtoP\001Z+google.golang.org/ge" "otobufB\010ApiProtoP\001Z,google.golang.org/pr"
"nproto/protobuf/api;api\242\002\003GPB\252\002\036Google.P" "otobuf/types/known/apipb\242\002\003GPB\252\002\036Google."
"rotobuf.WellKnownTypesb\006proto3" "Protobuf.WellKnownTypesb\006proto3"
; ;
static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_google_2fprotobuf_2fapi_2eproto_deps[2] = { static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_google_2fprotobuf_2fapi_2eproto_deps[2] = {
&::descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto, &::descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto,
@ -160,7 +157,7 @@ static ::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase*const descriptor_table_goo
}; };
static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_google_2fprotobuf_2fapi_2eproto_once; 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 = { 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, &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, 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, file_level_metadata_google_2fprotobuf_2fapi_2eproto, 3, file_level_enum_descriptors_google_2fprotobuf_2fapi_2eproto, file_level_service_descriptors_google_2fprotobuf_2fapi_2eproto,
@ -172,10 +169,6 @@ PROTOBUF_NAMESPACE_OPEN
// =================================================================== // ===================================================================
void Api::InitAsDefaultInstance() {
PROTOBUF_NAMESPACE_ID::_Api_default_instance_._instance.get_mutable()->source_context_ = const_cast< PROTOBUF_NAMESPACE_ID::SourceContext*>(
PROTOBUF_NAMESPACE_ID::SourceContext::internal_default_instance());
}
class Api::_Internal { class Api::_Internal {
public: public:
static const PROTOBUF_NAMESPACE_ID::SourceContext& source_context(const Api* msg); static const PROTOBUF_NAMESPACE_ID::SourceContext& source_context(const Api* msg);
@ -601,8 +594,6 @@ void Api::InternalSwap(Api* other) {
// =================================================================== // ===================================================================
void Method::InitAsDefaultInstance() {
}
class Method::_Internal { class Method::_Internal {
public: public:
}; };
@ -1002,8 +993,6 @@ void Method::InternalSwap(Method* other) {
// =================================================================== // ===================================================================
void Mixin::InitAsDefaultInstance() {
}
class Mixin::_Internal { class Mixin::_Internal {
public: public:
}; };

@ -112,7 +112,6 @@ class PROTOBUF_EXPORT Api PROTOBUF_FINAL :
} }
static const Api& default_instance(); static const Api& default_instance();
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
static inline const Api* internal_default_instance() { static inline const Api* internal_default_instance() {
return reinterpret_cast<const Api*>( return reinterpret_cast<const Api*>(
&_Api_default_instance_); &_Api_default_instance_);
@ -365,7 +364,6 @@ class PROTOBUF_EXPORT Method PROTOBUF_FINAL :
} }
static const Method& default_instance(); static const Method& default_instance();
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
static inline const Method* internal_default_instance() { static inline const Method* internal_default_instance() {
return reinterpret_cast<const Method*>( return reinterpret_cast<const Method*>(
&_Method_default_instance_); &_Method_default_instance_);
@ -598,7 +596,6 @@ class PROTOBUF_EXPORT Mixin PROTOBUF_FINAL :
} }
static const Mixin& default_instance(); static const Mixin& default_instance();
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
static inline const Mixin* internal_default_instance() { static inline const Mixin* internal_default_instance() {
return reinterpret_cast<const Mixin*>( return reinterpret_cast<const Mixin*>(
&_Mixin_default_instance_); &_Mixin_default_instance_);
@ -941,8 +938,8 @@ inline bool Api::has_source_context() const {
} }
inline const PROTOBUF_NAMESPACE_ID::SourceContext& Api::_internal_source_context() const { inline const PROTOBUF_NAMESPACE_ID::SourceContext& Api::_internal_source_context() const {
const PROTOBUF_NAMESPACE_ID::SourceContext* p = source_context_; const PROTOBUF_NAMESPACE_ID::SourceContext* p = source_context_;
return p != nullptr ? *p : *reinterpret_cast<const PROTOBUF_NAMESPACE_ID::SourceContext*>( return p != nullptr ? *p : reinterpret_cast<const PROTOBUF_NAMESPACE_ID::SourceContext&>(
&PROTOBUF_NAMESPACE_ID::_SourceContext_default_instance_); PROTOBUF_NAMESPACE_ID::_SourceContext_default_instance_);
} }
inline const PROTOBUF_NAMESPACE_ID::SourceContext& Api::source_context() const { inline const PROTOBUF_NAMESPACE_ID::SourceContext& Api::source_context() const {
// @@protoc_insertion_point(field_get:google.protobuf.Api.source_context) // @@protoc_insertion_point(field_get:google.protobuf.Api.source_context)

@ -40,7 +40,7 @@ option java_package = "com.google.protobuf";
option java_outer_classname = "ApiProto"; option java_outer_classname = "ApiProto";
option java_multiple_files = true; option java_multiple_files = true;
option objc_class_prefix = "GPB"; 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. // Api is a light-weight descriptor for an API Interface.
// //
@ -52,7 +52,6 @@ option go_package = "google.golang.org/genproto/protobuf/api;api";
// this message itself. See https://cloud.google.com/apis/design/glossary for // this message itself. See https://cloud.google.com/apis/design/glossary for
// detailed terminology. // detailed terminology.
message Api { message Api {
// The fully qualified name of this interface, including package name // The fully qualified name of this interface, including package name
// followed by the interface's simple name. // followed by the interface's simple name.
string name = 1; string name = 1;
@ -99,7 +98,6 @@ message Api {
// Method represents a method of an API interface. // Method represents a method of an API interface.
message Method { message Method {
// The simple name of this method. // The simple name of this method.
string name = 1; string name = 1;

@ -166,27 +166,19 @@ void ArenaImpl::AddCleanup(void* elem, void (*cleanup)(void*)) {
PROTOBUF_NOINLINE PROTOBUF_NOINLINE
void* ArenaImpl::AllocateAlignedFallback(size_t n) { void* ArenaImpl::AllocateAlignedFallback(size_t n) {
return GetSerialArena()->AllocateAligned(n); return GetSerialArenaFallback(&thread_cache())->AllocateAligned(n);
} }
PROTOBUF_NOINLINE PROTOBUF_NOINLINE
void* ArenaImpl::AllocateAlignedAndAddCleanupFallback(size_t n, void* ArenaImpl::AllocateAlignedAndAddCleanupFallback(size_t n,
void (*cleanup)(void*)) { void (*cleanup)(void*)) {
return GetSerialArena()->AllocateAlignedAndAddCleanup(n, cleanup); return GetSerialArenaFallback(
&thread_cache())->AllocateAlignedAndAddCleanup(n, cleanup);
} }
PROTOBUF_NOINLINE PROTOBUF_NOINLINE
void ArenaImpl::AddCleanupFallback(void* elem, void (*cleanup)(void*)) { void ArenaImpl::AddCleanupFallback(void* elem, void (*cleanup)(void*)) {
GetSerialArena()->AddCleanup(elem, cleanup); GetSerialArenaFallback(&thread_cache())->AddCleanup(elem, cleanup);
}
ArenaImpl::SerialArena* ArenaImpl::GetSerialArena() {
SerialArena* arena;
if (PROTOBUF_PREDICT_TRUE(GetSerialArenaFast(&arena))) {
return arena;
} else {
return GetSerialArenaFallback(&thread_cache());
}
} }
PROTOBUF_NOINLINE PROTOBUF_NOINLINE

@ -329,7 +329,6 @@ class PROTOBUF_EXPORT ArenaImpl {
Block* NewBlock(Block* last_block, size_t min_bytes); Block* NewBlock(Block* last_block, size_t min_bytes);
SerialArena* GetSerialArena();
PROTOBUF_ALWAYS_INLINE bool GetSerialArenaFast(SerialArena** arena) { PROTOBUF_ALWAYS_INLINE bool GetSerialArenaFast(SerialArena** arena) {
if (GetSerialArenaFromThreadCache(arena)) return true; if (GetSerialArenaFromThreadCache(arena)) return true;

@ -1166,7 +1166,6 @@ TEST(ArenaTest, MessageLiteOnArena) {
} }
#endif // PROTOBUF_RTTI #endif // PROTOBUF_RTTI
// RepeatedField should support non-POD types, and invoke constructors and // RepeatedField should support non-POD types, and invoke constructors and
// destructors appropriately, because it's used this way by lots of other code // destructors appropriately, because it's used this way by lots of other code
// (even if this was not its original intent). // (even if this was not its original intent).

@ -229,7 +229,6 @@ struct PROTOBUF_EXPORT ArenaStringPtr {
// Clears content, assuming that the current value is not the empty string // Clears content, assuming that the current value is not the empty string
// default. // default.
inline void ClearNonDefaultToEmpty() { ptr_->clear(); } inline void ClearNonDefaultToEmpty() { ptr_->clear(); }
inline void ClearNonDefaultToEmptyNoArena() { ptr_->clear(); }
// Clears content, but keeps allocated string if arena != NULL, to avoid the // Clears content, but keeps allocated string if arena != NULL, to avoid the
// overhead of heap operations. After this returns, the content (as seen by // overhead of heap operations. After this returns, the content (as seen by
@ -257,93 +256,13 @@ struct PROTOBUF_EXPORT ArenaStringPtr {
ptr_ = const_cast< ::std::string*>(default_value); ptr_ = const_cast< ::std::string*>(default_value);
} }
// The 'NoArena' variants of methods below assume arena == NULL and are // Destroy the string. Assumes `arena == nullptr`.
// optimized to provide very little overhead relative to a raw string pointer
// (while still being in-memory compatible with other code that assumes
// ArenaStringPtr). Note the invariant that a class instance that has only
// ever been mutated by NoArena methods must *only* be in the String state
// (i.e., tag bits are not used), *NEVER* ArenaString. This allows all
// tagged-pointer manipulations to be avoided.
inline void SetNoArena(const ::std::string* default_value,
const ::std::string& value) {
if (ptr_ == default_value) {
CreateInstanceNoArena(&value);
} else {
*ptr_ = value;
}
}
void SetNoArena(const ::std::string* default_value, ::std::string&& value) {
if (IsDefault(default_value)) {
ptr_ = new ::std::string(std::move(value));
} else {
*ptr_ = std::move(value);
}
}
void AssignWithDefault(const ::std::string* default_value,
ArenaStringPtr value);
inline const ::std::string& GetNoArena() const { return *ptr_; }
inline ::std::string* MutableNoArena(const ::std::string* default_value) {
if (ptr_ == default_value) {
CreateInstanceNoArena(default_value);
}
return ptr_;
}
inline ::std::string* ReleaseNoArena(const ::std::string* default_value) {
if (ptr_ == default_value) {
return NULL;
} else {
return ReleaseNonDefaultNoArena(default_value);
}
}
inline ::std::string* ReleaseNonDefaultNoArena(
const ::std::string* default_value) {
GOOGLE_DCHECK(!IsDefault(default_value));
::std::string* released = ptr_;
ptr_ = const_cast< ::std::string*>(default_value);
return released;
}
inline void SetAllocatedNoArena(const ::std::string* default_value,
::std::string* value) {
if (ptr_ != default_value) {
delete ptr_;
}
if (value != NULL) {
ptr_ = value;
} else {
ptr_ = const_cast< ::std::string*>(default_value);
}
}
inline void DestroyNoArena(const ::std::string* default_value) { inline void DestroyNoArena(const ::std::string* default_value) {
if (ptr_ != default_value) { if (ptr_ != default_value) {
delete ptr_; delete ptr_;
} }
} }
inline void ClearToEmptyNoArena(const ::std::string* default_value) {
if (ptr_ == default_value) {
// Nothing: already equal to default (which is the empty string).
} else {
ptr_->clear();
}
}
inline void ClearToDefaultNoArena(const ::std::string* default_value) {
if (ptr_ == default_value) {
// Nothing: already set to default.
} else {
// Reuse existing allocated instance.
*ptr_ = *default_value;
}
}
// Internal accessor used only at parse time to provide direct access to the // Internal accessor used only at parse time to provide direct access to the
// raw pointer from the shared parse routine (in the non-arenas case). The // raw pointer from the shared parse routine (in the non-arenas case). The
// parse routine does the string allocation in order to save code size in the // parse routine does the string allocation in order to save code size in the
@ -379,22 +298,6 @@ struct PROTOBUF_EXPORT ArenaStringPtr {
} }
}; };
} // namespace internal
} // namespace protobuf
namespace protobuf {
namespace internal {
inline void ArenaStringPtr::AssignWithDefault(
const ::std::string* default_value, ArenaStringPtr value) {
const ::std::string* me = *UnsafeRawStringPointer();
const ::std::string* other = *value.UnsafeRawStringPointer();
// If the pointers are the same then do nothing.
if (me != other) {
SetNoArena(default_value, value.GetNoArena());
}
}
} // namespace internal } // namespace internal
} // namespace protobuf } // namespace protobuf
} // namespace google } // namespace google

@ -85,6 +85,12 @@ io::ZeroCopyOutputStream* GeneratorContext::OpenForInsert(
return NULL; // make compiler happy return NULL; // make compiler happy
} }
io::ZeroCopyOutputStream* GeneratorContext::OpenForInsertWithGeneratedCodeInfo(
const std::string& filename, const std::string& insertion_point,
const google::protobuf::GeneratedCodeInfo& /*info*/) {
return OpenForInsert(filename, insertion_point);
}
void GeneratorContext::ListParsedFiles( void GeneratorContext::ListParsedFiles(
std::vector<const FileDescriptor*>* output) { std::vector<const FileDescriptor*>* output) {
GOOGLE_LOG(FATAL) << "This GeneratorContext does not support ListParsedFiles"; GOOGLE_LOG(FATAL) << "This GeneratorContext does not support ListParsedFiles";

@ -52,6 +52,7 @@ namespace io {
class ZeroCopyOutputStream; class ZeroCopyOutputStream;
} }
class FileDescriptor; class FileDescriptor;
class GeneratedCodeInfo;
namespace compiler { namespace compiler {
class AccessInfoMap; class AccessInfoMap;
@ -156,6 +157,15 @@ class PROTOC_EXPORT GeneratorContext {
virtual io::ZeroCopyOutputStream* OpenForInsert( virtual io::ZeroCopyOutputStream* OpenForInsert(
const std::string& filename, const std::string& insertion_point); const std::string& filename, const std::string& insertion_point);
// Similar to OpenForInsert, but if `info` is non-empty, will open (or create)
// filename.pb.meta and insert info at the appropriate place with the
// necessary shifts. The default implementation ignores `info`.
//
// WARNING: This feature will be REMOVED in the near future.
virtual io::ZeroCopyOutputStream* OpenForInsertWithGeneratedCodeInfo(
const std::string& filename, const std::string& insertion_point,
const google::protobuf::GeneratedCodeInfo& info);
// Returns a vector of FileDescriptors for all the files being compiled // Returns a vector of FileDescriptors for all the files being compiled
// in this run. Useful for languages, such as Go, that treat files // in this run. Useful for languages, such as Go, that treat files
// differently when compiled as a set rather than individually. // differently when compiled as a set rather than individually.

@ -386,6 +386,9 @@ class CommandLineInterface::GeneratorContextImpl : public GeneratorContext {
io::ZeroCopyOutputStream* OpenForAppend(const std::string& filename); io::ZeroCopyOutputStream* OpenForAppend(const std::string& filename);
io::ZeroCopyOutputStream* OpenForInsert(const std::string& filename, io::ZeroCopyOutputStream* OpenForInsert(const std::string& filename,
const std::string& insertion_point); const std::string& insertion_point);
io::ZeroCopyOutputStream* OpenForInsertWithGeneratedCodeInfo(
const std::string& filename, const std::string& insertion_point,
const google::protobuf::GeneratedCodeInfo& info);
void ListParsedFiles(std::vector<const FileDescriptor*>* output) { void ListParsedFiles(std::vector<const FileDescriptor*>* output) {
*output = parsed_files_; *output = parsed_files_;
} }
@ -393,7 +396,8 @@ class CommandLineInterface::GeneratorContextImpl : public GeneratorContext {
private: private:
friend class MemoryOutputStream; friend class MemoryOutputStream;
// map instead of unordered_map so that files are written in order (good when // The files_ field maps from path keys to file content values. It's a map
// instead of an unordered_map so that files are written in order (good when
// writing zips). // writing zips).
std::map<std::string, std::string> files_; std::map<std::string, std::string> files_;
const std::vector<const FileDescriptor*>& parsed_files_; const std::vector<const FileDescriptor*>& parsed_files_;
@ -408,6 +412,10 @@ class CommandLineInterface::MemoryOutputStream
MemoryOutputStream(GeneratorContextImpl* directory, MemoryOutputStream(GeneratorContextImpl* directory,
const std::string& filename, const std::string& filename,
const std::string& insertion_point); const std::string& insertion_point);
MemoryOutputStream(GeneratorContextImpl* directory,
const std::string& filename,
const std::string& insertion_point,
const google::protobuf::GeneratedCodeInfo& info);
virtual ~MemoryOutputStream(); virtual ~MemoryOutputStream();
// implements ZeroCopyOutputStream --------------------------------- // implements ZeroCopyOutputStream ---------------------------------
@ -418,12 +426,23 @@ class CommandLineInterface::MemoryOutputStream
int64_t ByteCount() const override { return inner_->ByteCount(); } int64_t ByteCount() const override { return inner_->ByteCount(); }
private: private:
// Checks to see if "filename_.meta" exists in directory_; if so, fixes the // Checks to see if "filename_.pb.meta" exists in directory_; if so, fixes the
// offsets in that GeneratedCodeInfo record to reflect bytes inserted in // offsets in that GeneratedCodeInfo record to reflect bytes inserted in
// filename_ at original offset insertion_offset with length insertion_length. // filename_ at original offset insertion_offset with length insertion_length.
// We assume that insertions will not occur within any given annotated span // Also adds in the data from info_to_insert_ with updated offsets governed by
// of text. // insertion_offset and indent_length. We assume that insertions will not
void UpdateMetadata(size_t insertion_offset, size_t insertion_length); // occur within any given annotated span of text. insertion_content must end
// with an endline.
void UpdateMetadata(const std::string& insertion_content,
size_t insertion_offset, size_t insertion_length,
size_t indent_length);
// Inserts info_to_insert_ into target_info, assuming that the relevant
// insertion was made at insertion_offset in file_content with the given
// indent_length. insertion_content must end with an endline.
void InsertShiftedInfo(const std::string& insertion_content,
size_t insertion_offset, size_t indent_length,
google::protobuf::GeneratedCodeInfo& target_info);
// Where to insert the string when it's done. // Where to insert the string when it's done.
GeneratorContextImpl* directory_; GeneratorContextImpl* directory_;
@ -438,6 +457,9 @@ class CommandLineInterface::MemoryOutputStream
// StringOutputStream writing to data_. // StringOutputStream writing to data_.
std::unique_ptr<io::StringOutputStream> inner_; std::unique_ptr<io::StringOutputStream> inner_;
// The GeneratedCodeInfo to insert at the insertion point.
google::protobuf::GeneratedCodeInfo info_to_insert_;
}; };
// ------------------------------------------------------------------- // -------------------------------------------------------------------
@ -594,6 +616,13 @@ CommandLineInterface::GeneratorContextImpl::OpenForInsert(
return new MemoryOutputStream(this, filename, insertion_point); return new MemoryOutputStream(this, filename, insertion_point);
} }
io::ZeroCopyOutputStream*
CommandLineInterface::GeneratorContextImpl::OpenForInsertWithGeneratedCodeInfo(
const std::string& filename, const std::string& insertion_point,
const google::protobuf::GeneratedCodeInfo& info) {
return new MemoryOutputStream(this, filename, insertion_point, info);
}
// ------------------------------------------------------------------- // -------------------------------------------------------------------
CommandLineInterface::MemoryOutputStream::MemoryOutputStream( CommandLineInterface::MemoryOutputStream::MemoryOutputStream(
@ -612,40 +641,114 @@ CommandLineInterface::MemoryOutputStream::MemoryOutputStream(
insertion_point_(insertion_point), insertion_point_(insertion_point),
inner_(new io::StringOutputStream(&data_)) {} inner_(new io::StringOutputStream(&data_)) {}
CommandLineInterface::MemoryOutputStream::MemoryOutputStream(
GeneratorContextImpl* directory, const std::string& filename,
const std::string& insertion_point, const google::protobuf::GeneratedCodeInfo& info)
: directory_(directory),
filename_(filename),
insertion_point_(insertion_point),
inner_(new io::StringOutputStream(&data_)),
info_to_insert_(info) {}
void CommandLineInterface::MemoryOutputStream::InsertShiftedInfo(
const std::string& insertion_content, size_t insertion_offset,
size_t indent_length, google::protobuf::GeneratedCodeInfo& target_info) {
// Keep track of how much extra data was added for indents before the
// current annotation being inserted. `pos` and `source_annotation.begin()`
// are offsets in `insertion_content`. `insertion_offset` is updated so that
// it can be added to an annotation's `begin` field to reflect that
// annotation's updated location after `insertion_content` was inserted into
// the target file.
size_t pos = 0;
insertion_offset += indent_length;
for (const auto& source_annotation : info_to_insert_.annotation()) {
GeneratedCodeInfo::Annotation* annotation = target_info.add_annotation();
int inner_indent = 0;
// insertion_content is guaranteed to end in an endline. This last endline
// has no effect on indentation.
for (; pos < source_annotation.end() && pos < insertion_content.size() - 1;
++pos) {
if (insertion_content[pos] == '\n') {
if (pos >= source_annotation.begin()) {
// The beginning of the annotation is at insertion_offset, but the end
// can still move further in the target file.
inner_indent += indent_length;
} else {
insertion_offset += indent_length;
}
}
}
*annotation = source_annotation;
annotation->set_begin(annotation->begin() + insertion_offset);
insertion_offset += inner_indent;
annotation->set_end(annotation->end() + insertion_offset);
}
}
void CommandLineInterface::MemoryOutputStream::UpdateMetadata( void CommandLineInterface::MemoryOutputStream::UpdateMetadata(
size_t insertion_offset, size_t insertion_length) { const std::string& insertion_content, size_t insertion_offset,
auto it = directory_->files_.find(filename_ + ".meta"); size_t insertion_length, size_t indent_length) {
if (it == directory_->files_.end()) { auto it = directory_->files_.find(filename_ + ".pb.meta");
if (it == directory_->files_.end() && info_to_insert_.annotation().empty()) {
// No metadata was recorded for this file. // No metadata was recorded for this file.
return; return;
} }
std::string& encoded_data = it->second;
GeneratedCodeInfo metadata; GeneratedCodeInfo metadata;
bool is_text_format = false; bool is_text_format = false;
if (!metadata.ParseFromString(encoded_data)) { std::string* encoded_data = nullptr;
if (!TextFormat::ParseFromString(encoded_data, &metadata)) { if (it != directory_->files_.end()) {
// The metadata is invalid. encoded_data = &it->second;
std::cerr << filename_ // Try to decode a GeneratedCodeInfo proto from the .pb.meta file. It may be
<< ".meta: Could not parse metadata as wire or text format." // in wire or text format. Keep the same format when the data is written out
<< std::endl; // later.
return; if (!metadata.ParseFromString(*encoded_data)) {
} if (!TextFormat::ParseFromString(*encoded_data, &metadata)) {
// Generators that use the public plugin interface emit text-format // The metadata is invalid.
// metadata (because in the public plugin protocol, file content must be std::cerr
// UTF8-encoded strings). << filename_
is_text_format = true; << ".pb.meta: Could not parse metadata as wire or text format."
} << std::endl;
for (int i = 0; i < metadata.annotation_size(); ++i) { return;
GeneratedCodeInfo::Annotation* annotation = metadata.mutable_annotation(i); }
if (annotation->begin() >= insertion_offset) { // Generators that use the public plugin interface emit text-format
annotation->set_begin(annotation->begin() + insertion_length); // metadata (because in the public plugin protocol, file content must be
annotation->set_end(annotation->end() + insertion_length); // UTF8-encoded strings).
is_text_format = true;
} }
} else {
// Create a new file to store the new metadata in info_to_insert_.
encoded_data =
&directory_->files_.insert({filename_ + ".pb.meta", ""}).first->second;
}
GeneratedCodeInfo new_metadata;
bool crossed_offset = false;
size_t to_add = 0;
for (const auto& source_annotation : metadata.annotation()) {
// The first time an annotation at or after the insertion point is found,
// insert the new metadata from info_to_insert_. Shift all annotations
// after the new metadata by the length of the text that was inserted
// (including any additional indent length).
if (source_annotation.begin() >= insertion_offset && !crossed_offset) {
crossed_offset = true;
InsertShiftedInfo(insertion_content, insertion_offset, indent_length,
new_metadata);
to_add += insertion_length;
}
GeneratedCodeInfo::Annotation* annotation = new_metadata.add_annotation();
*annotation = source_annotation;
annotation->set_begin(annotation->begin() + to_add);
annotation->set_end(annotation->end() + to_add);
}
// If there were never any annotations at or after the insertion point,
// make sure to still insert the new metadata from info_to_insert_.
if (!crossed_offset) {
InsertShiftedInfo(insertion_content, insertion_offset, indent_length,
new_metadata);
} }
if (is_text_format) { if (is_text_format) {
TextFormat::PrintToString(metadata, &encoded_data); TextFormat::PrintToString(new_metadata, encoded_data);
} else { } else {
metadata.SerializeToString(&encoded_data); new_metadata.SerializeToString(encoded_data);
} }
} }
@ -728,7 +831,7 @@ CommandLineInterface::MemoryOutputStream::~MemoryOutputStream() {
if (indent_.empty()) { if (indent_.empty()) {
// No indent. This makes things easier. // No indent. This makes things easier.
target->insert(pos, data_); target->insert(pos, data_);
UpdateMetadata(pos, data_.size()); UpdateMetadata(data_, pos, data_.size(), 0);
} else { } else {
// Calculate how much space we need. // Calculate how much space we need.
int indent_size = 0; int indent_size = 0;
@ -738,7 +841,6 @@ CommandLineInterface::MemoryOutputStream::~MemoryOutputStream() {
// Make a hole for it. // Make a hole for it.
target->insert(pos, data_.size() + indent_size, '\0'); target->insert(pos, data_.size() + indent_size, '\0');
UpdateMetadata(pos, data_.size() + indent_size);
// Now copy in the data. // Now copy in the data.
std::string::size_type data_pos = 0; std::string::size_type data_pos = 0;
@ -757,6 +859,7 @@ CommandLineInterface::MemoryOutputStream::~MemoryOutputStream() {
target_ptr += line_length; target_ptr += line_length;
data_pos += line_length; data_pos += line_length;
} }
UpdateMetadata(data_, pos, data_.size() + indent_size, indent_.size());
GOOGLE_CHECK_EQ(target_ptr, GOOGLE_CHECK_EQ(target_ptr,
::google::protobuf::string_as_array(target) + pos + data_.size() + indent_size); ::google::protobuf::string_as_array(target) + pos + data_.size() + indent_size);
@ -1278,8 +1381,9 @@ bool CommandLineInterface::MakeProtoProtoPathRelative(
if (in_fallback_database) { if (in_fallback_database) {
return true; return true;
} }
std::string error_str = source_tree->GetLastErrorMessage().empty() ? std::string error_str = source_tree->GetLastErrorMessage().empty()
strerror(errno) : source_tree->GetLastErrorMessage(); ? strerror(errno)
: source_tree->GetLastErrorMessage();
std::cerr << "Could not map to virtual file: " << *proto << ": " std::cerr << "Could not map to virtual file: " << *proto << ": "
<< error_str << std::endl; << error_str << std::endl;
return false; return false;
@ -1426,13 +1530,36 @@ CommandLineInterface::ParseArgumentStatus CommandLineInterface::ParseArguments(
proto_path_.push_back(std::pair<std::string, std::string>("", ".")); proto_path_.push_back(std::pair<std::string, std::string>("", "."));
} }
// Check some error cases. // Check error cases that span multiple flag values.
bool decoding_raw = (mode_ == MODE_DECODE) && codec_type_.empty(); bool missing_proto_definitions = false;
if (decoding_raw && !input_files_.empty()) { switch (mode_) {
std::cerr << "When using --decode_raw, no input files should be given." case MODE_COMPILE:
missing_proto_definitions = input_files_.empty();
break;
case MODE_DECODE:
// Handle --decode_raw separately, since it requires that no proto
// definitions are specified.
if (codec_type_.empty()) {
if (!input_files_.empty() || !descriptor_set_in_names_.empty()) {
std::cerr
<< "When using --decode_raw, no input files should be given."
<< std::endl; << std::endl;
return PARSE_ARGUMENT_FAIL; return PARSE_ARGUMENT_FAIL;
} else if (!decoding_raw && input_files_.empty()) { }
missing_proto_definitions = false;
break; // only for --decode_raw
}
// --decode (not raw) is handled the same way as the rest of the modes.
PROTOBUF_FALLTHROUGH_INTENDED;
case MODE_ENCODE:
case MODE_PRINT:
missing_proto_definitions =
input_files_.empty() && descriptor_set_in_names_.empty();
break;
default:
GOOGLE_LOG(FATAL) << "Unexpected mode: " << mode_;
}
if (missing_proto_definitions) {
std::cerr << "Missing input file." << std::endl; std::cerr << "Missing input file." << std::endl;
return PARSE_ARGUMENT_FAIL; return PARSE_ARGUMENT_FAIL;
} }
@ -2223,8 +2350,10 @@ bool CommandLineInterface::GeneratePluginOutput(
// We reset current_output to NULL first so that the old file is closed // We reset current_output to NULL first so that the old file is closed
// before the new one is opened. // before the new one is opened.
current_output.reset(); current_output.reset();
current_output.reset(generator_context->OpenForInsert( current_output.reset(
filename, output_file.insertion_point())); generator_context->OpenForInsertWithGeneratedCodeInfo(
filename, output_file.insertion_point(),
output_file.generated_code_info()));
} else if (!output_file.name().empty()) { } else if (!output_file.name().empty()) {
// Starting a new file. Open it. // Starting a new file. Open it.
// We reset current_output to NULL first so that the old file is closed // We reset current_output to NULL first so that the old file is closed

@ -1192,8 +1192,8 @@ TEST_F(CommandLineInterfaceTest, InsertWithAnnotationFixup) {
Run("protocol_compiler " Run("protocol_compiler "
"--test_out=TestParameter:$tmpdir " "--test_out=TestParameter:$tmpdir "
"--plug_out=TestPluginParameter:$tmpdir " "--plug_out=TestPluginParameter:$tmpdir "
"--test_out=insert=test_generator,test_plugin:$tmpdir " "--test_out=insert_endlines=test_generator,test_plugin:$tmpdir "
"--plug_out=insert=test_generator,test_plugin:$tmpdir " "--plug_out=insert_endlines=test_generator,test_plugin:$tmpdir "
"--proto_path=$tmpdir foo.proto"); "--proto_path=$tmpdir foo.proto");
ExpectNoErrors(); ExpectNoErrors();
@ -2564,20 +2564,22 @@ class EncodeDecodeTest : public testing::TestWithParam<EncodeDecodeTestMode> {
enum Type { TEXT, BINARY }; enum Type { TEXT, BINARY };
enum ReturnCode { SUCCESS, ERROR }; enum ReturnCode { SUCCESS, ERROR };
bool Run(const std::string& command) { bool Run(const std::string& command, bool specify_proto_files = true) {
std::vector<std::string> args; std::vector<std::string> args;
args.push_back("protoc"); args.push_back("protoc");
SplitStringUsing(command, " ", &args); SplitStringUsing(command, " ", &args);
switch (GetParam()) { if (specify_proto_files) {
case PROTO_PATH: switch (GetParam()) {
args.push_back("--proto_path=" + TestUtil::TestSourceDir()); case PROTO_PATH:
break; args.push_back("--proto_path=" + TestUtil::TestSourceDir());
case DESCRIPTOR_SET_IN: break;
args.push_back(StrCat("--descriptor_set_in=", case DESCRIPTOR_SET_IN:
unittest_proto_descriptor_set_filename_)); args.push_back(StrCat("--descriptor_set_in=",
break; unittest_proto_descriptor_set_filename_));
default: break;
ADD_FAILURE() << "unexpected EncodeDecodeTestMode: " << GetParam(); default:
ADD_FAILURE() << "unexpected EncodeDecodeTestMode: " << GetParam();
}
} }
std::unique_ptr<const char*[]> argv(new const char*[args.size()]); std::unique_ptr<const char*[]> argv(new const char*[args.size()]);
@ -2659,9 +2661,12 @@ TEST_P(EncodeDecodeTest, Encode) {
RedirectStdinFromFile(TestUtil::GetTestDataPath( RedirectStdinFromFile(TestUtil::GetTestDataPath(
"net/proto2/internal/" "net/proto2/internal/"
"testdata/text_format_unittest_data_oneof_implemented.txt")); "testdata/text_format_unittest_data_oneof_implemented.txt"));
EXPECT_TRUE( std::string args;
Run(TestUtil::MaybeTranslatePath("net/proto2/internal/unittest.proto") + if (GetParam() != DESCRIPTOR_SET_IN) {
" --encode=protobuf_unittest.TestAllTypes")); args.append(
TestUtil::MaybeTranslatePath("net/proto2/internal/unittest.proto"));
}
EXPECT_TRUE(Run(args + " --encode=protobuf_unittest.TestAllTypes"));
ExpectStdoutMatchesBinaryFile(TestUtil::GetTestDataPath( ExpectStdoutMatchesBinaryFile(TestUtil::GetTestDataPath(
"net/proto2/internal/testdata/golden_message_oneof_implemented")); "net/proto2/internal/testdata/golden_message_oneof_implemented"));
ExpectStderrMatchesText(""); ExpectStderrMatchesText("");
@ -2697,7 +2702,7 @@ TEST_P(EncodeDecodeTest, DecodeRaw) {
message.SerializeToString(&data); message.SerializeToString(&data);
RedirectStdinFromText(data); RedirectStdinFromText(data);
EXPECT_TRUE(Run("--decode_raw")); EXPECT_TRUE(Run("--decode_raw", /*specify_proto_files=*/false));
ExpectStdoutMatchesText( ExpectStdoutMatchesText(
"1: 123\n" "1: 123\n"
"14: \"foo\"\n"); "14: \"foo\"\n");

@ -441,12 +441,11 @@ void FileGenerator::GenerateSourceDefaultInstance(int idx,
" ::$proto_ns$::internal::ExplicitlyConstructed<$2$> _instance;\n", " ::$proto_ns$::internal::ExplicitlyConstructed<$2$> _instance;\n",
DefaultInstanceType(generator->descriptor_, options_), DefaultInstanceType(generator->descriptor_, options_),
generator->classname_); generator->classname_);
format.Indent();
generator->GenerateExtraDefaultFields(printer);
format.Outdent();
format("} $1$;\n", DefaultInstanceName(generator->descriptor_, options_)); format("} $1$;\n", DefaultInstanceName(generator->descriptor_, options_));
if (options_.lite_implicit_weak_fields) { if (options_.lite_implicit_weak_fields) {
format("$1$DefaultTypeInternal* $2$ = &$3$;\n", generator->classname_, format("$1$* $2$ = &$3$;\n",
DefaultInstanceType(generator->descriptor_, options_),
DefaultInstancePtr(generator->descriptor_, options_), DefaultInstancePtr(generator->descriptor_, options_),
DefaultInstanceName(generator->descriptor_, options_)); DefaultInstanceName(generator->descriptor_, options_));
} }
@ -942,8 +941,6 @@ void FileGenerator::GenerateInitForSCC(const SCC* scc,
if (scc_analyzer_.GetSCC(message_generators_[i]->descriptor_) != scc) { if (scc_analyzer_.GetSCC(message_generators_[i]->descriptor_) != scc) {
continue; continue;
} }
// TODO(gerbens) This requires this function to be friend. Remove
// the need for this.
message_generators_[i]->GenerateFieldDefaultInstances(printer); message_generators_[i]->GenerateFieldDefaultInstances(printer);
format( format(
"{\n" "{\n"
@ -961,17 +958,6 @@ void FileGenerator::GenerateInitForSCC(const SCC* scc,
} }
format("}\n"); format("}\n");
} }
// TODO(gerbens) make default instances be the same as normal instances.
// Default instances differ from normal instances because they have cross
// linked message fields.
for (int i = 0; i < message_generators_.size(); i++) {
if (scc_analyzer_.GetSCC(message_generators_[i]->descriptor_) != scc) {
continue;
}
format("$1$::InitAsDefaultInstance();\n",
QualifiedClassName(message_generators_[i]->descriptor_, options_));
}
format.Outdent(); format.Outdent();
format("}\n\n"); format("}\n\n");

@ -1388,7 +1388,7 @@ class ParseLoopGenerator {
std::vector<const FieldDescriptor*> ordered_fields; std::vector<const FieldDescriptor*> ordered_fields;
for (auto field : FieldRange(descriptor)) { for (auto field : FieldRange(descriptor)) {
if (IsFieldUsed(field, options_)) { if (!IsFieldStripped(field, options_)) {
ordered_fields.push_back(field); ordered_fields.push_back(field);
} }
} }
@ -1615,9 +1615,13 @@ class ParseLoopGenerator {
} }
} else if (IsWeak(field, options_)) { } else if (IsWeak(field, options_)) {
format_( format_(
"ptr = ctx->ParseMessage(_weak_field_map_.MutableMessage($1$," "{\n"
" _$classname$_default_instance_.$2$_), ptr);\n", " auto* default_ = &reinterpret_cast<const Message&>($1$);\n"
field->number(), FieldName(field)); " ptr = ctx->ParseMessage(_weak_field_map_.MutableMessage($2$,"
" default_), ptr);\n"
"}\n",
QualifiedDefaultInstanceName(field->message_type(), options_),
field->number());
} else { } else {
format_("ptr = ctx->ParseMessage(_internal_$1$_$2$(), ptr);\n", format_("ptr = ctx->ParseMessage(_internal_$1$_$2$(), ptr);\n",
field->is_repeated() ? "add" : "mutable", FieldName(field)); field->is_repeated() ? "add" : "mutable", FieldName(field));

@ -347,12 +347,16 @@ inline bool IsLazy(const FieldDescriptor* field, const Options& options) {
!options.opensource_runtime; !options.opensource_runtime;
} }
// Returns true if "field" is used. inline bool IsFieldUsed(const FieldDescriptor* field, const Options& options) {
inline bool IsFieldUsed(const FieldDescriptor* /*field*/,
const Options& /*options*/) {
return true; return true;
} }
// Returns true if "field" is stripped.
inline bool IsFieldStripped(const FieldDescriptor* /*field*/,
const Options& /*options*/) {
return false;
}
// Does the file contain any definitions that need extension_set.h? // Does the file contain any definitions that need extension_set.h?
bool HasExtensionsOrExtendableMessage(const FileDescriptor* file); bool HasExtensionsOrExtendableMessage(const FileDescriptor* file);
@ -450,27 +454,11 @@ inline bool HasPreservingUnknownEnumSemantics(const FieldDescriptor* field) {
return field->file()->syntax() == FileDescriptor::SYNTAX_PROTO3; return field->file()->syntax() == FileDescriptor::SYNTAX_PROTO3;
} }
inline bool SupportsArenas(const FileDescriptor* file) {
return file->options().cc_enable_arenas();
}
inline bool SupportsArenas(const Descriptor* desc) {
return SupportsArenas(desc->file());
}
inline bool SupportsArenas(const FieldDescriptor* field) {
return SupportsArenas(field->file());
}
inline bool IsCrossFileMessage(const FieldDescriptor* field) { inline bool IsCrossFileMessage(const FieldDescriptor* field) {
return field->type() == FieldDescriptor::TYPE_MESSAGE && return field->type() == FieldDescriptor::TYPE_MESSAGE &&
field->message_type()->file() != field->file(); field->message_type()->file() != field->file();
} }
inline std::string MessageCreateFunction(const Descriptor* d) {
return SupportsArenas(d) ? "CreateMessage" : "Create";
}
inline std::string MakeDefaultName(const FieldDescriptor* field) { inline std::string MakeDefaultName(const FieldDescriptor* field) {
return "_i_give_permission_to_break_this_code_default_" + FieldName(field) + return "_i_give_permission_to_break_this_code_default_" + FieldName(field) +
"_"; "_";

@ -81,13 +81,6 @@ void SetMessageVariables(const FieldDescriptor* descriptor,
} else { } else {
(*variables)["lite"] = "Lite"; (*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, MapFieldGenerator::MapFieldGenerator(const FieldDescriptor* descriptor,
@ -105,8 +98,8 @@ void MapFieldGenerator::GeneratePrivateMembers(io::Printer* printer) const {
" $map_classname$,\n" " $map_classname$,\n"
" $key_cpp$, $val_cpp$,\n" " $key_cpp$, $val_cpp$,\n"
" ::$proto_ns$::internal::WireFormatLite::$key_wire_type$,\n" " ::$proto_ns$::internal::WireFormatLite::$key_wire_type$,\n"
" ::$proto_ns$::internal::WireFormatLite::$val_wire_type$,\n" " ::$proto_ns$::internal::WireFormatLite::$val_wire_type$> "
" $default_enum_value$ > $name$_;\n"); "$name$_;\n");
} }
void MapFieldGenerator::GenerateAccessorDeclarations( void MapFieldGenerator::GenerateAccessorDeclarations(

@ -268,13 +268,6 @@ void CollectMapInfo(const Options& options, const Descriptor* descriptor,
"TYPE_" + ToUpper(DeclaredTypeMethodName(key->type())); "TYPE_" + ToUpper(DeclaredTypeMethodName(key->type()));
vars["val_wire_type"] = vars["val_wire_type"] =
"TYPE_" + ToUpper(DeclaredTypeMethodName(val->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$() // Does the given field have a private (internal helper only) has_$name$()
@ -323,6 +316,17 @@ bool ShouldMarkNewAsFinal(const Descriptor* descriptor,
options.opensource_runtime; options.opensource_runtime;
} }
// Returns true to make the message serialize in order, decided by the following
// factors in the order of precedence.
// --options().message_set_wire_format() == true
// --the message is in the allowlist (true)
// --GOOGLE_PROTOBUF_SHUFFLE_SERIALIZE is defined (false)
// --a ranage of message names that are allowed to stay in order (true)
bool ShouldSerializeInOrder(const Descriptor* descriptor,
const Options& options) {
return true;
}
bool TableDrivenParsingEnabled(const Descriptor* descriptor, bool TableDrivenParsingEnabled(const Descriptor* descriptor,
const Options& options) { const Options& options) {
if (!options.table_driven_parsing) { if (!options.table_driven_parsing) {
@ -591,7 +595,7 @@ MessageGenerator::MessageGenerator(
// Compute optimized field order to be used for layout and initialization // Compute optimized field order to be used for layout and initialization
// purposes. // purposes.
for (auto field : FieldRange(descriptor_)) { for (auto field : FieldRange(descriptor_)) {
if (!IsFieldUsed(field, options_)) { if (IsFieldStripped(field, options_)) {
continue; continue;
} }
@ -631,16 +635,7 @@ MessageGenerator::MessageGenerator(
MessageGenerator::~MessageGenerator() = default; MessageGenerator::~MessageGenerator() = default;
size_t MessageGenerator::HasBitsSize() const { size_t MessageGenerator::HasBitsSize() const {
size_t sizeof_has_bits = (max_has_bit_index_ + 31) / 32 * 4; return (max_has_bit_index_ + 31) / 32;
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;
} }
int MessageGenerator::HasBitIndex(const FieldDescriptor* field) const { int MessageGenerator::HasBitIndex(const FieldDescriptor* field) const {
@ -689,7 +684,7 @@ void MessageGenerator::GenerateFieldAccessorDeclarations(io::Printer* printer) {
optimized_order_.end()); optimized_order_.end());
for (auto field : FieldRange(descriptor_)) { for (auto field : FieldRange(descriptor_)) {
if (!field->real_containing_oneof() && !field->options().weak() && if (!field->real_containing_oneof() && !field->options().weak() &&
IsFieldUsed(field, options_)) { !IsFieldStripped(field, options_)) {
continue; continue;
} }
ordered_fields.push_back(field); ordered_fields.push_back(field);
@ -718,8 +713,8 @@ void MessageGenerator::GenerateFieldAccessorDeclarations(io::Printer* printer) {
if (field->is_repeated()) { if (field->is_repeated()) {
format("$deprecated_attr$int ${1$$name$_size$}$() const$2$\n", field, format("$deprecated_attr$int ${1$$name$_size$}$() const$2$\n", field,
IsFieldUsed(field, options_) ? ";" : " {__builtin_trap();}"); !IsFieldStripped(field, options_) ? ";" : " {__builtin_trap();}");
if (IsFieldUsed(field, options_)) { if (!IsFieldStripped(field, options_)) {
format( format(
"private:\n" "private:\n"
"int ${1$_internal_$name$_size$}$() const;\n" "int ${1$_internal_$name$_size$}$() const;\n"
@ -728,15 +723,15 @@ void MessageGenerator::GenerateFieldAccessorDeclarations(io::Printer* printer) {
} }
} else if (HasHasMethod(field)) { } else if (HasHasMethod(field)) {
format("$deprecated_attr$bool ${1$has_$name$$}$() const$2$\n", field, format("$deprecated_attr$bool ${1$has_$name$$}$() const$2$\n", field,
IsFieldUsed(field, options_) ? ";" : " {__builtin_trap();}"); !IsFieldStripped(field, options_) ? ";" : " {__builtin_trap();}");
if (IsFieldUsed(field, options_)) { if (!IsFieldStripped(field, options_)) {
format( format(
"private:\n" "private:\n"
"bool _internal_has_$name$() const;\n" "bool _internal_has_$name$() const;\n"
"public:\n"); "public:\n");
} }
} else if (HasPrivateHasMethod(field)) { } else if (HasPrivateHasMethod(field)) {
if (IsFieldUsed(field, options_)) { if (!IsFieldStripped(field, options_)) {
format( format(
"private:\n" "private:\n"
"bool ${1$_internal_has_$name$$}$() const;\n" "bool ${1$_internal_has_$name$$}$() const;\n"
@ -745,7 +740,7 @@ void MessageGenerator::GenerateFieldAccessorDeclarations(io::Printer* printer) {
} }
} }
format("$deprecated_attr$void ${1$clear_$name$$}$()$2$\n", field, format("$deprecated_attr$void ${1$clear_$name$$}$()$2$\n", field,
IsFieldUsed(field, options_) ? ";" : "{__builtin_trap();}"); !IsFieldStripped(field, options_) ? ";" : "{__builtin_trap();}");
// Generate type-specific accessor declarations. // Generate type-specific accessor declarations.
field_generators_.get(field).GenerateAccessorDeclarations(printer); field_generators_.get(field).GenerateAccessorDeclarations(printer);
@ -780,7 +775,7 @@ void MessageGenerator::GenerateFieldAccessorDeclarations(io::Printer* printer) {
void MessageGenerator::GenerateSingularFieldHasBits( void MessageGenerator::GenerateSingularFieldHasBits(
const FieldDescriptor* field, Formatter format) { const FieldDescriptor* field, Formatter format) {
if (!IsFieldUsed(field, options_)) { if (IsFieldStripped(field, options_)) {
format( format(
"inline bool $classname$::has_$name$() const { " "inline bool $classname$::has_$name$() const { "
"__builtin_trap(); }\n"); "__builtin_trap(); }\n");
@ -861,7 +856,7 @@ void MessageGenerator::GenerateOneofHasBits(io::Printer* printer) {
void MessageGenerator::GenerateOneofMemberHasBits(const FieldDescriptor* field, void MessageGenerator::GenerateOneofMemberHasBits(const FieldDescriptor* field,
const Formatter& format) { const Formatter& format) {
if (!IsFieldUsed(field, options_)) { if (IsFieldStripped(field, options_)) {
if (HasHasMethod(field)) { if (HasHasMethod(field)) {
format( format(
"inline bool $classname$::has_$name$() const { " "inline bool $classname$::has_$name$() const { "
@ -906,7 +901,7 @@ void MessageGenerator::GenerateOneofMemberHasBits(const FieldDescriptor* field,
void MessageGenerator::GenerateFieldClear(const FieldDescriptor* field, void MessageGenerator::GenerateFieldClear(const FieldDescriptor* field,
bool is_inline, Formatter format) { bool is_inline, Formatter format) {
if (!IsFieldUsed(field, options_)) { if (IsFieldStripped(field, options_)) {
format("void $classname$::clear_$name$() { __builtin_trap(); }\n"); format("void $classname$::clear_$name$() { __builtin_trap(); }\n");
return; return;
} }
@ -952,7 +947,7 @@ void MessageGenerator::GenerateFieldAccessorDefinitions(io::Printer* printer) {
for (auto field : FieldRange(descriptor_)) { for (auto field : FieldRange(descriptor_)) {
PrintFieldComment(format, field); PrintFieldComment(format, field);
if (!IsFieldUsed(field, options_)) { if (IsFieldStripped(field, options_)) {
continue; continue;
} }
@ -964,7 +959,7 @@ void MessageGenerator::GenerateFieldAccessorDefinitions(io::Printer* printer) {
// Generate has_$name$() or $name$_size(). // Generate has_$name$() or $name$_size().
if (field->is_repeated()) { if (field->is_repeated()) {
if (!IsFieldUsed(field, options_)) { if (IsFieldStripped(field, options_)) {
format( format(
"inline int $classname$::$name$_size() const { " "inline int $classname$::$name$_size() const { "
"__builtin_trap(); }\n"); "__builtin_trap(); }\n");
@ -998,7 +993,7 @@ void MessageGenerator::GenerateFieldAccessorDefinitions(io::Printer* printer) {
} }
// Generate type-specific accessors. // Generate type-specific accessors.
if (IsFieldUsed(field, options_)) { if (!IsFieldStripped(field, options_)) {
field_generators_.get(field).GenerateInlineAccessorDefinitions(printer); field_generators_.get(field).GenerateInlineAccessorDefinitions(printer);
} }
@ -1026,14 +1021,13 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
"::$proto_ns$::internal::MapEntry$lite$<$classname$, \n" "::$proto_ns$::internal::MapEntry$lite$<$classname$, \n"
" $key_cpp$, $val_cpp$,\n" " $key_cpp$, $val_cpp$,\n"
" ::$proto_ns$::internal::WireFormatLite::$key_wire_type$,\n" " ::$proto_ns$::internal::WireFormatLite::$key_wire_type$,\n"
" ::$proto_ns$::internal::WireFormatLite::$val_wire_type$,\n" " ::$proto_ns$::internal::WireFormatLite::$val_wire_type$> {\n"
" $default_enum_value$ > {\n"
"public:\n" "public:\n"
" typedef ::$proto_ns$::internal::MapEntry$lite$<$classname$, \n" " typedef ::$proto_ns$::internal::MapEntry$lite$<$classname$, \n"
" $key_cpp$, $val_cpp$,\n" " $key_cpp$, $val_cpp$,\n"
" ::$proto_ns$::internal::WireFormatLite::$key_wire_type$,\n" " ::$proto_ns$::internal::WireFormatLite::$key_wire_type$,\n"
" ::$proto_ns$::internal::WireFormatLite::$val_wire_type$,\n" " ::$proto_ns$::internal::WireFormatLite::$val_wire_type$> "
" $default_enum_value$ > SuperType;\n" "SuperType;\n"
" $classname$();\n" " $classname$();\n"
" explicit $classname$(::$proto_ns$::Arena* arena);\n" " explicit $classname$(::$proto_ns$::Arena* arena);\n"
" void MergeFrom(const $classname$& other);\n" " void MergeFrom(const $classname$& other);\n"
@ -1122,13 +1116,8 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
format(" public:\n"); format(" public:\n");
format.Indent(); format.Indent();
if (SupportsArenas(descriptor_)) {
format("inline $classname$() : $classname$(nullptr) {}\n");
} else {
format("$classname$();\n");
}
format( format(
"inline $classname$() : $classname$(nullptr) {}\n"
"virtual ~$classname$();\n" "virtual ~$classname$();\n"
"\n" "\n"
"$classname$(const $classname$& from);\n" "$classname$(const $classname$& from);\n"
@ -1224,7 +1213,6 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
// TODO(gerbens) make this private, while still granting other protos access. // TODO(gerbens) make this private, while still granting other protos access.
format( format(
"static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY\n"
"static inline const $classname$* internal_default_instance() {\n" "static inline const $classname$* internal_default_instance() {\n"
" return reinterpret_cast<const $classname$*>(\n" " return reinterpret_cast<const $classname$*>(\n"
" &_$classname$_default_instance_);\n" " &_$classname$_default_instance_);\n"
@ -1244,7 +1232,8 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
" _any_metadata_.PackFrom(message);\n" " _any_metadata_.PackFrom(message);\n"
"}\n" "}\n"
"void PackFrom(const ::$proto_ns$::Message& message,\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" " _any_metadata_.PackFrom(message, type_url_prefix);\n"
"}\n" "}\n"
"bool UnpackTo(::$proto_ns$::Message* message) const {\n" "bool UnpackTo(::$proto_ns$::Message* message) const {\n"
@ -1264,7 +1253,8 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
"!std::is_convertible<T, const ::$proto_ns$::Message&>" "!std::is_convertible<T, const ::$proto_ns$::Message&>"
"::value>::type>\n" "::value>::type>\n"
"void PackFrom(const T& message,\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);" " _any_metadata_.PackFrom<T>(message, type_url_prefix);"
"}\n" "}\n"
"template <typename T, class = typename std::enable_if<" "template <typename T, class = typename std::enable_if<"
@ -1281,7 +1271,8 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
"}\n" "}\n"
"template <typename T>\n" "template <typename T>\n"
"void PackFrom(const T& message,\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" " _any_metadata_.PackFrom(message, type_url_prefix);\n"
"}\n" "}\n"
"template <typename T>\n" "template <typename T>\n"
@ -1293,7 +1284,8 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
"template<typename T> bool Is() const {\n" "template<typename T> bool Is() const {\n"
" return _any_metadata_.Is<T>();\n" " return _any_metadata_.Is<T>();\n"
"}\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"); " std::string* full_type_name);\n");
} }
@ -1303,31 +1295,21 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
format( format(
"friend void swap($classname$& a, $classname$& b) {\n" "friend void swap($classname$& a, $classname$& b) {\n"
" a.Swap(&b);\n" " a.Swap(&b);\n"
"}\n"
"inline void Swap($classname$* other) {\n"
" if (other == this) return;\n"
" if (GetArena() == other->GetArena()) {\n"
" InternalSwap(other);\n"
" } else {\n"
" ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other);\n"
" }\n"
"}\n"
"void UnsafeArenaSwap($classname$* other) {\n"
" if (other == this) return;\n"
" $DCHK$(GetArena() == other->GetArena());\n"
" InternalSwap(other);\n"
"}\n"); "}\n");
if (SupportsArenas(descriptor_)) {
format(
"inline void Swap($classname$* other) {\n"
" if (other == this) return;\n"
" if (GetArena() == other->GetArena()) {\n"
" InternalSwap(other);\n"
" } else {\n"
" ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other);\n"
" }\n"
"}\n"
"void UnsafeArenaSwap($classname$* other) {\n"
" if (other == this) return;\n"
" $DCHK$(GetArena() == other->GetArena());\n"
" InternalSwap(other);\n"
"}\n");
} else {
format(
"inline void Swap($classname$* other) {\n"
" if (other == this) return;\n"
" InternalSwap(other);\n"
"}\n");
}
format( format(
"\n" "\n"
"// implements Message ----------------------------------------------\n" "// implements Message ----------------------------------------------\n"
@ -1400,17 +1382,15 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
options_.opensource_runtime ? "::PROTOBUF_NAMESPACE_ID::StringPiece" options_.opensource_runtime ? "::PROTOBUF_NAMESPACE_ID::StringPiece"
: "::StringPiece"); : "::StringPiece");
if (SupportsArenas(descriptor_)) { format(
format( // TODO(gerbens) Make this private! Currently people are deriving from
// TODO(gerbens) Make this private! Currently people are deriving from // protos to give access to this constructor, breaking the invariants
// protos to give access to this constructor, breaking the invariants // we rely on.
// we rely on. "protected:\n"
"protected:\n" "explicit $classname$(::$proto_ns$::Arena* arena);\n"
"explicit $classname$(::$proto_ns$::Arena* arena);\n" "private:\n"
"private:\n" "static void ArenaDtor(void* object);\n"
"static void ArenaDtor(void* object);\n" "inline void RegisterArenaDtor(::$proto_ns$::Arena* arena);\n");
"inline void RegisterArenaDtor(::$proto_ns$::Arena* arena);\n");
}
format( format(
"public:\n" "public:\n"
@ -1515,10 +1495,9 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
const size_t sizeof_has_bits = HasBitsSize(); const size_t sizeof_has_bits = HasBitsSize();
const std::string has_bits_decl = const std::string has_bits_decl =
sizeof_has_bits == 0 sizeof_has_bits == 0 ? ""
? "" : StrCat("::$proto_ns$::internal::HasBits<",
: StrCat("::$proto_ns$::internal::HasBits<", sizeof_has_bits, "> _has_bits_;\n");
sizeof_has_bits / 4, "> _has_bits_;\n");
// To minimize padding, data members are divided into three sections: // To minimize padding, data members are divided into three sections:
// (1) members assumed to align to 8 bytes // (1) members assumed to align to 8 bytes
@ -1534,13 +1513,11 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
"\n"); "\n");
} }
if (SupportsArenas(descriptor_)) { format(
format( "template <typename T> friend class "
"template <typename T> friend class " "::$proto_ns$::Arena::InternalHelper;\n"
"::$proto_ns$::Arena::InternalHelper;\n" "typedef void InternalArenaConstructable_;\n"
"typedef void InternalArenaConstructable_;\n" "typedef void DestructorSkippable_;\n");
"typedef void DestructorSkippable_;\n");
}
if (!has_bit_indices_.empty()) { if (!has_bit_indices_.empty()) {
// _has_bits_ is frequently accessed, so to reduce code size and improve // _has_bits_ is frequently accessed, so to reduce code size and improve
@ -1572,14 +1549,14 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
camel_oneof_name); camel_oneof_name);
format.Indent(); format.Indent();
for (auto field : FieldRange(oneof)) { for (auto field : FieldRange(oneof)) {
if (IsFieldUsed(field, options_)) { if (!IsFieldStripped(field, options_)) {
field_generators_.get(field).GeneratePrivateMembers(printer); field_generators_.get(field).GeneratePrivateMembers(printer);
} }
} }
format.Outdent(); format.Outdent();
format("} $1$_;\n", oneof->name()); format("} $1$_;\n", oneof->name());
for (auto field : FieldRange(oneof)) { for (auto field : FieldRange(oneof)) {
if (IsFieldUsed(field, options_)) { if (!IsFieldStripped(field, options_)) {
field_generators_.get(field).GenerateStaticMembers(printer); field_generators_.get(field).GenerateStaticMembers(printer);
} }
} }
@ -1637,30 +1614,6 @@ void MessageGenerator::GenerateInlineMethods(io::Printer* printer) {
} }
} }
void MessageGenerator::GenerateExtraDefaultFields(io::Printer* printer) {
// Generate oneof default instance and weak field instances for reflection
// usage.
Formatter format(printer, variables_);
for (auto oneof : OneOfRange(descriptor_)) {
for (auto field : FieldRange(oneof)) {
if (!IsFieldUsed(field, options_)) {
continue;
}
if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE ||
(field->cpp_type() == FieldDescriptor::CPPTYPE_STRING &&
EffectiveStringCType(field, options_) != FieldOptions::STRING)) {
format("const ");
}
field_generators_.get(field).GeneratePrivateMembers(printer);
}
}
for (auto field : FieldRange(descriptor_)) {
if (field->options().weak() && IsFieldUsed(field, options_)) {
format(" const ::$proto_ns$::Message* $1$_;\n", FieldName(field));
}
}
}
bool MessageGenerator::GenerateParseTable(io::Printer* printer, size_t offset, bool MessageGenerator::GenerateParseTable(io::Printer* printer, size_t offset,
size_t aux_offset) { size_t aux_offset) {
Formatter format(printer, variables_); Formatter format(printer, variables_);
@ -1952,66 +1905,6 @@ void MessageGenerator::GenerateFieldDefaultInstances(io::Printer* printer) {
} }
} }
void MessageGenerator::GenerateDefaultInstanceInitializer(
io::Printer* printer) {
Formatter format(printer, variables_);
// The default instance needs all of its embedded message pointers
// cross-linked to other default instances. We can't do this initialization
// in the constructor because some other default instances may not have been
// constructed yet at that time.
// TODO(kenton): Maybe all message fields (even for non-default messages)
// should be initialized to point at default instances rather than NULL?
for (auto field : FieldRange(descriptor_)) {
if (!IsFieldUsed(field, options_)) {
continue;
}
Formatter::SaveState saver(&format);
if (!field->is_repeated() && !IsLazy(field, options_) &&
field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE &&
(!field->real_containing_oneof() ||
HasDescriptorMethods(descriptor_->file(), options_))) {
std::string name;
if (field->real_containing_oneof() || field->options().weak()) {
name = "_" + classname_ + "_default_instance_.";
} else {
name =
"_" + classname_ + "_default_instance_._instance.get_mutable()->";
}
name += FieldName(field);
format.Set("name", name);
if (IsWeak(field, options_)) {
format(
"$package_ns$::$name$_ = reinterpret_cast<const "
"::$proto_ns$::Message*>(&$1$);\n"
"if ($package_ns$::$name$_ == nullptr) {\n"
" $package_ns$::$name$_ = "
"::$proto_ns$::Empty::internal_default_instance();\n"
"}\n",
QualifiedDefaultInstanceName(field->message_type(),
options_)); // 1
continue;
}
if (IsImplicitWeakField(field, options_, scc_analyzer_)) {
format(
"$package_ns$::$name$_ = reinterpret_cast<$1$*>(\n"
" $2$);\n",
FieldMessageTypeName(field, options_),
QualifiedDefaultInstancePtr(field->message_type(), options_));
} else {
format(
"$package_ns$::$name$_ = const_cast< $1$*>(\n"
" $1$::internal_default_instance());\n",
FieldMessageTypeName(field, options_));
}
} else if (field->real_containing_oneof() &&
HasDescriptorMethods(descriptor_->file(), options_)) {
field_generators_.get(field).GenerateConstructorCode(printer);
}
}
}
void MessageGenerator::GenerateClassMethods(io::Printer* printer) { void MessageGenerator::GenerateClassMethods(io::Printer* printer) {
Formatter format(printer, variables_); Formatter format(printer, variables_);
if (IsMapEntryMessage(descriptor_)) { if (IsMapEntryMessage(descriptor_)) {
@ -2037,14 +1930,6 @@ void MessageGenerator::GenerateClassMethods(io::Printer* printer) {
return; return;
} }
// TODO(gerbens) Remove this function. With a little bit of cleanup and
// refactoring this is superfluous.
format("void $classname$::InitAsDefaultInstance() {\n");
format.Indent();
GenerateDefaultInstanceInitializer(printer);
format.Outdent();
format("}\n");
if (IsAnyMessage(descriptor_, options_)) { if (IsAnyMessage(descriptor_, options_)) {
if (HasDescriptorMethods(descriptor_->file(), options_)) { if (HasDescriptorMethods(descriptor_->file(), options_)) {
format( format(
@ -2057,8 +1942,9 @@ void MessageGenerator::GenerateClassMethods(io::Printer* printer) {
"}\n"); "}\n");
} }
format( format(
"bool $classname$::ParseAnyTypeUrl(const string& type_url,\n" "bool $classname$::ParseAnyTypeUrl(\n"
" std::string* full_type_name) {\n" " ::PROTOBUF_NAMESPACE_ID::ConstStringParam type_url,\n"
" std::string* full_type_name) {\n"
" return ::$proto_ns$::internal::ParseAnyTypeUrl(type_url,\n" " return ::$proto_ns$::internal::ParseAnyTypeUrl(type_url,\n"
" full_type_name);\n" " full_type_name);\n"
"}\n" "}\n"
@ -2075,7 +1961,7 @@ void MessageGenerator::GenerateClassMethods(io::Printer* printer) {
} }
for (auto field : FieldRange(descriptor_)) { for (auto field : FieldRange(descriptor_)) {
field_generators_.get(field).GenerateInternalAccessorDeclarations(printer); field_generators_.get(field).GenerateInternalAccessorDeclarations(printer);
if (!IsFieldUsed(field, options_)) { if (IsFieldStripped(field, options_)) {
continue; continue;
} }
if (HasHasbit(field)) { if (HasHasbit(field)) {
@ -2101,14 +1987,14 @@ void MessageGenerator::GenerateClassMethods(io::Printer* printer) {
format.Outdent(); format.Outdent();
format("};\n\n"); format("};\n\n");
for (auto field : FieldRange(descriptor_)) { for (auto field : FieldRange(descriptor_)) {
if (IsFieldUsed(field, options_)) { if (!IsFieldStripped(field, options_)) {
field_generators_.get(field).GenerateInternalAccessorDefinitions(printer); field_generators_.get(field).GenerateInternalAccessorDefinitions(printer);
} }
} }
// Generate non-inline field definitions. // Generate non-inline field definitions.
for (auto field : FieldRange(descriptor_)) { for (auto field : FieldRange(descriptor_)) {
if (!IsFieldUsed(field, options_)) { if (IsFieldStripped(field, options_)) {
continue; continue;
} }
field_generators_.get(field).GenerateNonInlineAccessorDefinitions(printer); field_generators_.get(field).GenerateNonInlineAccessorDefinitions(printer);
@ -2413,13 +2299,16 @@ std::pair<size_t, size_t> MessageGenerator::GenerateOffsets(
descriptor_->real_oneof_decl_count(); descriptor_->real_oneof_decl_count();
size_t entries = offsets; size_t entries = offsets;
for (auto field : FieldRange(descriptor_)) { for (auto field : FieldRange(descriptor_)) {
if (!IsFieldUsed(field, options_)) { if (IsFieldStripped(field, options_)) {
format("~0u, // stripped\n"); format("~0u, // stripped\n");
continue; continue;
} }
if (field->real_containing_oneof() || field->options().weak()) { // TODO(sbenza): We should not have an entry in the offset table for fields
format("offsetof($classtype$DefaultTypeInternal, $1$_)", // that do not use them.
FieldName(field)); if (field->options().weak() || field->real_containing_oneof()) {
// Mark the field to prevent unintentional access through reflection.
// Don't use the top bit because that is for unused fields.
format("::$proto_ns$::internal::kInvalidFieldOffsetTag");
} else { } else {
format("PROTOBUF_FIELD_OFFSET($classtype$, $1$_)", FieldName(field)); format("PROTOBUF_FIELD_OFFSET($classtype$, $1$_)", FieldName(field));
} }
@ -2429,7 +2318,11 @@ std::pair<size_t, size_t> MessageGenerator::GenerateOffsets(
format(" | $1$", tag); format(" | $1$", tag);
} }
format(",\n"); if (!IsFieldUsed(field, options_)) {
format(" | 0x80000000u, // unused\n");
} else {
format(",\n");
}
} }
int count = 0; int count = 0;
@ -2483,9 +2376,7 @@ void MessageGenerator::GenerateSharedDestructorCode(io::Printer* printer) {
format("void $classname$::SharedDtor() {\n"); format("void $classname$::SharedDtor() {\n");
format.Indent(); format.Indent();
if (SupportsArenas(descriptor_)) { format("$DCHK$(GetArena() == nullptr);\n");
format("$DCHK$(GetArena() == nullptr);\n");
}
// Write the destructors for each field except oneof members. // Write the destructors for each field except oneof members.
// optimized_order_ does not contain oneof fields. // optimized_order_ does not contain oneof fields.
for (auto field : optimized_order_) { for (auto field : optimized_order_) {
@ -2541,7 +2432,7 @@ void MessageGenerator::GenerateArenaDestructorCode(io::Printer* printer) {
// and returns false for oneof fields. // and returns false for oneof fields.
for (auto oneof : OneOfRange(descriptor_)) { for (auto oneof : OneOfRange(descriptor_)) {
for (auto field : FieldRange(oneof)) { for (auto field : FieldRange(oneof)) {
if (IsFieldUsed(field, options_) && if (!IsFieldStripped(field, options_) &&
field_generators_.get(field).GenerateArenaDestructorCode(printer)) { field_generators_.get(field).GenerateArenaDestructorCode(printer)) {
need_registration = true; need_registration = true;
} }
@ -2644,7 +2535,7 @@ void MessageGenerator::GenerateStructors(io::Printer* printer) {
// Initialize member variables with arena constructor. // Initialize member variables with arena constructor.
for (auto field : optimized_order_) { for (auto field : optimized_order_) {
GOOGLE_DCHECK(IsFieldUsed(field, options_)); GOOGLE_DCHECK(!IsFieldStripped(field, options_));
bool has_arena_constructor = field->is_repeated(); bool has_arena_constructor = field->is_repeated();
if (!field->real_containing_oneof() && if (!field->real_containing_oneof() &&
(IsLazy(field, options_) || IsStringPiece(field, options_))) { (IsLazy(field, options_) || IsStringPiece(field, options_))) {
@ -2671,24 +2562,14 @@ void MessageGenerator::GenerateStructors(io::Printer* printer) {
initializer_null += ", _weak_field_map_(nullptr)"; initializer_null += ", _weak_field_map_(nullptr)";
} }
if (SupportsArenas(descriptor_)) { format(
format( "$classname$::$classname$(::$proto_ns$::Arena* arena)\n"
"$classname$::$classname$(::$proto_ns$::Arena* arena)\n" " : $1$ {\n"
" : $1$ {\n" " SharedCtor();\n"
" SharedCtor();\n" " RegisterArenaDtor(arena);\n"
" RegisterArenaDtor(arena);\n" " // @@protoc_insertion_point(arena_constructor:$full_name$)\n"
" // @@protoc_insertion_point(arena_constructor:$full_name$)\n" "}\n",
"}\n", initializer_with_arena);
initializer_with_arena);
} else {
format(
"$classname$::$classname$()\n"
" : $1$ {\n"
" SharedCtor();\n"
" // @@protoc_insertion_point(constructor:$full_name$)\n"
"}\n",
initializer_null);
}
std::map<std::string, std::string> vars; std::map<std::string, std::string> vars;
SetUnknkownFieldsVariable(descriptor_, options_, &vars); SetUnknkownFieldsVariable(descriptor_, options_, &vars);
@ -2760,7 +2641,7 @@ void MessageGenerator::GenerateStructors(io::Printer* printer) {
for (auto field : FieldRange(oneof)) { for (auto field : FieldRange(oneof)) {
format("case k$1$: {\n", UnderscoresToCamelCase(field->name(), true)); format("case k$1$: {\n", UnderscoresToCamelCase(field->name(), true));
format.Indent(); format.Indent();
if (IsFieldUsed(field, options_)) { if (!IsFieldStripped(field, options_)) {
field_generators_.get(field).GenerateMergingCode(printer); field_generators_.get(field).GenerateMergingCode(printer);
} }
format("break;\n"); format("break;\n");
@ -2799,9 +2680,7 @@ void MessageGenerator::GenerateStructors(io::Printer* printer) {
GenerateSharedDestructorCode(printer); GenerateSharedDestructorCode(printer);
// Generate the arena-specific destructor code. // Generate the arena-specific destructor code.
if (SupportsArenas(descriptor_)) { GenerateArenaDestructorCode(printer);
GenerateArenaDestructorCode(printer);
}
// Generate SetCachedSize. // Generate SetCachedSize.
format( format(
@ -2824,9 +2703,8 @@ void MessageGenerator::GenerateSourceInProto2Namespace(io::Printer* printer) {
"template<> " "template<> "
"PROTOBUF_NOINLINE " "PROTOBUF_NOINLINE "
"$classtype$* Arena::CreateMaybeMessage< $classtype$ >(Arena* arena) {\n" "$classtype$* Arena::CreateMaybeMessage< $classtype$ >(Arena* arena) {\n"
" return Arena::$1$Internal< $classtype$ >(arena);\n" " return Arena::CreateMessageInternal< $classtype$ >(arena);\n"
"}\n", "}\n");
MessageCreateFunction(descriptor_));
} }
void MessageGenerator::GenerateClear(io::Printer* printer) { void MessageGenerator::GenerateClear(io::Printer* printer) {
@ -3018,7 +2896,7 @@ void MessageGenerator::GenerateOneofClear(io::Printer* printer) {
format("case k$1$: {\n", UnderscoresToCamelCase(field->name(), true)); format("case k$1$: {\n", UnderscoresToCamelCase(field->name(), true));
format.Indent(); format.Indent();
// We clear only allocated objects in oneofs // We clear only allocated objects in oneofs
if (!IsStringOrMessage(field) || !IsFieldUsed(field, options_)) { if (!IsStringOrMessage(field) || IsFieldStripped(field, options_)) {
format("// No need to clear\n"); format("// No need to clear\n");
} else { } else {
field_generators_.get(field).GenerateClearingCode(printer); field_generators_.get(field).GenerateClearingCode(printer);
@ -3065,7 +2943,7 @@ void MessageGenerator::GenerateSwap(io::Printer* printer) {
"metadata_);\n"); "metadata_);\n");
if (!has_bit_indices_.empty()) { 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); format("swap(_has_bits_[$1$], other->_has_bits_[$1$]);\n", i);
} }
} }
@ -3307,7 +3185,7 @@ void MessageGenerator::GenerateClassSpecificMergeFrom(io::Printer* printer) {
for (auto field : FieldRange(oneof)) { for (auto field : FieldRange(oneof)) {
format("case k$1$: {\n", UnderscoresToCamelCase(field->name(), true)); format("case k$1$: {\n", UnderscoresToCamelCase(field->name(), true));
format.Indent(); format.Indent();
if (IsFieldUsed(field, options_)) { if (!IsFieldStripped(field, options_)) {
field_generators_.get(field).GenerateMergingCode(printer); field_generators_.get(field).GenerateMergingCode(printer);
} }
format("break;\n"); format("break;\n");
@ -3527,8 +3405,26 @@ void MessageGenerator::GenerateSerializeWithCachedSizesToArray(
format("// @@protoc_insertion_point(serialize_to_array_start:$full_name$)\n"); format("// @@protoc_insertion_point(serialize_to_array_start:$full_name$)\n");
if (!ShouldSerializeInOrder(descriptor_, options_)) {
format.Outdent();
format("#ifdef NDEBUG\n");
format.Indent();
}
GenerateSerializeWithCachedSizesBody(printer); GenerateSerializeWithCachedSizesBody(printer);
if (!ShouldSerializeInOrder(descriptor_, options_)) {
format.Outdent();
format("#else // NDEBUG\n");
format.Indent();
GenerateSerializeWithCachedSizesBodyShuffled(printer);
format.Outdent();
format("#endif // !NDEBUG\n");
format.Indent();
}
format("// @@protoc_insertion_point(serialize_to_array_end:$full_name$)\n"); format("// @@protoc_insertion_point(serialize_to_array_end:$full_name$)\n");
format.Outdent(); format.Outdent();
@ -3643,11 +3539,14 @@ void MessageGenerator::GenerateSerializeWithCachedSizesBody(
(i < descriptor_->field_count() && (i < descriptor_->field_count() &&
ordered_fields[i]->number() < sorted_extensions[j]->start)) { ordered_fields[i]->number() < sorted_extensions[j]->start)) {
const FieldDescriptor* field = ordered_fields[i++]; const FieldDescriptor* field = ordered_fields[i++];
if (!IsFieldUsed(field, options_)) { if (IsFieldStripped(field, options_)) {
continue; continue;
} }
if (field->options().weak()) { if (field->options().weak()) {
last_weak_field = field; if (last_weak_field == nullptr ||
last_weak_field->number() < field->number()) {
last_weak_field = field;
}
PrintFieldComment(format, field); PrintFieldComment(format, field);
} else { } else {
if (last_weak_field != nullptr) { if (last_weak_field != nullptr) {
@ -3690,6 +3589,115 @@ void MessageGenerator::GenerateSerializeWithCachedSizesBody(
format("}\n"); format("}\n");
} }
void MessageGenerator::GenerateSerializeWithCachedSizesBodyShuffled(
io::Printer* printer) {
Formatter format(printer, variables_);
std::vector<const FieldDescriptor*> ordered_fields =
SortFieldsByNumber(descriptor_);
ordered_fields.erase(
std::remove_if(ordered_fields.begin(), ordered_fields.end(),
[this](const FieldDescriptor* f) {
return !IsFieldUsed(f, options_);
}),
ordered_fields.end());
std::vector<const Descriptor::ExtensionRange*> sorted_extensions;
sorted_extensions.reserve(descriptor_->extension_range_count());
for (int i = 0; i < descriptor_->extension_range_count(); ++i) {
sorted_extensions.push_back(descriptor_->extension_range(i));
}
std::sort(sorted_extensions.begin(), sorted_extensions.end(),
ExtensionRangeSorter());
int num_fields = ordered_fields.size() + sorted_extensions.size();
constexpr int kLargePrime = 1000003;
GOOGLE_CHECK_LT(num_fields, kLargePrime)
<< "Prime offset must be greater than the number of fields to ensure "
"those are coprime.";
if (num_weak_fields_) {
format(
"::$proto_ns$::internal::WeakFieldMap::FieldWriter field_writer("
"_weak_field_map_);\n");
}
format(
"static const int kStart = GetInvariantPerBuild($1$UL) % $2$;\n"
"bool first_pass = true;\n"
"for (int i = kStart; i != kStart || first_pass; i = ((i + $3$) % $2$)) "
"{\n",
0,
num_fields, kLargePrime);
format.Indent();
format("switch(i) {\n");
format.Indent();
bool first_pass_set = false;
int index = 0;
for (const auto* f : ordered_fields) {
format("case $1$: {\n", index++);
format.Indent();
if (!first_pass_set) {
first_pass_set = true;
format("first_pass = false;\n");
}
GenerateSerializeOneField(printer, f, -1);
format("break;\n");
format.Outdent();
format("}\n");
}
for (const auto* r : sorted_extensions) {
format("case $1$: {\n", index++);
format.Indent();
if (!first_pass_set) {
first_pass_set = true;
format("first_pass = false;\n");
}
GenerateSerializeOneExtensionRange(printer, r);
format("break;\n");
format.Outdent();
format("}\n");
}
format(
"default: {\n"
" $DCHK$(false) << \"Unexpected index: \" << i;\n"
"}\n");
format.Outdent();
format("}\n");
format.Outdent();
format("}\n");
std::map<std::string, std::string> vars;
SetUnknkownFieldsVariable(descriptor_, options_, &vars);
format.AddMap(vars);
format("if (PROTOBUF_PREDICT_FALSE($have_unknown_fields$)) {\n");
format.Indent();
if (UseUnknownFieldSet(descriptor_->file(), options_)) {
format(
"target = "
"::$proto_ns$::internal::WireFormat::"
"InternalSerializeUnknownFieldsToArray(\n"
" $unknown_fields$, target, stream);\n");
} else {
format(
"target = stream->WriteRaw($unknown_fields$.data(),\n"
" static_cast<int>($unknown_fields$.size()), target);\n");
}
format.Outdent();
format("}\n");
}
std::vector<uint32> MessageGenerator::RequiredFieldsBitMask() const { std::vector<uint32> MessageGenerator::RequiredFieldsBitMask() const {
const int array_size = HasBitsSize(); const int array_size = HasBitsSize();
std::vector<uint32> masks(array_size, 0); std::vector<uint32> masks(array_size, 0);
@ -3911,7 +3919,7 @@ void MessageGenerator::GenerateByteSize(io::Printer* printer) {
PrintFieldComment(format, field); PrintFieldComment(format, field);
format("case k$1$: {\n", UnderscoresToCamelCase(field->name(), true)); format("case k$1$: {\n", UnderscoresToCamelCase(field->name(), true));
format.Indent(); format.Indent();
if (IsFieldUsed(field, options_)) { if (!IsFieldStripped(field, options_)) {
field_generators_.get(field).GenerateByteSize(printer); field_generators_.get(field).GenerateByteSize(printer);
} }
format("break;\n"); format("break;\n");
@ -4039,7 +4047,7 @@ void MessageGenerator::GenerateIsInitialized(io::Printer* printer) {
format("case k$1$: {\n", UnderscoresToCamelCase(field->name(), true)); format("case k$1$: {\n", UnderscoresToCamelCase(field->name(), true));
format.Indent(); format.Indent();
if (IsFieldUsed(field, options_) && if (!IsFieldStripped(field, options_) &&
field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE && field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE &&
!ShouldIgnoreRequiredFieldCheck(field, options_) && !ShouldIgnoreRequiredFieldCheck(field, options_) &&
scc_analyzer_->HasRequiredFields(field->message_type())) { scc_analyzer_->HasRequiredFields(field->message_type())) {

@ -82,17 +82,9 @@ class MessageGenerator {
// Source file stuff. // Source file stuff.
// Generate extra fields
void GenerateExtraDefaultFields(io::Printer* printer);
// Generates code that creates default instances for fields. // Generates code that creates default instances for fields.
void GenerateFieldDefaultInstances(io::Printer* printer); void GenerateFieldDefaultInstances(io::Printer* printer);
// Generates code that initializes the message's default instance. This
// is separate from allocating because all default instances must be
// allocated before any can be initialized.
void GenerateDefaultInstanceInitializer(io::Printer* printer);
// Generate all non-inline methods for this class. // Generate all non-inline methods for this class.
void GenerateClassMethods(io::Printer* printer); void GenerateClassMethods(io::Printer* printer);
@ -142,6 +134,7 @@ class MessageGenerator {
void GenerateSerializeWithCachedSizes(io::Printer* printer); void GenerateSerializeWithCachedSizes(io::Printer* printer);
void GenerateSerializeWithCachedSizesToArray(io::Printer* printer); void GenerateSerializeWithCachedSizesToArray(io::Printer* printer);
void GenerateSerializeWithCachedSizesBody(io::Printer* printer); void GenerateSerializeWithCachedSizesBody(io::Printer* printer);
void GenerateSerializeWithCachedSizesBodyShuffled(io::Printer* printer);
void GenerateByteSize(io::Printer* printer); void GenerateByteSize(io::Printer* printer);
void GenerateMergeFrom(io::Printer* printer); void GenerateMergeFrom(io::Printer* printer);
void GenerateClassSpecificMergeFrom(io::Printer* printer); void GenerateClassSpecificMergeFrom(io::Printer* printer);

@ -67,8 +67,9 @@ void SetMessageVariables(const FieldDescriptor* descriptor,
QualifiedDefaultInstancePtr(descriptor->message_type(), options); QualifiedDefaultInstancePtr(descriptor->message_type(), options);
(*variables)["type_reference_function"] = (*variables)["type_reference_function"] =
implicit_weak ? (" ::" + (*variables)["proto_ns"] + implicit_weak ? (" ::" + (*variables)["proto_ns"] +
"::internal::StrongReference(" + "::internal::StrongReference(reinterpret_cast<const " +
(*variables)["type_default_instance"] + ");\n") (*variables)["type"] + "&>(\n" +
(*variables)["type_default_instance"] + "));\n")
: ""; : "";
// NOTE: Escaped here to unblock proto1->proto2 migration. // NOTE: Escaped here to unblock proto1->proto2 migration.
// TODO(liujisi): Extend this to apply for other conflicting methods. // TODO(liujisi): Extend this to apply for other conflicting methods.
@ -104,7 +105,7 @@ void MessageFieldGenerator::GeneratePrivateMembers(io::Printer* printer) const {
void MessageFieldGenerator::GenerateAccessorDeclarations( void MessageFieldGenerator::GenerateAccessorDeclarations(
io::Printer* printer) const { io::Printer* printer) const {
Formatter format(printer, variables_); Formatter format(printer, variables_);
if (!IsFieldUsed(descriptor_, options_)) { if (IsFieldStripped(descriptor_, options_)) {
format( format(
"$deprecated_attr$const $type$& ${1$$name$$}$() const { " "$deprecated_attr$const $type$& ${1$$name$$}$() const { "
"__builtin_trap(); }\n" "__builtin_trap(); }\n"
@ -113,17 +114,13 @@ void MessageFieldGenerator::GenerateAccessorDeclarations(
"$deprecated_attr$$type$* ${1$mutable_$name$$}$() { " "$deprecated_attr$$type$* ${1$mutable_$name$$}$() { "
"__builtin_trap(); }\n" "__builtin_trap(); }\n"
"$deprecated_attr$void ${1$set_allocated_$name$$}$" "$deprecated_attr$void ${1$set_allocated_$name$$}$"
"($type$* $name$) { __builtin_trap(); }\n", "($type$* $name$) { __builtin_trap(); }\n"
"$deprecated_attr$void "
"${1$unsafe_arena_set_allocated_$name$$}$(\n"
" $type$* $name$) { __builtin_trap(); }\n"
"$deprecated_attr$$type$* ${1$unsafe_arena_release_$name$$}$() { "
"__builtin_trap(); }\n",
descriptor_); descriptor_);
if (SupportsArenas(descriptor_)) {
format(
"$deprecated_attr$void "
"${1$unsafe_arena_set_allocated_$name$$}$(\n"
" $type$* $name$) { __builtin_trap(); }\n"
"$deprecated_attr$$type$* ${1$unsafe_arena_release_$name$$}$() { "
"__builtin_trap(); }\n",
descriptor_);
}
return; return;
} }
format( format(
@ -133,7 +130,7 @@ void MessageFieldGenerator::GenerateAccessorDeclarations(
"$deprecated_attr$void ${1$set_allocated_$name$$}$" "$deprecated_attr$void ${1$set_allocated_$name$$}$"
"($type$* $name$);\n", "($type$* $name$);\n",
descriptor_); descriptor_);
if (IsFieldUsed(descriptor_, options_)) { if (!IsFieldStripped(descriptor_, options_)) {
format( format(
"private:\n" "private:\n"
"const $type$& ${1$_internal_$name$$}$() const;\n" "const $type$& ${1$_internal_$name$$}$() const;\n"
@ -141,14 +138,12 @@ void MessageFieldGenerator::GenerateAccessorDeclarations(
"public:\n", "public:\n",
descriptor_); descriptor_);
} }
if (SupportsArenas(descriptor_)) { format(
format( "$deprecated_attr$void "
"$deprecated_attr$void " "${1$unsafe_arena_set_allocated_$name$$}$(\n"
"${1$unsafe_arena_set_allocated_$name$$}$(\n" " $type$* $name$);\n"
" $type$* $name$);\n" "$deprecated_attr$$type$* ${1$unsafe_arena_release_$name$$}$();\n",
"$deprecated_attr$$type$* ${1$unsafe_arena_release_$name$$}$();\n", descriptor_);
descriptor_);
}
} }
void MessageFieldGenerator::GenerateNonInlineAccessorDefinitions( void MessageFieldGenerator::GenerateNonInlineAccessorDefinitions(
@ -162,8 +157,8 @@ void MessageFieldGenerator::GenerateInlineAccessorDefinitions(
"inline const $type$& $classname$::_internal_$name$() const {\n" "inline const $type$& $classname$::_internal_$name$() const {\n"
"$type_reference_function$" "$type_reference_function$"
" const $type$* p = $casted_member$;\n" " const $type$* p = $casted_member$;\n"
" return p != nullptr ? *p : *reinterpret_cast<const $type$*>(\n" " return p != nullptr ? *p : reinterpret_cast<const $type$&>(\n"
" &$type_default_instance$);\n" " $type_default_instance$);\n"
"}\n" "}\n"
"inline const $type$& $classname$::$name$() const {\n" "inline const $type$& $classname$::$name$() const {\n"
"$annotate_accessor$" "$annotate_accessor$"
@ -171,48 +166,43 @@ void MessageFieldGenerator::GenerateInlineAccessorDefinitions(
" return _internal_$name$();\n" " return _internal_$name$();\n"
"}\n"); "}\n");
if (SupportsArenas(descriptor_)) { format(
format( "inline void $classname$::unsafe_arena_set_allocated_$name$(\n"
"inline void $classname$::unsafe_arena_set_allocated_$name$(\n" " $type$* $name$) {\n"
" $type$* $name$) {\n" "$annotate_accessor$"
"$annotate_accessor$" // If we're not on an arena, free whatever we were holding before.
// If we're not on an arena, free whatever we were holding before. // (If we are on arena, we can just forget the earlier pointer.)
// (If we are on arena, we can just forget the earlier pointer.) " if (GetArena() == nullptr) {\n"
" if (GetArena() == nullptr) {\n" " delete reinterpret_cast<::$proto_ns$::MessageLite*>($name$_);\n"
" delete reinterpret_cast<::$proto_ns$::MessageLite*>($name$_);\n" " }\n");
" }\n"); if (implicit_weak_field_) {
if (implicit_weak_field_) {
format(
" $name$_ = "
"reinterpret_cast<::$proto_ns$::MessageLite*>($name$);\n");
} else {
format(" $name$_ = $name$;\n");
}
format(
" if ($name$) {\n"
" $set_hasbit$\n"
" } else {\n"
" $clear_hasbit$\n"
" }\n"
" // @@protoc_insertion_point(field_unsafe_arena_set_allocated"
":$full_name$)\n"
"}\n");
format( format(
"inline $type$* $classname$::$release_name$() {\n" " $name$_ = "
"$type_reference_function$" "reinterpret_cast<::$proto_ns$::MessageLite*>($name$);\n");
" $clear_hasbit$\n"
" $type$* temp = $casted_member$;\n"
" $name$_ = nullptr;\n"
" if (GetArena() != nullptr) {\n"
" temp = ::$proto_ns$::internal::DuplicateIfNonNull(temp);\n"
" }\n"
" return temp;\n"
"}\n"
"inline $type$* $classname$::unsafe_arena_release_$name$() {\n");
} else { } else {
format("inline $type$* $classname$::$release_name$() {\n"); format(" $name$_ = $name$;\n");
} }
format( format(
" if ($name$) {\n"
" $set_hasbit$\n"
" } else {\n"
" $clear_hasbit$\n"
" }\n"
" // @@protoc_insertion_point(field_unsafe_arena_set_allocated"
":$full_name$)\n"
"}\n");
format(
"inline $type$* $classname$::$release_name$() {\n"
"$type_reference_function$"
" $clear_hasbit$\n"
" $type$* temp = $casted_member$;\n"
" $name$_ = nullptr;\n"
" if (GetArena() != nullptr) {\n"
" temp = ::$proto_ns$::internal::DuplicateIfNonNull(temp);\n"
" }\n"
" return temp;\n"
"}\n"
"inline $type$* $classname$::unsafe_arena_release_$name$() {\n"
"$annotate_accessor$" "$annotate_accessor$"
" // @@protoc_insertion_point(field_release:$full_name$)\n" " // @@protoc_insertion_point(field_release:$full_name$)\n"
"$type_reference_function$" "$type_reference_function$"
@ -259,16 +249,13 @@ void MessageFieldGenerator::GenerateInlineAccessorDefinitions(
format( format(
" }\n" " }\n"
" if ($name$) {\n"); " if ($name$) {\n");
if (SupportsArenas(descriptor_->message_type()) && if (IsCrossFileMessage(descriptor_)) {
IsCrossFileMessage(descriptor_)) {
// We have to read the arena through the virtual method, because the type // We have to read the arena through the virtual method, because the type
// isn't defined in this file. // isn't defined in this file.
format( format(
" ::$proto_ns$::Arena* submessage_arena =\n" " ::$proto_ns$::Arena* submessage_arena =\n"
" " " "
"reinterpret_cast<::$proto_ns$::MessageLite*>($name$)->GetArena();\n"); "reinterpret_cast<::$proto_ns$::MessageLite*>($name$)->GetArena();\n");
} else if (!SupportsArenas(descriptor_->message_type())) {
format(" ::$proto_ns$::Arena* submessage_arena = nullptr;\n");
} else { } else {
format( format(
" ::$proto_ns$::Arena* submessage_arena =\n" " ::$proto_ns$::Arena* submessage_arena =\n"
@ -330,48 +317,26 @@ void MessageFieldGenerator::GenerateInternalAccessorDefinitions(
"*::$proto_ns$::internal::ImplicitWeakMessage::default_instance();\n" "*::$proto_ns$::internal::ImplicitWeakMessage::default_instance();\n"
" }\n" " }\n"
"}\n"); "}\n");
if (SupportsArenas(descriptor_)) { format(
format( "::$proto_ns$::MessageLite*\n"
"::$proto_ns$::MessageLite*\n" "$classname$::_Internal::mutable_$name$($classname$* msg) {\n");
"$classname$::_Internal::mutable_$name$($classname$* msg) {\n"); if (HasFieldPresence(descriptor_->file())) {
if (HasFieldPresence(descriptor_->file())) { format(" msg->$set_hasbit$\n");
format(" msg->$set_hasbit$\n");
}
format(
" if (msg->$name$_ == nullptr) {\n"
" if ($type_default_instance_ptr$ == nullptr) {\n"
" msg->$name$_ = ::$proto_ns$::Arena::CreateMessage<\n"
" ::$proto_ns$::internal::ImplicitWeakMessage>(\n"
" msg->GetArena());\n"
" } else {\n"
" msg->$name$_ = reinterpret_cast<const "
"::$proto_ns$::MessageLite*>(\n"
" $type_default_instance_ptr$)->New(msg->GetArena());\n"
" }\n"
" }\n"
" return msg->$name$_;\n"
"}\n");
} else {
format(
"::$proto_ns$::MessageLite*\n"
"$classname$::_Internal::mutable_$name$($classname$* msg) {\n");
if (HasFieldPresence(descriptor_->file())) {
format(" msg->$set_hasbit$\n");
}
format(
" if (msg->$name$_ == nullptr) {\n"
" if ($type_default_instance_ptr$ == nullptr) {\n"
" msg->$name$_ = "
"new ::$proto_ns$::internal::ImplicitWeakMessage;\n"
" } else {\n"
" msg->$name$_ = "
"reinterpret_cast<const ::$proto_ns$::MessageLite*>(\n"
" $type_default_instance_ptr$)->New();\n"
" }\n"
" }\n"
" return msg->$name$_;\n"
"}\n");
} }
format(
" if (msg->$name$_ == nullptr) {\n"
" if ($type_default_instance_ptr$ == nullptr) {\n"
" msg->$name$_ = ::$proto_ns$::Arena::CreateMessage<\n"
" ::$proto_ns$::internal::ImplicitWeakMessage>(\n"
" msg->GetArena());\n"
" } else {\n"
" msg->$name$_ = reinterpret_cast<const "
"::$proto_ns$::MessageLite*>(\n"
" $type_default_instance_ptr$)->New(msg->GetArena());\n"
" }\n"
" }\n"
" return msg->$name$_;\n"
"}\n");
} else { } else {
// This inline accessor directly returns member field and is used in // This inline accessor directly returns member field and is used in
// Serialize such that AFDO profile correctly captures access information to // Serialize such that AFDO profile correctly captures access information to
@ -385,7 +350,7 @@ void MessageFieldGenerator::GenerateInternalAccessorDefinitions(
} }
void MessageFieldGenerator::GenerateClearingCode(io::Printer* printer) const { void MessageFieldGenerator::GenerateClearingCode(io::Printer* printer) const {
GOOGLE_CHECK(IsFieldUsed(descriptor_, options_)); GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_));
Formatter format(printer, variables_); Formatter format(printer, variables_);
if (!HasFieldPresence(descriptor_->file())) { if (!HasFieldPresence(descriptor_->file())) {
@ -403,7 +368,7 @@ void MessageFieldGenerator::GenerateClearingCode(io::Printer* printer) const {
void MessageFieldGenerator::GenerateMessageClearingCode( void MessageFieldGenerator::GenerateMessageClearingCode(
io::Printer* printer) const { io::Printer* printer) const {
GOOGLE_CHECK(IsFieldUsed(descriptor_, options_)); GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_));
Formatter format(printer, variables_); Formatter format(printer, variables_);
if (!HasFieldPresence(descriptor_->file())) { if (!HasFieldPresence(descriptor_->file())) {
@ -422,7 +387,7 @@ void MessageFieldGenerator::GenerateMessageClearingCode(
} }
void MessageFieldGenerator::GenerateMergingCode(io::Printer* printer) const { void MessageFieldGenerator::GenerateMergingCode(io::Printer* printer) const {
GOOGLE_CHECK(IsFieldUsed(descriptor_, options_)); GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_));
Formatter format(printer, variables_); Formatter format(printer, variables_);
if (implicit_weak_field_) { if (implicit_weak_field_) {
@ -437,14 +402,14 @@ void MessageFieldGenerator::GenerateMergingCode(io::Printer* printer) const {
} }
void MessageFieldGenerator::GenerateSwappingCode(io::Printer* printer) const { void MessageFieldGenerator::GenerateSwappingCode(io::Printer* printer) const {
GOOGLE_CHECK(IsFieldUsed(descriptor_, options_)); GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_));
Formatter format(printer, variables_); Formatter format(printer, variables_);
format("swap($name$_, other->$name$_);\n"); format("swap($name$_, other->$name$_);\n");
} }
void MessageFieldGenerator::GenerateDestructorCode(io::Printer* printer) const { void MessageFieldGenerator::GenerateDestructorCode(io::Printer* printer) const {
GOOGLE_CHECK(IsFieldUsed(descriptor_, options_)); GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_));
Formatter format(printer, variables_); Formatter format(printer, variables_);
if (options_.opensource_runtime) { if (options_.opensource_runtime) {
@ -460,7 +425,7 @@ void MessageFieldGenerator::GenerateDestructorCode(io::Printer* printer) const {
void MessageFieldGenerator::GenerateConstructorCode( void MessageFieldGenerator::GenerateConstructorCode(
io::Printer* printer) const { io::Printer* printer) const {
GOOGLE_CHECK(IsFieldUsed(descriptor_, options_)); GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_));
Formatter format(printer, variables_); Formatter format(printer, variables_);
format("$name$_ = nullptr;\n"); format("$name$_ = nullptr;\n");
@ -468,7 +433,7 @@ void MessageFieldGenerator::GenerateConstructorCode(
void MessageFieldGenerator::GenerateCopyConstructorCode( void MessageFieldGenerator::GenerateCopyConstructorCode(
io::Printer* printer) const { io::Printer* printer) const {
GOOGLE_CHECK(IsFieldUsed(descriptor_, options_)); GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_));
Formatter format(printer, variables_); Formatter format(printer, variables_);
format( format(
@ -481,7 +446,7 @@ void MessageFieldGenerator::GenerateCopyConstructorCode(
void MessageFieldGenerator::GenerateSerializeWithCachedSizesToArray( void MessageFieldGenerator::GenerateSerializeWithCachedSizesToArray(
io::Printer* printer) const { io::Printer* printer) const {
GOOGLE_CHECK(IsFieldUsed(descriptor_, options_)); GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_));
Formatter format(printer, variables_); Formatter format(printer, variables_);
format( format(
@ -492,7 +457,7 @@ void MessageFieldGenerator::GenerateSerializeWithCachedSizesToArray(
} }
void MessageFieldGenerator::GenerateByteSize(io::Printer* printer) const { void MessageFieldGenerator::GenerateByteSize(io::Printer* printer) const {
GOOGLE_CHECK(IsFieldUsed(descriptor_, options_)); GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_));
Formatter format(printer, variables_); Formatter format(printer, variables_);
format( format(
@ -521,16 +486,13 @@ void MessageOneofFieldGenerator::GenerateNonInlineAccessorDefinitions(
" ::$proto_ns$::Arena* message_arena = GetArena();\n" " ::$proto_ns$::Arena* message_arena = GetArena();\n"
" clear_$oneof_name$();\n" " clear_$oneof_name$();\n"
" if ($name$) {\n"); " if ($name$) {\n");
if (SupportsArenas(descriptor_->message_type()) && if (descriptor_->file() != descriptor_->message_type()->file()) {
descriptor_->file() != descriptor_->message_type()->file()) {
// We have to read the arena through the virtual method, because the type // We have to read the arena through the virtual method, because the type
// isn't defined in this file. // isn't defined in this file.
format( format(
" ::$proto_ns$::Arena* submessage_arena =\n" " ::$proto_ns$::Arena* submessage_arena =\n"
" " " "
"reinterpret_cast<::$proto_ns$::MessageLite*>($name$)->GetArena();\n"); "reinterpret_cast<::$proto_ns$::MessageLite*>($name$)->GetArena();\n");
} else if (!SupportsArenas(descriptor_->message_type())) {
format(" ::$proto_ns$::Arena* submessage_arena = nullptr;\n");
} else { } else {
format( format(
" ::$proto_ns$::Arena* submessage_arena =\n" " ::$proto_ns$::Arena* submessage_arena =\n"
@ -557,14 +519,10 @@ void MessageOneofFieldGenerator::GenerateInlineAccessorDefinitions(
" // @@protoc_insertion_point(field_release:$full_name$)\n" " // @@protoc_insertion_point(field_release:$full_name$)\n"
" if (_internal_has_$name$()) {\n" " if (_internal_has_$name$()) {\n"
" clear_has_$oneof_name$();\n" " clear_has_$oneof_name$();\n"
" $type$* temp = $field_member$;\n"); " $type$* temp = $field_member$;\n"
if (SupportsArenas(descriptor_)) { " if (GetArena() != nullptr) {\n"
format( " temp = ::$proto_ns$::internal::DuplicateIfNonNull(temp);\n"
" if (GetArena() != nullptr) {\n" " }\n"
" temp = ::$proto_ns$::internal::DuplicateIfNonNull(temp);\n"
" }\n");
}
format(
" $field_member$ = nullptr;\n" " $field_member$ = nullptr;\n"
" return temp;\n" " return temp;\n"
" } else {\n" " } else {\n"
@ -576,46 +534,40 @@ void MessageOneofFieldGenerator::GenerateInlineAccessorDefinitions(
"inline const $type$& $classname$::_internal_$name$() const {\n" "inline const $type$& $classname$::_internal_$name$() const {\n"
" return _internal_has_$name$()\n" " return _internal_has_$name$()\n"
" ? *$field_member$\n" " ? *$field_member$\n"
" : *reinterpret_cast< $type$*>(&$type_default_instance$);\n" " : reinterpret_cast< $type$&>($type_default_instance$);\n"
"}\n" "}\n"
"inline const $type$& $classname$::$name$() const {\n" "inline const $type$& $classname$::$name$() const {\n"
"$annotate_accessor$" "$annotate_accessor$"
" // @@protoc_insertion_point(field_get:$full_name$)\n" " // @@protoc_insertion_point(field_get:$full_name$)\n"
" return _internal_$name$();\n" " return _internal_$name$();\n"
"}\n"); "}\n"
"inline $type$* $classname$::unsafe_arena_release_$name$() {\n"
if (SupportsArenas(descriptor_)) { "$annotate_accessor$"
format( " // @@protoc_insertion_point(field_unsafe_arena_release"
"inline $type$* $classname$::unsafe_arena_release_$name$() {\n" ":$full_name$)\n"
"$annotate_accessor$" " if (_internal_has_$name$()) {\n"
" // @@protoc_insertion_point(field_unsafe_arena_release" " clear_has_$oneof_name$();\n"
":$full_name$)\n" " $type$* temp = $field_member$;\n"
" if (_internal_has_$name$()) {\n" " $field_member$ = nullptr;\n"
" clear_has_$oneof_name$();\n" " return temp;\n"
" $type$* temp = $field_member$;\n" " } else {\n"
" $field_member$ = nullptr;\n" " return nullptr;\n"
" return temp;\n" " }\n"
" } else {\n" "}\n"
" return nullptr;\n" "inline void $classname$::unsafe_arena_set_allocated_$name$"
" }\n" "($type$* $name$) {\n"
"}\n" "$annotate_accessor$"
"inline void $classname$::unsafe_arena_set_allocated_$name$" // We rely on the oneof clear method to free the earlier contents of
"($type$* $name$) {\n" // this oneof. We can directly use the pointer we're given to set the
"$annotate_accessor$" // new value.
// We rely on the oneof clear method to free the earlier contents of " clear_$oneof_name$();\n"
// this oneof. We can directly use the pointer we're given to set the " if ($name$) {\n"
// new value. " set_has_$name$();\n"
" clear_$oneof_name$();\n" " $field_member$ = $name$;\n"
" if ($name$) {\n" " }\n"
" set_has_$name$();\n" " // @@protoc_insertion_point(field_unsafe_arena_set_allocated:"
" $field_member$ = $name$;\n" "$full_name$)\n"
" }\n" "}\n"
" // @@protoc_insertion_point(field_unsafe_arena_set_allocated:"
"$full_name$)\n"
"}\n");
}
format(
"inline $type$* $classname$::_internal_mutable_$name$() {\n" "inline $type$* $classname$::_internal_mutable_$name$() {\n"
" if (!_internal_has_$name$()) {\n" " if (!_internal_has_$name$()) {\n"
" clear_$oneof_name$();\n" " clear_$oneof_name$();\n"
@ -633,17 +585,13 @@ void MessageOneofFieldGenerator::GenerateInlineAccessorDefinitions(
void MessageOneofFieldGenerator::GenerateClearingCode( void MessageOneofFieldGenerator::GenerateClearingCode(
io::Printer* printer) const { io::Printer* printer) const {
GOOGLE_CHECK(IsFieldUsed(descriptor_, options_)); GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_));
Formatter format(printer, variables_); Formatter format(printer, variables_);
if (SupportsArenas(descriptor_)) { format(
format( "if (GetArena() == nullptr) {\n"
"if (GetArena() == nullptr) {\n" " delete $field_member$;\n"
" delete $field_member$;\n" "}\n");
"}\n");
} else {
format("delete $field_member$;\n");
}
} }
void MessageOneofFieldGenerator::GenerateMessageClearingCode( void MessageOneofFieldGenerator::GenerateMessageClearingCode(
@ -694,7 +642,7 @@ void RepeatedMessageFieldGenerator::GeneratePrivateMembers(
void RepeatedMessageFieldGenerator::GenerateAccessorDeclarations( void RepeatedMessageFieldGenerator::GenerateAccessorDeclarations(
io::Printer* printer) const { io::Printer* printer) const {
Formatter format(printer, variables_); Formatter format(printer, variables_);
if (!IsFieldUsed(descriptor_, options_)) { if (IsFieldStripped(descriptor_, options_)) {
format( format(
"$deprecated_attr$$type$* ${1$mutable_$name$$}$(int index) { " "$deprecated_attr$$type$* ${1$mutable_$name$$}$(int index) { "
"__builtin_trap(); }\n" "__builtin_trap(); }\n"
@ -714,7 +662,7 @@ void RepeatedMessageFieldGenerator::GenerateAccessorDeclarations(
"$deprecated_attr$::$proto_ns$::RepeatedPtrField< $type$ >*\n" "$deprecated_attr$::$proto_ns$::RepeatedPtrField< $type$ >*\n"
" ${1$mutable_$name$$}$();\n", " ${1$mutable_$name$$}$();\n",
descriptor_); descriptor_);
if (IsFieldUsed(descriptor_, options_)) { if (!IsFieldStripped(descriptor_, options_)) {
format( format(
"private:\n" "private:\n"
"const $type$& ${1$_internal_$name$$}$(int index) const;\n" "const $type$& ${1$_internal_$name$$}$(int index) const;\n"
@ -756,7 +704,7 @@ void RepeatedMessageFieldGenerator::GenerateInlineAccessorDefinitions(
"inline const $type$& $classname$::_internal_$name$(int index) const " "inline const $type$& $classname$::_internal_$name$(int index) const "
"{\n" "{\n"
" return $name$_$weak$.InternalCheckedGet(index,\n" " return $name$_$weak$.InternalCheckedGet(index,\n"
" *reinterpret_cast<const $type$*>(&$type_default_instance$));\n" " reinterpret_cast<const $type$&>($type_default_instance$));\n"
"}\n"); "}\n");
} else { } else {
format( format(
@ -794,7 +742,7 @@ void RepeatedMessageFieldGenerator::GenerateInlineAccessorDefinitions(
void RepeatedMessageFieldGenerator::GenerateClearingCode( void RepeatedMessageFieldGenerator::GenerateClearingCode(
io::Printer* printer) const { io::Printer* printer) const {
GOOGLE_CHECK(IsFieldUsed(descriptor_, options_)); GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_));
Formatter format(printer, variables_); Formatter format(printer, variables_);
format("$name$_.Clear();\n"); format("$name$_.Clear();\n");
@ -802,7 +750,7 @@ void RepeatedMessageFieldGenerator::GenerateClearingCode(
void RepeatedMessageFieldGenerator::GenerateMergingCode( void RepeatedMessageFieldGenerator::GenerateMergingCode(
io::Printer* printer) const { io::Printer* printer) const {
GOOGLE_CHECK(IsFieldUsed(descriptor_, options_)); GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_));
Formatter format(printer, variables_); Formatter format(printer, variables_);
format("$name$_.MergeFrom(from.$name$_);\n"); format("$name$_.MergeFrom(from.$name$_);\n");
@ -810,7 +758,7 @@ void RepeatedMessageFieldGenerator::GenerateMergingCode(
void RepeatedMessageFieldGenerator::GenerateSwappingCode( void RepeatedMessageFieldGenerator::GenerateSwappingCode(
io::Printer* printer) const { io::Printer* printer) const {
GOOGLE_CHECK(IsFieldUsed(descriptor_, options_)); GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_));
Formatter format(printer, variables_); Formatter format(printer, variables_);
format("$name$_.InternalSwap(&other->$name$_);\n"); format("$name$_.InternalSwap(&other->$name$_);\n");
@ -823,7 +771,7 @@ void RepeatedMessageFieldGenerator::GenerateConstructorCode(
void RepeatedMessageFieldGenerator::GenerateSerializeWithCachedSizesToArray( void RepeatedMessageFieldGenerator::GenerateSerializeWithCachedSizesToArray(
io::Printer* printer) const { io::Printer* printer) const {
GOOGLE_CHECK(IsFieldUsed(descriptor_, options_)); GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_));
Formatter format(printer, variables_); Formatter format(printer, variables_);
if (implicit_weak_field_) { if (implicit_weak_field_) {
@ -850,7 +798,7 @@ void RepeatedMessageFieldGenerator::GenerateSerializeWithCachedSizesToArray(
void RepeatedMessageFieldGenerator::GenerateByteSize( void RepeatedMessageFieldGenerator::GenerateByteSize(
io::Printer* printer) const { io::Printer* printer) const {
GOOGLE_CHECK(IsFieldUsed(descriptor_, options_)); GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_));
Formatter format(printer, variables_); Formatter format(printer, variables_);
format( format(

@ -99,18 +99,6 @@ void StringFieldGenerator::GeneratePrivateMembers(io::Printer* printer) const {
if (inlined_) { if (inlined_) {
format("::$proto_ns$::internal::InlinedStringField $name$_;\n"); format("::$proto_ns$::internal::InlinedStringField $name$_;\n");
} else { } else {
// N.B. that we continue to use |ArenaStringPtr| instead of |string*| for
// string fields, even when SupportArenas(descriptor_) == false. Why? The
// simple answer is to avoid unmaintainable complexity. The reflection code
// assumes ArenaStringPtrs. These are *almost* in-memory-compatible with
// string*, except for the pointer tags and related ownership semantics. We
// could modify the runtime code to use string* for the
// not-supporting-arenas case, but this would require a way to detect which
// type of class was generated (adding overhead and complexity to
// GeneratedMessageReflection) and littering the runtime code paths with
// conditionals. It's simpler to stick with this but use lightweight
// accessors that assume arena == NULL. There should be very little
// overhead anyway because it's just a tagged pointer in-memory.
format("::$proto_ns$::internal::ArenaStringPtr $name$_;\n"); format("::$proto_ns$::internal::ArenaStringPtr $name$_;\n");
} }
} }
@ -211,163 +199,82 @@ void StringFieldGenerator::GenerateInlineAccessorDefinitions(
"$annotate_accessor$" "$annotate_accessor$"
" // @@protoc_insertion_point(field_mutable:$full_name$)\n" " // @@protoc_insertion_point(field_mutable:$full_name$)\n"
" return _internal_mutable_$name$();\n" " return _internal_mutable_$name$();\n"
"}\n"
"inline const std::string& $classname$::_internal_$name$() const {\n"
" return $name$_.Get();\n"
"}\n"
"inline void $classname$::_internal_set_$name$(const std::string& "
"value) {\n"
" $set_hasbit$\n"
" $name$_.Set$lite$($default_variable$, value, GetArena());\n"
"}\n"
"inline void $classname$::set_$name$(std::string&& value) {\n"
"$annotate_accessor$"
" $set_hasbit$\n"
" $name$_.Set$lite$(\n"
" $default_variable$, ::std::move(value), GetArena());\n"
" // @@protoc_insertion_point(field_set_rvalue:$full_name$)\n"
"}\n"
"inline void $classname$::set_$name$(const char* value) {\n"
"$annotate_accessor$"
" $null_check$"
" $set_hasbit$\n"
" $name$_.Set$lite$($default_variable$, $string_piece$(value),\n"
" GetArena());\n"
" // @@protoc_insertion_point(field_set_char:$full_name$)\n"
"}\n"); "}\n");
if (SupportsArenas(descriptor_)) { if (!options_.opensource_runtime) {
format( format(
"inline const std::string& $classname$::_internal_$name$() const {\n" "inline void $classname$::set_$name$(::StringPiece value) {\n"
" return $name$_.Get();\n"
"}\n"
"inline void $classname$::_internal_set_$name$(const std::string& "
"value) {\n"
" $set_hasbit$\n"
" $name$_.Set$lite$($default_variable$, value, GetArena());\n"
"}\n"
"inline void $classname$::set_$name$(std::string&& value) {\n"
"$annotate_accessor$"
" $set_hasbit$\n"
" $name$_.Set$lite$(\n"
" $default_variable$, ::std::move(value), GetArena());\n"
" // @@protoc_insertion_point(field_set_rvalue:$full_name$)\n"
"}\n"
"inline void $classname$::set_$name$(const char* value) {\n"
"$annotate_accessor$" "$annotate_accessor$"
" $null_check$"
" $set_hasbit$\n" " $set_hasbit$\n"
" $name$_.Set$lite$($default_variable$, $string_piece$(value),\n" " $name$_.Set$lite$($default_variable$, value,GetArena());\n"
" GetArena());\n" " // @@protoc_insertion_point(field_set_string_piece:$full_name$)\n"
" // @@protoc_insertion_point(field_set_char:$full_name$)\n"
"}\n"); "}\n");
if (!options_.opensource_runtime) { }
format( format(
"inline void $classname$::set_$name$(::StringPiece value) {\n" "inline "
"$annotate_accessor$" "void $classname$::set_$name$(const $pointer_type$* value,\n"
" $set_hasbit$\n" " size_t size) {\n"
" $name$_.Set$lite$($default_variable$, value,GetArena());\n" "$annotate_accessor$"
" // @@protoc_insertion_point(field_set_string_piece:$full_name$)\n" " $set_hasbit$\n"
"}\n"); " $name$_.Set$lite$($default_variable$, $string_piece$(\n"
} " reinterpret_cast<const char*>(value), size), GetArena());\n"
format( " // @@protoc_insertion_point(field_set_pointer:$full_name$)\n"
"inline " "}\n"
"void $classname$::set_$name$(const $pointer_type$* value,\n" "inline std::string* $classname$::_internal_mutable_$name$() {\n"
" size_t size) {\n" " $set_hasbit$\n"
"$annotate_accessor$" " return $name$_.Mutable($default_variable$, GetArena());\n"
" $set_hasbit$\n" "}\n"
" $name$_.Set$lite$($default_variable$, $string_piece$(\n" "inline std::string* $classname$::$release_name$() {\n"
" reinterpret_cast<const char*>(value), size), GetArena());\n" "$annotate_accessor$"
" // @@protoc_insertion_point(field_set_pointer:$full_name$)\n" " // @@protoc_insertion_point(field_release:$full_name$)\n");
"}\n"
"inline std::string* $classname$::_internal_mutable_$name$() {\n"
" $set_hasbit$\n"
" return $name$_.Mutable($default_variable$, GetArena());\n"
"}\n"
"inline std::string* $classname$::$release_name$() {\n"
"$annotate_accessor$"
" // @@protoc_insertion_point(field_release:$full_name$)\n");
if (HasHasbit(descriptor_)) {
format(
" if (!_internal_has_$name$()) {\n"
" return nullptr;\n"
" }\n"
" $clear_hasbit$\n"
" return $name$_.ReleaseNonDefault("
"$default_variable$, GetArena());\n");
} else {
format(
" return $name$_.Release($default_variable$, GetArena());\n");
}
if (HasHasbit(descriptor_)) {
format( format(
"}\n" " if (!_internal_has_$name$()) {\n"
"inline void $classname$::set_allocated_$name$(std::string* $name$) {\n" " return nullptr;\n"
"$annotate_accessor$"
" if ($name$ != nullptr) {\n"
" $set_hasbit$\n"
" } else {\n"
" $clear_hasbit$\n"
" }\n" " }\n"
" $name$_.SetAllocated($default_variable$, $name$,\n" " $clear_hasbit$\n"
" GetArena());\n" " return $name$_.ReleaseNonDefault("
" // @@protoc_insertion_point(field_set_allocated:$full_name$)\n" "$default_variable$, GetArena());\n");
"}\n");
} else { } else {
// No-arena case. format(" return $name$_.Release($default_variable$, GetArena());\n");
format(
"inline const std::string& $classname$::_internal_$name$() const {\n"
" return $name$_.GetNoArena();\n"
"}\n"
"inline void $classname$::_internal_set_$name$(const std::string& "
"value) {\n"
" $set_hasbit$\n"
" $name$_.SetNoArena($default_variable$, value);\n"
"}\n"
"inline void $classname$::set_$name$(std::string&& value) {\n"
"$annotate_accessor$"
" $set_hasbit$\n"
" $name$_.SetNoArena(\n"
" $default_variable$, ::std::move(value));\n"
" // @@protoc_insertion_point(field_set_rvalue:$full_name$)\n"
"}\n"
"inline void $classname$::set_$name$(const char* value) {\n"
"$annotate_accessor$"
" $null_check$"
" $set_hasbit$\n"
" $name$_.SetNoArena($default_variable$, $string_piece$(value));\n"
" // @@protoc_insertion_point(field_set_char:$full_name$)\n"
"}\n");
if (!options_.opensource_runtime) {
format(
"inline void $classname$::set_$name$(::StringPiece value) {\n"
"$annotate_accessor$"
" $set_hasbit$\n"
" $name$_.SetNoArena($default_variable$, value);\n"
" // @@protoc_insertion_point(field_set_string_piece:$full_name$)\n"
"}\n");
}
format(
"inline "
"void $classname$::set_$name$(const $pointer_type$* value, "
"size_t size) {\n"
"$annotate_accessor$"
" $set_hasbit$\n"
" $name$_.SetNoArena($default_variable$,\n"
" $string_piece$(reinterpret_cast<const char*>(value), size));\n"
" // @@protoc_insertion_point(field_set_pointer:$full_name$)\n"
"}\n"
"inline std::string* $classname$::_internal_mutable_$name$() {\n"
" $set_hasbit$\n"
" return $name$_.MutableNoArena($default_variable$);\n"
"}\n"
"inline std::string* $classname$::$release_name$() {\n"
"$annotate_accessor$"
" // @@protoc_insertion_point(field_release:$full_name$)\n");
if (HasHasbit(descriptor_)) {
format(
" if (!_internal_has_$name$()) {\n"
" return nullptr;\n"
" }\n"
" $clear_hasbit$\n"
" return $name$_.ReleaseNonDefaultNoArena($default_variable$);\n");
} else {
format(
" $clear_hasbit$\n"
" return $name$_.ReleaseNoArena($default_variable$);\n");
}
format(
"}\n"
"inline void $classname$::set_allocated_$name$(std::string* $name$) {\n"
"$annotate_accessor$"
" if ($name$ != nullptr) {\n"
" $set_hasbit$\n"
" } else {\n"
" $clear_hasbit$\n"
" }\n"
" $name$_.SetAllocatedNoArena($default_variable$, $name$);\n"
" // @@protoc_insertion_point(field_set_allocated:$full_name$)\n"
"}\n");
} }
format(
"}\n"
"inline void $classname$::set_allocated_$name$(std::string* $name$) {\n"
"$annotate_accessor$"
" if ($name$ != nullptr) {\n"
" $set_hasbit$\n"
" } else {\n"
" $clear_hasbit$\n"
" }\n"
" $name$_.SetAllocated($default_variable$, $name$,\n"
" GetArena());\n"
" // @@protoc_insertion_point(field_set_allocated:$full_name$)\n"
"}\n");
} }
void StringFieldGenerator::GenerateNonInlineAccessorDefinitions( void StringFieldGenerator::GenerateNonInlineAccessorDefinitions(
@ -387,18 +294,10 @@ void StringFieldGenerator::GenerateClearingCode(io::Printer* printer) const {
// value is the empty string or not. Complexity here ensures the minimal // value is the empty string or not. Complexity here ensures the minimal
// number of branches / amount of extraneous code at runtime (given that the // number of branches / amount of extraneous code at runtime (given that the
// below methods are inlined one-liners)! // below methods are inlined one-liners)!
if (SupportsArenas(descriptor_)) { if (descriptor_->default_value_string().empty()) {
if (descriptor_->default_value_string().empty()) { format("$name$_.ClearToEmpty($default_variable$, GetArena());\n");
format("$name$_.ClearToEmpty($default_variable$, GetArena());\n");
} else {
format("$name$_.ClearToDefault($default_variable$, GetArena());\n");
}
} else { } else {
if (descriptor_->default_value_string().empty()) { format("$name$_.ClearToDefault($default_variable$, GetArena());\n");
format("$name$_.ClearToEmptyNoArena($default_variable$);\n");
} else {
format("$name$_.ClearToDefaultNoArena($default_variable$);\n");
}
} }
} }
@ -427,45 +326,23 @@ void StringFieldGenerator::GenerateMessageClearingCode(
format("$DCHK$(!$name$_.IsDefault($default_variable$));\n"); format("$DCHK$(!$name$_.IsDefault($default_variable$));\n");
} }
if (SupportsArenas(descriptor_)) { if (descriptor_->default_value_string().empty()) {
if (descriptor_->default_value_string().empty()) { if (must_be_present) {
if (must_be_present) { format("$name$_.ClearNonDefaultToEmpty();\n");
format("$name$_.ClearNonDefaultToEmpty();\n");
} else {
format("$name$_.ClearToEmpty($default_variable$, GetArena());\n");
}
} else {
// Clear to a non-empty default is more involved, as we try to use the
// Arena if one is present and may need to reallocate the string.
format("$name$_.ClearToDefault($default_variable$, GetArena());\n");
}
} else if (must_be_present) {
// When Arenas are disabled and field presence has been checked, we can
// safely treat the ArenaStringPtr as a string*.
if (descriptor_->default_value_string().empty()) {
format("$name$_.ClearNonDefaultToEmptyNoArena();\n");
} else { } else {
format("$name$_.UnsafeMutablePointer()->assign(*$default_variable$);\n"); format("$name$_.ClearToEmpty($default_variable$, GetArena());\n");
} }
} else { } else {
if (descriptor_->default_value_string().empty()) { // Clear to a non-empty default is more involved, as we try to use the
format("$name$_.ClearToEmptyNoArena($default_variable$);\n"); // Arena if one is present and may need to reallocate the string.
} else { format("$name$_.ClearToDefault($default_variable$, GetArena());\n");
format("$name$_.ClearToDefaultNoArena($default_variable$);\n");
}
} }
} }
void StringFieldGenerator::GenerateMergingCode(io::Printer* printer) const { void StringFieldGenerator::GenerateMergingCode(io::Printer* printer) const {
Formatter format(printer, variables_); Formatter format(printer, variables_);
if (SupportsArenas(descriptor_) || descriptor_->real_containing_oneof()) { // TODO(gpike): improve this
// TODO(gpike): improve this format("_internal_set_$name$(from._internal_$name$());\n");
format("_internal_set_$name$(from._internal_$name$());\n");
} else {
format(
"$set_hasbit$\n"
"$name$_.AssignWithDefault($default_variable$, from.$name$_);\n");
}
} }
void StringFieldGenerator::GenerateSwappingCode(io::Printer* printer) const { void StringFieldGenerator::GenerateSwappingCode(io::Printer* printer) const {
@ -502,14 +379,10 @@ void StringFieldGenerator::GenerateCopyConstructorCode(
format.Indent(); format.Indent();
if (SupportsArenas(descriptor_) || descriptor_->real_containing_oneof()) { // TODO(gpike): improve this
// TODO(gpike): improve this format(
format( "$name$_.Set$lite$($default_variable$, from._internal_$name$(),\n"
"$name$_.Set$lite$($default_variable$, from._internal_$name$(),\n" " GetArena());\n");
" GetArena());\n");
} else {
format("$name$_.AssignWithDefault($default_variable$, from.$name$_);\n");
}
format.Outdent(); format.Outdent();
format("}\n"); format("}\n");
@ -613,219 +486,115 @@ void StringOneofFieldGenerator::GenerateInlineAccessorDefinitions(
"$annotate_accessor$" "$annotate_accessor$"
" // @@protoc_insertion_point(field_mutable:$full_name$)\n" " // @@protoc_insertion_point(field_mutable:$full_name$)\n"
" return _internal_mutable_$name$();\n" " return _internal_mutable_$name$();\n"
"}\n"
"inline const std::string& $classname$::_internal_$name$() const {\n"
" if (_internal_has_$name$()) {\n"
" return $field_member$.Get();\n"
" }\n"
" return *$default_variable$;\n"
"}\n"
"inline void $classname$::_internal_set_$name$(const std::string& "
"value) {\n"
" if (!_internal_has_$name$()) {\n"
" clear_$oneof_name$();\n"
" set_has_$name$();\n"
" $field_member$.UnsafeSetDefault($default_variable$);\n"
" }\n"
" $field_member$.Set$lite$($default_variable$, value, GetArena());\n"
"}\n"
"inline void $classname$::set_$name$(std::string&& value) {\n"
"$annotate_accessor$"
" // @@protoc_insertion_point(field_set:$full_name$)\n"
" if (!_internal_has_$name$()) {\n"
" clear_$oneof_name$();\n"
" set_has_$name$();\n"
" $field_member$.UnsafeSetDefault($default_variable$);\n"
" }\n"
" $field_member$.Set$lite$(\n"
" $default_variable$, ::std::move(value), GetArena());\n"
" // @@protoc_insertion_point(field_set_rvalue:$full_name$)\n"
"}\n"
"inline void $classname$::set_$name$(const char* value) {\n"
"$annotate_accessor$"
" $null_check$"
" if (!_internal_has_$name$()) {\n"
" clear_$oneof_name$();\n"
" set_has_$name$();\n"
" $field_member$.UnsafeSetDefault($default_variable$);\n"
" }\n"
" $field_member$.Set$lite$($default_variable$,\n"
" $string_piece$(value), GetArena());\n"
" // @@protoc_insertion_point(field_set_char:$full_name$)\n"
"}\n"); "}\n");
if (SupportsArenas(descriptor_)) { if (!options_.opensource_runtime) {
format(
"inline const std::string& $classname$::_internal_$name$() const {\n"
" if (_internal_has_$name$()) {\n"
" return $field_member$.Get();\n"
" }\n"
" return *$default_variable$;\n"
"}\n"
"inline void $classname$::_internal_set_$name$(const std::string& "
"value) {\n"
" if (!_internal_has_$name$()) {\n"
" clear_$oneof_name$();\n"
" set_has_$name$();\n"
" $field_member$.UnsafeSetDefault($default_variable$);\n"
" }\n"
" $field_member$.Set$lite$($default_variable$, value, GetArena());\n"
"}\n"
"inline void $classname$::set_$name$(std::string&& value) {\n"
"$annotate_accessor$"
" // @@protoc_insertion_point(field_set:$full_name$)\n"
" if (!_internal_has_$name$()) {\n"
" clear_$oneof_name$();\n"
" set_has_$name$();\n"
" $field_member$.UnsafeSetDefault($default_variable$);\n"
" }\n"
" $field_member$.Set$lite$(\n"
" $default_variable$, ::std::move(value), GetArena());\n"
" // @@protoc_insertion_point(field_set_rvalue:$full_name$)\n"
"}\n"
"inline void $classname$::set_$name$(const char* value) {\n"
"$annotate_accessor$"
" $null_check$"
" if (!_internal_has_$name$()) {\n"
" clear_$oneof_name$();\n"
" set_has_$name$();\n"
" $field_member$.UnsafeSetDefault($default_variable$);\n"
" }\n"
" $field_member$.Set$lite$($default_variable$,\n"
" $string_piece$(value), GetArena());\n"
" // @@protoc_insertion_point(field_set_char:$full_name$)\n"
"}\n");
if (!options_.opensource_runtime) {
format(
"inline void $classname$::set_$name$(::StringPiece value) {\n"
"$annotate_accessor$"
" if (!_internal_has_$name$()) {\n"
" clear_$oneof_name$();\n"
" set_has_$name$();\n"
" $field_member$.UnsafeSetDefault($default_variable$);\n"
" }\n"
" $field_member$.Set$lite$($default_variable$, value,\n"
" GetArena());\n"
" // @@protoc_insertion_point(field_set_string_piece:$full_name$)\n"
"}\n");
}
format( format(
"inline " "inline void $classname$::set_$name$(::StringPiece value) {\n"
"void $classname$::set_$name$(const $pointer_type$* value,\n"
" size_t size) {\n"
"$annotate_accessor$" "$annotate_accessor$"
" if (!_internal_has_$name$()) {\n" " if (!_internal_has_$name$()) {\n"
" clear_$oneof_name$();\n" " clear_$oneof_name$();\n"
" set_has_$name$();\n" " set_has_$name$();\n"
" $field_member$.UnsafeSetDefault($default_variable$);\n" " $field_member$.UnsafeSetDefault($default_variable$);\n"
" }\n" " }\n"
" $field_member$.Set$lite$(\n" " $field_member$.Set$lite$($default_variable$, value,\n"
" $default_variable$, $string_piece$(\n"
" reinterpret_cast<const char*>(value), size),\n"
" GetArena());\n" " GetArena());\n"
" // @@protoc_insertion_point(field_set_pointer:$full_name$)\n" " // @@protoc_insertion_point(field_set_string_piece:$full_name$)\n"
"}\n"
"inline std::string* $classname$::_internal_mutable_$name$() {\n"
" if (!_internal_has_$name$()) {\n"
" clear_$oneof_name$();\n"
" set_has_$name$();\n"
" $field_member$.UnsafeSetDefault($default_variable$);\n"
" }\n"
" return $field_member$.Mutable($default_variable$, GetArena());\n"
"}\n"
"inline std::string* $classname$::$release_name$() {\n"
"$annotate_accessor$"
" // @@protoc_insertion_point(field_release:$full_name$)\n"
" if (_internal_has_$name$()) {\n"
" clear_has_$oneof_name$();\n"
" return $field_member$.Release($default_variable$, GetArena());\n"
" } else {\n"
" return nullptr;\n"
" }\n"
"}\n"
"inline void $classname$::set_allocated_$name$(std::string* $name$) {\n"
"$annotate_accessor$"
" if (has_$oneof_name$()) {\n"
" clear_$oneof_name$();\n"
" }\n"
" if ($name$ != nullptr) {\n"
" set_has_$name$();\n"
" $field_member$.UnsafeSetDefault($name$);\n"
" ::$proto_ns$::Arena* arena = GetArena();\n"
" if (arena != nullptr) {\n"
" arena->Own($name$);\n"
" }\n"
" }\n"
" // @@protoc_insertion_point(field_set_allocated:$full_name$)\n"
"}\n");
} else {
// No-arena case.
format(
"inline const std::string& $classname$::_internal_$name$() const {\n"
" if (_internal_has_$name$()) {\n"
" return $field_member$.GetNoArena();\n"
" }\n"
" return *$default_variable$;\n"
"}\n"
"inline void $classname$::_internal_set_$name$(const std::string& "
"value) {\n"
" if (!_internal_has_$name$()) {\n"
" clear_$oneof_name$();\n"
" set_has_$name$();\n"
" $field_member$.UnsafeSetDefault($default_variable$);\n"
" }\n"
" $field_member$.SetNoArena($default_variable$, value);\n"
"}\n"
"inline void $classname$::set_$name$(std::string&& value) {\n"
"$annotate_accessor$"
" // @@protoc_insertion_point(field_set:$full_name$)\n"
" if (!_internal_has_$name$()) {\n"
" clear_$oneof_name$();\n"
" set_has_$name$();\n"
" $field_member$.UnsafeSetDefault($default_variable$);\n"
" }\n"
" $field_member$.SetNoArena($default_variable$, ::std::move(value));\n"
" // @@protoc_insertion_point(field_set_rvalue:$full_name$)\n"
"}\n"
"inline void $classname$::set_$name$(const char* value) {\n"
"$annotate_accessor$"
" $null_check$"
" if (!_internal_has_$name$()) {\n"
" clear_$oneof_name$();\n"
" set_has_$name$();\n"
" $field_member$.UnsafeSetDefault($default_variable$);\n"
" }\n"
" $field_member$.SetNoArena($default_variable$,\n"
" $string_piece$(value));\n"
" // @@protoc_insertion_point(field_set_char:$full_name$)\n"
"}\n");
if (!options_.opensource_runtime) {
format(
"inline void $classname$::set_$name$(::StringPiece value) {\n"
"$annotate_accessor$"
" if (!_internal_has_$name$()) {\n"
" clear_$oneof_name$();\n"
" set_has_$name$();\n"
" $field_member$.UnsafeSetDefault($default_variable$);\n"
" }\n"
" $field_member$.SetNoArena($default_variable$, value);\n"
" // @@protoc_insertion_point(field_set_string_piece:$full_name$)\n"
"}\n");
}
format(
"inline "
"void $classname$::set_$name$(const $pointer_type$* value, size_t "
"size) {\n"
"$annotate_accessor$"
" if (!_internal_has_$name$()) {\n"
" clear_$oneof_name$();\n"
" set_has_$name$();\n"
" $field_member$.UnsafeSetDefault($default_variable$);\n"
" }\n"
" $field_member$.SetNoArena($default_variable$, $string_piece$(\n"
" reinterpret_cast<const char*>(value), size));\n"
" // @@protoc_insertion_point(field_set_pointer:$full_name$)\n"
"}\n"
"inline std::string* $classname$::_internal_mutable_$name$() {\n"
" if (!_internal_has_$name$()) {\n"
" clear_$oneof_name$();\n"
" set_has_$name$();\n"
" $field_member$.UnsafeSetDefault($default_variable$);\n"
" }\n"
" return $field_member$.MutableNoArena($default_variable$);\n"
"}\n"
"inline std::string* $classname$::$release_name$() {\n"
"$annotate_accessor$"
" // @@protoc_insertion_point(field_release:$full_name$)\n"
" if (_internal_has_$name$()) {\n"
" clear_has_$oneof_name$();\n"
" return $field_member$.ReleaseNoArena($default_variable$);\n"
" } else {\n"
" return nullptr;\n"
" }\n"
"}\n"
"inline void $classname$::set_allocated_$name$(std::string* $name$) {\n"
"$annotate_accessor$"
" if (has_$oneof_name$()) {\n"
" clear_$oneof_name$();\n"
" }\n"
" if ($name$ != nullptr) {\n"
" set_has_$name$();\n"
" $field_member$.UnsafeSetDefault($name$);\n"
" }\n"
" // @@protoc_insertion_point(field_set_allocated:$full_name$)\n"
"}\n"); "}\n");
} }
format(
"inline "
"void $classname$::set_$name$(const $pointer_type$* value,\n"
" size_t size) {\n"
"$annotate_accessor$"
" if (!_internal_has_$name$()) {\n"
" clear_$oneof_name$();\n"
" set_has_$name$();\n"
" $field_member$.UnsafeSetDefault($default_variable$);\n"
" }\n"
" $field_member$.Set$lite$(\n"
" $default_variable$, $string_piece$(\n"
" reinterpret_cast<const char*>(value), size),\n"
" GetArena());\n"
" // @@protoc_insertion_point(field_set_pointer:$full_name$)\n"
"}\n"
"inline std::string* $classname$::_internal_mutable_$name$() {\n"
" if (!_internal_has_$name$()) {\n"
" clear_$oneof_name$();\n"
" set_has_$name$();\n"
" $field_member$.UnsafeSetDefault($default_variable$);\n"
" }\n"
" return $field_member$.Mutable($default_variable$, GetArena());\n"
"}\n"
"inline std::string* $classname$::$release_name$() {\n"
"$annotate_accessor$"
" // @@protoc_insertion_point(field_release:$full_name$)\n"
" if (_internal_has_$name$()) {\n"
" clear_has_$oneof_name$();\n"
" return $field_member$.Release($default_variable$, GetArena());\n"
" } else {\n"
" return nullptr;\n"
" }\n"
"}\n"
"inline void $classname$::set_allocated_$name$(std::string* $name$) {\n"
"$annotate_accessor$"
" if (has_$oneof_name$()) {\n"
" clear_$oneof_name$();\n"
" }\n"
" if ($name$ != nullptr) {\n"
" set_has_$name$();\n"
" $field_member$.UnsafeSetDefault($name$);\n"
" ::$proto_ns$::Arena* arena = GetArena();\n"
" if (arena != nullptr) {\n"
" arena->Own($name$);\n"
" }\n"
" }\n"
" // @@protoc_insertion_point(field_set_allocated:$full_name$)\n"
"}\n");
} }
void StringOneofFieldGenerator::GenerateClearingCode( void StringOneofFieldGenerator::GenerateClearingCode(
io::Printer* printer) const { io::Printer* printer) const {
Formatter format(printer, variables_); Formatter format(printer, variables_);
if (SupportsArenas(descriptor_)) { format("$field_member$.Destroy($default_variable$, GetArena());\n");
format("$field_member$.Destroy($default_variable$, GetArena());\n");
} else {
format("$field_member$.DestroyNoArena($default_variable$);\n");
}
} }
void StringOneofFieldGenerator::GenerateMessageClearingCode( void StringOneofFieldGenerator::GenerateMessageClearingCode(

@ -495,7 +495,7 @@ io::ZeroCopyInputStream* DiskSourceTree::OpenDiskFile(
do { do {
ret = stat(filename.c_str(), &sb); ret = stat(filename.c_str(), &sb);
} while (ret != 0 && errno == EINTR); } while (ret != 0 && errno == EINTR);
if (sb.st_mode & S_IFDIR) { if (ret == 0 && sb.st_mode & S_IFDIR) {
last_error_message_ = "Input file is a directory."; last_error_message_ = "Input file is a directory.";
return NULL; return NULL;
} }

@ -2689,8 +2689,7 @@ void Generator::GenerateClassField(const GeneratorOptions& options,
"\n" "\n"
"\n", "\n",
"index", JSFieldIndex(field), "oneofgroup", "index", JSFieldIndex(field), "oneofgroup",
(InRealOneof(field) ? (", " + JSOneofArray(options, field)) (InRealOneof(field) ? (", " + JSOneofArray(options, field)) : ""));
: ""));
if (field->is_repeated()) { if (field->is_repeated()) {
GenerateRepeatedMessageHelperMethods(options, printer, field); GenerateRepeatedMessageHelperMethods(options, printer, field);
@ -2995,8 +2994,8 @@ void Generator::GenerateRepeatedMessageHelperMethods(
"\n" "\n"
"\n", "\n",
"index", JSFieldIndex(field), "oneofgroup", "index", JSFieldIndex(field), "oneofgroup",
(InRealOneof(field) ? (", " + JSOneofArray(options, field)) : ""), (InRealOneof(field) ? (", " + JSOneofArray(options, field)) : ""), "ctor",
"ctor", GetMessagePath(options, field->message_type())); GetMessagePath(options, field->message_type()));
} }
void Generator::GenerateClassExtensionFieldInfo(const GeneratorOptions& options, void Generator::GenerateClassExtensionFieldInfo(const GeneratorOptions& options,

@ -166,17 +166,36 @@ void MockCodeGenerator::CheckGeneratedAnnotations(
&file_content, true)); &file_content, true));
std::string meta_content; std::string meta_content;
GOOGLE_CHECK_OK(File::GetContents( GOOGLE_CHECK_OK(File::GetContents(
output_directory + "/" + GetOutputFileName(name, file) + ".meta", output_directory + "/" + GetOutputFileName(name, file) + ".pb.meta",
&meta_content, true)); &meta_content, true));
GeneratedCodeInfo annotations; GeneratedCodeInfo annotations;
GOOGLE_CHECK(TextFormat::ParseFromString(meta_content, &annotations)); GOOGLE_CHECK(TextFormat::ParseFromString(meta_content, &annotations));
ASSERT_EQ(3, annotations.annotation_size()); ASSERT_EQ(7, annotations.annotation_size());
CheckSingleAnnotation("first_annotation", "first", file_content, CheckSingleAnnotation("first_annotation", "first", file_content,
annotations.annotation(0)); annotations.annotation(0));
CheckSingleAnnotation("first_path",
"test_generator: first_insert,\n foo.proto,\n "
"MockCodeGenerator_Annotate,\n foo.proto\n",
file_content, annotations.annotation(1));
CheckSingleAnnotation("first_path",
"test_plugin: first_insert,\n foo.proto,\n "
"MockCodeGenerator_Annotate,\n foo.proto\n",
file_content, annotations.annotation(2));
CheckSingleAnnotation("second_annotation", "second", file_content, CheckSingleAnnotation("second_annotation", "second", file_content,
annotations.annotation(1)); annotations.annotation(3));
// This annotated text has changed because it was inserted at an indented
// insertion point.
CheckSingleAnnotation("second_path",
"test_generator: second_insert,\n foo.proto,\n "
"MockCodeGenerator_Annotate,\n foo.proto\n",
file_content, annotations.annotation(4));
CheckSingleAnnotation("second_path",
"test_plugin: second_insert,\n foo.proto,\n "
"MockCodeGenerator_Annotate,\n foo.proto\n",
file_content, annotations.annotation(5));
CheckSingleAnnotation("third_annotation", "third", file_content, CheckSingleAnnotation("third_annotation", "third", file_content,
annotations.annotation(2)); annotations.annotation(6));
} }
bool MockCodeGenerator::Generate(const FileDescriptor* file, bool MockCodeGenerator::Generate(const FileDescriptor* file,
@ -229,18 +248,35 @@ bool MockCodeGenerator::Generate(const FileDescriptor* file,
} }
} }
if (HasPrefixString(parameter, "insert=")) { bool insert_endlines = HasPrefixString(parameter, "insert_endlines=");
if (insert_endlines || HasPrefixString(parameter, "insert=")) {
std::vector<std::string> insert_into; std::vector<std::string> insert_into;
SplitStringUsing(StripPrefixString(parameter, "insert="), ",",
&insert_into); SplitStringUsing(
StripPrefixString(
parameter, insert_endlines ? "insert_endlines=" : "insert="),
",", &insert_into);
for (size_t i = 0; i < insert_into.size(); i++) { for (size_t i = 0; i < insert_into.size(); i++) {
{ {
std::unique_ptr<io::ZeroCopyOutputStream> output(context->OpenForInsert( google::protobuf::GeneratedCodeInfo info;
GetOutputFileName(insert_into[i], file), kFirstInsertionPointName)); std::string content =
GetOutputFileContent(name_, "first_insert", file, context);
if (insert_endlines) {
GlobalReplaceSubstring(",", ",\n", &content);
}
if (annotate) {
auto* annotation = info.add_annotation();
annotation->set_begin(0);
annotation->set_end(content.size());
annotation->set_source_file("first_path");
}
std::unique_ptr<io::ZeroCopyOutputStream> output(
context->OpenForInsertWithGeneratedCodeInfo(
GetOutputFileName(insert_into[i], file),
kFirstInsertionPointName, info));
io::Printer printer(output.get(), '$'); io::Printer printer(output.get(), '$');
printer.PrintRaw( printer.PrintRaw(content);
GetOutputFileContent(name_, "first_insert", file, context));
if (printer.failed()) { if (printer.failed()) {
*error = "MockCodeGenerator detected write error."; *error = "MockCodeGenerator detected write error.";
return false; return false;
@ -248,12 +284,24 @@ bool MockCodeGenerator::Generate(const FileDescriptor* file,
} }
{ {
google::protobuf::GeneratedCodeInfo info;
std::string content =
GetOutputFileContent(name_, "second_insert", file, context);
if (insert_endlines) {
GlobalReplaceSubstring(",", ",\n", &content);
}
if (annotate) {
auto* annotation = info.add_annotation();
annotation->set_begin(0);
annotation->set_end(content.size());
annotation->set_source_file("second_path");
}
std::unique_ptr<io::ZeroCopyOutputStream> output( std::unique_ptr<io::ZeroCopyOutputStream> output(
context->OpenForInsert(GetOutputFileName(insert_into[i], file), context->OpenForInsertWithGeneratedCodeInfo(
kSecondInsertionPointName)); GetOutputFileName(insert_into[i], file),
kSecondInsertionPointName, info));
io::Printer printer(output.get(), '$'); io::Printer printer(output.get(), '$');
printer.PrintRaw( printer.PrintRaw(content);
GetOutputFileContent(name_, "second_insert", file, context));
if (printer.failed()) { if (printer.failed()) {
*error = "MockCodeGenerator detected write error."; *error = "MockCodeGenerator detected write error.";
return false; return false;
@ -272,17 +320,17 @@ bool MockCodeGenerator::Generate(const FileDescriptor* file,
printer.PrintRaw(GetOutputFileContent(name_, parameter, file, context)); printer.PrintRaw(GetOutputFileContent(name_, parameter, file, context));
std::string annotate_suffix = "_annotation"; std::string annotate_suffix = "_annotation";
if (annotate) { if (annotate) {
printer.Print("$p$", "p", "first"); printer.Print("$p$\n", "p", "first");
printer.Annotate("p", "first" + annotate_suffix); printer.Annotate("p", "first" + annotate_suffix);
} }
printer.PrintRaw(kFirstInsertionPoint); printer.PrintRaw(kFirstInsertionPoint);
if (annotate) { if (annotate) {
printer.Print("$p$", "p", "second"); printer.Print("$p$\n", "p", "second");
printer.Annotate("p", "second" + annotate_suffix); printer.Annotate("p", "second" + annotate_suffix);
} }
printer.PrintRaw(kSecondInsertionPoint); printer.PrintRaw(kSecondInsertionPoint);
if (annotate) { if (annotate) {
printer.Print("$p$", "p", "third"); printer.Print("$p$\n", "p", "third");
printer.Annotate("p", "third" + annotate_suffix); printer.Annotate("p", "third" + annotate_suffix);
} }
@ -292,9 +340,9 @@ bool MockCodeGenerator::Generate(const FileDescriptor* file,
} }
if (annotate) { if (annotate) {
std::unique_ptr<io::ZeroCopyOutputStream> meta_output( std::unique_ptr<io::ZeroCopyOutputStream> meta_output(
context->Open(GetOutputFileName(name_, file) + ".meta")); context->Open(GetOutputFileName(name_, file) + ".pb.meta"));
if (!TextFormat::Print(annotations, meta_output.get())) { if (!TextFormat::Print(annotations, meta_output.get())) {
*error = "MockCodeGenerator couldn't write .meta"; *error = "MockCodeGenerator couldn't write .pb.meta";
return false; return false;
} }
} }

@ -56,7 +56,9 @@ namespace compiler {
// If the parameter is "insert=NAMES", the MockCodeGenerator will insert lines // If the parameter is "insert=NAMES", the MockCodeGenerator will insert lines
// into the files generated by other MockCodeGenerators instead of creating // into the files generated by other MockCodeGenerators instead of creating
// its own file. NAMES is a comma-separated list of the names of those other // its own file. NAMES is a comma-separated list of the names of those other
// MockCodeGenerators. // MockCodeGenerators. If the parameter is "insert_endlines=NAMES", the
// MockCodeGenerator will insert data guaranteed to contain more than one
// endline into the files generated by NAMES.
// //
// MockCodeGenerator will also modify its behavior slightly if the input file // MockCodeGenerator will also modify its behavior slightly if the input file
// contains a message type with one of the following names: // contains a message type with one of the following names:

@ -86,6 +86,16 @@ class GeneratorResponseContext : public GeneratorContext {
return new io::StringOutputStream(file->mutable_content()); return new io::StringOutputStream(file->mutable_content());
} }
virtual io::ZeroCopyOutputStream* OpenForInsertWithGeneratedCodeInfo(
const std::string& filename, const std::string& insertion_point,
const google::protobuf::GeneratedCodeInfo& info) {
CodeGeneratorResponse::File* file = response_->add_file();
file->set_name(filename);
file->set_insertion_point(insertion_point);
*file->mutable_generated_code_info() = info;
return new io::StringOutputStream(file->mutable_content());
}
void ListParsedFiles(std::vector<const FileDescriptor*>* output) { void ListParsedFiles(std::vector<const FileDescriptor*>* output) {
*output = parsed_files_; *output = parsed_files_;
} }

@ -15,7 +15,8 @@
// @@protoc_insertion_point(includes) // @@protoc_insertion_point(includes)
#include <google/protobuf/port_def.inc> #include <google/protobuf/port_def.inc>
extern PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fdescriptor_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<6> scc_info_FileDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto; extern PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fdescriptor_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<6> scc_info_FileDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto;
extern PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fcompiler_2fplugin_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_CodeGeneratorResponse_File_google_2fprotobuf_2fcompiler_2fplugin_2eproto; extern PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fdescriptor_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_GeneratedCodeInfo_google_2fprotobuf_2fdescriptor_2eproto;
extern PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fcompiler_2fplugin_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_CodeGeneratorResponse_File_google_2fprotobuf_2fcompiler_2fplugin_2eproto;
extern PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fcompiler_2fplugin_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_Version_google_2fprotobuf_2fcompiler_2fplugin_2eproto; extern PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fcompiler_2fplugin_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_Version_google_2fprotobuf_2fcompiler_2fplugin_2eproto;
PROTOBUF_NAMESPACE_OPEN PROTOBUF_NAMESPACE_OPEN
namespace compiler { namespace compiler {
@ -45,7 +46,6 @@ static void InitDefaultsscc_info_CodeGeneratorRequest_google_2fprotobuf_2fcompil
new (ptr) PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest(); new (ptr) PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest();
::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
} }
PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest::InitAsDefaultInstance();
} }
PROTOC_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<2> scc_info_CodeGeneratorRequest_google_2fprotobuf_2fcompiler_2fplugin_2eproto = PROTOC_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<2> scc_info_CodeGeneratorRequest_google_2fprotobuf_2fcompiler_2fplugin_2eproto =
@ -61,7 +61,6 @@ static void InitDefaultsscc_info_CodeGeneratorResponse_google_2fprotobuf_2fcompi
new (ptr) PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse(); new (ptr) PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse();
::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
} }
PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse::InitAsDefaultInstance();
} }
PROTOC_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_CodeGeneratorResponse_google_2fprotobuf_2fcompiler_2fplugin_2eproto = PROTOC_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_CodeGeneratorResponse_google_2fprotobuf_2fcompiler_2fplugin_2eproto =
@ -76,11 +75,11 @@ static void InitDefaultsscc_info_CodeGeneratorResponse_File_google_2fprotobuf_2f
new (ptr) PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File(); new (ptr) PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File();
::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
} }
PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File::InitAsDefaultInstance();
} }
PROTOC_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_CodeGeneratorResponse_File_google_2fprotobuf_2fcompiler_2fplugin_2eproto = PROTOC_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_CodeGeneratorResponse_File_google_2fprotobuf_2fcompiler_2fplugin_2eproto =
{{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_CodeGeneratorResponse_File_google_2fprotobuf_2fcompiler_2fplugin_2eproto}, {}}; {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_CodeGeneratorResponse_File_google_2fprotobuf_2fcompiler_2fplugin_2eproto}, {
&scc_info_GeneratedCodeInfo_google_2fprotobuf_2fdescriptor_2eproto.base,}};
static void InitDefaultsscc_info_Version_google_2fprotobuf_2fcompiler_2fplugin_2eproto() { static void InitDefaultsscc_info_Version_google_2fprotobuf_2fcompiler_2fplugin_2eproto() {
GOOGLE_PROTOBUF_VERIFY_VERSION; GOOGLE_PROTOBUF_VERIFY_VERSION;
@ -90,7 +89,6 @@ static void InitDefaultsscc_info_Version_google_2fprotobuf_2fcompiler_2fplugin_2
new (ptr) PROTOBUF_NAMESPACE_ID::compiler::Version(); new (ptr) PROTOBUF_NAMESPACE_ID::compiler::Version();
::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
} }
PROTOBUF_NAMESPACE_ID::compiler::Version::InitAsDefaultInstance();
} }
PROTOC_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_Version_google_2fprotobuf_2fcompiler_2fplugin_2eproto = PROTOC_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_Version_google_2fprotobuf_2fcompiler_2fplugin_2eproto =
@ -135,9 +133,11 @@ const ::PROTOBUF_NAMESPACE_ID::uint32 TableStruct_google_2fprotobuf_2fcompiler_2
PROTOBUF_FIELD_OFFSET(PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File, name_), PROTOBUF_FIELD_OFFSET(PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File, name_),
PROTOBUF_FIELD_OFFSET(PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File, insertion_point_), PROTOBUF_FIELD_OFFSET(PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File, insertion_point_),
PROTOBUF_FIELD_OFFSET(PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File, content_), PROTOBUF_FIELD_OFFSET(PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File, content_),
PROTOBUF_FIELD_OFFSET(PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File, generated_code_info_),
0, 0,
1, 1,
2, 2,
3,
PROTOBUF_FIELD_OFFSET(PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse, _has_bits_), PROTOBUF_FIELD_OFFSET(PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse, _has_bits_),
PROTOBUF_FIELD_OFFSET(PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse, _internal_metadata_), PROTOBUF_FIELD_OFFSET(PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse, _internal_metadata_),
~0u, // no _extensions_ ~0u, // no _extensions_
@ -153,8 +153,8 @@ const ::PROTOBUF_NAMESPACE_ID::uint32 TableStruct_google_2fprotobuf_2fcompiler_2
static const ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { static const ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
{ 0, 9, sizeof(PROTOBUF_NAMESPACE_ID::compiler::Version)}, { 0, 9, sizeof(PROTOBUF_NAMESPACE_ID::compiler::Version)},
{ 13, 22, sizeof(PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest)}, { 13, 22, sizeof(PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest)},
{ 26, 34, sizeof(PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File)}, { 26, 35, sizeof(PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File)},
{ 37, 45, sizeof(PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse)}, { 39, 47, sizeof(PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse)},
}; };
static ::PROTOBUF_NAMESPACE_ID::Message const * const file_default_instances[] = { static ::PROTOBUF_NAMESPACE_ID::Message const * const file_default_instances[] = {
@ -174,16 +174,17 @@ const char descriptor_table_protodef_google_2fprotobuf_2fcompiler_2fplugin_2epro
"\t\0228\n\nproto_file\030\017 \003(\0132$.google.protobuf." "\t\0228\n\nproto_file\030\017 \003(\0132$.google.protobuf."
"FileDescriptorProto\022;\n\020compiler_version\030" "FileDescriptorProto\022;\n\020compiler_version\030"
"\003 \001(\0132!.google.protobuf.compiler.Version" "\003 \001(\0132!.google.protobuf.compiler.Version"
"\"\200\002\n\025CodeGeneratorResponse\022\r\n\005error\030\001 \001(" "\"\301\002\n\025CodeGeneratorResponse\022\r\n\005error\030\001 \001("
"\t\022\032\n\022supported_features\030\002 \001(\004\022B\n\004file\030\017 " "\t\022\032\n\022supported_features\030\002 \001(\004\022B\n\004file\030\017 "
"\003(\01324.google.protobuf.compiler.CodeGener" "\003(\01324.google.protobuf.compiler.CodeGener"
"atorResponse.File\032>\n\004File\022\014\n\004name\030\001 \001(\t\022" "atorResponse.File\032\177\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(" "\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" "\t\022\?\n\023generated_code_info\030\020 \001(\0132\".google."
"E_PROTO3_OPTIONAL\020\001Bg\n\034com.google.protob" "protobuf.GeneratedCodeInfo\"8\n\007Feature\022\020\n"
"uf.compilerB\014PluginProtosZ9github.com/go" "\014FEATURE_NONE\020\000\022\033\n\027FEATURE_PROTO3_OPTION"
"lang/protobuf/protoc-gen-go/plugin;plugi" "AL\020\001BW\n\034com.google.protobuf.compilerB\014Pl"
"n_go" "uginProtosZ)google.golang.org/protobuf/t"
"ypes/pluginpb"
; ;
static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_deps[1] = { static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_deps[1] = {
&::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto, &::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto,
@ -196,7 +197,7 @@ static ::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase*const descriptor_table_goo
}; };
static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once; 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 = { 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", 773,
&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, &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, 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, 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,
@ -230,8 +231,6 @@ constexpr int CodeGeneratorResponse::Feature_ARRAYSIZE;
// =================================================================== // ===================================================================
void Version::InitAsDefaultInstance() {
}
class Version::_Internal { class Version::_Internal {
public: public:
using HasBits = decltype(std::declval<Version>()._has_bits_); using HasBits = decltype(std::declval<Version>()._has_bits_);
@ -559,10 +558,6 @@ void Version::InternalSwap(Version* other) {
// =================================================================== // ===================================================================
void CodeGeneratorRequest::InitAsDefaultInstance() {
PROTOBUF_NAMESPACE_ID::compiler::_CodeGeneratorRequest_default_instance_._instance.get_mutable()->compiler_version_ = const_cast< PROTOBUF_NAMESPACE_ID::compiler::Version*>(
PROTOBUF_NAMESPACE_ID::compiler::Version::internal_default_instance());
}
class CodeGeneratorRequest::_Internal { class CodeGeneratorRequest::_Internal {
public: public:
using HasBits = decltype(std::declval<CodeGeneratorRequest>()._has_bits_); using HasBits = decltype(std::declval<CodeGeneratorRequest>()._has_bits_);
@ -913,8 +908,6 @@ void CodeGeneratorRequest::InternalSwap(CodeGeneratorRequest* other) {
// =================================================================== // ===================================================================
void CodeGeneratorResponse_File::InitAsDefaultInstance() {
}
class CodeGeneratorResponse_File::_Internal { class CodeGeneratorResponse_File::_Internal {
public: public:
using HasBits = decltype(std::declval<CodeGeneratorResponse_File>()._has_bits_); using HasBits = decltype(std::declval<CodeGeneratorResponse_File>()._has_bits_);
@ -927,8 +920,20 @@ class CodeGeneratorResponse_File::_Internal {
static void set_has_content(HasBits* has_bits) { static void set_has_content(HasBits* has_bits) {
(*has_bits)[0] |= 4u; (*has_bits)[0] |= 4u;
} }
static const PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo& generated_code_info(const CodeGeneratorResponse_File* msg);
static void set_has_generated_code_info(HasBits* has_bits) {
(*has_bits)[0] |= 8u;
}
}; };
const PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo&
CodeGeneratorResponse_File::_Internal::generated_code_info(const CodeGeneratorResponse_File* msg) {
return *msg->generated_code_info_;
}
void CodeGeneratorResponse_File::clear_generated_code_info() {
if (generated_code_info_ != nullptr) generated_code_info_->Clear();
_has_bits_[0] &= ~0x00000008u;
}
CodeGeneratorResponse_File::CodeGeneratorResponse_File(::PROTOBUF_NAMESPACE_ID::Arena* arena) CodeGeneratorResponse_File::CodeGeneratorResponse_File(::PROTOBUF_NAMESPACE_ID::Arena* arena)
: ::PROTOBUF_NAMESPACE_ID::Message(arena) { : ::PROTOBUF_NAMESPACE_ID::Message(arena) {
SharedCtor(); SharedCtor();
@ -954,6 +959,11 @@ CodeGeneratorResponse_File::CodeGeneratorResponse_File(const CodeGeneratorRespon
content_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_content(), content_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_content(),
GetArena()); GetArena());
} }
if (from._internal_has_generated_code_info()) {
generated_code_info_ = new PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo(*from.generated_code_info_);
} else {
generated_code_info_ = nullptr;
}
// @@protoc_insertion_point(copy_constructor:google.protobuf.compiler.CodeGeneratorResponse.File) // @@protoc_insertion_point(copy_constructor:google.protobuf.compiler.CodeGeneratorResponse.File)
} }
@ -962,6 +972,7 @@ void CodeGeneratorResponse_File::SharedCtor() {
name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
insertion_point_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); insertion_point_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
content_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); content_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
generated_code_info_ = nullptr;
} }
CodeGeneratorResponse_File::~CodeGeneratorResponse_File() { CodeGeneratorResponse_File::~CodeGeneratorResponse_File() {
@ -975,6 +986,7 @@ void CodeGeneratorResponse_File::SharedDtor() {
name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
insertion_point_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); insertion_point_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
content_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); content_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (this != internal_default_instance()) delete generated_code_info_;
} }
void CodeGeneratorResponse_File::ArenaDtor(void* object) { void CodeGeneratorResponse_File::ArenaDtor(void* object) {
@ -999,7 +1011,7 @@ void CodeGeneratorResponse_File::Clear() {
(void) cached_has_bits; (void) cached_has_bits;
cached_has_bits = _has_bits_[0]; cached_has_bits = _has_bits_[0];
if (cached_has_bits & 0x00000007u) { if (cached_has_bits & 0x0000000fu) {
if (cached_has_bits & 0x00000001u) { if (cached_has_bits & 0x00000001u) {
name_.ClearNonDefaultToEmpty(); name_.ClearNonDefaultToEmpty();
} }
@ -1009,6 +1021,10 @@ void CodeGeneratorResponse_File::Clear() {
if (cached_has_bits & 0x00000004u) { if (cached_has_bits & 0x00000004u) {
content_.ClearNonDefaultToEmpty(); content_.ClearNonDefaultToEmpty();
} }
if (cached_has_bits & 0x00000008u) {
GOOGLE_DCHECK(generated_code_info_ != nullptr);
generated_code_info_->Clear();
}
} }
_has_bits_.Clear(); _has_bits_.Clear();
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
@ -1056,6 +1072,13 @@ const char* CodeGeneratorResponse_File::_InternalParse(const char* ptr, ::PROTOB
CHK_(ptr); CHK_(ptr);
} else goto handle_unusual; } else goto handle_unusual;
continue; continue;
// optional .google.protobuf.GeneratedCodeInfo generated_code_info = 16;
case 16:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 130)) {
ptr = ctx->ParseMessage(_internal_mutable_generated_code_info(), ptr);
CHK_(ptr);
} else goto handle_unusual;
continue;
default: { default: {
handle_unusual: handle_unusual:
if ((tag & 7) == 4 || tag == 0) { if ((tag & 7) == 4 || tag == 0) {
@ -1116,6 +1139,14 @@ failure:
15, this->_internal_content(), target); 15, this->_internal_content(), target);
} }
// optional .google.protobuf.GeneratedCodeInfo generated_code_info = 16;
if (cached_has_bits & 0x00000008u) {
target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
InternalWriteMessage(
16, _Internal::generated_code_info(this), target, stream);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
_internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream);
@ -1133,7 +1164,7 @@ size_t CodeGeneratorResponse_File::ByteSizeLong() const {
(void) cached_has_bits; (void) cached_has_bits;
cached_has_bits = _has_bits_[0]; cached_has_bits = _has_bits_[0];
if (cached_has_bits & 0x00000007u) { if (cached_has_bits & 0x0000000fu) {
// optional string name = 1; // optional string name = 1;
if (cached_has_bits & 0x00000001u) { if (cached_has_bits & 0x00000001u) {
total_size += 1 + total_size += 1 +
@ -1155,6 +1186,13 @@ size_t CodeGeneratorResponse_File::ByteSizeLong() const {
this->_internal_content()); this->_internal_content());
} }
// optional .google.protobuf.GeneratedCodeInfo generated_code_info = 16;
if (cached_has_bits & 0x00000008u) {
total_size += 2 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(
*generated_code_info_);
}
} }
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize(
@ -1188,7 +1226,7 @@ void CodeGeneratorResponse_File::MergeFrom(const CodeGeneratorResponse_File& fro
(void) cached_has_bits; (void) cached_has_bits;
cached_has_bits = from._has_bits_[0]; cached_has_bits = from._has_bits_[0];
if (cached_has_bits & 0x00000007u) { if (cached_has_bits & 0x0000000fu) {
if (cached_has_bits & 0x00000001u) { if (cached_has_bits & 0x00000001u) {
_internal_set_name(from._internal_name()); _internal_set_name(from._internal_name());
} }
@ -1198,6 +1236,9 @@ void CodeGeneratorResponse_File::MergeFrom(const CodeGeneratorResponse_File& fro
if (cached_has_bits & 0x00000004u) { if (cached_has_bits & 0x00000004u) {
_internal_set_content(from._internal_content()); _internal_set_content(from._internal_content());
} }
if (cached_has_bits & 0x00000008u) {
_internal_mutable_generated_code_info()->PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo::MergeFrom(from._internal_generated_code_info());
}
} }
} }
@ -1226,6 +1267,7 @@ void CodeGeneratorResponse_File::InternalSwap(CodeGeneratorResponse_File* other)
name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena());
insertion_point_.Swap(&other->insertion_point_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); insertion_point_.Swap(&other->insertion_point_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena());
content_.Swap(&other->content_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); content_.Swap(&other->content_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena());
swap(generated_code_info_, other->generated_code_info_);
} }
::PROTOBUF_NAMESPACE_ID::Metadata CodeGeneratorResponse_File::GetMetadata() const { ::PROTOBUF_NAMESPACE_ID::Metadata CodeGeneratorResponse_File::GetMetadata() const {
@ -1235,8 +1277,6 @@ void CodeGeneratorResponse_File::InternalSwap(CodeGeneratorResponse_File* other)
// =================================================================== // ===================================================================
void CodeGeneratorResponse::InitAsDefaultInstance() {
}
class CodeGeneratorResponse::_Internal { class CodeGeneratorResponse::_Internal {
public: public:
using HasBits = decltype(std::declval<CodeGeneratorResponse>()._has_bits_); using HasBits = decltype(std::declval<CodeGeneratorResponse>()._has_bits_);

@ -155,7 +155,6 @@ class PROTOC_EXPORT Version PROTOBUF_FINAL :
} }
static const Version& default_instance(); static const Version& default_instance();
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
static inline const Version* internal_default_instance() { static inline const Version* internal_default_instance() {
return reinterpret_cast<const Version*>( return reinterpret_cast<const Version*>(
&_Version_default_instance_); &_Version_default_instance_);
@ -356,7 +355,6 @@ class PROTOC_EXPORT CodeGeneratorRequest PROTOBUF_FINAL :
} }
static const CodeGeneratorRequest& default_instance(); static const CodeGeneratorRequest& default_instance();
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
static inline const CodeGeneratorRequest* internal_default_instance() { static inline const CodeGeneratorRequest* internal_default_instance() {
return reinterpret_cast<const CodeGeneratorRequest*>( return reinterpret_cast<const CodeGeneratorRequest*>(
&_CodeGeneratorRequest_default_instance_); &_CodeGeneratorRequest_default_instance_);
@ -578,7 +576,6 @@ class PROTOC_EXPORT CodeGeneratorResponse_File PROTOBUF_FINAL :
} }
static const CodeGeneratorResponse_File& default_instance(); static const CodeGeneratorResponse_File& default_instance();
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
static inline const CodeGeneratorResponse_File* internal_default_instance() { static inline const CodeGeneratorResponse_File* internal_default_instance() {
return reinterpret_cast<const CodeGeneratorResponse_File*>( return reinterpret_cast<const CodeGeneratorResponse_File*>(
&_CodeGeneratorResponse_File_default_instance_); &_CodeGeneratorResponse_File_default_instance_);
@ -658,6 +655,7 @@ class PROTOC_EXPORT CodeGeneratorResponse_File PROTOBUF_FINAL :
kNameFieldNumber = 1, kNameFieldNumber = 1,
kInsertionPointFieldNumber = 2, kInsertionPointFieldNumber = 2,
kContentFieldNumber = 15, kContentFieldNumber = 15,
kGeneratedCodeInfoFieldNumber = 16,
}; };
// optional string name = 1; // optional string name = 1;
bool has_name() const; bool has_name() const;
@ -719,6 +717,24 @@ class PROTOC_EXPORT CodeGeneratorResponse_File PROTOBUF_FINAL :
std::string* _internal_mutable_content(); std::string* _internal_mutable_content();
public: public:
// optional .google.protobuf.GeneratedCodeInfo generated_code_info = 16;
bool has_generated_code_info() const;
private:
bool _internal_has_generated_code_info() const;
public:
void clear_generated_code_info();
const PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo& generated_code_info() const;
PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* release_generated_code_info();
PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* mutable_generated_code_info();
void set_allocated_generated_code_info(PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* generated_code_info);
private:
const PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo& _internal_generated_code_info() const;
PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* _internal_mutable_generated_code_info();
public:
void unsafe_arena_set_allocated_generated_code_info(
PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* generated_code_info);
PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* unsafe_arena_release_generated_code_info();
// @@protoc_insertion_point(class_scope:google.protobuf.compiler.CodeGeneratorResponse.File) // @@protoc_insertion_point(class_scope:google.protobuf.compiler.CodeGeneratorResponse.File)
private: private:
class _Internal; class _Internal;
@ -731,6 +747,7 @@ class PROTOC_EXPORT CodeGeneratorResponse_File PROTOBUF_FINAL :
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_; ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_;
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr insertion_point_; ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr insertion_point_;
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr content_; ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr content_;
PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* generated_code_info_;
friend struct ::TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto; friend struct ::TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto;
}; };
// ------------------------------------------------------------------- // -------------------------------------------------------------------
@ -778,7 +795,6 @@ class PROTOC_EXPORT CodeGeneratorResponse PROTOBUF_FINAL :
} }
static const CodeGeneratorResponse& default_instance(); static const CodeGeneratorResponse& default_instance();
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
static inline const CodeGeneratorResponse* internal_default_instance() { static inline const CodeGeneratorResponse* internal_default_instance() {
return reinterpret_cast<const CodeGeneratorResponse*>( return reinterpret_cast<const CodeGeneratorResponse*>(
&_CodeGeneratorResponse_default_instance_); &_CodeGeneratorResponse_default_instance_);
@ -1328,8 +1344,8 @@ inline void CodeGeneratorRequest::clear_compiler_version() {
} }
inline const PROTOBUF_NAMESPACE_ID::compiler::Version& CodeGeneratorRequest::_internal_compiler_version() const { inline const PROTOBUF_NAMESPACE_ID::compiler::Version& CodeGeneratorRequest::_internal_compiler_version() const {
const PROTOBUF_NAMESPACE_ID::compiler::Version* p = compiler_version_; const PROTOBUF_NAMESPACE_ID::compiler::Version* p = compiler_version_;
return p != nullptr ? *p : *reinterpret_cast<const PROTOBUF_NAMESPACE_ID::compiler::Version*>( return p != nullptr ? *p : reinterpret_cast<const PROTOBUF_NAMESPACE_ID::compiler::Version&>(
&PROTOBUF_NAMESPACE_ID::compiler::_Version_default_instance_); PROTOBUF_NAMESPACE_ID::compiler::_Version_default_instance_);
} }
inline const PROTOBUF_NAMESPACE_ID::compiler::Version& CodeGeneratorRequest::compiler_version() const { inline const PROTOBUF_NAMESPACE_ID::compiler::Version& CodeGeneratorRequest::compiler_version() const {
// @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorRequest.compiler_version) // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorRequest.compiler_version)
@ -1622,6 +1638,85 @@ inline void CodeGeneratorResponse_File::set_allocated_content(std::string* conte
// @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.content) // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.content)
} }
// optional .google.protobuf.GeneratedCodeInfo generated_code_info = 16;
inline bool CodeGeneratorResponse_File::_internal_has_generated_code_info() const {
bool value = (_has_bits_[0] & 0x00000008u) != 0;
PROTOBUF_ASSUME(!value || generated_code_info_ != nullptr);
return value;
}
inline bool CodeGeneratorResponse_File::has_generated_code_info() const {
return _internal_has_generated_code_info();
}
inline const PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo& CodeGeneratorResponse_File::_internal_generated_code_info() const {
const PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* p = generated_code_info_;
return p != nullptr ? *p : reinterpret_cast<const PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo&>(
PROTOBUF_NAMESPACE_ID::_GeneratedCodeInfo_default_instance_);
}
inline const PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo& CodeGeneratorResponse_File::generated_code_info() const {
// @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.generated_code_info)
return _internal_generated_code_info();
}
inline void CodeGeneratorResponse_File::unsafe_arena_set_allocated_generated_code_info(
PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* generated_code_info) {
if (GetArena() == nullptr) {
delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(generated_code_info_);
}
generated_code_info_ = generated_code_info;
if (generated_code_info) {
_has_bits_[0] |= 0x00000008u;
} else {
_has_bits_[0] &= ~0x00000008u;
}
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.generated_code_info)
}
inline PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* CodeGeneratorResponse_File::release_generated_code_info() {
_has_bits_[0] &= ~0x00000008u;
PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* temp = generated_code_info_;
generated_code_info_ = nullptr;
if (GetArena() != nullptr) {
temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp);
}
return temp;
}
inline PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* CodeGeneratorResponse_File::unsafe_arena_release_generated_code_info() {
// @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.File.generated_code_info)
_has_bits_[0] &= ~0x00000008u;
PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* temp = generated_code_info_;
generated_code_info_ = nullptr;
return temp;
}
inline PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* CodeGeneratorResponse_File::_internal_mutable_generated_code_info() {
_has_bits_[0] |= 0x00000008u;
if (generated_code_info_ == nullptr) {
auto* p = CreateMaybeMessage<PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo>(GetArena());
generated_code_info_ = p;
}
return generated_code_info_;
}
inline PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* CodeGeneratorResponse_File::mutable_generated_code_info() {
// @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorResponse.File.generated_code_info)
return _internal_mutable_generated_code_info();
}
inline void CodeGeneratorResponse_File::set_allocated_generated_code_info(PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* generated_code_info) {
::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena();
if (message_arena == nullptr) {
delete reinterpret_cast< ::PROTOBUF_NAMESPACE_ID::MessageLite*>(generated_code_info_);
}
if (generated_code_info) {
::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena =
reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(generated_code_info)->GetArena();
if (message_arena != submessage_arena) {
generated_code_info = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage(
message_arena, generated_code_info, submessage_arena);
}
_has_bits_[0] |= 0x00000008u;
} else {
_has_bits_[0] &= ~0x00000008u;
}
generated_code_info_ = generated_code_info;
// @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.generated_code_info)
}
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// CodeGeneratorResponse // CodeGeneratorResponse

@ -50,7 +50,7 @@ package google.protobuf.compiler;
option java_package = "com.google.protobuf.compiler"; option java_package = "com.google.protobuf.compiler";
option java_outer_classname = "PluginProtos"; 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"; import "google/protobuf/descriptor.proto";
@ -173,6 +173,11 @@ message CodeGeneratorResponse {
// The file contents. // The file contents.
optional string content = 15; optional string content = 15;
// Information describing the file content being inserted. If an insertion
// point is used, this information will be appropriately offset and inserted
// into the code generation metadata for the generated files.
optional GeneratedCodeInfo generated_code_info = 16;
} }
repeated File file = 15; repeated File file = 15;
} }

@ -2723,7 +2723,7 @@ void FieldDescriptor::DebugString(
if (has_json_name_) { if (has_json_name_) {
if (!bracketed) { if (!bracketed) {
bracketed = true; bracketed = true;
contents->append("["); contents->append(" [");
} else { } else {
contents->append(", "); contents->append(", ");
} }
@ -4883,6 +4883,7 @@ void DescriptorBuilder::BuildFieldOrExtension(const FieldDescriptorProto& proto,
DescriptorPool::ErrorCollector::DEFAULT_VALUE, DescriptorPool::ErrorCollector::DEFAULT_VALUE,
"Messages can't have default values."); "Messages can't have default values.");
result->has_default_value_ = false; result->has_default_value_ = false;
result->default_generated_instance_ = nullptr;
break; break;
} }
@ -4929,6 +4930,7 @@ void DescriptorBuilder::BuildFieldOrExtension(const FieldDescriptorProto& proto,
result->default_value_string_ = &internal::GetEmptyString(); result->default_value_string_ = &internal::GetEmptyString();
break; break;
case FieldDescriptor::CPPTYPE_MESSAGE: case FieldDescriptor::CPPTYPE_MESSAGE:
result->default_generated_instance_ = nullptr;
break; break;
} }
} }

@ -54,6 +54,7 @@
#ifndef GOOGLE_PROTOBUF_DESCRIPTOR_H__ #ifndef GOOGLE_PROTOBUF_DESCRIPTOR_H__
#define GOOGLE_PROTOBUF_DESCRIPTOR_H__ #define GOOGLE_PROTOBUF_DESCRIPTOR_H__
#include <atomic>
#include <map> #include <map>
#include <memory> #include <memory>
#include <set> #include <set>
@ -839,6 +840,7 @@ class PROTOBUF_EXPORT FieldDescriptor {
// Allows access to GetLocationPath for annotations. // Allows access to GetLocationPath for annotations.
friend class io::Printer; friend class io::Printer;
friend class compiler::cpp::Formatter; friend class compiler::cpp::Formatter;
friend class Reflection;
// Fill the json_name field of FieldDescriptorProto. // Fill the json_name field of FieldDescriptorProto.
void CopyJsonNameTo(FieldDescriptorProto* proto) const; void CopyJsonNameTo(FieldDescriptorProto* proto) const;
@ -906,6 +908,7 @@ class PROTOBUF_EXPORT FieldDescriptor {
mutable const EnumValueDescriptor* default_value_enum_; mutable const EnumValueDescriptor* default_value_enum_;
const std::string* default_value_string_; const std::string* default_value_string_;
mutable std::atomic<const Message*> default_generated_instance_;
}; };
static const CppType kTypeToCppTypeMap[MAX_TYPE + 1]; static const CppType kTypeToCppTypeMap[MAX_TYPE + 1];
@ -1235,6 +1238,7 @@ class PROTOBUF_EXPORT EnumValueDescriptor {
friend class EnumDescriptor; friend class EnumDescriptor;
friend class DescriptorPool; friend class DescriptorPool;
friend class FileDescriptorTables; friend class FileDescriptorTables;
friend class Reflection;
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumValueDescriptor); GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumValueDescriptor);
}; };
@ -1857,7 +1861,7 @@ class PROTOBUF_EXPORT DescriptorPool {
// Delay the building of dependencies of a file descriptor until absolutely // Delay the building of dependencies of a file descriptor until absolutely
// necessary, like when message_type() is called on a field that is defined // necessary, like when message_type() is called on a field that is defined
// in that dependency's file. This will cause functional issues if a proto // in that dependency's file. This will cause functional issues if a proto
// or one of it's dependencies has errors. Should only be enabled for the // or one of its dependencies has errors. Should only be enabled for the
// generated_pool_ (because no descriptor build errors are guaranteed by // generated_pool_ (because no descriptor build errors are guaranteed by
// the compilation generation process), testing, or if a lack of descriptor // the compilation generation process), testing, or if a lack of descriptor
// build errors can be guaranteed for a pool. // build errors can be guaranteed for a pool.

@ -157,7 +157,6 @@ static void InitDefaultsscc_info_DescriptorProto_google_2fprotobuf_2fdescriptor_
new (ptr) PROTOBUF_NAMESPACE_ID::DescriptorProto(); new (ptr) PROTOBUF_NAMESPACE_ID::DescriptorProto();
::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
} }
PROTOBUF_NAMESPACE_ID::DescriptorProto::InitAsDefaultInstance();
} }
PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<6> scc_info_DescriptorProto_google_2fprotobuf_2fdescriptor_2eproto = PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<6> scc_info_DescriptorProto_google_2fprotobuf_2fdescriptor_2eproto =
@ -177,7 +176,6 @@ static void InitDefaultsscc_info_DescriptorProto_ExtensionRange_google_2fprotobu
new (ptr) PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange(); new (ptr) PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange();
::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
} }
PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange::InitAsDefaultInstance();
} }
PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_DescriptorProto_ExtensionRange_google_2fprotobuf_2fdescriptor_2eproto = PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_DescriptorProto_ExtensionRange_google_2fprotobuf_2fdescriptor_2eproto =
@ -192,7 +190,6 @@ static void InitDefaultsscc_info_DescriptorProto_ReservedRange_google_2fprotobuf
new (ptr) PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange(); new (ptr) PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange();
::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
} }
PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange::InitAsDefaultInstance();
} }
PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_DescriptorProto_ReservedRange_google_2fprotobuf_2fdescriptor_2eproto = PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_DescriptorProto_ReservedRange_google_2fprotobuf_2fdescriptor_2eproto =
@ -206,7 +203,6 @@ static void InitDefaultsscc_info_EnumDescriptorProto_google_2fprotobuf_2fdescrip
new (ptr) PROTOBUF_NAMESPACE_ID::EnumDescriptorProto(); new (ptr) PROTOBUF_NAMESPACE_ID::EnumDescriptorProto();
::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
} }
PROTOBUF_NAMESPACE_ID::EnumDescriptorProto::InitAsDefaultInstance();
} }
PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<3> scc_info_EnumDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto = PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<3> scc_info_EnumDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto =
@ -223,7 +219,6 @@ static void InitDefaultsscc_info_EnumDescriptorProto_EnumReservedRange_google_2f
new (ptr) PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange(); new (ptr) PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange();
::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
} }
PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange::InitAsDefaultInstance();
} }
PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_EnumDescriptorProto_EnumReservedRange_google_2fprotobuf_2fdescriptor_2eproto = PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_EnumDescriptorProto_EnumReservedRange_google_2fprotobuf_2fdescriptor_2eproto =
@ -237,7 +232,6 @@ static void InitDefaultsscc_info_EnumOptions_google_2fprotobuf_2fdescriptor_2epr
new (ptr) PROTOBUF_NAMESPACE_ID::EnumOptions(); new (ptr) PROTOBUF_NAMESPACE_ID::EnumOptions();
::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
} }
PROTOBUF_NAMESPACE_ID::EnumOptions::InitAsDefaultInstance();
} }
PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_EnumOptions_google_2fprotobuf_2fdescriptor_2eproto = PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_EnumOptions_google_2fprotobuf_2fdescriptor_2eproto =
@ -252,7 +246,6 @@ static void InitDefaultsscc_info_EnumValueDescriptorProto_google_2fprotobuf_2fde
new (ptr) PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto(); new (ptr) PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto();
::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
} }
PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto::InitAsDefaultInstance();
} }
PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_EnumValueDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto = PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_EnumValueDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto =
@ -267,7 +260,6 @@ static void InitDefaultsscc_info_EnumValueOptions_google_2fprotobuf_2fdescriptor
new (ptr) PROTOBUF_NAMESPACE_ID::EnumValueOptions(); new (ptr) PROTOBUF_NAMESPACE_ID::EnumValueOptions();
::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
} }
PROTOBUF_NAMESPACE_ID::EnumValueOptions::InitAsDefaultInstance();
} }
PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_EnumValueOptions_google_2fprotobuf_2fdescriptor_2eproto = PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_EnumValueOptions_google_2fprotobuf_2fdescriptor_2eproto =
@ -282,7 +274,6 @@ static void InitDefaultsscc_info_ExtensionRangeOptions_google_2fprotobuf_2fdescr
new (ptr) PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions(); new (ptr) PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions();
::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
} }
PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions::InitAsDefaultInstance();
} }
PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_ExtensionRangeOptions_google_2fprotobuf_2fdescriptor_2eproto = PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_ExtensionRangeOptions_google_2fprotobuf_2fdescriptor_2eproto =
@ -297,7 +288,6 @@ static void InitDefaultsscc_info_FieldDescriptorProto_google_2fprotobuf_2fdescri
new (ptr) PROTOBUF_NAMESPACE_ID::FieldDescriptorProto(); new (ptr) PROTOBUF_NAMESPACE_ID::FieldDescriptorProto();
::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
} }
PROTOBUF_NAMESPACE_ID::FieldDescriptorProto::InitAsDefaultInstance();
} }
PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_FieldDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto = PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_FieldDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto =
@ -312,7 +302,6 @@ static void InitDefaultsscc_info_FieldOptions_google_2fprotobuf_2fdescriptor_2ep
new (ptr) PROTOBUF_NAMESPACE_ID::FieldOptions(); new (ptr) PROTOBUF_NAMESPACE_ID::FieldOptions();
::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
} }
PROTOBUF_NAMESPACE_ID::FieldOptions::InitAsDefaultInstance();
} }
PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_FieldOptions_google_2fprotobuf_2fdescriptor_2eproto = PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_FieldOptions_google_2fprotobuf_2fdescriptor_2eproto =
@ -327,7 +316,6 @@ static void InitDefaultsscc_info_FileDescriptorProto_google_2fprotobuf_2fdescrip
new (ptr) PROTOBUF_NAMESPACE_ID::FileDescriptorProto(); new (ptr) PROTOBUF_NAMESPACE_ID::FileDescriptorProto();
::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
} }
PROTOBUF_NAMESPACE_ID::FileDescriptorProto::InitAsDefaultInstance();
} }
PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<6> scc_info_FileDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto = PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<6> scc_info_FileDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto =
@ -347,7 +335,6 @@ static void InitDefaultsscc_info_FileDescriptorSet_google_2fprotobuf_2fdescripto
new (ptr) PROTOBUF_NAMESPACE_ID::FileDescriptorSet(); new (ptr) PROTOBUF_NAMESPACE_ID::FileDescriptorSet();
::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
} }
PROTOBUF_NAMESPACE_ID::FileDescriptorSet::InitAsDefaultInstance();
} }
PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_FileDescriptorSet_google_2fprotobuf_2fdescriptor_2eproto = PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_FileDescriptorSet_google_2fprotobuf_2fdescriptor_2eproto =
@ -362,7 +349,6 @@ static void InitDefaultsscc_info_FileOptions_google_2fprotobuf_2fdescriptor_2epr
new (ptr) PROTOBUF_NAMESPACE_ID::FileOptions(); new (ptr) PROTOBUF_NAMESPACE_ID::FileOptions();
::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
} }
PROTOBUF_NAMESPACE_ID::FileOptions::InitAsDefaultInstance();
} }
PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_FileOptions_google_2fprotobuf_2fdescriptor_2eproto = PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_FileOptions_google_2fprotobuf_2fdescriptor_2eproto =
@ -377,7 +363,6 @@ static void InitDefaultsscc_info_GeneratedCodeInfo_google_2fprotobuf_2fdescripto
new (ptr) PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo(); new (ptr) PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo();
::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
} }
PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo::InitAsDefaultInstance();
} }
PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_GeneratedCodeInfo_google_2fprotobuf_2fdescriptor_2eproto = PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_GeneratedCodeInfo_google_2fprotobuf_2fdescriptor_2eproto =
@ -392,7 +377,6 @@ static void InitDefaultsscc_info_GeneratedCodeInfo_Annotation_google_2fprotobuf_
new (ptr) PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation(); new (ptr) PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation();
::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
} }
PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation::InitAsDefaultInstance();
} }
PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_GeneratedCodeInfo_Annotation_google_2fprotobuf_2fdescriptor_2eproto = PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_GeneratedCodeInfo_Annotation_google_2fprotobuf_2fdescriptor_2eproto =
@ -406,7 +390,6 @@ static void InitDefaultsscc_info_MessageOptions_google_2fprotobuf_2fdescriptor_2
new (ptr) PROTOBUF_NAMESPACE_ID::MessageOptions(); new (ptr) PROTOBUF_NAMESPACE_ID::MessageOptions();
::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
} }
PROTOBUF_NAMESPACE_ID::MessageOptions::InitAsDefaultInstance();
} }
PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_MessageOptions_google_2fprotobuf_2fdescriptor_2eproto = PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_MessageOptions_google_2fprotobuf_2fdescriptor_2eproto =
@ -421,7 +404,6 @@ static void InitDefaultsscc_info_MethodDescriptorProto_google_2fprotobuf_2fdescr
new (ptr) PROTOBUF_NAMESPACE_ID::MethodDescriptorProto(); new (ptr) PROTOBUF_NAMESPACE_ID::MethodDescriptorProto();
::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
} }
PROTOBUF_NAMESPACE_ID::MethodDescriptorProto::InitAsDefaultInstance();
} }
PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_MethodDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto = PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_MethodDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto =
@ -436,7 +418,6 @@ static void InitDefaultsscc_info_MethodOptions_google_2fprotobuf_2fdescriptor_2e
new (ptr) PROTOBUF_NAMESPACE_ID::MethodOptions(); new (ptr) PROTOBUF_NAMESPACE_ID::MethodOptions();
::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
} }
PROTOBUF_NAMESPACE_ID::MethodOptions::InitAsDefaultInstance();
} }
PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_MethodOptions_google_2fprotobuf_2fdescriptor_2eproto = PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_MethodOptions_google_2fprotobuf_2fdescriptor_2eproto =
@ -451,7 +432,6 @@ static void InitDefaultsscc_info_OneofDescriptorProto_google_2fprotobuf_2fdescri
new (ptr) PROTOBUF_NAMESPACE_ID::OneofDescriptorProto(); new (ptr) PROTOBUF_NAMESPACE_ID::OneofDescriptorProto();
::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
} }
PROTOBUF_NAMESPACE_ID::OneofDescriptorProto::InitAsDefaultInstance();
} }
PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_OneofDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto = PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_OneofDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto =
@ -466,7 +446,6 @@ static void InitDefaultsscc_info_OneofOptions_google_2fprotobuf_2fdescriptor_2ep
new (ptr) PROTOBUF_NAMESPACE_ID::OneofOptions(); new (ptr) PROTOBUF_NAMESPACE_ID::OneofOptions();
::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
} }
PROTOBUF_NAMESPACE_ID::OneofOptions::InitAsDefaultInstance();
} }
PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_OneofOptions_google_2fprotobuf_2fdescriptor_2eproto = PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_OneofOptions_google_2fprotobuf_2fdescriptor_2eproto =
@ -481,7 +460,6 @@ static void InitDefaultsscc_info_ServiceDescriptorProto_google_2fprotobuf_2fdesc
new (ptr) PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto(); new (ptr) PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto();
::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
} }
PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto::InitAsDefaultInstance();
} }
PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<2> scc_info_ServiceDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto = PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<2> scc_info_ServiceDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto =
@ -497,7 +475,6 @@ static void InitDefaultsscc_info_ServiceOptions_google_2fprotobuf_2fdescriptor_2
new (ptr) PROTOBUF_NAMESPACE_ID::ServiceOptions(); new (ptr) PROTOBUF_NAMESPACE_ID::ServiceOptions();
::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
} }
PROTOBUF_NAMESPACE_ID::ServiceOptions::InitAsDefaultInstance();
} }
PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_ServiceOptions_google_2fprotobuf_2fdescriptor_2eproto = PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_ServiceOptions_google_2fprotobuf_2fdescriptor_2eproto =
@ -512,7 +489,6 @@ static void InitDefaultsscc_info_SourceCodeInfo_google_2fprotobuf_2fdescriptor_2
new (ptr) PROTOBUF_NAMESPACE_ID::SourceCodeInfo(); new (ptr) PROTOBUF_NAMESPACE_ID::SourceCodeInfo();
::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
} }
PROTOBUF_NAMESPACE_ID::SourceCodeInfo::InitAsDefaultInstance();
} }
PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_SourceCodeInfo_google_2fprotobuf_2fdescriptor_2eproto = PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_SourceCodeInfo_google_2fprotobuf_2fdescriptor_2eproto =
@ -527,7 +503,6 @@ static void InitDefaultsscc_info_SourceCodeInfo_Location_google_2fprotobuf_2fdes
new (ptr) PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location(); new (ptr) PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location();
::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
} }
PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location::InitAsDefaultInstance();
} }
PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_SourceCodeInfo_Location_google_2fprotobuf_2fdescriptor_2eproto = PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_SourceCodeInfo_Location_google_2fprotobuf_2fdescriptor_2eproto =
@ -541,7 +516,6 @@ static void InitDefaultsscc_info_UninterpretedOption_google_2fprotobuf_2fdescrip
new (ptr) PROTOBUF_NAMESPACE_ID::UninterpretedOption(); new (ptr) PROTOBUF_NAMESPACE_ID::UninterpretedOption();
::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
} }
PROTOBUF_NAMESPACE_ID::UninterpretedOption::InitAsDefaultInstance();
} }
PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_UninterpretedOption_google_2fprotobuf_2fdescriptor_2eproto = PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_UninterpretedOption_google_2fprotobuf_2fdescriptor_2eproto =
@ -556,7 +530,6 @@ static void InitDefaultsscc_info_UninterpretedOption_NamePart_google_2fprotobuf_
new (ptr) PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart(); new (ptr) PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart();
::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
} }
PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart::InitAsDefaultInstance();
} }
PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_UninterpretedOption_NamePart_google_2fprotobuf_2fdescriptor_2eproto = PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_UninterpretedOption_NamePart_google_2fprotobuf_2fdescriptor_2eproto =
@ -1156,11 +1129,10 @@ const char descriptor_table_protodef_google_2fprotobuf_2fdescriptor_2eproto[] PR
"tation\030\001 \003(\0132-.google.protobuf.Generated" "tation\030\001 \003(\0132-.google.protobuf.Generated"
"CodeInfo.Annotation\032O\n\nAnnotation\022\020\n\004pat" "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" "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" "n\030\003 \001(\005\022\013\n\003end\030\004 \001(\005B~\n\023com.google.proto"
"obufB\020DescriptorProtosH\001Z>github.com/gol" "bufB\020DescriptorProtosH\001Z-google.golang.o"
"ang/protobuf/protoc-gen-go/descriptor;de" "rg/protobuf/types/descriptorpb\370\001\001\242\002\003GPB\252"
"scriptor\370\001\001\242\002\003GPB\252\002\032Google.Protobuf.Refl" "\002\032Google.Protobuf.Reflection"
"ection"
; ;
static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_deps[1] = { static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_deps[1] = {
}; };
@ -1195,7 +1167,7 @@ static ::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase*const descriptor_table_goo
}; };
static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once; 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 = { 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, &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, 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, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto, 27, file_level_enum_descriptors_google_2fprotobuf_2fdescriptor_2eproto, file_level_service_descriptors_google_2fprotobuf_2fdescriptor_2eproto,
@ -1375,8 +1347,6 @@ constexpr int MethodOptions::IdempotencyLevel_ARRAYSIZE;
// =================================================================== // ===================================================================
void FileDescriptorSet::InitAsDefaultInstance() {
}
class FileDescriptorSet::_Internal { class FileDescriptorSet::_Internal {
public: public:
}; };
@ -1579,12 +1549,6 @@ void FileDescriptorSet::InternalSwap(FileDescriptorSet* other) {
// =================================================================== // ===================================================================
void FileDescriptorProto::InitAsDefaultInstance() {
PROTOBUF_NAMESPACE_ID::_FileDescriptorProto_default_instance_._instance.get_mutable()->options_ = const_cast< PROTOBUF_NAMESPACE_ID::FileOptions*>(
PROTOBUF_NAMESPACE_ID::FileOptions::internal_default_instance());
PROTOBUF_NAMESPACE_ID::_FileDescriptorProto_default_instance_._instance.get_mutable()->source_code_info_ = const_cast< PROTOBUF_NAMESPACE_ID::SourceCodeInfo*>(
PROTOBUF_NAMESPACE_ID::SourceCodeInfo::internal_default_instance());
}
class FileDescriptorProto::_Internal { class FileDescriptorProto::_Internal {
public: public:
using HasBits = decltype(std::declval<FileDescriptorProto>()._has_bits_); using HasBits = decltype(std::declval<FileDescriptorProto>()._has_bits_);
@ -2244,10 +2208,6 @@ void FileDescriptorProto::InternalSwap(FileDescriptorProto* other) {
// =================================================================== // ===================================================================
void DescriptorProto_ExtensionRange::InitAsDefaultInstance() {
PROTOBUF_NAMESPACE_ID::_DescriptorProto_ExtensionRange_default_instance_._instance.get_mutable()->options_ = const_cast< PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions*>(
PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions::internal_default_instance());
}
class DescriptorProto_ExtensionRange::_Internal { class DescriptorProto_ExtensionRange::_Internal {
public: public:
using HasBits = decltype(std::declval<DescriptorProto_ExtensionRange>()._has_bits_); using HasBits = decltype(std::declval<DescriptorProto_ExtensionRange>()._has_bits_);
@ -2549,8 +2509,6 @@ void DescriptorProto_ExtensionRange::InternalSwap(DescriptorProto_ExtensionRange
// =================================================================== // ===================================================================
void DescriptorProto_ReservedRange::InitAsDefaultInstance() {
}
class DescriptorProto_ReservedRange::_Internal { class DescriptorProto_ReservedRange::_Internal {
public: public:
using HasBits = decltype(std::declval<DescriptorProto_ReservedRange>()._has_bits_); using HasBits = decltype(std::declval<DescriptorProto_ReservedRange>()._has_bits_);
@ -2805,10 +2763,6 @@ void DescriptorProto_ReservedRange::InternalSwap(DescriptorProto_ReservedRange*
// =================================================================== // ===================================================================
void DescriptorProto::InitAsDefaultInstance() {
PROTOBUF_NAMESPACE_ID::_DescriptorProto_default_instance_._instance.get_mutable()->options_ = const_cast< PROTOBUF_NAMESPACE_ID::MessageOptions*>(
PROTOBUF_NAMESPACE_ID::MessageOptions::internal_default_instance());
}
class DescriptorProto::_Internal { class DescriptorProto::_Internal {
public: public:
using HasBits = decltype(std::declval<DescriptorProto>()._has_bits_); using HasBits = decltype(std::declval<DescriptorProto>()._has_bits_);
@ -3356,8 +3310,6 @@ void DescriptorProto::InternalSwap(DescriptorProto* other) {
// =================================================================== // ===================================================================
void ExtensionRangeOptions::InitAsDefaultInstance() {
}
class ExtensionRangeOptions::_Internal { class ExtensionRangeOptions::_Internal {
public: public:
}; };
@ -3581,10 +3533,6 @@ void ExtensionRangeOptions::InternalSwap(ExtensionRangeOptions* other) {
// =================================================================== // ===================================================================
void FieldDescriptorProto::InitAsDefaultInstance() {
PROTOBUF_NAMESPACE_ID::_FieldDescriptorProto_default_instance_._instance.get_mutable()->options_ = const_cast< PROTOBUF_NAMESPACE_ID::FieldOptions*>(
PROTOBUF_NAMESPACE_ID::FieldOptions::internal_default_instance());
}
class FieldDescriptorProto::_Internal { class FieldDescriptorProto::_Internal {
public: public:
using HasBits = decltype(std::declval<FieldDescriptorProto>()._has_bits_); using HasBits = decltype(std::declval<FieldDescriptorProto>()._has_bits_);
@ -4214,10 +4162,6 @@ void FieldDescriptorProto::InternalSwap(FieldDescriptorProto* other) {
// =================================================================== // ===================================================================
void OneofDescriptorProto::InitAsDefaultInstance() {
PROTOBUF_NAMESPACE_ID::_OneofDescriptorProto_default_instance_._instance.get_mutable()->options_ = const_cast< PROTOBUF_NAMESPACE_ID::OneofOptions*>(
PROTOBUF_NAMESPACE_ID::OneofOptions::internal_default_instance());
}
class OneofDescriptorProto::_Internal { class OneofDescriptorProto::_Internal {
public: public:
using HasBits = decltype(std::declval<OneofDescriptorProto>()._has_bits_); using HasBits = decltype(std::declval<OneofDescriptorProto>()._has_bits_);
@ -4496,8 +4440,6 @@ void OneofDescriptorProto::InternalSwap(OneofDescriptorProto* other) {
// =================================================================== // ===================================================================
void EnumDescriptorProto_EnumReservedRange::InitAsDefaultInstance() {
}
class EnumDescriptorProto_EnumReservedRange::_Internal { class EnumDescriptorProto_EnumReservedRange::_Internal {
public: public:
using HasBits = decltype(std::declval<EnumDescriptorProto_EnumReservedRange>()._has_bits_); using HasBits = decltype(std::declval<EnumDescriptorProto_EnumReservedRange>()._has_bits_);
@ -4752,10 +4694,6 @@ void EnumDescriptorProto_EnumReservedRange::InternalSwap(EnumDescriptorProto_Enu
// =================================================================== // ===================================================================
void EnumDescriptorProto::InitAsDefaultInstance() {
PROTOBUF_NAMESPACE_ID::_EnumDescriptorProto_default_instance_._instance.get_mutable()->options_ = const_cast< PROTOBUF_NAMESPACE_ID::EnumOptions*>(
PROTOBUF_NAMESPACE_ID::EnumOptions::internal_default_instance());
}
class EnumDescriptorProto::_Internal { class EnumDescriptorProto::_Internal {
public: public:
using HasBits = decltype(std::declval<EnumDescriptorProto>()._has_bits_); using HasBits = decltype(std::declval<EnumDescriptorProto>()._has_bits_);
@ -5138,10 +5076,6 @@ void EnumDescriptorProto::InternalSwap(EnumDescriptorProto* other) {
// =================================================================== // ===================================================================
void EnumValueDescriptorProto::InitAsDefaultInstance() {
PROTOBUF_NAMESPACE_ID::_EnumValueDescriptorProto_default_instance_._instance.get_mutable()->options_ = const_cast< PROTOBUF_NAMESPACE_ID::EnumValueOptions*>(
PROTOBUF_NAMESPACE_ID::EnumValueOptions::internal_default_instance());
}
class EnumValueDescriptorProto::_Internal { class EnumValueDescriptorProto::_Internal {
public: public:
using HasBits = decltype(std::declval<EnumValueDescriptorProto>()._has_bits_); using HasBits = decltype(std::declval<EnumValueDescriptorProto>()._has_bits_);
@ -5457,10 +5391,6 @@ void EnumValueDescriptorProto::InternalSwap(EnumValueDescriptorProto* other) {
// =================================================================== // ===================================================================
void ServiceDescriptorProto::InitAsDefaultInstance() {
PROTOBUF_NAMESPACE_ID::_ServiceDescriptorProto_default_instance_._instance.get_mutable()->options_ = const_cast< PROTOBUF_NAMESPACE_ID::ServiceOptions*>(
PROTOBUF_NAMESPACE_ID::ServiceOptions::internal_default_instance());
}
class ServiceDescriptorProto::_Internal { class ServiceDescriptorProto::_Internal {
public: public:
using HasBits = decltype(std::declval<ServiceDescriptorProto>()._has_bits_); using HasBits = decltype(std::declval<ServiceDescriptorProto>()._has_bits_);
@ -5772,10 +5702,6 @@ void ServiceDescriptorProto::InternalSwap(ServiceDescriptorProto* other) {
// =================================================================== // ===================================================================
void MethodDescriptorProto::InitAsDefaultInstance() {
PROTOBUF_NAMESPACE_ID::_MethodDescriptorProto_default_instance_._instance.get_mutable()->options_ = const_cast< PROTOBUF_NAMESPACE_ID::MethodOptions*>(
PROTOBUF_NAMESPACE_ID::MethodOptions::internal_default_instance());
}
class MethodDescriptorProto::_Internal { class MethodDescriptorProto::_Internal {
public: public:
using HasBits = decltype(std::declval<MethodDescriptorProto>()._has_bits_); using HasBits = decltype(std::declval<MethodDescriptorProto>()._has_bits_);
@ -6208,8 +6134,6 @@ void MethodDescriptorProto::InternalSwap(MethodDescriptorProto* other) {
// =================================================================== // ===================================================================
void FileOptions::InitAsDefaultInstance() {
}
class FileOptions::_Internal { class FileOptions::_Internal {
public: public:
using HasBits = decltype(std::declval<FileOptions>()._has_bits_); using HasBits = decltype(std::declval<FileOptions>()._has_bits_);
@ -7195,8 +7119,6 @@ void FileOptions::InternalSwap(FileOptions* other) {
// =================================================================== // ===================================================================
void MessageOptions::InitAsDefaultInstance() {
}
class MessageOptions::_Internal { class MessageOptions::_Internal {
public: public:
using HasBits = decltype(std::declval<MessageOptions>()._has_bits_); using HasBits = decltype(std::declval<MessageOptions>()._has_bits_);
@ -7549,8 +7471,6 @@ void MessageOptions::InternalSwap(MessageOptions* other) {
// =================================================================== // ===================================================================
void FieldOptions::InitAsDefaultInstance() {
}
class FieldOptions::_Internal { class FieldOptions::_Internal {
public: public:
using HasBits = decltype(std::declval<FieldOptions>()._has_bits_); using HasBits = decltype(std::declval<FieldOptions>()._has_bits_);
@ -7968,8 +7888,6 @@ void FieldOptions::InternalSwap(FieldOptions* other) {
// =================================================================== // ===================================================================
void OneofOptions::InitAsDefaultInstance() {
}
class OneofOptions::_Internal { class OneofOptions::_Internal {
public: public:
}; };
@ -8193,8 +8111,6 @@ void OneofOptions::InternalSwap(OneofOptions* other) {
// =================================================================== // ===================================================================
void EnumOptions::InitAsDefaultInstance() {
}
class EnumOptions::_Internal { class EnumOptions::_Internal {
public: public:
using HasBits = decltype(std::declval<EnumOptions>()._has_bits_); using HasBits = decltype(std::declval<EnumOptions>()._has_bits_);
@ -8497,8 +8413,6 @@ void EnumOptions::InternalSwap(EnumOptions* other) {
// =================================================================== // ===================================================================
void EnumValueOptions::InitAsDefaultInstance() {
}
class EnumValueOptions::_Internal { class EnumValueOptions::_Internal {
public: public:
using HasBits = decltype(std::declval<EnumValueOptions>()._has_bits_); using HasBits = decltype(std::declval<EnumValueOptions>()._has_bits_);
@ -8759,8 +8673,6 @@ void EnumValueOptions::InternalSwap(EnumValueOptions* other) {
// =================================================================== // ===================================================================
void ServiceOptions::InitAsDefaultInstance() {
}
class ServiceOptions::_Internal { class ServiceOptions::_Internal {
public: public:
using HasBits = decltype(std::declval<ServiceOptions>()._has_bits_); using HasBits = decltype(std::declval<ServiceOptions>()._has_bits_);
@ -9021,8 +8933,6 @@ void ServiceOptions::InternalSwap(ServiceOptions* other) {
// =================================================================== // ===================================================================
void MethodOptions::InitAsDefaultInstance() {
}
class MethodOptions::_Internal { class MethodOptions::_Internal {
public: public:
using HasBits = decltype(std::declval<MethodOptions>()._has_bits_); using HasBits = decltype(std::declval<MethodOptions>()._has_bits_);
@ -9334,8 +9244,6 @@ void MethodOptions::InternalSwap(MethodOptions* other) {
// =================================================================== // ===================================================================
void UninterpretedOption_NamePart::InitAsDefaultInstance() {
}
class UninterpretedOption_NamePart::_Internal { class UninterpretedOption_NamePart::_Internal {
public: public:
using HasBits = decltype(std::declval<UninterpretedOption_NamePart>()._has_bits_); using HasBits = decltype(std::declval<UninterpretedOption_NamePart>()._has_bits_);
@ -9613,8 +9521,6 @@ void UninterpretedOption_NamePart::InternalSwap(UninterpretedOption_NamePart* ot
// =================================================================== // ===================================================================
void UninterpretedOption::InitAsDefaultInstance() {
}
class UninterpretedOption::_Internal { class UninterpretedOption::_Internal {
public: public:
using HasBits = decltype(std::declval<UninterpretedOption>()._has_bits_); using HasBits = decltype(std::declval<UninterpretedOption>()._has_bits_);
@ -10058,8 +9964,6 @@ void UninterpretedOption::InternalSwap(UninterpretedOption* other) {
// =================================================================== // ===================================================================
void SourceCodeInfo_Location::InitAsDefaultInstance() {
}
class SourceCodeInfo_Location::_Internal { class SourceCodeInfo_Location::_Internal {
public: public:
using HasBits = decltype(std::declval<SourceCodeInfo_Location>()._has_bits_); using HasBits = decltype(std::declval<SourceCodeInfo_Location>()._has_bits_);
@ -10452,8 +10356,6 @@ void SourceCodeInfo_Location::InternalSwap(SourceCodeInfo_Location* other) {
// =================================================================== // ===================================================================
void SourceCodeInfo::InitAsDefaultInstance() {
}
class SourceCodeInfo::_Internal { class SourceCodeInfo::_Internal {
public: public:
}; };
@ -10655,8 +10557,6 @@ void SourceCodeInfo::InternalSwap(SourceCodeInfo* other) {
// =================================================================== // ===================================================================
void GeneratedCodeInfo_Annotation::InitAsDefaultInstance() {
}
class GeneratedCodeInfo_Annotation::_Internal { class GeneratedCodeInfo_Annotation::_Internal {
public: public:
using HasBits = decltype(std::declval<GeneratedCodeInfo_Annotation>()._has_bits_); using HasBits = decltype(std::declval<GeneratedCodeInfo_Annotation>()._has_bits_);
@ -10996,8 +10896,6 @@ void GeneratedCodeInfo_Annotation::InternalSwap(GeneratedCodeInfo_Annotation* ot
// =================================================================== // ===================================================================
void GeneratedCodeInfo::InitAsDefaultInstance() {
}
class GeneratedCodeInfo::_Internal { class GeneratedCodeInfo::_Internal {
public: public:
}; };

@ -373,7 +373,6 @@ class PROTOBUF_EXPORT FileDescriptorSet PROTOBUF_FINAL :
} }
static const FileDescriptorSet& default_instance(); static const FileDescriptorSet& default_instance();
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
static inline const FileDescriptorSet* internal_default_instance() { static inline const FileDescriptorSet* internal_default_instance() {
return reinterpret_cast<const FileDescriptorSet*>( return reinterpret_cast<const FileDescriptorSet*>(
&_FileDescriptorSet_default_instance_); &_FileDescriptorSet_default_instance_);
@ -526,7 +525,6 @@ class PROTOBUF_EXPORT FileDescriptorProto PROTOBUF_FINAL :
} }
static const FileDescriptorProto& default_instance(); static const FileDescriptorProto& default_instance();
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
static inline const FileDescriptorProto* internal_default_instance() { static inline const FileDescriptorProto* internal_default_instance() {
return reinterpret_cast<const FileDescriptorProto*>( return reinterpret_cast<const FileDescriptorProto*>(
&_FileDescriptorProto_default_instance_); &_FileDescriptorProto_default_instance_);
@ -920,7 +918,6 @@ class PROTOBUF_EXPORT DescriptorProto_ExtensionRange PROTOBUF_FINAL :
} }
static const DescriptorProto_ExtensionRange& default_instance(); static const DescriptorProto_ExtensionRange& default_instance();
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
static inline const DescriptorProto_ExtensionRange* internal_default_instance() { static inline const DescriptorProto_ExtensionRange* internal_default_instance() {
return reinterpret_cast<const DescriptorProto_ExtensionRange*>( return reinterpret_cast<const DescriptorProto_ExtensionRange*>(
&_DescriptorProto_ExtensionRange_default_instance_); &_DescriptorProto_ExtensionRange_default_instance_);
@ -1104,7 +1101,6 @@ class PROTOBUF_EXPORT DescriptorProto_ReservedRange PROTOBUF_FINAL :
} }
static const DescriptorProto_ReservedRange& default_instance(); static const DescriptorProto_ReservedRange& default_instance();
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
static inline const DescriptorProto_ReservedRange* internal_default_instance() { static inline const DescriptorProto_ReservedRange* internal_default_instance() {
return reinterpret_cast<const DescriptorProto_ReservedRange*>( return reinterpret_cast<const DescriptorProto_ReservedRange*>(
&_DescriptorProto_ReservedRange_default_instance_); &_DescriptorProto_ReservedRange_default_instance_);
@ -1268,7 +1264,6 @@ class PROTOBUF_EXPORT DescriptorProto PROTOBUF_FINAL :
} }
static const DescriptorProto& default_instance(); static const DescriptorProto& default_instance();
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
static inline const DescriptorProto* internal_default_instance() { static inline const DescriptorProto* internal_default_instance() {
return reinterpret_cast<const DescriptorProto*>( return reinterpret_cast<const DescriptorProto*>(
&_DescriptorProto_default_instance_); &_DescriptorProto_default_instance_);
@ -1613,7 +1608,6 @@ class PROTOBUF_EXPORT ExtensionRangeOptions PROTOBUF_FINAL :
} }
static const ExtensionRangeOptions& default_instance(); static const ExtensionRangeOptions& default_instance();
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
static inline const ExtensionRangeOptions* internal_default_instance() { static inline const ExtensionRangeOptions* internal_default_instance() {
return reinterpret_cast<const ExtensionRangeOptions*>( return reinterpret_cast<const ExtensionRangeOptions*>(
&_ExtensionRangeOptions_default_instance_); &_ExtensionRangeOptions_default_instance_);
@ -1769,7 +1763,6 @@ class PROTOBUF_EXPORT FieldDescriptorProto PROTOBUF_FINAL :
} }
static const FieldDescriptorProto& default_instance(); static const FieldDescriptorProto& default_instance();
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
static inline const FieldDescriptorProto* internal_default_instance() { static inline const FieldDescriptorProto* internal_default_instance() {
return reinterpret_cast<const FieldDescriptorProto*>( return reinterpret_cast<const FieldDescriptorProto*>(
&_FieldDescriptorProto_default_instance_); &_FieldDescriptorProto_default_instance_);
@ -2202,7 +2195,6 @@ class PROTOBUF_EXPORT OneofDescriptorProto PROTOBUF_FINAL :
} }
static const OneofDescriptorProto& default_instance(); static const OneofDescriptorProto& default_instance();
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
static inline const OneofDescriptorProto* internal_default_instance() { static inline const OneofDescriptorProto* internal_default_instance() {
return reinterpret_cast<const OneofDescriptorProto*>( return reinterpret_cast<const OneofDescriptorProto*>(
&_OneofDescriptorProto_default_instance_); &_OneofDescriptorProto_default_instance_);
@ -2378,7 +2370,6 @@ class PROTOBUF_EXPORT EnumDescriptorProto_EnumReservedRange PROTOBUF_FINAL :
} }
static const EnumDescriptorProto_EnumReservedRange& default_instance(); static const EnumDescriptorProto_EnumReservedRange& default_instance();
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
static inline const EnumDescriptorProto_EnumReservedRange* internal_default_instance() { static inline const EnumDescriptorProto_EnumReservedRange* internal_default_instance() {
return reinterpret_cast<const EnumDescriptorProto_EnumReservedRange*>( return reinterpret_cast<const EnumDescriptorProto_EnumReservedRange*>(
&_EnumDescriptorProto_EnumReservedRange_default_instance_); &_EnumDescriptorProto_EnumReservedRange_default_instance_);
@ -2542,7 +2533,6 @@ class PROTOBUF_EXPORT EnumDescriptorProto PROTOBUF_FINAL :
} }
static const EnumDescriptorProto& default_instance(); static const EnumDescriptorProto& default_instance();
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
static inline const EnumDescriptorProto* internal_default_instance() { static inline const EnumDescriptorProto* internal_default_instance() {
return reinterpret_cast<const EnumDescriptorProto*>( return reinterpret_cast<const EnumDescriptorProto*>(
&_EnumDescriptorProto_default_instance_); &_EnumDescriptorProto_default_instance_);
@ -2786,7 +2776,6 @@ class PROTOBUF_EXPORT EnumValueDescriptorProto PROTOBUF_FINAL :
} }
static const EnumValueDescriptorProto& default_instance(); static const EnumValueDescriptorProto& default_instance();
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
static inline const EnumValueDescriptorProto* internal_default_instance() { static inline const EnumValueDescriptorProto* internal_default_instance() {
return reinterpret_cast<const EnumValueDescriptorProto*>( return reinterpret_cast<const EnumValueDescriptorProto*>(
&_EnumValueDescriptorProto_default_instance_); &_EnumValueDescriptorProto_default_instance_);
@ -2977,7 +2966,6 @@ class PROTOBUF_EXPORT ServiceDescriptorProto PROTOBUF_FINAL :
} }
static const ServiceDescriptorProto& default_instance(); static const ServiceDescriptorProto& default_instance();
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
static inline const ServiceDescriptorProto* internal_default_instance() { static inline const ServiceDescriptorProto* internal_default_instance() {
return reinterpret_cast<const ServiceDescriptorProto*>( return reinterpret_cast<const ServiceDescriptorProto*>(
&_ServiceDescriptorProto_default_instance_); &_ServiceDescriptorProto_default_instance_);
@ -3173,7 +3161,6 @@ class PROTOBUF_EXPORT MethodDescriptorProto PROTOBUF_FINAL :
} }
static const MethodDescriptorProto& default_instance(); static const MethodDescriptorProto& default_instance();
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
static inline const MethodDescriptorProto* internal_default_instance() { static inline const MethodDescriptorProto* internal_default_instance() {
return reinterpret_cast<const MethodDescriptorProto*>( return reinterpret_cast<const MethodDescriptorProto*>(
&_MethodDescriptorProto_default_instance_); &_MethodDescriptorProto_default_instance_);
@ -3423,7 +3410,6 @@ class PROTOBUF_EXPORT FileOptions PROTOBUF_FINAL :
} }
static const FileOptions& default_instance(); static const FileOptions& default_instance();
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
static inline const FileOptions* internal_default_instance() { static inline const FileOptions* internal_default_instance() {
return reinterpret_cast<const FileOptions*>( return reinterpret_cast<const FileOptions*>(
&_FileOptions_default_instance_); &_FileOptions_default_instance_);
@ -3982,7 +3968,6 @@ class PROTOBUF_EXPORT MessageOptions PROTOBUF_FINAL :
} }
static const MessageOptions& default_instance(); static const MessageOptions& default_instance();
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
static inline const MessageOptions* internal_default_instance() { static inline const MessageOptions* internal_default_instance() {
return reinterpret_cast<const MessageOptions*>( return reinterpret_cast<const MessageOptions*>(
&_MessageOptions_default_instance_); &_MessageOptions_default_instance_);
@ -4199,7 +4184,6 @@ class PROTOBUF_EXPORT FieldOptions PROTOBUF_FINAL :
} }
static const FieldOptions& default_instance(); static const FieldOptions& default_instance();
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
static inline const FieldOptions* internal_default_instance() { static inline const FieldOptions* internal_default_instance() {
return reinterpret_cast<const FieldOptions*>( return reinterpret_cast<const FieldOptions*>(
&_FieldOptions_default_instance_); &_FieldOptions_default_instance_);
@ -4510,7 +4494,6 @@ class PROTOBUF_EXPORT OneofOptions PROTOBUF_FINAL :
} }
static const OneofOptions& default_instance(); static const OneofOptions& default_instance();
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
static inline const OneofOptions* internal_default_instance() { static inline const OneofOptions* internal_default_instance() {
return reinterpret_cast<const OneofOptions*>( return reinterpret_cast<const OneofOptions*>(
&_OneofOptions_default_instance_); &_OneofOptions_default_instance_);
@ -4666,7 +4649,6 @@ class PROTOBUF_EXPORT EnumOptions PROTOBUF_FINAL :
} }
static const EnumOptions& default_instance(); static const EnumOptions& default_instance();
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
static inline const EnumOptions* internal_default_instance() { static inline const EnumOptions* internal_default_instance() {
return reinterpret_cast<const EnumOptions*>( return reinterpret_cast<const EnumOptions*>(
&_EnumOptions_default_instance_); &_EnumOptions_default_instance_);
@ -4853,7 +4835,6 @@ class PROTOBUF_EXPORT EnumValueOptions PROTOBUF_FINAL :
} }
static const EnumValueOptions& default_instance(); static const EnumValueOptions& default_instance();
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
static inline const EnumValueOptions* internal_default_instance() { static inline const EnumValueOptions* internal_default_instance() {
return reinterpret_cast<const EnumValueOptions*>( return reinterpret_cast<const EnumValueOptions*>(
&_EnumValueOptions_default_instance_); &_EnumValueOptions_default_instance_);
@ -5025,7 +5006,6 @@ class PROTOBUF_EXPORT ServiceOptions PROTOBUF_FINAL :
} }
static const ServiceOptions& default_instance(); static const ServiceOptions& default_instance();
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
static inline const ServiceOptions* internal_default_instance() { static inline const ServiceOptions* internal_default_instance() {
return reinterpret_cast<const ServiceOptions*>( return reinterpret_cast<const ServiceOptions*>(
&_ServiceOptions_default_instance_); &_ServiceOptions_default_instance_);
@ -5197,7 +5177,6 @@ class PROTOBUF_EXPORT MethodOptions PROTOBUF_FINAL :
} }
static const MethodOptions& default_instance(); static const MethodOptions& default_instance();
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
static inline const MethodOptions* internal_default_instance() { static inline const MethodOptions* internal_default_instance() {
return reinterpret_cast<const MethodOptions*>( return reinterpret_cast<const MethodOptions*>(
&_MethodOptions_default_instance_); &_MethodOptions_default_instance_);
@ -5416,7 +5395,6 @@ class PROTOBUF_EXPORT UninterpretedOption_NamePart PROTOBUF_FINAL :
} }
static const UninterpretedOption_NamePart& default_instance(); static const UninterpretedOption_NamePart& default_instance();
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
static inline const UninterpretedOption_NamePart* internal_default_instance() { static inline const UninterpretedOption_NamePart* internal_default_instance() {
return reinterpret_cast<const UninterpretedOption_NamePart*>( return reinterpret_cast<const UninterpretedOption_NamePart*>(
&_UninterpretedOption_NamePart_default_instance_); &_UninterpretedOption_NamePart_default_instance_);
@ -5590,7 +5568,6 @@ class PROTOBUF_EXPORT UninterpretedOption PROTOBUF_FINAL :
} }
static const UninterpretedOption& default_instance(); static const UninterpretedOption& default_instance();
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
static inline const UninterpretedOption* internal_default_instance() { static inline const UninterpretedOption* internal_default_instance() {
return reinterpret_cast<const UninterpretedOption*>( return reinterpret_cast<const UninterpretedOption*>(
&_UninterpretedOption_default_instance_); &_UninterpretedOption_default_instance_);
@ -5857,7 +5834,6 @@ class PROTOBUF_EXPORT SourceCodeInfo_Location PROTOBUF_FINAL :
} }
static const SourceCodeInfo_Location& default_instance(); static const SourceCodeInfo_Location& default_instance();
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
static inline const SourceCodeInfo_Location* internal_default_instance() { static inline const SourceCodeInfo_Location* internal_default_instance() {
return reinterpret_cast<const SourceCodeInfo_Location*>( return reinterpret_cast<const SourceCodeInfo_Location*>(
&_SourceCodeInfo_Location_default_instance_); &_SourceCodeInfo_Location_default_instance_);
@ -6111,7 +6087,6 @@ class PROTOBUF_EXPORT SourceCodeInfo PROTOBUF_FINAL :
} }
static const SourceCodeInfo& default_instance(); static const SourceCodeInfo& default_instance();
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
static inline const SourceCodeInfo* internal_default_instance() { static inline const SourceCodeInfo* internal_default_instance() {
return reinterpret_cast<const SourceCodeInfo*>( return reinterpret_cast<const SourceCodeInfo*>(
&_SourceCodeInfo_default_instance_); &_SourceCodeInfo_default_instance_);
@ -6266,7 +6241,6 @@ class PROTOBUF_EXPORT GeneratedCodeInfo_Annotation PROTOBUF_FINAL :
} }
static const GeneratedCodeInfo_Annotation& default_instance(); static const GeneratedCodeInfo_Annotation& default_instance();
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
static inline const GeneratedCodeInfo_Annotation* internal_default_instance() { static inline const GeneratedCodeInfo_Annotation* internal_default_instance() {
return reinterpret_cast<const GeneratedCodeInfo_Annotation*>( return reinterpret_cast<const GeneratedCodeInfo_Annotation*>(
&_GeneratedCodeInfo_Annotation_default_instance_); &_GeneratedCodeInfo_Annotation_default_instance_);
@ -6477,7 +6451,6 @@ class PROTOBUF_EXPORT GeneratedCodeInfo PROTOBUF_FINAL :
} }
static const GeneratedCodeInfo& default_instance(); static const GeneratedCodeInfo& default_instance();
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
static inline const GeneratedCodeInfo* internal_default_instance() { static inline const GeneratedCodeInfo* internal_default_instance() {
return reinterpret_cast<const GeneratedCodeInfo*>( return reinterpret_cast<const GeneratedCodeInfo*>(
&_GeneratedCodeInfo_default_instance_); &_GeneratedCodeInfo_default_instance_);
@ -7128,8 +7101,8 @@ inline void FileDescriptorProto::clear_options() {
} }
inline const PROTOBUF_NAMESPACE_ID::FileOptions& FileDescriptorProto::_internal_options() const { inline const PROTOBUF_NAMESPACE_ID::FileOptions& FileDescriptorProto::_internal_options() const {
const PROTOBUF_NAMESPACE_ID::FileOptions* p = options_; const PROTOBUF_NAMESPACE_ID::FileOptions* p = options_;
return p != nullptr ? *p : *reinterpret_cast<const PROTOBUF_NAMESPACE_ID::FileOptions*>( return p != nullptr ? *p : reinterpret_cast<const PROTOBUF_NAMESPACE_ID::FileOptions&>(
&PROTOBUF_NAMESPACE_ID::_FileOptions_default_instance_); PROTOBUF_NAMESPACE_ID::_FileOptions_default_instance_);
} }
inline const PROTOBUF_NAMESPACE_ID::FileOptions& FileDescriptorProto::options() const { inline const PROTOBUF_NAMESPACE_ID::FileOptions& FileDescriptorProto::options() const {
// @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.options) // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.options)
@ -7211,8 +7184,8 @@ inline void FileDescriptorProto::clear_source_code_info() {
} }
inline const PROTOBUF_NAMESPACE_ID::SourceCodeInfo& FileDescriptorProto::_internal_source_code_info() const { inline const PROTOBUF_NAMESPACE_ID::SourceCodeInfo& FileDescriptorProto::_internal_source_code_info() const {
const PROTOBUF_NAMESPACE_ID::SourceCodeInfo* p = source_code_info_; const PROTOBUF_NAMESPACE_ID::SourceCodeInfo* p = source_code_info_;
return p != nullptr ? *p : *reinterpret_cast<const PROTOBUF_NAMESPACE_ID::SourceCodeInfo*>( return p != nullptr ? *p : reinterpret_cast<const PROTOBUF_NAMESPACE_ID::SourceCodeInfo&>(
&PROTOBUF_NAMESPACE_ID::_SourceCodeInfo_default_instance_); PROTOBUF_NAMESPACE_ID::_SourceCodeInfo_default_instance_);
} }
inline const PROTOBUF_NAMESPACE_ID::SourceCodeInfo& FileDescriptorProto::source_code_info() const { inline const PROTOBUF_NAMESPACE_ID::SourceCodeInfo& FileDescriptorProto::source_code_info() const {
// @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.source_code_info) // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.source_code_info)
@ -7428,8 +7401,8 @@ inline void DescriptorProto_ExtensionRange::clear_options() {
} }
inline const PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions& DescriptorProto_ExtensionRange::_internal_options() const { inline const PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions& DescriptorProto_ExtensionRange::_internal_options() const {
const PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions* p = options_; const PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions* p = options_;
return p != nullptr ? *p : *reinterpret_cast<const PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions*>( return p != nullptr ? *p : reinterpret_cast<const PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions&>(
&PROTOBUF_NAMESPACE_ID::_ExtensionRangeOptions_default_instance_); PROTOBUF_NAMESPACE_ID::_ExtensionRangeOptions_default_instance_);
} }
inline const PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions& DescriptorProto_ExtensionRange::options() const { inline const PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions& DescriptorProto_ExtensionRange::options() const {
// @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.ExtensionRange.options) // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.ExtensionRange.options)
@ -7883,8 +7856,8 @@ inline void DescriptorProto::clear_options() {
} }
inline const PROTOBUF_NAMESPACE_ID::MessageOptions& DescriptorProto::_internal_options() const { inline const PROTOBUF_NAMESPACE_ID::MessageOptions& DescriptorProto::_internal_options() const {
const PROTOBUF_NAMESPACE_ID::MessageOptions* p = options_; const PROTOBUF_NAMESPACE_ID::MessageOptions* p = options_;
return p != nullptr ? *p : *reinterpret_cast<const PROTOBUF_NAMESPACE_ID::MessageOptions*>( return p != nullptr ? *p : reinterpret_cast<const PROTOBUF_NAMESPACE_ID::MessageOptions&>(
&PROTOBUF_NAMESPACE_ID::_MessageOptions_default_instance_); PROTOBUF_NAMESPACE_ID::_MessageOptions_default_instance_);
} }
inline const PROTOBUF_NAMESPACE_ID::MessageOptions& DescriptorProto::options() const { inline const PROTOBUF_NAMESPACE_ID::MessageOptions& DescriptorProto::options() const {
// @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.options) // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.options)
@ -8610,8 +8583,8 @@ inline void FieldDescriptorProto::clear_options() {
} }
inline const PROTOBUF_NAMESPACE_ID::FieldOptions& FieldDescriptorProto::_internal_options() const { inline const PROTOBUF_NAMESPACE_ID::FieldOptions& FieldDescriptorProto::_internal_options() const {
const PROTOBUF_NAMESPACE_ID::FieldOptions* p = options_; const PROTOBUF_NAMESPACE_ID::FieldOptions* p = options_;
return p != nullptr ? *p : *reinterpret_cast<const PROTOBUF_NAMESPACE_ID::FieldOptions*>( return p != nullptr ? *p : reinterpret_cast<const PROTOBUF_NAMESPACE_ID::FieldOptions&>(
&PROTOBUF_NAMESPACE_ID::_FieldOptions_default_instance_); PROTOBUF_NAMESPACE_ID::_FieldOptions_default_instance_);
} }
inline const PROTOBUF_NAMESPACE_ID::FieldOptions& FieldDescriptorProto::options() const { inline const PROTOBUF_NAMESPACE_ID::FieldOptions& FieldDescriptorProto::options() const {
// @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.options) // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.options)
@ -8799,8 +8772,8 @@ inline void OneofDescriptorProto::clear_options() {
} }
inline const PROTOBUF_NAMESPACE_ID::OneofOptions& OneofDescriptorProto::_internal_options() const { inline const PROTOBUF_NAMESPACE_ID::OneofOptions& OneofDescriptorProto::_internal_options() const {
const PROTOBUF_NAMESPACE_ID::OneofOptions* p = options_; const PROTOBUF_NAMESPACE_ID::OneofOptions* p = options_;
return p != nullptr ? *p : *reinterpret_cast<const PROTOBUF_NAMESPACE_ID::OneofOptions*>( return p != nullptr ? *p : reinterpret_cast<const PROTOBUF_NAMESPACE_ID::OneofOptions&>(
&PROTOBUF_NAMESPACE_ID::_OneofOptions_default_instance_); PROTOBUF_NAMESPACE_ID::_OneofOptions_default_instance_);
} }
inline const PROTOBUF_NAMESPACE_ID::OneofOptions& OneofDescriptorProto::options() const { inline const PROTOBUF_NAMESPACE_ID::OneofOptions& OneofDescriptorProto::options() const {
// @@protoc_insertion_point(field_get:google.protobuf.OneofDescriptorProto.options) // @@protoc_insertion_point(field_get:google.protobuf.OneofDescriptorProto.options)
@ -9059,8 +9032,8 @@ inline void EnumDescriptorProto::clear_options() {
} }
inline const PROTOBUF_NAMESPACE_ID::EnumOptions& EnumDescriptorProto::_internal_options() const { inline const PROTOBUF_NAMESPACE_ID::EnumOptions& EnumDescriptorProto::_internal_options() const {
const PROTOBUF_NAMESPACE_ID::EnumOptions* p = options_; const PROTOBUF_NAMESPACE_ID::EnumOptions* p = options_;
return p != nullptr ? *p : *reinterpret_cast<const PROTOBUF_NAMESPACE_ID::EnumOptions*>( return p != nullptr ? *p : reinterpret_cast<const PROTOBUF_NAMESPACE_ID::EnumOptions&>(
&PROTOBUF_NAMESPACE_ID::_EnumOptions_default_instance_); PROTOBUF_NAMESPACE_ID::_EnumOptions_default_instance_);
} }
inline const PROTOBUF_NAMESPACE_ID::EnumOptions& EnumDescriptorProto::options() const { inline const PROTOBUF_NAMESPACE_ID::EnumOptions& EnumDescriptorProto::options() const {
// @@protoc_insertion_point(field_get:google.protobuf.EnumDescriptorProto.options) // @@protoc_insertion_point(field_get:google.protobuf.EnumDescriptorProto.options)
@ -9361,8 +9334,8 @@ inline void EnumValueDescriptorProto::clear_options() {
} }
inline const PROTOBUF_NAMESPACE_ID::EnumValueOptions& EnumValueDescriptorProto::_internal_options() const { inline const PROTOBUF_NAMESPACE_ID::EnumValueOptions& EnumValueDescriptorProto::_internal_options() const {
const PROTOBUF_NAMESPACE_ID::EnumValueOptions* p = options_; const PROTOBUF_NAMESPACE_ID::EnumValueOptions* p = options_;
return p != nullptr ? *p : *reinterpret_cast<const PROTOBUF_NAMESPACE_ID::EnumValueOptions*>( return p != nullptr ? *p : reinterpret_cast<const PROTOBUF_NAMESPACE_ID::EnumValueOptions&>(
&PROTOBUF_NAMESPACE_ID::_EnumValueOptions_default_instance_); PROTOBUF_NAMESPACE_ID::_EnumValueOptions_default_instance_);
} }
inline const PROTOBUF_NAMESPACE_ID::EnumValueOptions& EnumValueDescriptorProto::options() const { inline const PROTOBUF_NAMESPACE_ID::EnumValueOptions& EnumValueDescriptorProto::options() const {
// @@protoc_insertion_point(field_get:google.protobuf.EnumValueDescriptorProto.options) // @@protoc_insertion_point(field_get:google.protobuf.EnumValueDescriptorProto.options)
@ -9561,8 +9534,8 @@ inline void ServiceDescriptorProto::clear_options() {
} }
inline const PROTOBUF_NAMESPACE_ID::ServiceOptions& ServiceDescriptorProto::_internal_options() const { inline const PROTOBUF_NAMESPACE_ID::ServiceOptions& ServiceDescriptorProto::_internal_options() const {
const PROTOBUF_NAMESPACE_ID::ServiceOptions* p = options_; const PROTOBUF_NAMESPACE_ID::ServiceOptions* p = options_;
return p != nullptr ? *p : *reinterpret_cast<const PROTOBUF_NAMESPACE_ID::ServiceOptions*>( return p != nullptr ? *p : reinterpret_cast<const PROTOBUF_NAMESPACE_ID::ServiceOptions&>(
&PROTOBUF_NAMESPACE_ID::_ServiceOptions_default_instance_); PROTOBUF_NAMESPACE_ID::_ServiceOptions_default_instance_);
} }
inline const PROTOBUF_NAMESPACE_ID::ServiceOptions& ServiceDescriptorProto::options() const { inline const PROTOBUF_NAMESPACE_ID::ServiceOptions& ServiceDescriptorProto::options() const {
// @@protoc_insertion_point(field_get:google.protobuf.ServiceDescriptorProto.options) // @@protoc_insertion_point(field_get:google.protobuf.ServiceDescriptorProto.options)
@ -9870,8 +9843,8 @@ inline void MethodDescriptorProto::clear_options() {
} }
inline const PROTOBUF_NAMESPACE_ID::MethodOptions& MethodDescriptorProto::_internal_options() const { inline const PROTOBUF_NAMESPACE_ID::MethodOptions& MethodDescriptorProto::_internal_options() const {
const PROTOBUF_NAMESPACE_ID::MethodOptions* p = options_; const PROTOBUF_NAMESPACE_ID::MethodOptions* p = options_;
return p != nullptr ? *p : *reinterpret_cast<const PROTOBUF_NAMESPACE_ID::MethodOptions*>( return p != nullptr ? *p : reinterpret_cast<const PROTOBUF_NAMESPACE_ID::MethodOptions&>(
&PROTOBUF_NAMESPACE_ID::_MethodOptions_default_instance_); PROTOBUF_NAMESPACE_ID::_MethodOptions_default_instance_);
} }
inline const PROTOBUF_NAMESPACE_ID::MethodOptions& MethodDescriptorProto::options() const { inline const PROTOBUF_NAMESPACE_ID::MethodOptions& MethodDescriptorProto::options() const {
// @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.options) // @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.options)

@ -41,7 +41,7 @@ syntax = "proto2";
package google.protobuf; 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_package = "com.google.protobuf";
option java_outer_classname = "DescriptorProtos"; option java_outer_classname = "DescriptorProtos";
option csharp_namespace = "Google.Protobuf.Reflection"; option csharp_namespace = "Google.Protobuf.Reflection";

@ -44,7 +44,6 @@
#include <google/protobuf/unittest_custom_options.pb.h> #include <google/protobuf/unittest_custom_options.pb.h>
#include <google/protobuf/stubs/common.h> #include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/logging.h> #include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/stringprintf.h> #include <google/protobuf/stubs/stringprintf.h>
#include <google/protobuf/unittest_lazy_dependencies.pb.h> #include <google/protobuf/unittest_lazy_dependencies.pb.h>
#include <google/protobuf/unittest_proto3_arena.pb.h> #include <google/protobuf/unittest_proto3_arena.pb.h>
@ -58,6 +57,7 @@
#include <google/protobuf/stubs/strutil.h> #include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/testing/googletest.h> #include <google/protobuf/testing/googletest.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/substitute.h> #include <google/protobuf/stubs/substitute.h>

@ -28,7 +28,6 @@ static void InitDefaultsscc_info_Duration_google_2fprotobuf_2fduration_2eproto()
new (ptr) PROTOBUF_NAMESPACE_ID::Duration(); new (ptr) PROTOBUF_NAMESPACE_ID::Duration();
::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
} }
PROTOBUF_NAMESPACE_ID::Duration::InitAsDefaultInstance();
} }
PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_Duration_google_2fprotobuf_2fduration_2eproto = PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_Duration_google_2fprotobuf_2fduration_2eproto =
@ -58,10 +57,10 @@ static ::PROTOBUF_NAMESPACE_ID::Message const * const file_default_instances[] =
const char descriptor_table_protodef_google_2fprotobuf_2fduration_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = const char descriptor_table_protodef_google_2fprotobuf_2fduration_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) =
"\n\036google/protobuf/duration.proto\022\017google" "\n\036google/protobuf/duration.proto\022\017google"
".protobuf\"*\n\010Duration\022\017\n\007seconds\030\001 \001(\003\022\r" ".protobuf\"*\n\010Duration\022\017\n\007seconds\030\001 \001(\003\022\r"
"\n\005nanos\030\002 \001(\005B|\n\023com.google.protobufB\rDu" "\n\005nanos\030\002 \001(\005B\203\001\n\023com.google.protobufB\rD"
"rationProtoP\001Z*github.com/golang/protobu" "urationProtoP\001Z1google.golang.org/protob"
"f/ptypes/duration\370\001\001\242\002\003GPB\252\002\036Google.Prot" "uf/types/known/durationpb\370\001\001\242\002\003GPB\252\002\036Goo"
"obuf.WellKnownTypesb\006proto3" "gle.Protobuf.WellKnownTypesb\006proto3"
; ;
static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_google_2fprotobuf_2fduration_2eproto_deps[1] = { static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_google_2fprotobuf_2fduration_2eproto_deps[1] = {
}; };
@ -70,7 +69,7 @@ static ::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase*const descriptor_table_goo
}; };
static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_google_2fprotobuf_2fduration_2eproto_once; 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 = { 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, &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, 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, file_level_metadata_google_2fprotobuf_2fduration_2eproto, 1, file_level_enum_descriptors_google_2fprotobuf_2fduration_2eproto, file_level_service_descriptors_google_2fprotobuf_2fduration_2eproto,
@ -82,8 +81,6 @@ PROTOBUF_NAMESPACE_OPEN
// =================================================================== // ===================================================================
void Duration::InitAsDefaultInstance() {
}
class Duration::_Internal { class Duration::_Internal {
public: public:
}; };

@ -102,7 +102,6 @@ class PROTOBUF_EXPORT Duration PROTOBUF_FINAL :
} }
static const Duration& default_instance(); static const Duration& default_instance();
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
static inline const Duration* internal_default_instance() { static inline const Duration* internal_default_instance() {
return reinterpret_cast<const Duration*>( return reinterpret_cast<const Duration*>(
&_Duration_default_instance_); &_Duration_default_instance_);

@ -34,7 +34,7 @@ package google.protobuf;
option csharp_namespace = "Google.Protobuf.WellKnownTypes"; option csharp_namespace = "Google.Protobuf.WellKnownTypes";
option cc_enable_arenas = true; 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_package = "com.google.protobuf";
option java_outer_classname = "DurationProto"; option java_outer_classname = "DurationProto";
option java_multiple_files = true; option java_multiple_files = true;

@ -292,6 +292,13 @@ class DynamicMessage : public Message {
~DynamicMessage(); ~DynamicMessage();
// Called on the prototype after construction to initialize message fields. // Called on the prototype after construction to initialize message fields.
// Cross linking the default instances allows for fast reflection access of
// unset message fields. Without it we would have to go to the MessageFactory
// to get the prototype, which is a much more expensive operation.
//
// Generated messages do not cross-link to avoid dynamic initialization of the
// global instances.
// Instead, they keep the default instances in the FieldDescriptor objects.
void CrossLinkPrototypes(); void CrossLinkPrototypes();
// implements Message ---------------------------------------------- // implements Message ----------------------------------------------

@ -28,7 +28,6 @@ static void InitDefaultsscc_info_Empty_google_2fprotobuf_2fempty_2eproto() {
new (ptr) PROTOBUF_NAMESPACE_ID::Empty(); new (ptr) PROTOBUF_NAMESPACE_ID::Empty();
::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
} }
PROTOBUF_NAMESPACE_ID::Empty::InitAsDefaultInstance();
} }
PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_Empty_google_2fprotobuf_2fempty_2eproto = PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_Empty_google_2fprotobuf_2fempty_2eproto =
@ -55,10 +54,10 @@ static ::PROTOBUF_NAMESPACE_ID::Message const * const file_default_instances[] =
const char descriptor_table_protodef_google_2fprotobuf_2fempty_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = const char descriptor_table_protodef_google_2fprotobuf_2fempty_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) =
"\n\033google/protobuf/empty.proto\022\017google.pr" "\n\033google/protobuf/empty.proto\022\017google.pr"
"otobuf\"\007\n\005EmptyBv\n\023com.google.protobufB\n" "otobuf\"\007\n\005EmptyB}\n\023com.google.protobufB\n"
"EmptyProtoP\001Z\'github.com/golang/protobuf" "EmptyProtoP\001Z.google.golang.org/protobuf"
"/ptypes/empty\370\001\001\242\002\003GPB\252\002\036Google.Protobuf" "/types/known/emptypb\370\001\001\242\002\003GPB\252\002\036Google.P"
".WellKnownTypesb\006proto3" "rotobuf.WellKnownTypesb\006proto3"
; ;
static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_google_2fprotobuf_2fempty_2eproto_deps[1] = { static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_google_2fprotobuf_2fempty_2eproto_deps[1] = {
}; };
@ -67,7 +66,7 @@ static ::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase*const descriptor_table_goo
}; };
static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_google_2fprotobuf_2fempty_2eproto_once; 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 = { 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, &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, 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, file_level_metadata_google_2fprotobuf_2fempty_2eproto, 1, file_level_enum_descriptors_google_2fprotobuf_2fempty_2eproto, file_level_service_descriptors_google_2fprotobuf_2fempty_2eproto,
@ -79,8 +78,6 @@ PROTOBUF_NAMESPACE_OPEN
// =================================================================== // ===================================================================
void Empty::InitAsDefaultInstance() {
}
class Empty::_Internal { class Empty::_Internal {
public: public:
}; };

@ -102,7 +102,6 @@ class PROTOBUF_EXPORT Empty PROTOBUF_FINAL :
} }
static const Empty& default_instance(); static const Empty& default_instance();
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
static inline const Empty* internal_default_instance() { static inline const Empty* internal_default_instance() {
return reinterpret_cast<const Empty*>( return reinterpret_cast<const Empty*>(
&_Empty_default_instance_); &_Empty_default_instance_);

@ -33,7 +33,7 @@ syntax = "proto3";
package google.protobuf; package google.protobuf;
option csharp_namespace = "Google.Protobuf.WellKnownTypes"; 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_package = "com.google.protobuf";
option java_outer_classname = "EmptyProto"; option java_outer_classname = "EmptyProto";
option java_multiple_files = true; option java_multiple_files = true;

@ -1870,28 +1870,32 @@ void ExtensionSet::GrowCapacity(size_t minimum_new_capacity) {
return; return;
} }
const auto old_flat_capacity = flat_capacity_; auto new_flat_capacity = flat_capacity_;
do { do {
flat_capacity_ = flat_capacity_ == 0 ? 1 : flat_capacity_ * 4; new_flat_capacity = new_flat_capacity == 0 ? 1 : new_flat_capacity * 4;
} while (flat_capacity_ < minimum_new_capacity); } while (new_flat_capacity < minimum_new_capacity);
const KeyValue* begin = flat_begin(); const KeyValue* begin = flat_begin();
const KeyValue* end = flat_end(); const KeyValue* end = flat_end();
if (flat_capacity_ > kMaximumFlatCapacity) { AllocatedData new_map;
// Switch to LargeMap if (new_flat_capacity > kMaximumFlatCapacity) {
map_.large = Arena::Create<LargeMap>(arena_); new_map.large = Arena::Create<LargeMap>(arena_);
LargeMap::iterator hint = map_.large->begin(); LargeMap::iterator hint = new_map.large->begin();
for (const KeyValue* it = begin; it != end; ++it) { for (const KeyValue* it = begin; it != end; ++it) {
hint = map_.large->insert(hint, {it->first, it->second}); hint = new_map.large->insert(hint, {it->first, it->second});
} }
flat_size_ = 0;
} else { } else {
map_.flat = Arena::CreateArray<KeyValue>(arena_, flat_capacity_); new_map.flat = Arena::CreateArray<KeyValue>(arena_, new_flat_capacity);
std::copy(begin, end, map_.flat); std::copy(begin, end, new_map.flat);
} }
if (arena_ == nullptr) { if (arena_ == nullptr) {
DeleteFlatMap(begin, old_flat_capacity); DeleteFlatMap(begin, flat_capacity_);
}
flat_capacity_ = new_flat_capacity;
map_ = new_map;
if (is_large()) {
flat_size_ = 0;
} }
} }

@ -1105,8 +1105,6 @@ TEST(ExtensionSetTest, RepeatedFields) {
ASSERT_EQ(msg_const_iter->bb(), 1234); 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. // Test one primitive field.
for (auto& x : for (auto& x :
*message.MutableRepeatedExtension(unittest::repeated_int32_extension)) { *message.MutableRepeatedExtension(unittest::repeated_int32_extension)) {
@ -1134,7 +1132,6 @@ TEST(ExtensionSetTest, RepeatedFields) {
unittest::repeated_nested_message_extension)) { unittest::repeated_nested_message_extension)) {
ASSERT_EQ(x.bb(), 4321); ASSERT_EQ(x.bb(), 4321);
} }
#endif
} }
// From b/12926163 // From b/12926163

@ -28,7 +28,6 @@ static void InitDefaultsscc_info_FieldMask_google_2fprotobuf_2ffield_5fmask_2epr
new (ptr) PROTOBUF_NAMESPACE_ID::FieldMask(); new (ptr) PROTOBUF_NAMESPACE_ID::FieldMask();
::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
} }
PROTOBUF_NAMESPACE_ID::FieldMask::InitAsDefaultInstance();
} }
PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_FieldMask_google_2fprotobuf_2ffield_5fmask_2eproto = PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_FieldMask_google_2fprotobuf_2ffield_5fmask_2eproto =
@ -57,10 +56,10 @@ static ::PROTOBUF_NAMESPACE_ID::Message const * const file_default_instances[] =
const char descriptor_table_protodef_google_2fprotobuf_2ffield_5fmask_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = const char descriptor_table_protodef_google_2fprotobuf_2ffield_5fmask_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) =
"\n google/protobuf/field_mask.proto\022\017goog" "\n google/protobuf/field_mask.proto\022\017goog"
"le.protobuf\"\032\n\tFieldMask\022\r\n\005paths\030\001 \003(\tB" "le.protobuf\"\032\n\tFieldMask\022\r\n\005paths\030\001 \003(\tB"
"\214\001\n\023com.google.protobufB\016FieldMaskProtoP" "\205\001\n\023com.google.protobufB\016FieldMaskProtoP"
"\001Z9google.golang.org/genproto/protobuf/f" "\001Z2google.golang.org/protobuf/types/know"
"ield_mask;field_mask\370\001\001\242\002\003GPB\252\002\036Google.P" "n/fieldmaskpb\370\001\001\242\002\003GPB\252\002\036Google.Protobuf"
"rotobuf.WellKnownTypesb\006proto3" ".WellKnownTypesb\006proto3"
; ;
static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto_deps[1] = { static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto_deps[1] = {
}; };
@ -69,7 +68,7 @@ static ::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase*const descriptor_table_goo
}; };
static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto_once; 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 = { 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, &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, 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, 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,
@ -81,8 +80,6 @@ PROTOBUF_NAMESPACE_OPEN
// =================================================================== // ===================================================================
void FieldMask::InitAsDefaultInstance() {
}
class FieldMask::_Internal { class FieldMask::_Internal {
public: public:
}; };

@ -102,7 +102,6 @@ class PROTOBUF_EXPORT FieldMask PROTOBUF_FINAL :
} }
static const FieldMask& default_instance(); static const FieldMask& default_instance();
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
static inline const FieldMask* internal_default_instance() { static inline const FieldMask* internal_default_instance() {
return reinterpret_cast<const FieldMask*>( return reinterpret_cast<const FieldMask*>(
&_FieldMask_default_instance_); &_FieldMask_default_instance_);

@ -37,7 +37,7 @@ option java_package = "com.google.protobuf";
option java_outer_classname = "FieldMaskProto"; option java_outer_classname = "FieldMaskProto";
option java_multiple_files = true; option java_multiple_files = true;
option objc_class_prefix = "GPB"; 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; option cc_enable_arenas = true;
// `FieldMask` represents a set of symbolic field paths, for example: // `FieldMask` represents a set of symbolic field paths, for example:

@ -320,15 +320,16 @@ size_t Reflection::SpaceUsedLong(const Message& message) const {
break; break;
} }
// Initially, the string points to the default value stored
// in the prototype. Only count the string if it has been
// changed from the default value.
const std::string* default_ptr =
&DefaultRaw<ArenaStringPtr>(field).Get();
const std::string* ptr = const std::string* ptr =
&GetField<ArenaStringPtr>(message, field).Get(); &GetField<ArenaStringPtr>(message, field).Get();
if (ptr != default_ptr) { // Initially, the string points to the default value stored
// in the prototype. Only count the string if it has been
// changed from the default value.
// Except oneof fields, those never point to a default instance,
// and there is no default instance to point to.
if (schema_.InRealOneof(field) ||
ptr != &DefaultRaw<ArenaStringPtr>(field).Get()) {
// string fields are represented by just a pointer, so also // string fields are represented by just a pointer, so also
// include sizeof(string) as well. // include sizeof(string) as well.
total_size += total_size +=
@ -359,8 +360,6 @@ size_t Reflection::SpaceUsedLong(const Message& message) const {
void Reflection::SwapField(Message* message1, Message* message2, void Reflection::SwapField(Message* message1, Message* message2,
const FieldDescriptor* field) const { const FieldDescriptor* field) const {
CheckInvalidAccess(schema_, field);
if (field->is_repeated()) { if (field->is_repeated()) {
switch (field->cpp_type()) { switch (field->cpp_type()) {
#define SWAP_ARRAYS(CPPTYPE, TYPE) \ #define SWAP_ARRAYS(CPPTYPE, TYPE) \
@ -1121,6 +1120,8 @@ void Reflection::ListFieldsOmitStripped(
if (field->is_extension()) { \ if (field->is_extension()) { \
return GetExtensionSet(message).Get##TYPENAME( \ return GetExtensionSet(message).Get##TYPENAME( \
field->number(), field->default_value_##PASSTYPE()); \ field->number(), field->default_value_##PASSTYPE()); \
} else if (schema_.InRealOneof(field) && !HasOneofField(message, field)) { \
return field->default_value_##PASSTYPE(); \
} else { \ } else { \
return GetField<TYPE>(message, field); \ return GetField<TYPE>(message, field); \
} \ } \
@ -1190,6 +1191,9 @@ std::string Reflection::GetString(const Message& message,
return GetExtensionSet(message).GetString(field->number(), return GetExtensionSet(message).GetString(field->number(),
field->default_value_string()); field->default_value_string());
} else { } else {
if (schema_.InRealOneof(field) && !HasOneofField(message, field)) {
return field->default_value_string();
}
switch (field->options().ctype()) { switch (field->options().ctype()) {
default: // TODO(kenton): Support other string reps. default: // TODO(kenton): Support other string reps.
case FieldOptions::STRING: { case FieldOptions::STRING: {
@ -1211,6 +1215,9 @@ const std::string& Reflection::GetStringReference(const Message& message,
return GetExtensionSet(message).GetString(field->number(), return GetExtensionSet(message).GetString(field->number(),
field->default_value_string()); field->default_value_string());
} else { } else {
if (schema_.InRealOneof(field) && !HasOneofField(message, field)) {
return field->default_value_string();
}
switch (field->options().ctype()) { switch (field->options().ctype()) {
default: // TODO(kenton): Support other string reps. default: // TODO(kenton): Support other string reps.
case FieldOptions::STRING: { case FieldOptions::STRING: {
@ -1241,16 +1248,21 @@ void Reflection::SetString(Message* message, const FieldDescriptor* field,
break; break;
} }
// Oneof string fields are never set as a default instance.
// We just need to pass some arbitrary default string to make it work.
// This allows us to not have the real default accessible from
// reflection.
const std::string* default_ptr = const std::string* default_ptr =
&DefaultRaw<ArenaStringPtr>(field).Get(); schema_.InRealOneof(field)
? &GetEmptyString()
: &DefaultRaw<ArenaStringPtr>(field).Get();
if (schema_.InRealOneof(field) && !HasOneofField(*message, field)) { if (schema_.InRealOneof(field) && !HasOneofField(*message, field)) {
ClearOneof(message, field->containing_oneof()); ClearOneof(message, field->containing_oneof());
MutableField<ArenaStringPtr>(message, field) MutableField<ArenaStringPtr>(message, field)
->UnsafeSetDefault(default_ptr); ->UnsafeSetDefault(default_ptr);
} }
MutableField<ArenaStringPtr>(message, field) MutableField<ArenaStringPtr>(message, field)
->Mutable(default_ptr, GetArena(message)) ->Set(default_ptr, std::move(value), GetArena(message));
->assign(std::move(value));
break; break;
} }
} }
@ -1342,6 +1354,8 @@ int Reflection::GetEnumValue(const Message& message,
if (field->is_extension()) { if (field->is_extension()) {
value = GetExtensionSet(message).GetEnum( value = GetExtensionSet(message).GetEnum(
field->number(), field->default_value_enum()->number()); field->number(), field->default_value_enum()->number());
} else if (schema_.InRealOneof(field) && !HasOneofField(message, field)) {
value = field->default_value_enum()->number();
} else { } else {
value = GetField<int>(message, field); value = GetField<int>(message, field);
} }
@ -1476,6 +1490,40 @@ void Reflection::AddEnumValueInternal(Message* message,
// ------------------------------------------------------------------- // -------------------------------------------------------------------
const Message* Reflection::GetDefaultMessageInstance(
const FieldDescriptor* field) const {
// If we are using the generated factory, we cache the prototype in the field
// descriptor for faster access.
// The default instances of generated messages are not cross-linked, which
// means they contain null pointers on their message fields and can't be used
// to get the default of submessages.
if (message_factory_ == MessageFactory::generated_factory()) {
auto& ptr = field->default_generated_instance_;
auto* res = ptr.load(std::memory_order_acquire);
if (res == nullptr) {
// First time asking for this field's default. Load it and cache it.
res = message_factory_->GetPrototype(field->message_type());
ptr.store(res, std::memory_order_release);
}
return res;
}
// For other factories, we try the default's object field.
// In particular, the DynamicMessageFactory will cross link the default
// instances to allow for this. But only do this for real fields.
// This is an optimization to avoid going to GetPrototype() below, as that
// requires a lock and a map lookup.
if (!field->is_extension() && !field->options().weak() &&
!field->options().lazy() && !schema_.InRealOneof(field)) {
auto* res = DefaultRaw<const Message*>(field);
if (res != nullptr) {
return res;
}
}
// Otherwise, just go to the factory.
return message_factory_->GetPrototype(field->message_type());
}
const Message& Reflection::GetMessage(const Message& message, const Message& Reflection::GetMessage(const Message& message,
const FieldDescriptor* field, const FieldDescriptor* field,
MessageFactory* factory) const { MessageFactory* factory) const {
@ -1488,9 +1536,12 @@ const Message& Reflection::GetMessage(const Message& message,
return static_cast<const Message&>(GetExtensionSet(message).GetMessage( return static_cast<const Message&>(GetExtensionSet(message).GetMessage(
field->number(), field->message_type(), factory)); field->number(), field->message_type(), factory));
} else { } else {
if (schema_.InRealOneof(field) && !HasOneofField(message, field)) {
return *GetDefaultMessageInstance(field);
}
const Message* result = GetRaw<const Message*>(message, field); const Message* result = GetRaw<const Message*>(message, field);
if (result == nullptr) { if (result == nullptr) {
result = DefaultRaw<const Message*>(field); result = GetDefaultMessageInstance(field);
} }
return *result; return *result;
} }
@ -1516,7 +1567,7 @@ Message* Reflection::MutableMessage(Message* message,
if (!HasOneofField(*message, field)) { if (!HasOneofField(*message, field)) {
ClearOneof(message, field->containing_oneof()); ClearOneof(message, field->containing_oneof());
result_holder = MutableField<Message*>(message, field); result_holder = MutableField<Message*>(message, field);
const Message* default_message = DefaultRaw<const Message*>(field); const Message* default_message = GetDefaultMessageInstance(field);
*result_holder = default_message->New(message->GetArena()); *result_holder = default_message->New(message->GetArena());
} }
} else { } else {
@ -1524,7 +1575,7 @@ Message* Reflection::MutableMessage(Message* message,
} }
if (*result_holder == nullptr) { if (*result_holder == nullptr) {
const Message* default_message = DefaultRaw<const Message*>(field); const Message* default_message = GetDefaultMessageInstance(field);
*result_holder = default_message->New(message->GetArena()); *result_holder = default_message->New(message->GetArena());
} }
result = *result_holder; result = *result_holder;
@ -1903,9 +1954,8 @@ Type* Reflection::MutableRawNonOneof(Message* message,
template <typename Type> template <typename Type>
const Type& Reflection::GetRaw(const Message& message, const Type& Reflection::GetRaw(const Message& message,
const FieldDescriptor* field) const { const FieldDescriptor* field) const {
if (schema_.InRealOneof(field) && !HasOneofField(message, field)) { GOOGLE_DCHECK(!schema_.InRealOneof(field) || HasOneofField(message, field))
return DefaultRaw<Type>(field); << "Field = " << field->full_name();
}
return GetConstRefAtOffset<Type>(message, schema_.GetFieldOffset(field)); return GetConstRefAtOffset<Type>(message, schema_.GetFieldOffset(field));
} }
@ -2044,9 +2094,6 @@ void Reflection::SetBit(Message* message, const FieldDescriptor* field) const {
void Reflection::ClearBit(Message* message, void Reflection::ClearBit(Message* message,
const FieldDescriptor* field) const { const FieldDescriptor* field) const {
GOOGLE_DCHECK(!field->options().weak()); GOOGLE_DCHECK(!field->options().weak());
if (!schema_.HasHasbits()) {
return;
}
const uint32 index = schema_.HasBitIndex(field); const uint32 index = schema_.HasBitIndex(field);
if (index == -1) return; if (index == -1) return;
MutableHasBits(message)[index / 32] &= MutableHasBits(message)[index / 32] &=
@ -2115,8 +2162,11 @@ void Reflection::ClearOneof(Message* message,
switch (field->options().ctype()) { switch (field->options().ctype()) {
default: // TODO(kenton): Support other string reps. default: // TODO(kenton): Support other string reps.
case FieldOptions::STRING: { case FieldOptions::STRING: {
const std::string* default_ptr = // Oneof string fields are never set as a default instance.
&DefaultRaw<ArenaStringPtr>(field).Get(); // We just need to pass some arbitrary default string to make it
// work. This allows us to not have the real default accessible
// from reflection.
const std::string* default_ptr = &GetEmptyString();
MutableField<ArenaStringPtr>(message, field) MutableField<ArenaStringPtr>(message, field)
->Destroy(default_ptr, GetArena(message)); ->Destroy(default_ptr, GetArena(message));
break; break;

@ -212,6 +212,12 @@ struct ReflectionSchema {
OffsetValue(offsets_[field->index()], field->type()); OffsetValue(offsets_[field->index()], field->type());
} }
// Returns true if the field's accessor is called by any external code (aka,
// non proto library code).
bool IsFieldUsed(const FieldDescriptor* field) const {
return true;
}
bool IsFieldStripped(const FieldDescriptor* field) const { bool IsFieldStripped(const FieldDescriptor* field) const {
return false; return false;
} }
@ -242,6 +248,7 @@ struct ReflectionSchema {
// We tag offset values to provide additional data about fields (such as // We tag offset values to provide additional data about fields (such as
// inlined). // inlined).
static uint32 OffsetValue(uint32 v, FieldDescriptor::Type type) { static uint32 OffsetValue(uint32 v, FieldDescriptor::Type type) {
v &= 0x7FFFFFFFu;
if (type == FieldDescriptor::TYPE_STRING || if (type == FieldDescriptor::TYPE_STRING ||
type == FieldDescriptor::TYPE_BYTES) { type == FieldDescriptor::TYPE_BYTES) {
return v & ~1u; return v & ~1u;
@ -296,6 +303,13 @@ struct PROTOBUF_EXPORT DescriptorTable {
const ServiceDescriptor** file_level_service_descriptors; const ServiceDescriptor** file_level_service_descriptors;
}; };
enum {
// Tag used on offsets for fields that don't have a real offset.
// For example, weak message fields go into the WeakFieldMap and not in an
// actual field.
kInvalidFieldOffsetTag = 0x40000000u,
};
// AssignDescriptors() pulls the compiled FileDescriptor from the DescriptorPool // AssignDescriptors() pulls the compiled FileDescriptor from the DescriptorPool
// and uses it to populate all of the global variables which store pointers to // and uses it to populate all of the global variables which store pointers to
// the descriptor objects. It also constructs the reflection objects. It is // the descriptor objects. It also constructs the reflection objects. It is

@ -486,6 +486,7 @@ TEST(GeneratedMessageReflectionTest, FindKnownExtensionByName) {
->FindKnownExtensionByName(extension1->full_name()) == NULL); ->FindKnownExtensionByName(extension1->full_name()) == NULL);
} }
TEST(GeneratedMessageReflectionTest, SetAllocatedMessageTest) { TEST(GeneratedMessageReflectionTest, SetAllocatedMessageTest) {
unittest::TestAllTypes from_message1; unittest::TestAllTypes from_message1;
unittest::TestAllTypes from_message2; unittest::TestAllTypes from_message2;

@ -65,7 +65,7 @@ void DestroyMessage(const void* message) {
static_cast<const MessageLite*>(message)->~MessageLite(); static_cast<const MessageLite*>(message)->~MessageLite();
} }
void DestroyString(const void* s) { 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; ExplicitlyConstructed<std::string> fixed_address_empty_string;

@ -940,14 +940,15 @@ static void AppendUTF8(uint32 code_point, std::string* output) {
tmp = 0x00e08080 | ((code_point & 0xf000) << 4) | tmp = 0x00e08080 | ((code_point & 0xf000) << 4) |
((code_point & 0x0fc0) << 2) | (code_point & 0x003f); ((code_point & 0x0fc0) << 2) | (code_point & 0x003f);
len = 3; len = 3;
} else if (code_point <= 0x1fffff) { } else if (code_point <= 0x10ffff) {
tmp = 0xf0808080 | ((code_point & 0x1c0000) << 6) | tmp = 0xf0808080 | ((code_point & 0x1c0000) << 6) |
((code_point & 0x03f000) << 4) | ((code_point & 0x000fc0) << 2) | ((code_point & 0x03f000) << 4) | ((code_point & 0x000fc0) << 2) |
(code_point & 0x003f); (code_point & 0x003f);
len = 4; len = 4;
} else { } else {
// UTF-16 is only defined for code points up to 0x10FFFF, and UTF-8 is // Unicode code points end at 0x10FFFF, so this is out-of-range.
// normally only defined up to there as well. // ConsumeString permits hex values up to 0x1FFFFF, and FetchUnicodePoint
// doesn't perform a range check.
StringAppendF(output, "\\U%08x", code_point); StringAppendF(output, "\\U%08x", code_point);
return; return;
} }

@ -808,8 +808,11 @@ TEST_F(TokenizerTest, ParseString) {
Tokenizer::ParseString("'\\ud852XX'", &output); Tokenizer::ParseString("'\\ud852XX'", &output);
EXPECT_EQ("\xed\xa1\x92XX", output); EXPECT_EQ("\xed\xa1\x92XX", output);
// Malformed escape: Demons may fly out of the nose. // Malformed escape: Demons may fly out of the nose.
Tokenizer::ParseString("\\u0", &output); Tokenizer::ParseString("'\\u0'", &output);
EXPECT_EQ("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. // Test invalid strings that will never be tokenized as strings.
#ifdef PROTOBUF_HAS_DEATH_TEST // death tests do not work on Windows yet #ifdef PROTOBUF_HAS_DEATH_TEST // death tests do not work on Windows yet

@ -48,7 +48,6 @@
#include <google/protobuf/io/zero_copy_stream.h> #include <google/protobuf/io/zero_copy_stream.h>
#include <google/protobuf/io/zero_copy_stream_impl_lite.h> #include <google/protobuf/io/zero_copy_stream_impl_lite.h>
#include <google/protobuf/port_def.inc> #include <google/protobuf/port_def.inc>
namespace google { namespace google {

@ -140,29 +140,25 @@ StringOutputStream::StringOutputStream(std::string* target) : target_(target) {}
bool StringOutputStream::Next(void** data, int* size) { bool StringOutputStream::Next(void** data, int* size) {
GOOGLE_CHECK(target_ != NULL); GOOGLE_CHECK(target_ != NULL);
int old_size = target_->size(); size_t old_size = target_->size();
// Grow the string. // Grow the string.
size_t new_size;
if (old_size < target_->capacity()) { if (old_size < target_->capacity()) {
// Resize the string to match its capacity, since we can get away // Resize the string to match its capacity, since we can get away
// without a memory allocation this way. // without a memory allocation this way.
STLStringResizeUninitialized(target_, target_->capacity()); new_size = target_->capacity();
} else { } else {
// Size has reached capacity, try to double the size. // Size has reached capacity, try to double it.
if (old_size > std::numeric_limits<int>::max() / 2) { new_size = old_size * 2;
// Can not double the size otherwise it is going to cause integer
// overflow in the expression below: old_size * 2 ";
GOOGLE_LOG(ERROR) << "Cannot allocate buffer larger than kint32max for "
<< "StringOutputStream.";
return false;
}
// Double the size, also make sure that the new size is at least
// kMinimumSize.
STLStringResizeUninitialized(
target_,
std::max(old_size * 2,
kMinimumSize + 0)); // "+ 0" works around GCC4 weirdness.
} }
// Avoid integer overflow in returned '*size'.
new_size = std::min(new_size, old_size + std::numeric_limits<int>::max());
// Increase the size, also make sure that it is at least kMinimumSize.
STLStringResizeUninitialized(
target_,
std::max(new_size,
kMinimumSize + 0)); // "+ 0" works around GCC4 weirdness.
*data = mutable_string_data(target_) + old_size; *data = mutable_string_data(target_) + old_size;
*size = target_->size() - old_size; *size = target_->size() - old_size;

@ -150,7 +150,7 @@ class PROTOBUF_EXPORT StringOutputStream : public ZeroCopyOutputStream {
int64_t ByteCount() const override; int64_t ByteCount() const override;
private: private:
static const int kMinimumSize = 16; static constexpr size_t kMinimumSize = 16;
std::string* target_; std::string* target_;

@ -712,6 +712,21 @@ TEST_F(IoTest, StringIo) {
} }
} }
// Verifies that outputs up to kint32max can be created.
TEST_F(IoTest, LargeOutput) {
std::string str;
StringOutputStream output(&str);
void* unused_data;
int size;
// Repeatedly calling Next should eventually grow the buffer to kint32max.
do {
EXPECT_TRUE(output.Next(&unused_data, &size));
} while (str.size() < std::numeric_limits<int>::max());
// Further increases should be possible.
output.Next(&unused_data, &size);
EXPECT_GT(size, 0);
}
// To test files, we create a temporary file, write, read, truncate, repeat. // To test files, we create a temporary file, write, read, truncate, repeat.
TEST_F(IoTest, FileIo) { TEST_F(IoTest, FileIo) {

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save