Переглянути джерело

Down-integrate internal changes to github.

Bo Yang 8 роки тому
батько
коміт
9cb253f46e
100 змінених файлів з 4179 додано та 2410 видалено
  1. 1 0
      conformance/failure_list_java.txt
  2. 520 0
      conformance/failure_list_python.txt
  3. 504 0
      conformance/failure_list_python_cpp.txt
  4. 0 1
      java/core/src/main/java/com/google/protobuf/AbstractMessageLite.java
  5. 1 0
      java/core/src/main/java/com/google/protobuf/FieldSet.java
  6. 1 1
      java/core/src/main/java/com/google/protobuf/MapFieldLite.java
  7. 12 9
      java/core/src/main/java/com/google/protobuf/SmallSortedMap.java
  8. 19 14
      java/core/src/main/java/com/google/protobuf/UnknownFieldSet.java
  9. 24 6
      java/core/src/main/java/com/google/protobuf/UnknownFieldSetLite.java
  10. 8 0
      java/core/src/test/java/com/google/protobuf/UnknownFieldSetLiteTest.java
  11. 2 2
      js/binary/decoder.js
  12. 5 5
      js/binary/decoder_test.js
  13. 2 2
      js/binary/encoder.js
  14. 60 0
      js/binary/message_test.js
  15. 35 23
      js/map.js
  16. 47 0
      js/maps_test.js
  17. 32 2
      js/message.js
  18. 0 19
      js/message_test.js
  19. 12 2
      objectivec/google/protobuf/Type.pbobjc.h
  20. 7 12
      python/google/protobuf/internal/python_message.py
  21. 2 0
      python/google/protobuf/pyext/extension_dict.cc
  22. 3 1
      python/google/protobuf/pyext/message.cc
  23. 57 41
      src/google/protobuf/any.pb.cc
  24. 35 8
      src/google/protobuf/any.pb.h
  25. 143 87
      src/google/protobuf/api.pb.cc
  26. 137 61
      src/google/protobuf/api.pb.h
  27. 6 17
      src/google/protobuf/arena.cc
  28. 14 10
      src/google/protobuf/arena.h
  29. 14 11
      src/google/protobuf/arenastring.h
  30. 35 16
      src/google/protobuf/compiler/command_line_interface.cc
  31. 4 0
      src/google/protobuf/compiler/command_line_interface.h
  32. 38 1
      src/google/protobuf/compiler/command_line_interface_unittest.cc
  33. 4 2
      src/google/protobuf/compiler/cpp/cpp_enum.cc
  34. 1 1
      src/google/protobuf/compiler/cpp/cpp_enum_field.cc
  35. 82 100
      src/google/protobuf/compiler/cpp/cpp_file.cc
  36. 2 17
      src/google/protobuf/compiler/cpp/cpp_helpers.cc
  37. 3 11
      src/google/protobuf/compiler/cpp/cpp_helpers.h
  38. 3 1
      src/google/protobuf/compiler/cpp/cpp_map_field.cc
  39. 75 72
      src/google/protobuf/compiler/cpp/cpp_message.cc
  40. 3 3
      src/google/protobuf/compiler/cpp/cpp_message.h
  41. 0 4
      src/google/protobuf/compiler/cpp/cpp_message_field.cc
  42. 28 22
      src/google/protobuf/compiler/cpp/cpp_primitive_field.cc
  43. 4 3
      src/google/protobuf/compiler/cpp/cpp_service.cc
  44. 34 7
      src/google/protobuf/compiler/cpp/cpp_string_field.cc
  45. 46 0
      src/google/protobuf/compiler/cpp/cpp_unittest.cc
  46. 1 0
      src/google/protobuf/compiler/java/java_enum_field_lite.cc
  47. 1 0
      src/google/protobuf/compiler/java/java_message_field_lite.cc
  48. 2 2
      src/google/protobuf/compiler/java/java_message_lite.cc
  49. 1 0
      src/google/protobuf/compiler/java/java_primitive_field_lite.cc
  50. 5 12
      src/google/protobuf/compiler/java/java_shared_code_generator.cc
  51. 0 5
      src/google/protobuf/compiler/java/java_shared_code_generator.h
  52. 1 0
      src/google/protobuf/compiler/java/java_string_field_lite.cc
  53. 6 6
      src/google/protobuf/compiler/parser.cc
  54. 157 109
      src/google/protobuf/compiler/plugin.pb.cc
  55. 124 62
      src/google/protobuf/compiler/plugin.pb.h
  56. 8 0
      src/google/protobuf/descriptor.cc
  57. 443 443
      src/google/protobuf/descriptor.pb.cc
  58. 309 274
      src/google/protobuf/descriptor.pb.h
  59. 5 1
      src/google/protobuf/descriptor.proto
  60. 42 42
      src/google/protobuf/duration.pb.cc
  61. 13 8
      src/google/protobuf/duration.pb.h
  62. 27 36
      src/google/protobuf/dynamic_message.cc
  63. 85 1
      src/google/protobuf/dynamic_message.h
  64. 40 40
      src/google/protobuf/empty.pb.cc
  65. 13 8
      src/google/protobuf/empty.pb.h
  66. 12 6
      src/google/protobuf/extension_set_heavy.cc
  67. 40 40
      src/google/protobuf/field_mask.pb.cc
  68. 13 8
      src/google/protobuf/field_mask.pb.h
  69. 29 67
      src/google/protobuf/generated_message_reflection.cc
  70. 11 42
      src/google/protobuf/generated_message_reflection.h
  71. 125 1
      src/google/protobuf/generated_message_reflection_unittest.cc
  72. 31 0
      src/google/protobuf/has_bits.h
  73. 8 0
      src/google/protobuf/io/coded_stream.h
  74. 7 8
      src/google/protobuf/io/tokenizer_unittest.cc
  75. 8 14
      src/google/protobuf/io/zero_copy_stream_impl.cc
  76. 2 2
      src/google/protobuf/io/zero_copy_stream_unittest.cc
  77. 3 2
      src/google/protobuf/map.h
  78. 0 1
      src/google/protobuf/map_entry.h
  79. 2 3
      src/google/protobuf/map_entry_lite.h
  80. 5 1
      src/google/protobuf/map_test.cc
  81. 4 4
      src/google/protobuf/message.cc
  82. 1 1
      src/google/protobuf/message.h
  83. 1 0
      src/google/protobuf/message_lite.cc
  84. 3 3
      src/google/protobuf/message_unittest.cc
  85. 9 8
      src/google/protobuf/repeated_field.h
  86. 48 40
      src/google/protobuf/source_context.pb.cc
  87. 24 8
      src/google/protobuf/source_context.pb.h
  88. 98 99
      src/google/protobuf/struct.pb.cc
  89. 19 20
      src/google/protobuf/struct.pb.h
  90. 0 1
      src/google/protobuf/stubs/port.h
  91. 6 64
      src/google/protobuf/text_format.cc
  92. 42 42
      src/google/protobuf/timestamp.pb.cc
  93. 13 8
      src/google/protobuf/timestamp.pb.h
  94. 136 136
      src/google/protobuf/type.pb.cc
  95. 106 113
      src/google/protobuf/type.pb.h
  96. 8 2
      src/google/protobuf/type.proto
  97. 2 1
      src/google/protobuf/util/field_mask_util.cc
  98. 3 3
      src/google/protobuf/util/internal/json_escaping.cc
  99. 11 10
      src/google/protobuf/util/internal/json_stream_parser.cc
  100. 1 9
      src/google/protobuf/util/internal/protostream_objectsource.cc

+ 1 - 0
conformance/failure_list_java.txt

@@ -32,6 +32,7 @@ Recommended.JsonInput.StringFieldSingleQuoteValue
 Recommended.JsonInput.StringFieldSurrogateInWrongOrder
 Recommended.JsonInput.StringFieldUnpairedHighSurrogate
 Recommended.JsonInput.StringFieldUnpairedLowSurrogate
+Recommended.JsonInput.StringFieldUppercaseEscapeLetter
 Recommended.JsonInput.Uint32MapFieldKeyNotQuoted
 Recommended.JsonInput.Uint64MapFieldKeyNotQuoted
 Required.JsonInput.EnumFieldNotQuoted

+ 520 - 0
conformance/failure_list_python.txt

@@ -1,13 +1,533 @@
+ProtobufInput.OneofZeroBool.JsonOutput
+ProtobufInput.OneofZeroBool.ProtobufOutput
+ProtobufInput.OneofZeroBytes.JsonOutput
+ProtobufInput.OneofZeroBytes.ProtobufOutput
+ProtobufInput.OneofZeroDouble.JsonOutput
+ProtobufInput.OneofZeroDouble.ProtobufOutput
+ProtobufInput.OneofZeroEnum.JsonOutput
+ProtobufInput.OneofZeroEnum.ProtobufOutput
+ProtobufInput.OneofZeroFloat.JsonOutput
+ProtobufInput.OneofZeroFloat.ProtobufOutput
+ProtobufInput.OneofZeroMessage.JsonOutput
+ProtobufInput.OneofZeroMessage.ProtobufOutput
+ProtobufInput.OneofZeroString.JsonOutput
+ProtobufInput.OneofZeroString.ProtobufOutput
+ProtobufInput.OneofZeroUint32.JsonOutput
+ProtobufInput.OneofZeroUint32.ProtobufOutput
+ProtobufInput.OneofZeroUint64.JsonOutput
+ProtobufInput.OneofZeroUint64.ProtobufOutput
+Recommended.FieldMaskNumbersDontRoundTrip.JsonOutput
+Recommended.FieldMaskPathsDontRoundTrip.JsonOutput
+Recommended.FieldMaskTooManyUnderscore.JsonOutput
+Recommended.JsonInput.BoolFieldAllCapitalFalse
+Recommended.JsonInput.BoolFieldAllCapitalTrue
+Recommended.JsonInput.BoolFieldCamelCaseFalse
+Recommended.JsonInput.BoolFieldCamelCaseTrue
+Recommended.JsonInput.BoolFieldDoubleQuotedFalse
+Recommended.JsonInput.BoolFieldDoubleQuotedTrue
+Recommended.JsonInput.BoolFieldIntegerOne
+Recommended.JsonInput.BoolFieldIntegerZero
+Recommended.JsonInput.BoolMapFieldKeyNotQuoted
 Recommended.JsonInput.DoubleFieldInfinityNotQuoted
 Recommended.JsonInput.DoubleFieldNanNotQuoted
 Recommended.JsonInput.DoubleFieldNegativeInfinityNotQuoted
+Recommended.JsonInput.DurationHas3FractionalDigits.Validator
+Recommended.JsonInput.DurationHas6FractionalDigits.Validator
+Recommended.JsonInput.DurationHas9FractionalDigits.Validator
+Recommended.JsonInput.DurationHasZeroFractionalDigit.Validator
+Recommended.JsonInput.FieldMaskInvalidCharacter
+Recommended.JsonInput.FieldNameDuplicate
+Recommended.JsonInput.FieldNameDuplicateDifferentCasing1
+Recommended.JsonInput.FieldNameDuplicateDifferentCasing2
+Recommended.JsonInput.FieldNameNotQuoted
+Recommended.JsonInput.FieldNameWithDoubleUnderscores.JsonOutput
+Recommended.JsonInput.FieldNameWithDoubleUnderscores.ProtobufOutput
+Recommended.JsonInput.FieldNameWithDoubleUnderscores.Validator
 Recommended.JsonInput.FloatFieldInfinityNotQuoted
 Recommended.JsonInput.FloatFieldNanNotQuoted
 Recommended.JsonInput.FloatFieldNegativeInfinityNotQuoted
+Recommended.JsonInput.Int32MapFieldKeyNotQuoted
+Recommended.JsonInput.Int64FieldBeString.Validator
+Recommended.JsonInput.Int64MapFieldKeyNotQuoted
+Recommended.JsonInput.JsonWithComments
+Recommended.JsonInput.MapFieldKeyIsNull
+Recommended.JsonInput.MapFieldValueIsNull
+Recommended.JsonInput.MissingCommaMultiline
+Recommended.JsonInput.MissingCommaOneLine
+Recommended.JsonInput.MultilineNoSpaces.JsonOutput
+Recommended.JsonInput.MultilineNoSpaces.ProtobufOutput
+Recommended.JsonInput.MultilineWithSpaces.JsonOutput
+Recommended.JsonInput.MultilineWithSpaces.ProtobufOutput
+Recommended.JsonInput.OneLineNoSpaces.JsonOutput
+Recommended.JsonInput.OneLineNoSpaces.ProtobufOutput
+Recommended.JsonInput.OneLineWithSpaces.JsonOutput
+Recommended.JsonInput.OneLineWithSpaces.ProtobufOutput
+Recommended.JsonInput.OneofZeroBool.JsonOutput
+Recommended.JsonInput.OneofZeroBool.ProtobufOutput
+Recommended.JsonInput.OneofZeroBytes.JsonOutput
+Recommended.JsonInput.OneofZeroBytes.ProtobufOutput
+Recommended.JsonInput.OneofZeroDouble.JsonOutput
+Recommended.JsonInput.OneofZeroDouble.ProtobufOutput
+Recommended.JsonInput.OneofZeroEnum.JsonOutput
+Recommended.JsonInput.OneofZeroEnum.ProtobufOutput
+Recommended.JsonInput.OneofZeroFloat.JsonOutput
+Recommended.JsonInput.OneofZeroFloat.ProtobufOutput
+Recommended.JsonInput.OneofZeroMessage.JsonOutput
+Recommended.JsonInput.OneofZeroMessage.ProtobufOutput
+Recommended.JsonInput.OneofZeroString.JsonOutput
+Recommended.JsonInput.OneofZeroString.ProtobufOutput
+Recommended.JsonInput.OneofZeroUint32.JsonOutput
+Recommended.JsonInput.OneofZeroUint32.ProtobufOutput
+Recommended.JsonInput.OneofZeroUint64.JsonOutput
+Recommended.JsonInput.OneofZeroUint64.ProtobufOutput
+Recommended.JsonInput.RepeatedFieldMessageElementIsNull
+Recommended.JsonInput.RepeatedFieldPrimitiveElementIsNull
+Recommended.JsonInput.RepeatedFieldTrailingComma
+Recommended.JsonInput.RepeatedFieldTrailingCommaWithNewlines
+Recommended.JsonInput.RepeatedFieldTrailingCommaWithSpace
+Recommended.JsonInput.RepeatedFieldTrailingCommaWithSpaceCommaSpace
+Recommended.JsonInput.StringEndsWithEscapeChar
+Recommended.JsonInput.StringFieldInvalidEscape
+Recommended.JsonInput.StringFieldSingleQuoteBoth
+Recommended.JsonInput.StringFieldSingleQuoteKey
+Recommended.JsonInput.StringFieldSingleQuoteValue
+Recommended.JsonInput.StringFieldSurrogateInWrongOrder
+Recommended.JsonInput.StringFieldUnpairedHighSurrogate
+Recommended.JsonInput.StringFieldUnpairedLowSurrogate
+Recommended.JsonInput.StringFieldUnterminatedEscape
+Recommended.JsonInput.StringFieldUppercaseEscapeLetter
+Recommended.JsonInput.TimestampHas3FractionalDigits.Validator
+Recommended.JsonInput.TimestampHas6FractionalDigits.Validator
+Recommended.JsonInput.TimestampHas9FractionalDigits.Validator
+Recommended.JsonInput.TimestampHasZeroFractionalDigit.Validator
+Recommended.JsonInput.TimestampZeroNormalized.Validator
+Recommended.JsonInput.TrailingCommaInAnObject
+Recommended.JsonInput.TrailingCommaInAnObjectWithNewlines
+Recommended.JsonInput.TrailingCommaInAnObjectWithSpace
+Recommended.JsonInput.TrailingCommaInAnObjectWithSpaceCommaSpace
+Recommended.JsonInput.Uint32MapFieldKeyNotQuoted
+Recommended.JsonInput.Uint64FieldBeString.Validator
+Recommended.JsonInput.Uint64MapFieldKeyNotQuoted
+Required.DurationProtoInputTooLarge.JsonOutput
+Required.DurationProtoInputTooSmall.JsonOutput
+Required.JsonInput.AllFieldAcceptNull.JsonOutput
+Required.JsonInput.AllFieldAcceptNull.ProtobufOutput
+Required.JsonInput.Any.JsonOutput
+Required.JsonInput.AnyNested.JsonOutput
+Required.JsonInput.AnyNested.ProtobufOutput
+Required.JsonInput.Any.ProtobufOutput
+Required.JsonInput.AnyUnorderedTypeTag.JsonOutput
+Required.JsonInput.AnyUnorderedTypeTag.ProtobufOutput
+Required.JsonInput.AnyWithDuration.JsonOutput
+Required.JsonInput.AnyWithDuration.ProtobufOutput
+Required.JsonInput.AnyWithFieldMask.JsonOutput
+Required.JsonInput.AnyWithFieldMask.ProtobufOutput
+Required.JsonInput.AnyWithInt32ValueWrapper.JsonOutput
+Required.JsonInput.AnyWithInt32ValueWrapper.ProtobufOutput
+Required.JsonInput.AnyWithStruct.JsonOutput
+Required.JsonInput.AnyWithStruct.ProtobufOutput
+Required.JsonInput.AnyWithTimestamp.JsonOutput
+Required.JsonInput.AnyWithTimestamp.ProtobufOutput
+Required.JsonInput.AnyWithValueForInteger.JsonOutput
+Required.JsonInput.AnyWithValueForInteger.ProtobufOutput
+Required.JsonInput.AnyWithValueForJsonObject.JsonOutput
+Required.JsonInput.AnyWithValueForJsonObject.ProtobufOutput
+Required.JsonInput.BoolFieldFalse.JsonOutput
+Required.JsonInput.BoolFieldFalse.ProtobufOutput
+Required.JsonInput.BoolFieldTrue.JsonOutput
+Required.JsonInput.BoolFieldTrue.ProtobufOutput
+Required.JsonInput.BoolMapEscapedKey.JsonOutput
+Required.JsonInput.BoolMapEscapedKey.ProtobufOutput
+Required.JsonInput.BoolMapField.JsonOutput
+Required.JsonInput.BoolMapField.ProtobufOutput
 Required.JsonInput.BytesFieldInvalidBase64Characters
+Required.JsonInput.BytesField.JsonOutput
+Required.JsonInput.BytesField.ProtobufOutput
+Required.JsonInput.BytesRepeatedField.JsonOutput
+Required.JsonInput.BytesRepeatedField.ProtobufOutput
+Required.JsonInput.DoubleFieldInfinity.JsonOutput
+Required.JsonInput.DoubleFieldInfinity.ProtobufOutput
+Required.JsonInput.DoubleFieldMaxNegativeValue.JsonOutput
+Required.JsonInput.DoubleFieldMaxNegativeValue.ProtobufOutput
+Required.JsonInput.DoubleFieldMaxPositiveValue.JsonOutput
+Required.JsonInput.DoubleFieldMaxPositiveValue.ProtobufOutput
+Required.JsonInput.DoubleFieldMinNegativeValue.JsonOutput
+Required.JsonInput.DoubleFieldMinNegativeValue.ProtobufOutput
+Required.JsonInput.DoubleFieldMinPositiveValue.JsonOutput
+Required.JsonInput.DoubleFieldMinPositiveValue.ProtobufOutput
+Required.JsonInput.DoubleFieldNan.JsonOutput
+Required.JsonInput.DoubleFieldNan.ProtobufOutput
+Required.JsonInput.DoubleFieldNegativeInfinity.JsonOutput
+Required.JsonInput.DoubleFieldNegativeInfinity.ProtobufOutput
+Required.JsonInput.DoubleFieldQuotedValue.JsonOutput
+Required.JsonInput.DoubleFieldQuotedValue.ProtobufOutput
+Required.JsonInput.DoubleFieldTooLarge
 Required.JsonInput.DoubleFieldTooSmall
+Required.JsonInput.DurationJsonInputTooLarge
+Required.JsonInput.DurationJsonInputTooSmall
+Required.JsonInput.DurationMaxValue.JsonOutput
+Required.JsonInput.DurationMaxValue.ProtobufOutput
+Required.JsonInput.DurationMinValue.JsonOutput
+Required.JsonInput.DurationMinValue.ProtobufOutput
+Required.JsonInput.DurationMissingS
+Required.JsonInput.DurationRepeatedValue.JsonOutput
+Required.JsonInput.DurationRepeatedValue.ProtobufOutput
+Required.JsonInput.EnumField.JsonOutput
+Required.JsonInput.EnumFieldNotQuoted
+Required.JsonInput.EnumFieldNumericValueNonZero.JsonOutput
+Required.JsonInput.EnumFieldNumericValueNonZero.ProtobufOutput
+Required.JsonInput.EnumFieldNumericValueZero.JsonOutput
+Required.JsonInput.EnumFieldNumericValueZero.ProtobufOutput
+Required.JsonInput.EnumField.ProtobufOutput
 Required.JsonInput.EnumFieldUnknownValue.Validator
+Required.JsonInput.EnumRepeatedField.JsonOutput
+Required.JsonInput.EnumRepeatedField.ProtobufOutput
+Required.JsonInput.FieldMask.JsonOutput
+Required.JsonInput.FieldMask.ProtobufOutput
+Required.JsonInput.FieldNameEscaped.JsonOutput
+Required.JsonInput.FieldNameEscaped.ProtobufOutput
+Required.JsonInput.FieldNameInLowerCamelCase.Validator
+Required.JsonInput.FieldNameInSnakeCase.JsonOutput
+Required.JsonInput.FieldNameInSnakeCase.ProtobufOutput
+Required.JsonInput.FieldNameWithMixedCases.JsonOutput
+Required.JsonInput.FieldNameWithMixedCases.ProtobufOutput
+Required.JsonInput.FieldNameWithMixedCases.Validator
+Required.JsonInput.FieldNameWithNumbers.JsonOutput
+Required.JsonInput.FieldNameWithNumbers.ProtobufOutput
+Required.JsonInput.FieldNameWithNumbers.Validator
+Required.JsonInput.FloatFieldInfinity.JsonOutput
+Required.JsonInput.FloatFieldInfinity.ProtobufOutput
+Required.JsonInput.FloatFieldMaxNegativeValue.JsonOutput
+Required.JsonInput.FloatFieldMaxNegativeValue.ProtobufOutput
+Required.JsonInput.FloatFieldMaxPositiveValue.JsonOutput
+Required.JsonInput.FloatFieldMaxPositiveValue.ProtobufOutput
+Required.JsonInput.FloatFieldMinNegativeValue.JsonOutput
+Required.JsonInput.FloatFieldMinNegativeValue.ProtobufOutput
+Required.JsonInput.FloatFieldMinPositiveValue.JsonOutput
+Required.JsonInput.FloatFieldMinPositiveValue.ProtobufOutput
+Required.JsonInput.FloatFieldNan.JsonOutput
+Required.JsonInput.FloatFieldNan.ProtobufOutput
+Required.JsonInput.FloatFieldNegativeInfinity.JsonOutput
+Required.JsonInput.FloatFieldNegativeInfinity.ProtobufOutput
+Required.JsonInput.FloatFieldQuotedValue.JsonOutput
+Required.JsonInput.FloatFieldQuotedValue.ProtobufOutput
 Required.JsonInput.FloatFieldTooLarge
 Required.JsonInput.FloatFieldTooSmall
+Required.JsonInput.HelloWorld.JsonOutput
+Required.JsonInput.HelloWorld.ProtobufOutput
+Required.JsonInput.Int32FieldExponentialFormat.JsonOutput
+Required.JsonInput.Int32FieldExponentialFormat.ProtobufOutput
+Required.JsonInput.Int32FieldFloatTrailingZero.JsonOutput
+Required.JsonInput.Int32FieldFloatTrailingZero.ProtobufOutput
+Required.JsonInput.Int32FieldLeadingSpace
+Required.JsonInput.Int32FieldLeadingZero
+Required.JsonInput.Int32FieldMaxFloatValue.JsonOutput
+Required.JsonInput.Int32FieldMaxFloatValue.ProtobufOutput
+Required.JsonInput.Int32FieldMaxValue.JsonOutput
+Required.JsonInput.Int32FieldMaxValue.ProtobufOutput
+Required.JsonInput.Int32FieldMinFloatValue.JsonOutput
+Required.JsonInput.Int32FieldMinFloatValue.ProtobufOutput
+Required.JsonInput.Int32FieldMinValue.JsonOutput
+Required.JsonInput.Int32FieldMinValue.ProtobufOutput
+Required.JsonInput.Int32FieldNegativeWithLeadingZero
+Required.JsonInput.Int32FieldNotInteger
+Required.JsonInput.Int32FieldNotNumber
+Required.JsonInput.Int32FieldPlusSign
+Required.JsonInput.Int32FieldStringValueEscaped.JsonOutput
+Required.JsonInput.Int32FieldStringValueEscaped.ProtobufOutput
+Required.JsonInput.Int32FieldStringValue.JsonOutput
+Required.JsonInput.Int32FieldStringValue.ProtobufOutput
+Required.JsonInput.Int32FieldTooLarge
+Required.JsonInput.Int32FieldTooSmall
+Required.JsonInput.Int32FieldTrailingSpace
+Required.JsonInput.Int32MapEscapedKey.JsonOutput
+Required.JsonInput.Int32MapEscapedKey.ProtobufOutput
+Required.JsonInput.Int32MapField.JsonOutput
+Required.JsonInput.Int32MapField.ProtobufOutput
+Required.JsonInput.Int64FieldMaxValue.JsonOutput
+Required.JsonInput.Int64FieldMaxValueNotQuoted.JsonOutput
+Required.JsonInput.Int64FieldMaxValueNotQuoted.ProtobufOutput
+Required.JsonInput.Int64FieldMaxValue.ProtobufOutput
+Required.JsonInput.Int64FieldMinValue.JsonOutput
+Required.JsonInput.Int64FieldMinValueNotQuoted.JsonOutput
+Required.JsonInput.Int64FieldMinValueNotQuoted.ProtobufOutput
+Required.JsonInput.Int64FieldMinValue.ProtobufOutput
+Required.JsonInput.Int64FieldNotInteger
+Required.JsonInput.Int64FieldNotNumber
+Required.JsonInput.Int64FieldTooLarge
+Required.JsonInput.Int64FieldTooSmall
+Required.JsonInput.Int64MapEscapedKey.JsonOutput
+Required.JsonInput.Int64MapEscapedKey.ProtobufOutput
+Required.JsonInput.Int64MapField.JsonOutput
+Required.JsonInput.Int64MapField.ProtobufOutput
+Required.JsonInput.MessageField.JsonOutput
+Required.JsonInput.MessageField.ProtobufOutput
+Required.JsonInput.MessageMapField.JsonOutput
+Required.JsonInput.MessageMapField.ProtobufOutput
+Required.JsonInput.MessageRepeatedField.JsonOutput
+Required.JsonInput.MessageRepeatedField.ProtobufOutput
+Required.JsonInput.OneofFieldDuplicate
+Required.JsonInput.OptionalBoolWrapper.JsonOutput
+Required.JsonInput.OptionalBoolWrapper.ProtobufOutput
+Required.JsonInput.OptionalBytesWrapper.JsonOutput
+Required.JsonInput.OptionalBytesWrapper.ProtobufOutput
+Required.JsonInput.OptionalDoubleWrapper.JsonOutput
+Required.JsonInput.OptionalDoubleWrapper.ProtobufOutput
+Required.JsonInput.OptionalFloatWrapper.JsonOutput
+Required.JsonInput.OptionalFloatWrapper.ProtobufOutput
+Required.JsonInput.OptionalInt32Wrapper.JsonOutput
+Required.JsonInput.OptionalInt32Wrapper.ProtobufOutput
+Required.JsonInput.OptionalInt64Wrapper.JsonOutput
+Required.JsonInput.OptionalInt64Wrapper.ProtobufOutput
+Required.JsonInput.OptionalStringWrapper.JsonOutput
+Required.JsonInput.OptionalStringWrapper.ProtobufOutput
+Required.JsonInput.OptionalUint32Wrapper.JsonOutput
+Required.JsonInput.OptionalUint32Wrapper.ProtobufOutput
+Required.JsonInput.OptionalUint64Wrapper.JsonOutput
+Required.JsonInput.OptionalUint64Wrapper.ProtobufOutput
+Required.JsonInput.OptionalWrapperTypesWithNonDefaultValue.JsonOutput
+Required.JsonInput.OptionalWrapperTypesWithNonDefaultValue.ProtobufOutput
+Required.JsonInput.OriginalProtoFieldName.JsonOutput
+Required.JsonInput.OriginalProtoFieldName.ProtobufOutput
+Required.JsonInput.PrimitiveRepeatedField.JsonOutput
+Required.JsonInput.PrimitiveRepeatedField.ProtobufOutput
+Required.JsonInput.RepeatedBoolWrapper.JsonOutput
+Required.JsonInput.RepeatedBoolWrapper.ProtobufOutput
+Required.JsonInput.RepeatedBytesWrapper.JsonOutput
+Required.JsonInput.RepeatedBytesWrapper.ProtobufOutput
+Required.JsonInput.RepeatedDoubleWrapper.JsonOutput
+Required.JsonInput.RepeatedDoubleWrapper.ProtobufOutput
 Required.JsonInput.RepeatedFieldWrongElementTypeExpectingIntegersGotBool
+Required.JsonInput.RepeatedFieldWrongElementTypeExpectingIntegersGotMessage
+Required.JsonInput.RepeatedFieldWrongElementTypeExpectingIntegersGotString
+Required.JsonInput.RepeatedFieldWrongElementTypeExpectingMessagesGotBool
+Required.JsonInput.RepeatedFieldWrongElementTypeExpectingMessagesGotInt
+Required.JsonInput.RepeatedFieldWrongElementTypeExpectingMessagesGotString
+Required.JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotBool
+Required.JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotInt
+Required.JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotMessage
+Required.JsonInput.RepeatedFloatWrapper.JsonOutput
+Required.JsonInput.RepeatedFloatWrapper.ProtobufOutput
+Required.JsonInput.RepeatedInt32Wrapper.JsonOutput
+Required.JsonInput.RepeatedInt32Wrapper.ProtobufOutput
+Required.JsonInput.RepeatedInt64Wrapper.JsonOutput
+Required.JsonInput.RepeatedInt64Wrapper.ProtobufOutput
+Required.JsonInput.RepeatedStringWrapper.JsonOutput
+Required.JsonInput.RepeatedStringWrapper.ProtobufOutput
+Required.JsonInput.RepeatedUint32Wrapper.JsonOutput
+Required.JsonInput.RepeatedUint32Wrapper.ProtobufOutput
+Required.JsonInput.RepeatedUint64Wrapper.JsonOutput
+Required.JsonInput.RepeatedUint64Wrapper.ProtobufOutput
+Required.JsonInput.StringFieldEscape.JsonOutput
+Required.JsonInput.StringFieldEscape.ProtobufOutput
+Required.JsonInput.StringField.JsonOutput
+Required.JsonInput.StringFieldNotAString
+Required.JsonInput.StringField.ProtobufOutput
+Required.JsonInput.StringFieldSurrogatePair.JsonOutput
+Required.JsonInput.StringFieldSurrogatePair.ProtobufOutput
+Required.JsonInput.StringFieldUnicodeEscape.JsonOutput
+Required.JsonInput.StringFieldUnicodeEscape.ProtobufOutput
+Required.JsonInput.StringFieldUnicodeEscapeWithLowercaseHexLetters.JsonOutput
+Required.JsonInput.StringFieldUnicodeEscapeWithLowercaseHexLetters.ProtobufOutput
+Required.JsonInput.StringFieldUnicode.JsonOutput
+Required.JsonInput.StringFieldUnicode.ProtobufOutput
+Required.JsonInput.StringRepeatedField.JsonOutput
+Required.JsonInput.StringRepeatedField.ProtobufOutput
+Required.JsonInput.Struct.JsonOutput
+Required.JsonInput.Struct.ProtobufOutput
 Required.JsonInput.TimestampJsonInputLowercaseT
+Required.JsonInput.TimestampJsonInputLowercaseZ
+Required.JsonInput.TimestampJsonInputMissingT
+Required.JsonInput.TimestampJsonInputMissingZ
+Required.JsonInput.TimestampJsonInputTooLarge
+Required.JsonInput.TimestampJsonInputTooSmall
+Required.JsonInput.TimestampMaxValue.JsonOutput
+Required.JsonInput.TimestampMaxValue.ProtobufOutput
+Required.JsonInput.TimestampMinValue.JsonOutput
+Required.JsonInput.TimestampMinValue.ProtobufOutput
+Required.JsonInput.TimestampRepeatedValue.JsonOutput
+Required.JsonInput.TimestampRepeatedValue.ProtobufOutput
+Required.JsonInput.TimestampWithNegativeOffset.JsonOutput
+Required.JsonInput.TimestampWithNegativeOffset.ProtobufOutput
+Required.JsonInput.TimestampWithPositiveOffset.JsonOutput
+Required.JsonInput.TimestampWithPositiveOffset.ProtobufOutput
+Required.JsonInput.Uint32FieldMaxFloatValue.JsonOutput
+Required.JsonInput.Uint32FieldMaxFloatValue.ProtobufOutput
+Required.JsonInput.Uint32FieldMaxValue.JsonOutput
+Required.JsonInput.Uint32FieldMaxValue.ProtobufOutput
+Required.JsonInput.Uint32FieldNotInteger
+Required.JsonInput.Uint32FieldNotNumber
+Required.JsonInput.Uint32FieldTooLarge
+Required.JsonInput.Uint32MapField.JsonOutput
+Required.JsonInput.Uint32MapField.ProtobufOutput
+Required.JsonInput.Uint64FieldMaxValue.JsonOutput
+Required.JsonInput.Uint64FieldMaxValueNotQuoted.JsonOutput
+Required.JsonInput.Uint64FieldMaxValueNotQuoted.ProtobufOutput
+Required.JsonInput.Uint64FieldMaxValue.ProtobufOutput
+Required.JsonInput.Uint64FieldNotInteger
+Required.JsonInput.Uint64FieldNotNumber
+Required.JsonInput.Uint64FieldTooLarge
+Required.JsonInput.Uint64MapField.JsonOutput
+Required.JsonInput.Uint64MapField.ProtobufOutput
+Required.JsonInput.ValueAcceptBool.JsonOutput
+Required.JsonInput.ValueAcceptBool.ProtobufOutput
+Required.JsonInput.ValueAcceptFloat.JsonOutput
+Required.JsonInput.ValueAcceptFloat.ProtobufOutput
+Required.JsonInput.ValueAcceptInteger.JsonOutput
+Required.JsonInput.ValueAcceptInteger.ProtobufOutput
+Required.JsonInput.ValueAcceptList.JsonOutput
+Required.JsonInput.ValueAcceptList.ProtobufOutput
+Required.JsonInput.ValueAcceptNull.JsonOutput
+Required.JsonInput.ValueAcceptNull.ProtobufOutput
+Required.JsonInput.ValueAcceptObject.JsonOutput
+Required.JsonInput.ValueAcceptObject.ProtobufOutput
+Required.JsonInput.ValueAcceptString.JsonOutput
+Required.JsonInput.ValueAcceptString.ProtobufOutput
+Required.JsonInput.WrapperTypesWithNullValue.JsonOutput
+Required.JsonInput.WrapperTypesWithNullValue.ProtobufOutput
+Required.ProtobufInput.DoubleFieldNormalizeQuietNan.JsonOutput
+Required.ProtobufInput.DoubleFieldNormalizeSignalingNan.JsonOutput
+Required.ProtobufInput.FloatFieldNormalizeQuietNan.JsonOutput
+Required.ProtobufInput.FloatFieldNormalizeSignalingNan.JsonOutput
+Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.BOOL
+Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.BYTES
+Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.DOUBLE
+Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.ENUM
+Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.FIXED32
+Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.FIXED64
+Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.FLOAT
+Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.INT32
+Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.INT64
+Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.MESSAGE
+Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.SFIXED32
+Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.SFIXED64
+Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.SINT32
+Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.SINT64
+Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.STRING
+Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.UINT32
+Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.UINT64
+Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.BOOL
+Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.BYTES
+Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.DOUBLE
+Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.ENUM
+Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.FIXED32
+Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.FIXED64
+Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.FLOAT
+Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.INT32
+Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.INT64
+Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.MESSAGE
+Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.SFIXED32
+Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.SFIXED64
+Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.SINT32
+Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.SINT64
+Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.STRING
+Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.UINT32
+Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.UINT64
+Required.ProtobufInput.PrematureEofBeforeUnknownValue.BOOL
+Required.ProtobufInput.PrematureEofBeforeUnknownValue.BYTES
+Required.ProtobufInput.PrematureEofBeforeUnknownValue.DOUBLE
+Required.ProtobufInput.PrematureEofBeforeUnknownValue.ENUM
+Required.ProtobufInput.PrematureEofBeforeUnknownValue.FIXED32
+Required.ProtobufInput.PrematureEofBeforeUnknownValue.FIXED64
+Required.ProtobufInput.PrematureEofBeforeUnknownValue.FLOAT
+Required.ProtobufInput.PrematureEofBeforeUnknownValue.INT32
+Required.ProtobufInput.PrematureEofBeforeUnknownValue.INT64
+Required.ProtobufInput.PrematureEofBeforeUnknownValue.MESSAGE
+Required.ProtobufInput.PrematureEofBeforeUnknownValue.SFIXED32
+Required.ProtobufInput.PrematureEofBeforeUnknownValue.SFIXED64
+Required.ProtobufInput.PrematureEofBeforeUnknownValue.SINT32
+Required.ProtobufInput.PrematureEofBeforeUnknownValue.SINT64
+Required.ProtobufInput.PrematureEofBeforeUnknownValue.STRING
+Required.ProtobufInput.PrematureEofBeforeUnknownValue.UINT32
+Required.ProtobufInput.PrematureEofBeforeUnknownValue.UINT64
+Required.ProtobufInput.PrematureEofInDelimitedDataForKnownNonRepeatedValue.BYTES
+Required.ProtobufInput.PrematureEofInDelimitedDataForKnownNonRepeatedValue.MESSAGE
+Required.ProtobufInput.PrematureEofInDelimitedDataForKnownNonRepeatedValue.STRING
+Required.ProtobufInput.PrematureEofInDelimitedDataForKnownRepeatedValue.BYTES
+Required.ProtobufInput.PrematureEofInDelimitedDataForKnownRepeatedValue.MESSAGE
+Required.ProtobufInput.PrematureEofInDelimitedDataForKnownRepeatedValue.STRING
+Required.ProtobufInput.PrematureEofInDelimitedDataForUnknownValue.BYTES
+Required.ProtobufInput.PrematureEofInDelimitedDataForUnknownValue.MESSAGE
+Required.ProtobufInput.PrematureEofInDelimitedDataForUnknownValue.STRING
+Required.ProtobufInput.PrematureEofInPackedField.BOOL
+Required.ProtobufInput.PrematureEofInPackedField.DOUBLE
+Required.ProtobufInput.PrematureEofInPackedField.ENUM
+Required.ProtobufInput.PrematureEofInPackedField.FIXED32
+Required.ProtobufInput.PrematureEofInPackedField.FIXED64
+Required.ProtobufInput.PrematureEofInPackedField.FLOAT
+Required.ProtobufInput.PrematureEofInPackedField.INT32
+Required.ProtobufInput.PrematureEofInPackedField.INT64
+Required.ProtobufInput.PrematureEofInPackedField.SFIXED32
+Required.ProtobufInput.PrematureEofInPackedField.SFIXED64
+Required.ProtobufInput.PrematureEofInPackedField.SINT32
+Required.ProtobufInput.PrematureEofInPackedField.SINT64
+Required.ProtobufInput.PrematureEofInPackedField.UINT32
+Required.ProtobufInput.PrematureEofInPackedField.UINT64
+Required.ProtobufInput.PrematureEofInPackedFieldValue.BOOL
+Required.ProtobufInput.PrematureEofInPackedFieldValue.DOUBLE
+Required.ProtobufInput.PrematureEofInPackedFieldValue.ENUM
+Required.ProtobufInput.PrematureEofInPackedFieldValue.FIXED32
+Required.ProtobufInput.PrematureEofInPackedFieldValue.FIXED64
+Required.ProtobufInput.PrematureEofInPackedFieldValue.FLOAT
+Required.ProtobufInput.PrematureEofInPackedFieldValue.INT32
+Required.ProtobufInput.PrematureEofInPackedFieldValue.INT64
+Required.ProtobufInput.PrematureEofInPackedFieldValue.SFIXED32
+Required.ProtobufInput.PrematureEofInPackedFieldValue.SFIXED64
+Required.ProtobufInput.PrematureEofInPackedFieldValue.SINT32
+Required.ProtobufInput.PrematureEofInPackedFieldValue.SINT64
+Required.ProtobufInput.PrematureEofInPackedFieldValue.UINT32
+Required.ProtobufInput.PrematureEofInPackedFieldValue.UINT64
+Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.BOOL
+Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.BYTES
+Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.DOUBLE
+Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.ENUM
+Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.FIXED32
+Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.FIXED64
+Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.FLOAT
+Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.INT32
+Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.INT64
+Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.MESSAGE
+Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.SFIXED32
+Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.SFIXED64
+Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.SINT32
+Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.SINT64
+Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.STRING
+Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.UINT32
+Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.UINT64
+Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.BOOL
+Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.BYTES
+Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.DOUBLE
+Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.ENUM
+Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.FIXED32
+Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.FIXED64
+Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.FLOAT
+Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.INT32
+Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.INT64
+Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.MESSAGE
+Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.SFIXED32
+Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.SFIXED64
+Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.SINT32
+Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.SINT64
+Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.STRING
+Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.UINT32
+Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.UINT64
+Required.ProtobufInput.PrematureEofInsideUnknownValue.BOOL
+Required.ProtobufInput.PrematureEofInsideUnknownValue.BYTES
+Required.ProtobufInput.PrematureEofInsideUnknownValue.DOUBLE
+Required.ProtobufInput.PrematureEofInsideUnknownValue.ENUM
+Required.ProtobufInput.PrematureEofInsideUnknownValue.FIXED32
+Required.ProtobufInput.PrematureEofInsideUnknownValue.FIXED64
+Required.ProtobufInput.PrematureEofInsideUnknownValue.FLOAT
+Required.ProtobufInput.PrematureEofInsideUnknownValue.INT32
+Required.ProtobufInput.PrematureEofInsideUnknownValue.INT64
+Required.ProtobufInput.PrematureEofInsideUnknownValue.MESSAGE
+Required.ProtobufInput.PrematureEofInsideUnknownValue.SFIXED32
+Required.ProtobufInput.PrematureEofInsideUnknownValue.SFIXED64
+Required.ProtobufInput.PrematureEofInsideUnknownValue.SINT32
+Required.ProtobufInput.PrematureEofInsideUnknownValue.SINT64
+Required.ProtobufInput.PrematureEofInsideUnknownValue.STRING
+Required.ProtobufInput.PrematureEofInsideUnknownValue.UINT32
+Required.ProtobufInput.PrematureEofInsideUnknownValue.UINT64
+Required.ProtobufInput.PrematureEofInSubmessageValue.MESSAGE
+Required.TimestampProtoInputTooLarge.JsonOutput
+Required.TimestampProtoInputTooSmall.JsonOutput

+ 504 - 0
conformance/failure_list_python_cpp.txt

@@ -7,21 +7,457 @@
 # TODO(haberman): insert links to corresponding bugs tracking the issue.
 # Should we use GitHub issues or the Google-internal bug tracker?
 
+ProtobufInput.OneofZeroBool.JsonOutput
+ProtobufInput.OneofZeroBool.ProtobufOutput
+ProtobufInput.OneofZeroBytes.JsonOutput
+ProtobufInput.OneofZeroBytes.ProtobufOutput
+ProtobufInput.OneofZeroDouble.JsonOutput
+ProtobufInput.OneofZeroDouble.ProtobufOutput
+ProtobufInput.OneofZeroEnum.JsonOutput
+ProtobufInput.OneofZeroEnum.ProtobufOutput
+ProtobufInput.OneofZeroFloat.JsonOutput
+ProtobufInput.OneofZeroFloat.ProtobufOutput
+ProtobufInput.OneofZeroMessage.JsonOutput
+ProtobufInput.OneofZeroMessage.ProtobufOutput
+ProtobufInput.OneofZeroString.JsonOutput
+ProtobufInput.OneofZeroString.ProtobufOutput
+ProtobufInput.OneofZeroUint32.JsonOutput
+ProtobufInput.OneofZeroUint32.ProtobufOutput
+ProtobufInput.OneofZeroUint64.JsonOutput
+ProtobufInput.OneofZeroUint64.ProtobufOutput
+Recommended.FieldMaskNumbersDontRoundTrip.JsonOutput
+Recommended.FieldMaskPathsDontRoundTrip.JsonOutput
+Recommended.FieldMaskTooManyUnderscore.JsonOutput
+Recommended.JsonInput.BoolFieldAllCapitalFalse
+Recommended.JsonInput.BoolFieldAllCapitalTrue
+Recommended.JsonInput.BoolFieldCamelCaseFalse
+Recommended.JsonInput.BoolFieldCamelCaseTrue
+Recommended.JsonInput.BoolFieldDoubleQuotedFalse
+Recommended.JsonInput.BoolFieldDoubleQuotedTrue
+Recommended.JsonInput.BoolFieldIntegerOne
+Recommended.JsonInput.BoolFieldIntegerZero
+Recommended.JsonInput.BoolMapFieldKeyNotQuoted
 Recommended.JsonInput.DoubleFieldInfinityNotQuoted
 Recommended.JsonInput.DoubleFieldNanNotQuoted
 Recommended.JsonInput.DoubleFieldNegativeInfinityNotQuoted
+Recommended.JsonInput.DurationHas3FractionalDigits.Validator
+Recommended.JsonInput.DurationHas6FractionalDigits.Validator
+Recommended.JsonInput.DurationHas9FractionalDigits.Validator
+Recommended.JsonInput.DurationHasZeroFractionalDigit.Validator
+Recommended.JsonInput.FieldMaskInvalidCharacter
+Recommended.JsonInput.FieldNameDuplicate
+Recommended.JsonInput.FieldNameDuplicateDifferentCasing1
+Recommended.JsonInput.FieldNameDuplicateDifferentCasing2
+Recommended.JsonInput.FieldNameNotQuoted
+Recommended.JsonInput.FieldNameWithDoubleUnderscores.JsonOutput
+Recommended.JsonInput.FieldNameWithDoubleUnderscores.ProtobufOutput
+Recommended.JsonInput.FieldNameWithDoubleUnderscores.Validator
 Recommended.JsonInput.FloatFieldInfinityNotQuoted
 Recommended.JsonInput.FloatFieldNanNotQuoted
 Recommended.JsonInput.FloatFieldNegativeInfinityNotQuoted
+Recommended.JsonInput.Int32MapFieldKeyNotQuoted
+Recommended.JsonInput.Int64FieldBeString.Validator
+Recommended.JsonInput.Int64MapFieldKeyNotQuoted
+Recommended.JsonInput.JsonWithComments
+Recommended.JsonInput.MapFieldKeyIsNull
+Recommended.JsonInput.MapFieldValueIsNull
+Recommended.JsonInput.MissingCommaMultiline
+Recommended.JsonInput.MissingCommaOneLine
+Recommended.JsonInput.MultilineNoSpaces.JsonOutput
+Recommended.JsonInput.MultilineNoSpaces.ProtobufOutput
+Recommended.JsonInput.MultilineWithSpaces.JsonOutput
+Recommended.JsonInput.MultilineWithSpaces.ProtobufOutput
+Recommended.JsonInput.OneLineNoSpaces.JsonOutput
+Recommended.JsonInput.OneLineNoSpaces.ProtobufOutput
+Recommended.JsonInput.OneLineWithSpaces.JsonOutput
+Recommended.JsonInput.OneLineWithSpaces.ProtobufOutput
+Recommended.JsonInput.OneofZeroBool.JsonOutput
+Recommended.JsonInput.OneofZeroBool.ProtobufOutput
+Recommended.JsonInput.OneofZeroBytes.JsonOutput
+Recommended.JsonInput.OneofZeroBytes.ProtobufOutput
+Recommended.JsonInput.OneofZeroDouble.JsonOutput
+Recommended.JsonInput.OneofZeroDouble.ProtobufOutput
+Recommended.JsonInput.OneofZeroEnum.JsonOutput
+Recommended.JsonInput.OneofZeroEnum.ProtobufOutput
+Recommended.JsonInput.OneofZeroFloat.JsonOutput
+Recommended.JsonInput.OneofZeroFloat.ProtobufOutput
+Recommended.JsonInput.OneofZeroMessage.JsonOutput
+Recommended.JsonInput.OneofZeroMessage.ProtobufOutput
+Recommended.JsonInput.OneofZeroString.JsonOutput
+Recommended.JsonInput.OneofZeroString.ProtobufOutput
+Recommended.JsonInput.OneofZeroUint32.JsonOutput
+Recommended.JsonInput.OneofZeroUint32.ProtobufOutput
+Recommended.JsonInput.OneofZeroUint64.JsonOutput
+Recommended.JsonInput.OneofZeroUint64.ProtobufOutput
+Recommended.JsonInput.RepeatedFieldMessageElementIsNull
+Recommended.JsonInput.RepeatedFieldPrimitiveElementIsNull
+Recommended.JsonInput.RepeatedFieldTrailingComma
+Recommended.JsonInput.RepeatedFieldTrailingCommaWithNewlines
+Recommended.JsonInput.RepeatedFieldTrailingCommaWithSpace
+Recommended.JsonInput.RepeatedFieldTrailingCommaWithSpaceCommaSpace
+Recommended.JsonInput.StringEndsWithEscapeChar
+Recommended.JsonInput.StringFieldInvalidEscape
+Recommended.JsonInput.StringFieldSingleQuoteBoth
+Recommended.JsonInput.StringFieldSingleQuoteKey
+Recommended.JsonInput.StringFieldSingleQuoteValue
+Recommended.JsonInput.StringFieldSurrogateInWrongOrder
+Recommended.JsonInput.StringFieldUnpairedHighSurrogate
+Recommended.JsonInput.StringFieldUnpairedLowSurrogate
+Recommended.JsonInput.StringFieldUnterminatedEscape
+Recommended.JsonInput.StringFieldUppercaseEscapeLetter
+Recommended.JsonInput.TimestampHas3FractionalDigits.Validator
+Recommended.JsonInput.TimestampHas6FractionalDigits.Validator
+Recommended.JsonInput.TimestampHas9FractionalDigits.Validator
+Recommended.JsonInput.TimestampHasZeroFractionalDigit.Validator
+Recommended.JsonInput.TimestampZeroNormalized.Validator
+Recommended.JsonInput.TrailingCommaInAnObject
+Recommended.JsonInput.TrailingCommaInAnObjectWithNewlines
+Recommended.JsonInput.TrailingCommaInAnObjectWithSpace
+Recommended.JsonInput.TrailingCommaInAnObjectWithSpaceCommaSpace
+Recommended.JsonInput.Uint32MapFieldKeyNotQuoted
+Recommended.JsonInput.Uint64FieldBeString.Validator
+Recommended.JsonInput.Uint64MapFieldKeyNotQuoted
+Required.DurationProtoInputTooLarge.JsonOutput
+Required.DurationProtoInputTooSmall.JsonOutput
+Required.JsonInput.AllFieldAcceptNull.JsonOutput
+Required.JsonInput.AllFieldAcceptNull.ProtobufOutput
+Required.JsonInput.Any.JsonOutput
+Required.JsonInput.AnyNested.JsonOutput
+Required.JsonInput.AnyNested.ProtobufOutput
+Required.JsonInput.Any.ProtobufOutput
+Required.JsonInput.AnyUnorderedTypeTag.JsonOutput
+Required.JsonInput.AnyUnorderedTypeTag.ProtobufOutput
+Required.JsonInput.AnyWithDuration.JsonOutput
+Required.JsonInput.AnyWithDuration.ProtobufOutput
+Required.JsonInput.AnyWithFieldMask.JsonOutput
+Required.JsonInput.AnyWithFieldMask.ProtobufOutput
+Required.JsonInput.AnyWithInt32ValueWrapper.JsonOutput
+Required.JsonInput.AnyWithInt32ValueWrapper.ProtobufOutput
+Required.JsonInput.AnyWithStruct.JsonOutput
+Required.JsonInput.AnyWithStruct.ProtobufOutput
+Required.JsonInput.AnyWithTimestamp.JsonOutput
+Required.JsonInput.AnyWithTimestamp.ProtobufOutput
+Required.JsonInput.AnyWithValueForInteger.JsonOutput
+Required.JsonInput.AnyWithValueForInteger.ProtobufOutput
+Required.JsonInput.AnyWithValueForJsonObject.JsonOutput
+Required.JsonInput.AnyWithValueForJsonObject.ProtobufOutput
+Required.JsonInput.BoolFieldFalse.JsonOutput
+Required.JsonInput.BoolFieldFalse.ProtobufOutput
+Required.JsonInput.BoolFieldTrue.JsonOutput
+Required.JsonInput.BoolFieldTrue.ProtobufOutput
+Required.JsonInput.BoolMapEscapedKey.JsonOutput
+Required.JsonInput.BoolMapEscapedKey.ProtobufOutput
+Required.JsonInput.BoolMapField.JsonOutput
+Required.JsonInput.BoolMapField.ProtobufOutput
 Required.JsonInput.BytesFieldInvalidBase64Characters
+Required.JsonInput.BytesField.JsonOutput
+Required.JsonInput.BytesField.ProtobufOutput
+Required.JsonInput.BytesRepeatedField.JsonOutput
+Required.JsonInput.BytesRepeatedField.ProtobufOutput
+Required.JsonInput.DoubleFieldInfinity.JsonOutput
+Required.JsonInput.DoubleFieldInfinity.ProtobufOutput
+Required.JsonInput.DoubleFieldMaxNegativeValue.JsonOutput
+Required.JsonInput.DoubleFieldMaxNegativeValue.ProtobufOutput
+Required.JsonInput.DoubleFieldMaxPositiveValue.JsonOutput
+Required.JsonInput.DoubleFieldMaxPositiveValue.ProtobufOutput
+Required.JsonInput.DoubleFieldMinNegativeValue.JsonOutput
+Required.JsonInput.DoubleFieldMinNegativeValue.ProtobufOutput
+Required.JsonInput.DoubleFieldMinPositiveValue.JsonOutput
+Required.JsonInput.DoubleFieldMinPositiveValue.ProtobufOutput
+Required.JsonInput.DoubleFieldNan.JsonOutput
+Required.JsonInput.DoubleFieldNan.ProtobufOutput
+Required.JsonInput.DoubleFieldNegativeInfinity.JsonOutput
+Required.JsonInput.DoubleFieldNegativeInfinity.ProtobufOutput
+Required.JsonInput.DoubleFieldQuotedValue.JsonOutput
+Required.JsonInput.DoubleFieldQuotedValue.ProtobufOutput
+Required.JsonInput.DoubleFieldTooLarge
 Required.JsonInput.DoubleFieldTooSmall
+Required.JsonInput.DurationJsonInputTooLarge
+Required.JsonInput.DurationJsonInputTooSmall
+Required.JsonInput.DurationMaxValue.JsonOutput
+Required.JsonInput.DurationMaxValue.ProtobufOutput
+Required.JsonInput.DurationMinValue.JsonOutput
+Required.JsonInput.DurationMinValue.ProtobufOutput
+Required.JsonInput.DurationMissingS
+Required.JsonInput.DurationRepeatedValue.JsonOutput
+Required.JsonInput.DurationRepeatedValue.ProtobufOutput
+Required.JsonInput.EnumField.JsonOutput
+Required.JsonInput.EnumFieldNotQuoted
+Required.JsonInput.EnumFieldNumericValueNonZero.JsonOutput
+Required.JsonInput.EnumFieldNumericValueNonZero.ProtobufOutput
+Required.JsonInput.EnumFieldNumericValueZero.JsonOutput
+Required.JsonInput.EnumFieldNumericValueZero.ProtobufOutput
+Required.JsonInput.EnumField.ProtobufOutput
 Required.JsonInput.EnumFieldUnknownValue.Validator
+Required.JsonInput.EnumRepeatedField.JsonOutput
+Required.JsonInput.EnumRepeatedField.ProtobufOutput
+Required.JsonInput.FieldMask.JsonOutput
+Required.JsonInput.FieldMask.ProtobufOutput
+Required.JsonInput.FieldNameEscaped.JsonOutput
+Required.JsonInput.FieldNameEscaped.ProtobufOutput
+Required.JsonInput.FieldNameInLowerCamelCase.Validator
+Required.JsonInput.FieldNameInSnakeCase.JsonOutput
+Required.JsonInput.FieldNameInSnakeCase.ProtobufOutput
+Required.JsonInput.FieldNameWithMixedCases.JsonOutput
+Required.JsonInput.FieldNameWithMixedCases.ProtobufOutput
+Required.JsonInput.FieldNameWithMixedCases.Validator
+Required.JsonInput.FieldNameWithNumbers.JsonOutput
+Required.JsonInput.FieldNameWithNumbers.ProtobufOutput
+Required.JsonInput.FieldNameWithNumbers.Validator
+Required.JsonInput.FloatFieldInfinity.JsonOutput
+Required.JsonInput.FloatFieldInfinity.ProtobufOutput
+Required.JsonInput.FloatFieldMaxNegativeValue.JsonOutput
+Required.JsonInput.FloatFieldMaxNegativeValue.ProtobufOutput
+Required.JsonInput.FloatFieldMaxPositiveValue.JsonOutput
+Required.JsonInput.FloatFieldMaxPositiveValue.ProtobufOutput
+Required.JsonInput.FloatFieldMinNegativeValue.JsonOutput
+Required.JsonInput.FloatFieldMinNegativeValue.ProtobufOutput
+Required.JsonInput.FloatFieldMinPositiveValue.JsonOutput
+Required.JsonInput.FloatFieldMinPositiveValue.ProtobufOutput
+Required.JsonInput.FloatFieldNan.JsonOutput
+Required.JsonInput.FloatFieldNan.ProtobufOutput
+Required.JsonInput.FloatFieldNegativeInfinity.JsonOutput
+Required.JsonInput.FloatFieldNegativeInfinity.ProtobufOutput
+Required.JsonInput.FloatFieldQuotedValue.JsonOutput
+Required.JsonInput.FloatFieldQuotedValue.ProtobufOutput
 Required.JsonInput.FloatFieldTooLarge
 Required.JsonInput.FloatFieldTooSmall
+Required.JsonInput.HelloWorld.JsonOutput
+Required.JsonInput.HelloWorld.ProtobufOutput
+Required.JsonInput.Int32FieldExponentialFormat.JsonOutput
+Required.JsonInput.Int32FieldExponentialFormat.ProtobufOutput
+Required.JsonInput.Int32FieldFloatTrailingZero.JsonOutput
+Required.JsonInput.Int32FieldFloatTrailingZero.ProtobufOutput
+Required.JsonInput.Int32FieldLeadingSpace
+Required.JsonInput.Int32FieldLeadingZero
+Required.JsonInput.Int32FieldMaxFloatValue.JsonOutput
+Required.JsonInput.Int32FieldMaxFloatValue.ProtobufOutput
+Required.JsonInput.Int32FieldMaxValue.JsonOutput
+Required.JsonInput.Int32FieldMaxValue.ProtobufOutput
+Required.JsonInput.Int32FieldMinFloatValue.JsonOutput
+Required.JsonInput.Int32FieldMinFloatValue.ProtobufOutput
+Required.JsonInput.Int32FieldMinValue.JsonOutput
+Required.JsonInput.Int32FieldMinValue.ProtobufOutput
+Required.JsonInput.Int32FieldNegativeWithLeadingZero
+Required.JsonInput.Int32FieldNotInteger
+Required.JsonInput.Int32FieldNotNumber
+Required.JsonInput.Int32FieldPlusSign
+Required.JsonInput.Int32FieldStringValueEscaped.JsonOutput
+Required.JsonInput.Int32FieldStringValueEscaped.ProtobufOutput
+Required.JsonInput.Int32FieldStringValue.JsonOutput
+Required.JsonInput.Int32FieldStringValue.ProtobufOutput
+Required.JsonInput.Int32FieldTooLarge
+Required.JsonInput.Int32FieldTooSmall
+Required.JsonInput.Int32FieldTrailingSpace
+Required.JsonInput.Int32MapEscapedKey.JsonOutput
+Required.JsonInput.Int32MapEscapedKey.ProtobufOutput
+Required.JsonInput.Int32MapField.JsonOutput
+Required.JsonInput.Int32MapField.ProtobufOutput
+Required.JsonInput.Int64FieldMaxValue.JsonOutput
+Required.JsonInput.Int64FieldMaxValueNotQuoted.JsonOutput
+Required.JsonInput.Int64FieldMaxValueNotQuoted.ProtobufOutput
+Required.JsonInput.Int64FieldMaxValue.ProtobufOutput
+Required.JsonInput.Int64FieldMinValue.JsonOutput
+Required.JsonInput.Int64FieldMinValueNotQuoted.JsonOutput
+Required.JsonInput.Int64FieldMinValueNotQuoted.ProtobufOutput
+Required.JsonInput.Int64FieldMinValue.ProtobufOutput
+Required.JsonInput.Int64FieldNotInteger
+Required.JsonInput.Int64FieldNotNumber
+Required.JsonInput.Int64FieldTooLarge
+Required.JsonInput.Int64FieldTooSmall
+Required.JsonInput.Int64MapEscapedKey.JsonOutput
+Required.JsonInput.Int64MapEscapedKey.ProtobufOutput
+Required.JsonInput.Int64MapField.JsonOutput
+Required.JsonInput.Int64MapField.ProtobufOutput
+Required.JsonInput.MessageField.JsonOutput
+Required.JsonInput.MessageField.ProtobufOutput
+Required.JsonInput.MessageMapField.JsonOutput
+Required.JsonInput.MessageMapField.ProtobufOutput
+Required.JsonInput.MessageRepeatedField.JsonOutput
+Required.JsonInput.MessageRepeatedField.ProtobufOutput
+Required.JsonInput.OneofFieldDuplicate
+Required.JsonInput.OptionalBoolWrapper.JsonOutput
+Required.JsonInput.OptionalBoolWrapper.ProtobufOutput
+Required.JsonInput.OptionalBytesWrapper.JsonOutput
+Required.JsonInput.OptionalBytesWrapper.ProtobufOutput
+Required.JsonInput.OptionalDoubleWrapper.JsonOutput
+Required.JsonInput.OptionalDoubleWrapper.ProtobufOutput
+Required.JsonInput.OptionalFloatWrapper.JsonOutput
+Required.JsonInput.OptionalFloatWrapper.ProtobufOutput
+Required.JsonInput.OptionalInt32Wrapper.JsonOutput
+Required.JsonInput.OptionalInt32Wrapper.ProtobufOutput
+Required.JsonInput.OptionalInt64Wrapper.JsonOutput
+Required.JsonInput.OptionalInt64Wrapper.ProtobufOutput
+Required.JsonInput.OptionalStringWrapper.JsonOutput
+Required.JsonInput.OptionalStringWrapper.ProtobufOutput
+Required.JsonInput.OptionalUint32Wrapper.JsonOutput
+Required.JsonInput.OptionalUint32Wrapper.ProtobufOutput
+Required.JsonInput.OptionalUint64Wrapper.JsonOutput
+Required.JsonInput.OptionalUint64Wrapper.ProtobufOutput
+Required.JsonInput.OptionalWrapperTypesWithNonDefaultValue.JsonOutput
+Required.JsonInput.OptionalWrapperTypesWithNonDefaultValue.ProtobufOutput
+Required.JsonInput.OriginalProtoFieldName.JsonOutput
+Required.JsonInput.OriginalProtoFieldName.ProtobufOutput
+Required.JsonInput.PrimitiveRepeatedField.JsonOutput
+Required.JsonInput.PrimitiveRepeatedField.ProtobufOutput
+Required.JsonInput.RepeatedBoolWrapper.JsonOutput
+Required.JsonInput.RepeatedBoolWrapper.ProtobufOutput
+Required.JsonInput.RepeatedBytesWrapper.JsonOutput
+Required.JsonInput.RepeatedBytesWrapper.ProtobufOutput
+Required.JsonInput.RepeatedDoubleWrapper.JsonOutput
+Required.JsonInput.RepeatedDoubleWrapper.ProtobufOutput
 Required.JsonInput.RepeatedFieldWrongElementTypeExpectingIntegersGotBool
+Required.JsonInput.RepeatedFieldWrongElementTypeExpectingIntegersGotMessage
+Required.JsonInput.RepeatedFieldWrongElementTypeExpectingIntegersGotString
+Required.JsonInput.RepeatedFieldWrongElementTypeExpectingMessagesGotBool
+Required.JsonInput.RepeatedFieldWrongElementTypeExpectingMessagesGotInt
+Required.JsonInput.RepeatedFieldWrongElementTypeExpectingMessagesGotString
+Required.JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotBool
+Required.JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotInt
+Required.JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotMessage
+Required.JsonInput.RepeatedFloatWrapper.JsonOutput
+Required.JsonInput.RepeatedFloatWrapper.ProtobufOutput
+Required.JsonInput.RepeatedInt32Wrapper.JsonOutput
+Required.JsonInput.RepeatedInt32Wrapper.ProtobufOutput
+Required.JsonInput.RepeatedInt64Wrapper.JsonOutput
+Required.JsonInput.RepeatedInt64Wrapper.ProtobufOutput
+Required.JsonInput.RepeatedStringWrapper.JsonOutput
+Required.JsonInput.RepeatedStringWrapper.ProtobufOutput
+Required.JsonInput.RepeatedUint32Wrapper.JsonOutput
+Required.JsonInput.RepeatedUint32Wrapper.ProtobufOutput
+Required.JsonInput.RepeatedUint64Wrapper.JsonOutput
+Required.JsonInput.RepeatedUint64Wrapper.ProtobufOutput
+Required.JsonInput.StringFieldEscape.JsonOutput
+Required.JsonInput.StringFieldEscape.ProtobufOutput
+Required.JsonInput.StringField.JsonOutput
+Required.JsonInput.StringFieldNotAString
+Required.JsonInput.StringField.ProtobufOutput
+Required.JsonInput.StringFieldSurrogatePair.JsonOutput
+Required.JsonInput.StringFieldSurrogatePair.ProtobufOutput
+Required.JsonInput.StringFieldUnicodeEscape.JsonOutput
+Required.JsonInput.StringFieldUnicodeEscape.ProtobufOutput
+Required.JsonInput.StringFieldUnicodeEscapeWithLowercaseHexLetters.JsonOutput
+Required.JsonInput.StringFieldUnicodeEscapeWithLowercaseHexLetters.ProtobufOutput
+Required.JsonInput.StringFieldUnicode.JsonOutput
+Required.JsonInput.StringFieldUnicode.ProtobufOutput
+Required.JsonInput.StringRepeatedField.JsonOutput
+Required.JsonInput.StringRepeatedField.ProtobufOutput
+Required.JsonInput.Struct.JsonOutput
+Required.JsonInput.Struct.ProtobufOutput
 Required.JsonInput.TimestampJsonInputLowercaseT
+Required.JsonInput.TimestampJsonInputLowercaseZ
+Required.JsonInput.TimestampJsonInputMissingT
+Required.JsonInput.TimestampJsonInputMissingZ
+Required.JsonInput.TimestampJsonInputTooLarge
+Required.JsonInput.TimestampJsonInputTooSmall
+Required.JsonInput.TimestampMaxValue.JsonOutput
+Required.JsonInput.TimestampMaxValue.ProtobufOutput
+Required.JsonInput.TimestampMinValue.JsonOutput
+Required.JsonInput.TimestampMinValue.ProtobufOutput
+Required.JsonInput.TimestampRepeatedValue.JsonOutput
+Required.JsonInput.TimestampRepeatedValue.ProtobufOutput
+Required.JsonInput.TimestampWithNegativeOffset.JsonOutput
+Required.JsonInput.TimestampWithNegativeOffset.ProtobufOutput
+Required.JsonInput.TimestampWithPositiveOffset.JsonOutput
+Required.JsonInput.TimestampWithPositiveOffset.ProtobufOutput
+Required.JsonInput.Uint32FieldMaxFloatValue.JsonOutput
+Required.JsonInput.Uint32FieldMaxFloatValue.ProtobufOutput
+Required.JsonInput.Uint32FieldMaxValue.JsonOutput
+Required.JsonInput.Uint32FieldMaxValue.ProtobufOutput
+Required.JsonInput.Uint32FieldNotInteger
+Required.JsonInput.Uint32FieldNotNumber
+Required.JsonInput.Uint32FieldTooLarge
+Required.JsonInput.Uint32MapField.JsonOutput
+Required.JsonInput.Uint32MapField.ProtobufOutput
+Required.JsonInput.Uint64FieldMaxValue.JsonOutput
+Required.JsonInput.Uint64FieldMaxValueNotQuoted.JsonOutput
+Required.JsonInput.Uint64FieldMaxValueNotQuoted.ProtobufOutput
+Required.JsonInput.Uint64FieldMaxValue.ProtobufOutput
+Required.JsonInput.Uint64FieldNotInteger
+Required.JsonInput.Uint64FieldNotNumber
+Required.JsonInput.Uint64FieldTooLarge
+Required.JsonInput.Uint64MapField.JsonOutput
+Required.JsonInput.Uint64MapField.ProtobufOutput
+Required.JsonInput.ValueAcceptBool.JsonOutput
+Required.JsonInput.ValueAcceptBool.ProtobufOutput
+Required.JsonInput.ValueAcceptFloat.JsonOutput
+Required.JsonInput.ValueAcceptFloat.ProtobufOutput
+Required.JsonInput.ValueAcceptInteger.JsonOutput
+Required.JsonInput.ValueAcceptInteger.ProtobufOutput
+Required.JsonInput.ValueAcceptList.JsonOutput
+Required.JsonInput.ValueAcceptList.ProtobufOutput
+Required.JsonInput.ValueAcceptNull.JsonOutput
+Required.JsonInput.ValueAcceptNull.ProtobufOutput
+Required.JsonInput.ValueAcceptObject.JsonOutput
+Required.JsonInput.ValueAcceptObject.ProtobufOutput
+Required.JsonInput.ValueAcceptString.JsonOutput
+Required.JsonInput.ValueAcceptString.ProtobufOutput
+Required.JsonInput.WrapperTypesWithNullValue.JsonOutput
+Required.JsonInput.WrapperTypesWithNullValue.ProtobufOutput
+Required.ProtobufInput.DoubleFieldNormalizeQuietNan.JsonOutput
+Required.ProtobufInput.DoubleFieldNormalizeSignalingNan.JsonOutput
+Required.ProtobufInput.FloatFieldNormalizeQuietNan.JsonOutput
+Required.ProtobufInput.FloatFieldNormalizeSignalingNan.JsonOutput
+Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.BOOL
+Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.BYTES
+Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.DOUBLE
+Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.ENUM
+Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.FIXED32
+Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.FIXED64
+Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.FLOAT
+Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.INT32
+Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.INT64
+Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.MESSAGE
+Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.SFIXED32
+Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.SFIXED64
+Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.SINT32
+Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.SINT64
+Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.STRING
+Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.UINT32
+Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.UINT64
+Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.BOOL
+Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.BYTES
+Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.DOUBLE
+Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.ENUM
+Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.FIXED32
+Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.FIXED64
+Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.FLOAT
+Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.INT32
+Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.INT64
+Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.MESSAGE
+Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.SFIXED32
+Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.SFIXED64
+Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.SINT32
+Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.SINT64
+Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.STRING
+Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.UINT32
+Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.UINT64
+Required.ProtobufInput.PrematureEofBeforeUnknownValue.BOOL
+Required.ProtobufInput.PrematureEofBeforeUnknownValue.BYTES
+Required.ProtobufInput.PrematureEofBeforeUnknownValue.DOUBLE
+Required.ProtobufInput.PrematureEofBeforeUnknownValue.ENUM
+Required.ProtobufInput.PrematureEofBeforeUnknownValue.FIXED32
+Required.ProtobufInput.PrematureEofBeforeUnknownValue.FIXED64
+Required.ProtobufInput.PrematureEofBeforeUnknownValue.FLOAT
+Required.ProtobufInput.PrematureEofBeforeUnknownValue.INT32
+Required.ProtobufInput.PrematureEofBeforeUnknownValue.INT64
+Required.ProtobufInput.PrematureEofBeforeUnknownValue.MESSAGE
+Required.ProtobufInput.PrematureEofBeforeUnknownValue.SFIXED32
+Required.ProtobufInput.PrematureEofBeforeUnknownValue.SFIXED64
+Required.ProtobufInput.PrematureEofBeforeUnknownValue.SINT32
+Required.ProtobufInput.PrematureEofBeforeUnknownValue.SINT64
+Required.ProtobufInput.PrematureEofBeforeUnknownValue.STRING
+Required.ProtobufInput.PrematureEofBeforeUnknownValue.UINT32
+Required.ProtobufInput.PrematureEofBeforeUnknownValue.UINT64
+Required.ProtobufInput.PrematureEofInDelimitedDataForKnownNonRepeatedValue.BYTES
 Required.ProtobufInput.PrematureEofInDelimitedDataForKnownNonRepeatedValue.MESSAGE
+Required.ProtobufInput.PrematureEofInDelimitedDataForKnownNonRepeatedValue.STRING
+Required.ProtobufInput.PrematureEofInDelimitedDataForKnownRepeatedValue.BYTES
 Required.ProtobufInput.PrematureEofInDelimitedDataForKnownRepeatedValue.MESSAGE
+Required.ProtobufInput.PrematureEofInDelimitedDataForKnownRepeatedValue.STRING
+Required.ProtobufInput.PrematureEofInDelimitedDataForUnknownValue.BYTES
+Required.ProtobufInput.PrematureEofInDelimitedDataForUnknownValue.MESSAGE
+Required.ProtobufInput.PrematureEofInDelimitedDataForUnknownValue.STRING
 Required.ProtobufInput.PrematureEofInPackedField.BOOL
 Required.ProtobufInput.PrematureEofInPackedField.DOUBLE
 Required.ProtobufInput.PrematureEofInPackedField.ENUM
@@ -36,3 +472,71 @@ Required.ProtobufInput.PrematureEofInPackedField.SINT32
 Required.ProtobufInput.PrematureEofInPackedField.SINT64
 Required.ProtobufInput.PrematureEofInPackedField.UINT32
 Required.ProtobufInput.PrematureEofInPackedField.UINT64
+Required.ProtobufInput.PrematureEofInPackedFieldValue.BOOL
+Required.ProtobufInput.PrematureEofInPackedFieldValue.DOUBLE
+Required.ProtobufInput.PrematureEofInPackedFieldValue.ENUM
+Required.ProtobufInput.PrematureEofInPackedFieldValue.FIXED32
+Required.ProtobufInput.PrematureEofInPackedFieldValue.FIXED64
+Required.ProtobufInput.PrematureEofInPackedFieldValue.FLOAT
+Required.ProtobufInput.PrematureEofInPackedFieldValue.INT32
+Required.ProtobufInput.PrematureEofInPackedFieldValue.INT64
+Required.ProtobufInput.PrematureEofInPackedFieldValue.SFIXED32
+Required.ProtobufInput.PrematureEofInPackedFieldValue.SFIXED64
+Required.ProtobufInput.PrematureEofInPackedFieldValue.SINT32
+Required.ProtobufInput.PrematureEofInPackedFieldValue.SINT64
+Required.ProtobufInput.PrematureEofInPackedFieldValue.UINT32
+Required.ProtobufInput.PrematureEofInPackedFieldValue.UINT64
+Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.BOOL
+Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.BYTES
+Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.DOUBLE
+Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.ENUM
+Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.FIXED32
+Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.FIXED64
+Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.FLOAT
+Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.INT32
+Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.INT64
+Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.MESSAGE
+Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.SFIXED32
+Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.SFIXED64
+Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.SINT32
+Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.SINT64
+Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.STRING
+Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.UINT32
+Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.UINT64
+Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.BOOL
+Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.BYTES
+Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.DOUBLE
+Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.ENUM
+Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.FIXED32
+Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.FIXED64
+Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.FLOAT
+Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.INT32
+Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.INT64
+Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.MESSAGE
+Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.SFIXED32
+Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.SFIXED64
+Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.SINT32
+Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.SINT64
+Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.STRING
+Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.UINT32
+Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.UINT64
+Required.ProtobufInput.PrematureEofInsideUnknownValue.BOOL
+Required.ProtobufInput.PrematureEofInsideUnknownValue.BYTES
+Required.ProtobufInput.PrematureEofInsideUnknownValue.DOUBLE
+Required.ProtobufInput.PrematureEofInsideUnknownValue.ENUM
+Required.ProtobufInput.PrematureEofInsideUnknownValue.FIXED32
+Required.ProtobufInput.PrematureEofInsideUnknownValue.FIXED64
+Required.ProtobufInput.PrematureEofInsideUnknownValue.FLOAT
+Required.ProtobufInput.PrematureEofInsideUnknownValue.INT32
+Required.ProtobufInput.PrematureEofInsideUnknownValue.INT64
+Required.ProtobufInput.PrematureEofInsideUnknownValue.MESSAGE
+Required.ProtobufInput.PrematureEofInsideUnknownValue.SFIXED32
+Required.ProtobufInput.PrematureEofInsideUnknownValue.SFIXED64
+Required.ProtobufInput.PrematureEofInsideUnknownValue.SINT32
+Required.ProtobufInput.PrematureEofInsideUnknownValue.SINT64
+Required.ProtobufInput.PrematureEofInsideUnknownValue.STRING
+Required.ProtobufInput.PrematureEofInsideUnknownValue.UINT32
+Required.ProtobufInput.PrematureEofInsideUnknownValue.UINT64
+Required.ProtobufInput.PrematureEofInSubmessageValue.MESSAGE
+Required.TimestampProtoInputTooLarge.JsonOutput
+Required.TimestampProtoInputTooSmall.JsonOutput

+ 0 - 1
java/core/src/main/java/com/google/protobuf/AbstractMessageLite.java

@@ -48,7 +48,6 @@ public abstract class AbstractMessageLite<
     BuilderType extends AbstractMessageLite.Builder<MessageType, BuilderType>>
         implements MessageLite {
   protected int memoizedHashCode = 0;
-
   @Override
   public ByteString toByteString() {
     try {

+ 1 - 0
java/core/src/main/java/com/google/protobuf/FieldSet.java

@@ -220,6 +220,7 @@ final class FieldSet<FieldDescriptorType extends
     return fields.entrySet().iterator();
   }
 
+
   /**
    * Useful for implementing
    * {@link Message#hasField(Descriptors.FieldDescriptor)}.

+ 1 - 1
java/core/src/main/java/com/google/protobuf/MapFieldLite.java

@@ -83,7 +83,7 @@ public final class MapFieldLite<K, V> extends LinkedHashMap<K, V> {
 
   @Override public void clear() {
     ensureMutable();
-    clear();
+    super.clear();
   }
 
   @Override public V put(K key, V value) {

+ 12 - 9
java/core/src/main/java/com/google/protobuf/SmallSortedMap.java

@@ -197,6 +197,7 @@ class SmallSortedMap<K extends Comparable<K>, V> extends AbstractMap<K, V> {
         overflowEntries.entrySet();
   }
 
+
   @Override
   public int size() {
     return entryList.size() + overflowEntries.size();
@@ -356,6 +357,7 @@ class SmallSortedMap<K extends Comparable<K>, V> extends AbstractMap<K, V> {
     return lazyEntrySet;
   }
 
+
   /**
    * @throws UnsupportedOperationException if {@link #makeImmutable()} has
    *         has been called.
@@ -525,6 +527,7 @@ class SmallSortedMap<K extends Comparable<K>, V> extends AbstractMap<K, V> {
     }
   }
 
+
   /**
    * Iterator implementation that switches from the entry array to the overflow
    * entries appropriately.
@@ -617,43 +620,43 @@ class SmallSortedMap<K extends Comparable<K>, V> extends AbstractMap<K, V> {
       return (Iterable<T>) ITERABLE;
     }
   }
-  
+
   @Override
   public boolean equals(Object o) {
     if (this == o) {
       return true;
     }
-    
+
     if (!(o instanceof SmallSortedMap)) {
       return super.equals(o);
     }
-    
+
     SmallSortedMap<?, ?> other = (SmallSortedMap<?, ?>) o;
     final int size = size();
     if (size != other.size()) {
       return false;
     }
-    
+
     // Best effort try to avoid allocating an entry set.
     final int numArrayEntries = getNumArrayEntries();
     if (numArrayEntries != other.getNumArrayEntries()) {
       return entrySet().equals(other.entrySet());
     }
-    
+
     for (int i = 0; i < numArrayEntries; i++) {
       if (!getArrayEntryAt(i).equals(other.getArrayEntryAt(i))) {
         return false;
       }
     }
-    
+
     if (numArrayEntries != size) {
       return overflowEntries.equals(other.overflowEntries);
     }
-    
-    
+
+
     return true;
   }
-  
+
   @Override
   public int hashCode() {
     int h = 0;

+ 19 - 14
java/core/src/main/java/com/google/protobuf/UnknownFieldSet.java

@@ -31,7 +31,6 @@
 package com.google.protobuf;
 
 import com.google.protobuf.AbstractMessageLite.Builder.LimitedInputStream;
-
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
@@ -39,6 +38,7 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
+import java.util.ListIterator;
 import java.util.Map;
 import java.util.TreeMap;
 
@@ -58,7 +58,9 @@ import java.util.TreeMap;
  */
 public final class UnknownFieldSet implements MessageLite {
 
-  private UnknownFieldSet() {}
+  private UnknownFieldSet() {
+    fields = null;
+  }
 
   /** Create a new {@link Builder}. */
   public static Builder newBuilder() {
@@ -82,16 +84,18 @@ public final class UnknownFieldSet implements MessageLite {
     return defaultInstance;
   }
   private static final UnknownFieldSet defaultInstance =
-    new UnknownFieldSet(Collections.<Integer, Field>emptyMap());
+    new UnknownFieldSet(Collections.<Integer, Field>emptyMap(),
+        Collections.<Integer, Field>emptyMap());
 
   /**
    * Construct an {@code UnknownFieldSet} around the given map.  The map is
    * expected to be immutable.
    */
-  private UnknownFieldSet(final Map<Integer, Field> fields) {
+  private UnknownFieldSet(final Map<Integer, Field> fields,
+      final Map<Integer, Field> fieldsDescending) {
     this.fields = fields;
   }
-  private Map<Integer, Field> fields;
+  private final Map<Integer, Field> fields;
 
 
   @Override
@@ -224,10 +228,8 @@ public final class UnknownFieldSet implements MessageLite {
     }
   }
 
-  /**
-   * Get the number of bytes required to encode this set using
-   * {@code MessageSet} wire format.
-   */
+
+  /** Get the number of bytes required to encode this set using {@code MessageSet} wire format. */
   public int getSerializedSizeAsMessageSet() {
     int result = 0;
     for (final Map.Entry<Integer, Field> entry : fields.entrySet()) {
@@ -343,12 +345,13 @@ public final class UnknownFieldSet implements MessageLite {
      */
     @Override
     public UnknownFieldSet build() {
-      getFieldBuilder(0);  // Force lastField to be built.
+      getFieldBuilder(0); // Force lastField to be built.
       final UnknownFieldSet result;
       if (fields.isEmpty()) {
         result = getDefaultInstance();
       } else {
-        result = new UnknownFieldSet(Collections.unmodifiableMap(fields));
+        Map<Integer, Field> descendingFields = null;
+        result = new UnknownFieldSet(Collections.unmodifiableMap(fields), descendingFields);
       }
       fields = null;
       return result;
@@ -363,8 +366,9 @@ public final class UnknownFieldSet implements MessageLite {
     @Override
     public Builder clone() {
       getFieldBuilder(0);  // Force lastField to be built.
+      Map<Integer, Field> descendingFields = null;
       return UnknownFieldSet.newBuilder().mergeFrom(
-          new UnknownFieldSet(fields));
+          new UnknownFieldSet(fields, descendingFields));
     }
 
     @Override
@@ -841,9 +845,10 @@ public final class UnknownFieldSet implements MessageLite {
       }
     }
 
+
     /**
-     * Get the number of bytes required to encode this field, including field
-     * number, using {@code MessageSet} wire format.
+     * Get the number of bytes required to encode this field, including field number, using {@code
+     * MessageSet} wire format.
      */
     public int getSerializedSizeAsMessageSetExtension(final int fieldNumber) {
       int result = 0;

+ 24 - 6
java/core/src/main/java/com/google/protobuf/UnknownFieldSetLite.java

@@ -186,10 +186,11 @@ public final class UnknownFieldSetLite {
       output.writeRawMessageSetExtension(fieldNumber, (ByteString) objects[i]);
     }
   }
-  
+
+
   /**
-   * Get the number of bytes required to encode this field, including field
-   * number, using {@code MessageSet} wire format.
+   * Get the number of bytes required to encode this field, including field number, using {@code
+   * MessageSet} wire format.
    */
   public int getSerializedSizeAsMessageSet() {
     int size = memoizedSerializedSize;
@@ -251,6 +252,24 @@ public final class UnknownFieldSetLite {
     
     return size;
   }
+  
+  private static boolean equals(int[] tags1, int[] tags2, int count) {
+    for (int i = 0; i < count; ++i) {
+      if (tags1[i] != tags2[i]) {
+        return false;
+      }
+    }
+    return true;
+  }
+
+  private static boolean equals(Object[] objects1, Object[] objects2, int count) {
+    for (int i = 0; i < count; ++i) {
+      if (!objects1[i].equals(objects2[i])) {
+        return false;
+      }
+    }
+    return true;
+  }
 
   @Override
   public boolean equals(Object obj) {
@@ -268,9 +287,8 @@ public final class UnknownFieldSetLite {
     
     UnknownFieldSetLite other = (UnknownFieldSetLite) obj;    
     if (count != other.count
-        // TODO(dweis): Only have to compare up to count but at worst 2x worse than we need to do.
-        || !Arrays.equals(tags, other.tags)
-        || !Arrays.deepEquals(objects, other.objects)) {
+        || !equals(tags, other.tags, count)
+        || !equals(objects, other.objects, count)) {
       return false;
     }
 

+ 8 - 0
java/core/src/test/java/com/google/protobuf/UnknownFieldSetLiteTest.java

@@ -53,6 +53,14 @@ public class UnknownFieldSetLiteTest extends TestCase {
     assertEquals(ByteString.EMPTY, toByteString(unknownFields));
   }
 
+  public void testEmptyInstance() {
+    UnknownFieldSetLite instance = UnknownFieldSetLite.newInstance();
+
+    assertEquals(0, instance.getSerializedSize());
+    assertEquals(ByteString.EMPTY, toByteString(instance));
+    assertEquals(UnknownFieldSetLite.getDefaultInstance(), instance);
+  }
+
   public void testMergeFieldFrom() throws IOException {
     Foo foo = Foo.newBuilder()
       .setValue(2)

+ 2 - 2
js/binary/decoder.js

@@ -942,7 +942,7 @@ jspb.BinaryDecoder.prototype.readEnum = function() {
 /**
  * Reads and parses a UTF-8 encoded unicode string from the stream.
  * The code is inspired by maps.vectortown.parse.StreamedDataViewReader.
- * Supports codepoints from U+0000 up to U+10FFFF. 
+ * Supports codepoints from U+0000 up to U+10FFFF.
  * (http://en.wikipedia.org/wiki/UTF-8).
  * @param {number} length The length of the string to read.
  * @return {string} The decoded string.
@@ -984,7 +984,7 @@ jspb.BinaryDecoder.prototype.readString = function(length) {
       // 4. Add 0xDC00 to the low value to form the low surrogate:
       var low = (codepoint & 1023) + 0xDC00;
       var high = ((codepoint >> 10) & 1023) + 0xD800;
-      codeUnits.push(high, low)
+      codeUnits.push(high, low);
     }
   }
   // String.fromCharCode.apply is faster than manually appending characters on

+ 5 - 5
js/binary/decoder_test.js

@@ -209,25 +209,25 @@ describe('binaryDecoderTest', function() {
     assertEquals(hashC, decoder.readFixedHash64());
     assertEquals(hashD, decoder.readFixedHash64());
   });
-  
+
   /**
    * Test encoding and decoding utf-8.
    */
    it('testUtf8', function() {
     var encoder = new jspb.BinaryEncoder();
 
-    var ascii = "ASCII should work in 3, 2, 1..."
+    var ascii = "ASCII should work in 3, 2, 1...";
     var utf8_two_bytes = "©";
     var utf8_three_bytes = "❄";
     var utf8_four_bytes = "😁";
-    
+
     encoder.writeString(ascii);
     encoder.writeString(utf8_two_bytes);
     encoder.writeString(utf8_three_bytes);
     encoder.writeString(utf8_four_bytes);
-    
+
     var decoder = jspb.BinaryDecoder.alloc(encoder.end());
-    
+
     assertEquals(ascii, decoder.readString(ascii.length));
     assertEquals(utf8_two_bytes, decoder.readString(utf8_two_bytes.length));
     assertEquals(utf8_three_bytes, decoder.readString(utf8_three_bytes.length));

+ 2 - 2
js/binary/encoder.js

@@ -452,9 +452,9 @@ jspb.BinaryEncoder.prototype.writeFixedHash64 = function(hash) {
  */
 jspb.BinaryEncoder.prototype.writeString = function(value) {
   var oldLength = this.buffer_.length;
- 
+
   for (var i = 0; i < value.length; i++) {
-    
+
     var c = value.charCodeAt(i);
 
     if (c < 128) {

+ 60 - 0
js/binary/message_test.js

@@ -0,0 +1,60 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc.  All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+//     * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// Test suite is written using Jasmine -- see http://jasmine.github.io/
+
+goog.setTestOnly();
+
+goog.require('goog.testing.asserts');
+
+// CommonJS-LoadFromFile: test_pb proto.jspb.test
+goog.require('proto.jspb.test.Deeply.Nested.Message');
+
+// CommonJS-LoadFromFile: test2_pb proto.jspb.test
+goog.require('proto.jspb.test.ForeignNestedFieldMessage');
+
+describe('Message test suite', function() {
+  // Verify that we can successfully use a field referring to a nested message
+  // from a different .proto file.
+  it('testForeignNestedMessage', function() {
+    var msg = new proto.jspb.test.ForeignNestedFieldMessage();
+    var nested = new proto.jspb.test.Deeply.Nested.Message();
+    nested.setCount(5);
+    msg.setDeeplyNestedMessage(nested);
+    assertEquals(5, msg.getDeeplyNestedMessage().getCount());
+
+    // After a serialization-deserialization round trip we should get back the
+    // same data we started with.
+    var serialized = msg.serializeBinary();
+    var deserialized =
+        proto.jspb.test.ForeignNestedFieldMessage.deserializeBinary(serialized);
+    assertEquals(5, deserialized.getDeeplyNestedMessage().getCount());
+  });
+});

+ 35 - 23
js/map.js

@@ -183,26 +183,39 @@ jspb.Map.fromObject = function(entries, valueCtor, valueFromObject) {
 
 
 /**
- * Helper: return an iterator over an array.
+ * Helper: an IteratorIterable over an array.
  * @template T
  * @param {!Array<T>} arr the array
- * @return {!Iterator<T>} an iterator
+ * @implements {IteratorIterable<T>}
+ * @constructor @struct
  * @private
  */
-jspb.Map.arrayIterator_ = function(arr) {
-  var idx = 0;
-  return /** @type {!Iterator} */ ({
-    next: function() {
-      if (idx < arr.length) {
-        return { done: false, value: arr[idx++] };
-      } else {
-        return { done: true };
-      }
-    }
-  });
+jspb.Map.ArrayIteratorIterable_ = function(arr) {
+  /** @type {number} @private */
+  this.idx_ = 0;
+
+  /** @const @private */
+  this.arr_ = arr;
 };
 
 
+/** @override @final */
+jspb.Map.ArrayIteratorIterable_.prototype.next = function() {
+  if (this.idx_ < this.arr_.length) {
+    return {done: false, value: this.arr_[this.idx_++]};
+  } else {
+    return {done: true, value: undefined};
+  }
+};
+
+if (typeof(Symbol) != 'undefined') {
+  /** @override */
+  jspb.Map.ArrayIteratorIterable_.prototype[Symbol.iterator] = function() {
+    return this;
+  };
+}
+
+
 /**
  * Returns the map's length (number of key/value pairs).
  * @return {number}
@@ -260,10 +273,9 @@ jspb.Map.prototype.getEntryList = function() {
 
 
 /**
- * Returns an iterator over [key, value] pairs in the map.
+ * Returns an iterator-iterable over [key, value] pairs in the map.
  * Closure compiler sadly doesn't support tuples, ie. Iterator<[K,V]>.
- * @return {!Iterator<!Array<K|V>>}
- *     The iterator
+ * @return {!IteratorIterable<!Array<K|V>>} The iterator-iterable.
  */
 jspb.Map.prototype.entries = function() {
   var entries = [];
@@ -273,13 +285,13 @@ jspb.Map.prototype.entries = function() {
     var entry = this.map_[strKeys[i]];
     entries.push([entry.key, this.wrapEntry_(entry)]);
   }
-  return jspb.Map.arrayIterator_(entries);
+  return new jspb.Map.ArrayIteratorIterable_(entries);
 };
 
 
 /**
- * Returns an iterator over keys in the map.
- * @return {!Iterator<K>} The iterator
+ * Returns an iterator-iterable over keys in the map.
+ * @return {!IteratorIterable<K>} The iterator-iterable.
  */
 jspb.Map.prototype.keys = function() {
   var keys = [];
@@ -289,13 +301,13 @@ jspb.Map.prototype.keys = function() {
     var entry = this.map_[strKeys[i]];
     keys.push(entry.key);
   }
-  return jspb.Map.arrayIterator_(keys);
+  return new jspb.Map.ArrayIteratorIterable_(keys);
 };
 
 
 /**
- * Returns an iterator over values in the map.
- * @return {!Iterator<V>} The iterator
+ * Returns an iterator-iterable over values in the map.
+ * @return {!IteratorIterable<V>} The iterator-iterable.
  */
 jspb.Map.prototype.values = function() {
   var values = [];
@@ -305,7 +317,7 @@ jspb.Map.prototype.values = function() {
     var entry = this.map_[strKeys[i]];
     values.push(this.wrapEntry_(entry));
   }
-  return jspb.Map.arrayIterator_(values);
+  return new jspb.Map.ArrayIteratorIterable_(values);
 };
 
 

+ 47 - 0
js/maps_test.js

@@ -288,6 +288,53 @@ function makeTests(msgInfo, submessageCtor, suffix) {
     var a = msg.toArray();
     assertEquals(a[0], entries);  // retains original reference
   });
+
+  /**
+   * Returns IteratorIterables for entries(), keys() and values().
+   */
+  it('testIteratorIterables' + suffix, function() {
+    var msg = new msgInfo.constructor();
+    var m = msg.getMapStringStringMap();
+    m.set('key1', 'value1');
+    m.set('key2', 'value2');
+    var entryIterator = m.entries();
+    assertElementsEquals(entryIterator.next().value, ['key1', 'value1']);
+    assertElementsEquals(entryIterator.next().value, ['key2', 'value2']);
+    assertEquals(entryIterator.next().done, true);
+
+    if (!goog.userAgent.IE) {
+      // Symbol is not defined in IE
+      var entryIterable = m.entries()[Symbol.iterator]();
+      assertElementsEquals(entryIterable.next().value, ['key1', 'value1']);
+      assertElementsEquals(entryIterable.next().value, ['key2', 'value2']);
+      assertEquals(entryIterable.next().done, true);
+    }
+
+    var keyIterator = m.keys();
+    assertEquals(keyIterator.next().value, 'key1');
+    assertEquals(keyIterator.next().value, 'key2');
+    assertEquals(keyIterator.next().done, true);
+
+    if (!goog.userAgent.IE) {
+      // Symbol is not defined in IE
+      var keyIterable = m.keys()[Symbol.iterator]();
+      assertEquals(keyIterable.next().value, 'key1');
+      assertEquals(keyIterable.next().value, 'key2');
+      assertEquals(keyIterable.next().done, true);
+    }
+    var valueIterator = m.values();
+    assertEquals(valueIterator.next().value, 'value1');
+    assertEquals(valueIterator.next().value, 'value2');
+    assertEquals(valueIterator.next().done, true);
+
+    if (!goog.userAgent.IE) {
+      // Symbol is not defined in IE
+      var valueIterable = m.values()[Symbol.iterator]();
+      assertEquals(valueIterable.next().value, 'value1');
+      assertEquals(valueIterable.next().value, 'value2');
+      assertEquals(valueIterable.next().done, true);
+    }
+  });
 }
 
 describe('mapsTest', function() {

+ 32 - 2
js/message.js

@@ -174,6 +174,22 @@ goog.define('jspb.Message.GENERATE_TO_OBJECT', true);
 goog.define('jspb.Message.GENERATE_FROM_OBJECT', !goog.DISALLOW_TEST_ONLY_CODE);
 
 
+/**
+ * @define {boolean} Whether to generate toString methods for objects. Turn
+ *     this off if you do use toString in your project and want to trim it from
+ *     compiled JS.
+ */
+goog.define('jspb.Message.GENERATE_TO_STRING', true);
+
+
+/**
+ * @define {boolean} Whether arrays passed to initialize() can be assumed to be
+ *     local (e.g. not from another iframe) and thus safely classified with
+ *     instanceof Array.
+ */
+goog.define('jspb.Message.ASSUME_LOCAL_ARRAYS', false);
+
+
 /**
  * @define {boolean} Turning on this flag does NOT change the behavior of JSPB
  *     and only affects private internal state. It may, however, break some
@@ -363,6 +379,18 @@ jspb.Message.EMPTY_LIST_SENTINEL_ = goog.DEBUG && Object.freeze ?
     [];
 
 
+/**
+ * Returns true if the provided argument is an array.
+ * @param {*} o The object to classify as array or not.
+ * @return {boolean} True if the provided object is an array.
+ * @private
+ */
+jspb.Message.isArray_ = function(o) {
+  return jspb.Message.ASSUME_LOCAL_ARRAYS ? o instanceof Array :
+                                            goog.isArray(o);
+};
+
+
 /**
  * Ensures that the array contains an extension object if necessary.
  * If the array contains an extension object in its last position, then the
@@ -383,8 +411,8 @@ jspb.Message.materializeExtensionObject_ = function(msg, suggestedPivot) {
     // the object is not an array, since arrays are valid field values.
     // NOTE(lukestebbing): We avoid looking at .length to avoid a JIT bug
     // in Safari on iOS 8. See the description of CL/86511464 for details.
-    if (obj && typeof obj == 'object' && !goog.isArray(obj) &&
-       !(jspb.Message.SUPPORTS_UINT8ARRAY_ && obj instanceof Uint8Array)) {
+    if (obj && typeof obj == 'object' && !jspb.Message.isArray_(obj) &&
+        !(jspb.Message.SUPPORTS_UINT8ARRAY_ && obj instanceof Uint8Array)) {
       msg.pivot_ = foundIndex - msg.arrayIndexOffset_;
       msg.extensionObject_ = obj;
       return;
@@ -1140,6 +1168,7 @@ jspb.Message.prototype.toArray = function() {
 
 
 
+if (jspb.Message.GENERATE_TO_STRING) {
 
 /**
  * Creates a string representation of the internal data array of this proto.
@@ -1152,6 +1181,7 @@ jspb.Message.prototype.toString = function() {
   return this.array.toString();
 };
 
+}
 
 /**
  * Gets the value of the extension field from the extended object.

+ 0 - 19
js/message_test.js

@@ -73,12 +73,10 @@ goog.require('proto.jspb.test.TestGroup1');
 goog.require('proto.jspb.test.TestMessageWithOneof');
 goog.require('proto.jspb.test.TestReservedNames');
 goog.require('proto.jspb.test.TestReservedNamesExtension');
-goog.require('proto.jspb.test.Deeply.Nested.Message');
 
 // CommonJS-LoadFromFile: test2_pb proto.jspb.test
 goog.require('proto.jspb.test.ExtensionMessage');
 goog.require('proto.jspb.test.TestExtensionsMessage');
-goog.require('proto.jspb.test.ForeignNestedFieldMessage');
 
 
 
@@ -1042,21 +1040,4 @@ describe('Message test suite', function() {
     assertNan(message.getDefaultDoubleField());
   });
 
-  // Verify that we can successfully use a field referring to a nested message
-  // from a different .proto file.
-  it('testForeignNestedMessage', function() {
-    var msg = new proto.jspb.test.ForeignNestedFieldMessage();
-    var nested = new proto.jspb.test.Deeply.Nested.Message();
-    nested.setCount(5);
-    msg.setDeeplyNestedMessage(nested);
-    assertEquals(5, msg.getDeeplyNestedMessage().getCount());
-
-    // After a serialization-deserialization round trip we should get back the
-    // same data we started with.
-    var serialized = msg.serializeBinary();
-    var deserialized =
-        proto.jspb.test.ForeignNestedFieldMessage.deserializeBinary(serialized);
-    assertEquals(5, deserialized.getDeeplyNestedMessage().getCount());
-  });
-
 });

+ 12 - 2
objectivec/google/protobuf/Type.pbobjc.h

@@ -411,10 +411,20 @@ typedef GPB_ENUM(GPBOption_FieldNumber) {
  **/
 @interface GPBOption : GPBMessage
 
-/** The option's name. For example, `"java_package"`. */
+/**
+ * The option's name. For protobuf built-in options (options defined in
+ * descriptor.proto), this is the short name. For example, `"map_entry"`.
+ * For custom options, it should be the fully-qualified name. For example,
+ * `"google.api.http"`.
+ **/
 @property(nonatomic, readwrite, copy, null_resettable) NSString *name;
 
-/** The option's value. For example, `"com.google.protobuf"`. */
+/**
+ * The option's value packed in an Any message. If the value is a primitive,
+ * the corresponding wrapper type defined in google/protobuf/wrappers.proto
+ * should be used. If the value is an enum, it should be stored as an int32
+ * value using the google.protobuf.Int32Value type.
+ **/
 @property(nonatomic, readwrite, strong, null_resettable) GPBAny *value;
 /** Test to see if @c value has been set. */
 @property(nonatomic, readwrite) BOOL hasValue;

+ 7 - 12
python/google/protobuf/internal/python_message.py

@@ -56,17 +56,6 @@ import sys
 import weakref
 
 import six
-try:
-  import six.moves.copyreg as copyreg
-except ImportError:
-  # On some platforms, for example gMac, we run native Python because there is
-  # nothing like hermetic Python. This means lesser control on the system and
-  # the six.moves package may be missing (is missing on 20150321 on gMac). Be
-  # extra conservative and try to load the old replacement if it fails.
-  try:
-    import copy_reg as copyreg  #PY26
-  except ImportError:
-    import copyreg
 
 # We use "as" to avoid name collisions with variables.
 from google.protobuf.internal import containers
@@ -179,7 +168,6 @@ class GeneratedProtocolMessageType(type):
     _AddStaticMethods(cls)
     _AddMessageMethods(descriptor, cls)
     _AddPrivateHelperMethods(descriptor, cls)
-    copyreg.pickle(cls, lambda obj: (cls, (), obj.__getstate__()))
 
     superclass = super(GeneratedProtocolMessageType, cls)
     superclass.__init__(name, bases, dictionary)
@@ -1271,6 +1259,12 @@ def _AddWhichOneofMethod(message_descriptor, cls):
   cls.WhichOneof = WhichOneof
 
 
+def _AddReduceMethod(cls):
+  def __reduce__(self):  # pylint: disable=invalid-name
+    return (type(self), (), self.__getstate__())
+  cls.__reduce__ = __reduce__
+
+
 def _Clear(self):
   # Clear fields.
   self._fields = {}
@@ -1316,6 +1310,7 @@ def _AddMessageMethods(message_descriptor, cls):
   _AddIsInitializedMethod(message_descriptor, cls)
   _AddMergeFromMethod(cls)
   _AddWhichOneofMethod(message_descriptor, cls)
+  _AddReduceMethod(cls)
   # Adds methods which do not depend on cls.
   cls.Clear = _Clear
   cls.DiscardUnknownFields = _DiscardUnknownFields

+ 2 - 0
python/google/protobuf/pyext/extension_dict.cc

@@ -126,6 +126,8 @@ PyObject* subscript(ExtensionDict* self, PyObject* key) {
       CMessageClass* message_class = message_factory::GetOrCreateMessageClass(
           cmessage::GetFactoryForMessage(self->parent),
           descriptor->message_type());
+      ScopedPyObjectPtr message_class_handler(
+        reinterpret_cast<PyObject*>(message_class));
       if (message_class == NULL) {
         return NULL;
       }

+ 3 - 1
python/google/protobuf/pyext/message.cc

@@ -2342,8 +2342,10 @@ PyObject* InternalGetSubMessage(
   const Message& sub_message = reflection->GetMessage(
       *self->message, field_descriptor, factory->message_factory);
 
-  CMessageClass* message_class = message_factory::GetMessageClass(
+  CMessageClass* message_class = message_factory::GetOrCreateMessageClass(
       factory, field_descriptor->message_type());
+  ScopedPyObjectPtr message_class_handler(
+      reinterpret_cast<PyObject*>(message_class));
   if (message_class == NULL) {
     return NULL;
   }

+ 57 - 41
src/google/protobuf/any.pb.cc

@@ -19,8 +19,11 @@
 
 namespace google {
 namespace protobuf {
-class AnyDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Any> {};
-AnyDefaultTypeInternal _Any_default_instance_;
+class AnyDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Any> {
+} _Any_default_instance_;
+
+namespace protobuf_google_2fprotobuf_2fany_2eproto {
+
 
 namespace {
 
@@ -28,35 +31,30 @@ namespace {
 
 }  // namespace
 
-
-const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fany_2eproto() GOOGLE_ATTRIBUTE_COLD;
-const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fany_2eproto() {
-  static const ::google::protobuf::uint32 offsets[] = {
-    ~0u,  // no _has_bits_
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Any, _internal_metadata_),
-    ~0u,  // no _extensions_
-    ~0u,  // no _oneof_case_
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Any, type_url_),
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Any, value_),
-  };
-  return offsets;
-}
+const ::google::protobuf::uint32 TableStruct::offsets[] = {
+  ~0u,  // no _has_bits_
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Any, _internal_metadata_),
+  ~0u,  // no _extensions_
+  ~0u,  // no _oneof_case_
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Any, type_url_),
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Any, value_),
+};
 
 static const ::google::protobuf::internal::MigrationSchema schemas[] = {
   { 0, -1, sizeof(Any)},
 };
 
-static const ::google::protobuf::internal::DefaultInstanceData file_default_instances[] = {
-  {reinterpret_cast<const ::google::protobuf::Message*>(&_Any_default_instance_), NULL},
+static ::google::protobuf::Message const * const file_default_instances[] = {
+  reinterpret_cast<const ::google::protobuf::Message*>(&_Any_default_instance_),
 };
 
 namespace {
 
 void protobuf_AssignDescriptors() {
-  protobuf_AddDesc_google_2fprotobuf_2fany_2eproto();
+  AddDescriptors();
   ::google::protobuf::MessageFactory* factory = NULL;
   AssignDescriptors(
-      "google/protobuf/any.proto", schemas, file_default_instances, protobuf_Offsets_google_2fprotobuf_2fany_2eproto(), factory,
+      "google/protobuf/any.proto", schemas, file_default_instances, TableStruct::offsets, factory,
       file_level_metadata, NULL, NULL);
 }
 
@@ -73,24 +71,24 @@ void protobuf_RegisterTypes(const ::std::string&) {
 
 }  // namespace
 
-void protobuf_ShutdownFile_google_2fprotobuf_2fany_2eproto() {
+void TableStruct::Shutdown() {
   _Any_default_instance_.Shutdown();
   delete file_level_metadata[0].reflection;
 }
 
-void protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto_impl() {
+void TableStruct::InitDefaultsImpl() {
   GOOGLE_PROTOBUF_VERIFY_VERSION;
 
   ::google::protobuf::internal::InitProtobufDefaults();
   _Any_default_instance_.DefaultConstruct();
 }
 
-void protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto() {
+void InitDefaults() {
   static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
-  ::google::protobuf::GoogleOnceInit(&once, &protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto_impl);
+  ::google::protobuf::GoogleOnceInit(&once, &TableStruct::InitDefaultsImpl);
 }
-void protobuf_AddDesc_google_2fprotobuf_2fany_2eproto_impl() {
-  protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto();
+void AddDescriptorsImpl() {
+  InitDefaults();
   static const char descriptor[] = {
       "\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"
@@ -103,20 +101,22 @@ void protobuf_AddDesc_google_2fprotobuf_2fany_2eproto_impl() {
       descriptor, 205);
   ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
     "google/protobuf/any.proto", &protobuf_RegisterTypes);
-  ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fany_2eproto);
+  ::google::protobuf::internal::OnShutdown(&TableStruct::Shutdown);
 }
 
-GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_google_2fprotobuf_2fany_2eproto_once_);
-void protobuf_AddDesc_google_2fprotobuf_2fany_2eproto() {
-  ::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_google_2fprotobuf_2fany_2eproto_once_,
-                 &protobuf_AddDesc_google_2fprotobuf_2fany_2eproto_impl);
+void AddDescriptors() {
+  static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
+  ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl);
 }
 // Force AddDescriptors() to be called at static initialization time.
-struct StaticDescriptorInitializer_google_2fprotobuf_2fany_2eproto {
-  StaticDescriptorInitializer_google_2fprotobuf_2fany_2eproto() {
-    protobuf_AddDesc_google_2fprotobuf_2fany_2eproto();
+struct StaticDescriptorInitializer {
+  StaticDescriptorInitializer() {
+    AddDescriptors();
   }
-} static_descriptor_initializer_google_2fprotobuf_2fany_2eproto_;
+} static_descriptor_initializer;
+
+}  // namespace protobuf_google_2fprotobuf_2fany_2eproto
+
 
 // ===================================================================
 
@@ -141,7 +141,7 @@ const int Any::kValueFieldNumber;
 Any::Any()
   : ::google::protobuf::Message(), _internal_metadata_(NULL), _any_metadata_(&type_url_, &value_) {
   if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
-    protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto();
+    protobuf_google_2fprotobuf_2fany_2eproto::InitDefaults();
   }
   SharedCtor();
   // @@protoc_insertion_point(constructor:google.protobuf.Any)
@@ -185,12 +185,12 @@ void Any::SetCachedSize(int size) const {
   GOOGLE_SAFE_CONCURRENT_WRITES_END();
 }
 const ::google::protobuf::Descriptor* Any::descriptor() {
-  protobuf_AssignDescriptorsOnce();
-  return file_level_metadata[0].descriptor;
+  protobuf_google_2fprotobuf_2fany_2eproto::protobuf_AssignDescriptorsOnce();
+  return protobuf_google_2fprotobuf_2fany_2eproto::file_level_metadata[0].descriptor;
 }
 
 const Any& Any::default_instance() {
-  protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto();
+  protobuf_google_2fprotobuf_2fany_2eproto::InitDefaults();
   return *internal_default_instance();
 }
 
@@ -289,7 +289,7 @@ void Any::SerializeWithCachedSizes(
 
 ::google::protobuf::uint8* Any::InternalSerializeWithCachedSizesToArray(
     bool deterministic, ::google::protobuf::uint8* target) const {
-  (void)deterministic; // Unused
+  (void)deterministic;  // Unused
   // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Any)
   // string type_url = 1;
   if (this->type_url().size() > 0) {
@@ -396,8 +396,8 @@ void Any::InternalSwap(Any* other) {
 }
 
 ::google::protobuf::Metadata Any::GetMetadata() const {
-  protobuf_AssignDescriptorsOnce();
-  return file_level_metadata[0];
+  protobuf_google_2fprotobuf_2fany_2eproto::protobuf_AssignDescriptorsOnce();
+  return protobuf_google_2fprotobuf_2fany_2eproto::file_level_metadata[0];
 }
 
 #if PROTOBUF_INLINE_NOT_IN_HEADERS
@@ -416,6 +416,14 @@ void Any::set_type_url(const ::std::string& value) {
   type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
   // @@protoc_insertion_point(field_set:google.protobuf.Any.type_url)
 }
+#if LANG_CXX11
+void Any::set_type_url(::std::string&& value) {
+  
+  type_url_.SetNoArena(
+    &::google::protobuf::internal::GetEmptyStringAlreadyInited(), std::move(value));
+  // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Any.type_url)
+}
+#endif
 void Any::set_type_url(const char* value) {
   
   type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -460,6 +468,14 @@ void Any::set_value(const ::std::string& value) {
   value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
   // @@protoc_insertion_point(field_set:google.protobuf.Any.value)
 }
+#if LANG_CXX11
+void Any::set_value(::std::string&& value) {
+  
+  value_.SetNoArena(
+    &::google::protobuf::internal::GetEmptyStringAlreadyInited(), std::move(value));
+  // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Any.value)
+}
+#endif
 void Any::set_value(const char* value) {
   
   value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));

+ 35 - 8
src/google/protobuf/any.pb.h

@@ -19,6 +19,7 @@
 #error regenerate this file with a newer version of protoc.
 #endif
 
+#include <google/protobuf/io/coded_stream.h>
 #include <google/protobuf/arena.h>
 #include <google/protobuf/arenastring.h>
 #include <google/protobuf/generated_message_util.h>
@@ -40,9 +41,16 @@ LIBPROTOBUF_EXPORT extern AnyDefaultTypeInternal _Any_default_instance_;
 namespace google {
 namespace protobuf {
 
+namespace protobuf_google_2fprotobuf_2fany_2eproto {
 // Internal implementation detail -- do not call these.
-void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fany_2eproto();
-void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto();
+struct LIBPROTOBUF_EXPORT TableStruct {
+  static const ::google::protobuf::uint32 offsets[];
+  static void InitDefaultsImpl();
+  static void Shutdown();
+};
+void LIBPROTOBUF_EXPORT AddDescriptors();
+void LIBPROTOBUF_EXPORT InitDefaults();
+}  // namespace protobuf_google_2fprotobuf_2fany_2eproto
 
 // ===================================================================
 
@@ -99,7 +107,8 @@ class LIBPROTOBUF_EXPORT Any : public ::google::protobuf::Message /* @@protoc_in
       bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
   ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
       const PROTOBUF_FINAL {
-    return InternalSerializeWithCachedSizesToArray(false, output);
+    return InternalSerializeWithCachedSizesToArray(
+        ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
   }
   int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
   private:
@@ -127,6 +136,9 @@ class LIBPROTOBUF_EXPORT Any : public ::google::protobuf::Message /* @@protoc_in
   static const int kTypeUrlFieldNumber = 1;
   const ::std::string& type_url() const;
   void set_type_url(const ::std::string& value);
+  #if LANG_CXX11
+  void set_type_url(::std::string&& value);
+  #endif
   void set_type_url(const char* value);
   void set_type_url(const char* value, size_t size);
   ::std::string* mutable_type_url();
@@ -138,6 +150,9 @@ class LIBPROTOBUF_EXPORT Any : public ::google::protobuf::Message /* @@protoc_in
   static const int kValueFieldNumber = 2;
   const ::std::string& value() const;
   void set_value(const ::std::string& value);
+  #if LANG_CXX11
+  void set_value(::std::string&& value);
+  #endif
   void set_value(const char* value);
   void set_value(const void* value, size_t size);
   ::std::string* mutable_value();
@@ -152,11 +167,7 @@ class LIBPROTOBUF_EXPORT Any : public ::google::protobuf::Message /* @@protoc_in
   ::google::protobuf::internal::ArenaStringPtr value_;
   mutable int _cached_size_;
   ::google::protobuf::internal::AnyMetadata _any_metadata_;
-  friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto_impl();
-  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fany_2eproto_impl();
-  friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fany_2eproto();
-  friend void protobuf_ShutdownFile_google_2fprotobuf_2fany_2eproto();
-
+  friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fany_2eproto::TableStruct;
 };
 // ===================================================================
 
@@ -179,6 +190,14 @@ inline void Any::set_type_url(const ::std::string& value) {
   type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
   // @@protoc_insertion_point(field_set:google.protobuf.Any.type_url)
 }
+#if LANG_CXX11
+inline void Any::set_type_url(::std::string&& value) {
+  
+  type_url_.SetNoArena(
+    &::google::protobuf::internal::GetEmptyStringAlreadyInited(), std::move(value));
+  // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Any.type_url)
+}
+#endif
 inline void Any::set_type_url(const char* value) {
   
   type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -223,6 +242,14 @@ inline void Any::set_value(const ::std::string& value) {
   value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
   // @@protoc_insertion_point(field_set:google.protobuf.Any.value)
 }
+#if LANG_CXX11
+inline void Any::set_value(::std::string&& value) {
+  
+  value_.SetNoArena(
+    &::google::protobuf::internal::GetEmptyStringAlreadyInited(), std::move(value));
+  // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Any.value)
+}
+#endif
 inline void Any::set_value(const char* value) {
   
   value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));

+ 143 - 87
src/google/protobuf/api.pb.cc

@@ -19,12 +19,15 @@
 
 namespace google {
 namespace protobuf {
-class ApiDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Api> {};
-ApiDefaultTypeInternal _Api_default_instance_;
-class MethodDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Method> {};
-MethodDefaultTypeInternal _Method_default_instance_;
-class MixinDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Mixin> {};
-MixinDefaultTypeInternal _Mixin_default_instance_;
+class ApiDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Api> {
+} _Api_default_instance_;
+class MethodDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Method> {
+} _Method_default_instance_;
+class MixinDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Mixin> {
+} _Mixin_default_instance_;
+
+namespace protobuf_google_2fprotobuf_2fapi_2eproto {
+
 
 namespace {
 
@@ -32,41 +35,36 @@ namespace {
 
 }  // namespace
 
-
-const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fapi_2eproto() GOOGLE_ATTRIBUTE_COLD;
-const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fapi_2eproto() {
-  static const ::google::protobuf::uint32 offsets[] = {
-    ~0u,  // no _has_bits_
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, _internal_metadata_),
-    ~0u,  // no _extensions_
-    ~0u,  // no _oneof_case_
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, name_),
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, methods_),
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, options_),
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, version_),
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, source_context_),
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, mixins_),
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, syntax_),
-    ~0u,  // no _has_bits_
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, _internal_metadata_),
-    ~0u,  // no _extensions_
-    ~0u,  // no _oneof_case_
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, name_),
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, request_type_url_),
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, request_streaming_),
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, response_type_url_),
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, response_streaming_),
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, options_),
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, syntax_),
-    ~0u,  // no _has_bits_
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Mixin, _internal_metadata_),
-    ~0u,  // no _extensions_
-    ~0u,  // no _oneof_case_
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Mixin, name_),
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Mixin, root_),
-  };
-  return offsets;
-}
+const ::google::protobuf::uint32 TableStruct::offsets[] = {
+  ~0u,  // no _has_bits_
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, _internal_metadata_),
+  ~0u,  // no _extensions_
+  ~0u,  // no _oneof_case_
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, name_),
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, methods_),
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, options_),
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, version_),
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, source_context_),
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, mixins_),
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, syntax_),
+  ~0u,  // no _has_bits_
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, _internal_metadata_),
+  ~0u,  // no _extensions_
+  ~0u,  // no _oneof_case_
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, name_),
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, request_type_url_),
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, request_streaming_),
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, response_type_url_),
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, response_streaming_),
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, options_),
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, syntax_),
+  ~0u,  // no _has_bits_
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Mixin, _internal_metadata_),
+  ~0u,  // no _extensions_
+  ~0u,  // no _oneof_case_
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Mixin, name_),
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Mixin, root_),
+};
 
 static const ::google::protobuf::internal::MigrationSchema schemas[] = {
   { 0, -1, sizeof(Api)},
@@ -74,19 +72,19 @@ static const ::google::protobuf::internal::MigrationSchema schemas[] = {
   { 22, -1, sizeof(Mixin)},
 };
 
-static const ::google::protobuf::internal::DefaultInstanceData file_default_instances[] = {
-  {reinterpret_cast<const ::google::protobuf::Message*>(&_Api_default_instance_), NULL},
-  {reinterpret_cast<const ::google::protobuf::Message*>(&_Method_default_instance_), NULL},
-  {reinterpret_cast<const ::google::protobuf::Message*>(&_Mixin_default_instance_), NULL},
+static ::google::protobuf::Message const * const file_default_instances[] = {
+  reinterpret_cast<const ::google::protobuf::Message*>(&_Api_default_instance_),
+  reinterpret_cast<const ::google::protobuf::Message*>(&_Method_default_instance_),
+  reinterpret_cast<const ::google::protobuf::Message*>(&_Mixin_default_instance_),
 };
 
 namespace {
 
 void protobuf_AssignDescriptors() {
-  protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto();
+  AddDescriptors();
   ::google::protobuf::MessageFactory* factory = NULL;
   AssignDescriptors(
-      "google/protobuf/api.proto", schemas, file_default_instances, protobuf_Offsets_google_2fprotobuf_2fapi_2eproto(), factory,
+      "google/protobuf/api.proto", schemas, file_default_instances, TableStruct::offsets, factory,
       file_level_metadata, NULL, NULL);
 }
 
@@ -103,7 +101,7 @@ void protobuf_RegisterTypes(const ::std::string&) {
 
 }  // namespace
 
-void protobuf_ShutdownFile_google_2fprotobuf_2fapi_2eproto() {
+void TableStruct::Shutdown() {
   _Api_default_instance_.Shutdown();
   delete file_level_metadata[0].reflection;
   _Method_default_instance_.Shutdown();
@@ -112,12 +110,12 @@ void protobuf_ShutdownFile_google_2fprotobuf_2fapi_2eproto() {
   delete file_level_metadata[2].reflection;
 }
 
-void protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto_impl() {
+void TableStruct::InitDefaultsImpl() {
   GOOGLE_PROTOBUF_VERIFY_VERSION;
 
-  ::google::protobuf::protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto();
-  ::google::protobuf::protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto();
   ::google::protobuf::internal::InitProtobufDefaults();
+  ::google::protobuf::protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto::InitDefaults();
+  ::google::protobuf::protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaults();
   _Api_default_instance_.DefaultConstruct();
   _Method_default_instance_.DefaultConstruct();
   _Mixin_default_instance_.DefaultConstruct();
@@ -125,12 +123,12 @@ void protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto_impl() {
       ::google::protobuf::SourceContext::internal_default_instance());
 }
 
-void protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto() {
+void InitDefaults() {
   static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
-  ::google::protobuf::GoogleOnceInit(&once, &protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto_impl);
+  ::google::protobuf::GoogleOnceInit(&once, &TableStruct::InitDefaultsImpl);
 }
-void protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto_impl() {
-  protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto();
+void AddDescriptorsImpl() {
+  InitDefaults();
   static const char descriptor[] = {
       "\n\031google/protobuf/api.proto\022\017google.prot"
       "obuf\032$google/protobuf/source_context.pro"
@@ -156,22 +154,24 @@ void protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto_impl() {
       descriptor, 750);
   ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
     "google/protobuf/api.proto", &protobuf_RegisterTypes);
-  ::google::protobuf::protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto();
-  ::google::protobuf::protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto();
-  ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fapi_2eproto);
+  ::google::protobuf::protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto::AddDescriptors();
+  ::google::protobuf::protobuf_google_2fprotobuf_2ftype_2eproto::AddDescriptors();
+  ::google::protobuf::internal::OnShutdown(&TableStruct::Shutdown);
 }
 
-GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto_once_);
-void protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto() {
-  ::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto_once_,
-                 &protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto_impl);
+void AddDescriptors() {
+  static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
+  ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl);
 }
 // Force AddDescriptors() to be called at static initialization time.
-struct StaticDescriptorInitializer_google_2fprotobuf_2fapi_2eproto {
-  StaticDescriptorInitializer_google_2fprotobuf_2fapi_2eproto() {
-    protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto();
+struct StaticDescriptorInitializer {
+  StaticDescriptorInitializer() {
+    AddDescriptors();
   }
-} static_descriptor_initializer_google_2fprotobuf_2fapi_2eproto_;
+} static_descriptor_initializer;
+
+}  // namespace protobuf_google_2fprotobuf_2fapi_2eproto
+
 
 // ===================================================================
 
@@ -188,7 +188,7 @@ const int Api::kSyntaxFieldNumber;
 Api::Api()
   : ::google::protobuf::Message(), _internal_metadata_(NULL) {
   if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
-    protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto();
+    protobuf_google_2fprotobuf_2fapi_2eproto::InitDefaults();
   }
   SharedCtor();
   // @@protoc_insertion_point(constructor:google.protobuf.Api)
@@ -245,12 +245,12 @@ void Api::SetCachedSize(int size) const {
   GOOGLE_SAFE_CONCURRENT_WRITES_END();
 }
 const ::google::protobuf::Descriptor* Api::descriptor() {
-  protobuf_AssignDescriptorsOnce();
-  return file_level_metadata[0].descriptor;
+  protobuf_google_2fprotobuf_2fapi_2eproto::protobuf_AssignDescriptorsOnce();
+  return protobuf_google_2fprotobuf_2fapi_2eproto::file_level_metadata[0].descriptor;
 }
 
 const Api& Api::default_instance() {
-  protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto();
+  protobuf_google_2fprotobuf_2fapi_2eproto::InitDefaults();
   return *internal_default_instance();
 }
 
@@ -459,7 +459,7 @@ void Api::SerializeWithCachedSizes(
 
 ::google::protobuf::uint8* Api::InternalSerializeWithCachedSizesToArray(
     bool deterministic, ::google::protobuf::uint8* target) const {
-  (void)deterministic; // Unused
+  (void)deterministic;  // Unused
   // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Api)
   // string name = 1;
   if (this->name().size() > 0) {
@@ -664,8 +664,8 @@ void Api::InternalSwap(Api* other) {
 }
 
 ::google::protobuf::Metadata Api::GetMetadata() const {
-  protobuf_AssignDescriptorsOnce();
-  return file_level_metadata[0];
+  protobuf_google_2fprotobuf_2fapi_2eproto::protobuf_AssignDescriptorsOnce();
+  return protobuf_google_2fprotobuf_2fapi_2eproto::file_level_metadata[0];
 }
 
 #if PROTOBUF_INLINE_NOT_IN_HEADERS
@@ -684,6 +684,14 @@ void Api::set_name(const ::std::string& value) {
   name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
   // @@protoc_insertion_point(field_set:google.protobuf.Api.name)
 }
+#if LANG_CXX11
+void Api::set_name(::std::string&& value) {
+  
+  name_.SetNoArena(
+    &::google::protobuf::internal::GetEmptyStringAlreadyInited(), std::move(value));
+  // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Api.name)
+}
+#endif
 void Api::set_name(const char* value) {
   
   name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -788,6 +796,14 @@ void Api::set_version(const ::std::string& value) {
   version_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
   // @@protoc_insertion_point(field_set:google.protobuf.Api.version)
 }
+#if LANG_CXX11
+void Api::set_version(::std::string&& value) {
+  
+  version_.SetNoArena(
+    &::google::protobuf::internal::GetEmptyStringAlreadyInited(), std::move(value));
+  // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Api.version)
+}
+#endif
 void Api::set_version(const char* value) {
   
   version_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -919,7 +935,7 @@ const int Method::kSyntaxFieldNumber;
 Method::Method()
   : ::google::protobuf::Message(), _internal_metadata_(NULL) {
   if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
-    protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto();
+    protobuf_google_2fprotobuf_2fapi_2eproto::InitDefaults();
   }
   SharedCtor();
   // @@protoc_insertion_point(constructor:google.protobuf.Method)
@@ -974,12 +990,12 @@ void Method::SetCachedSize(int size) const {
   GOOGLE_SAFE_CONCURRENT_WRITES_END();
 }
 const ::google::protobuf::Descriptor* Method::descriptor() {
-  protobuf_AssignDescriptorsOnce();
-  return file_level_metadata[1].descriptor;
+  protobuf_google_2fprotobuf_2fapi_2eproto::protobuf_AssignDescriptorsOnce();
+  return protobuf_google_2fprotobuf_2fapi_2eproto::file_level_metadata[1].descriptor;
 }
 
 const Method& Method::default_instance() {
-  protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto();
+  protobuf_google_2fprotobuf_2fapi_2eproto::InitDefaults();
   return *internal_default_instance();
 }
 
@@ -1190,7 +1206,7 @@ void Method::SerializeWithCachedSizes(
 
 ::google::protobuf::uint8* Method::InternalSerializeWithCachedSizesToArray(
     bool deterministic, ::google::protobuf::uint8* target) const {
-  (void)deterministic; // Unused
+  (void)deterministic;  // Unused
   // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Method)
   // string name = 1;
   if (this->name().size() > 0) {
@@ -1388,8 +1404,8 @@ void Method::InternalSwap(Method* other) {
 }
 
 ::google::protobuf::Metadata Method::GetMetadata() const {
-  protobuf_AssignDescriptorsOnce();
-  return file_level_metadata[1];
+  protobuf_google_2fprotobuf_2fapi_2eproto::protobuf_AssignDescriptorsOnce();
+  return protobuf_google_2fprotobuf_2fapi_2eproto::file_level_metadata[1];
 }
 
 #if PROTOBUF_INLINE_NOT_IN_HEADERS
@@ -1408,6 +1424,14 @@ void Method::set_name(const ::std::string& value) {
   name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
   // @@protoc_insertion_point(field_set:google.protobuf.Method.name)
 }
+#if LANG_CXX11
+void Method::set_name(::std::string&& value) {
+  
+  name_.SetNoArena(
+    &::google::protobuf::internal::GetEmptyStringAlreadyInited(), std::move(value));
+  // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Method.name)
+}
+#endif
 void Method::set_name(const char* value) {
   
   name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -1452,6 +1476,14 @@ void Method::set_request_type_url(const ::std::string& value) {
   request_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
   // @@protoc_insertion_point(field_set:google.protobuf.Method.request_type_url)
 }
+#if LANG_CXX11
+void Method::set_request_type_url(::std::string&& value) {
+  
+  request_type_url_.SetNoArena(
+    &::google::protobuf::internal::GetEmptyStringAlreadyInited(), std::move(value));
+  // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Method.request_type_url)
+}
+#endif
 void Method::set_request_type_url(const char* value) {
   
   request_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -1510,6 +1542,14 @@ void Method::set_response_type_url(const ::std::string& value) {
   response_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
   // @@protoc_insertion_point(field_set:google.protobuf.Method.response_type_url)
 }
+#if LANG_CXX11
+void Method::set_response_type_url(::std::string&& value) {
+  
+  response_type_url_.SetNoArena(
+    &::google::protobuf::internal::GetEmptyStringAlreadyInited(), std::move(value));
+  // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Method.response_type_url)
+}
+#endif
 void Method::set_response_type_url(const char* value) {
   
   response_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -1611,7 +1651,7 @@ const int Mixin::kRootFieldNumber;
 Mixin::Mixin()
   : ::google::protobuf::Message(), _internal_metadata_(NULL) {
   if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
-    protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto();
+    protobuf_google_2fprotobuf_2fapi_2eproto::InitDefaults();
   }
   SharedCtor();
   // @@protoc_insertion_point(constructor:google.protobuf.Mixin)
@@ -1654,12 +1694,12 @@ void Mixin::SetCachedSize(int size) const {
   GOOGLE_SAFE_CONCURRENT_WRITES_END();
 }
 const ::google::protobuf::Descriptor* Mixin::descriptor() {
-  protobuf_AssignDescriptorsOnce();
-  return file_level_metadata[2].descriptor;
+  protobuf_google_2fprotobuf_2fapi_2eproto::protobuf_AssignDescriptorsOnce();
+  return protobuf_google_2fprotobuf_2fapi_2eproto::file_level_metadata[2].descriptor;
 }
 
 const Mixin& Mixin::default_instance() {
-  protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto();
+  protobuf_google_2fprotobuf_2fapi_2eproto::InitDefaults();
   return *internal_default_instance();
 }
 
@@ -1766,7 +1806,7 @@ void Mixin::SerializeWithCachedSizes(
 
 ::google::protobuf::uint8* Mixin::InternalSerializeWithCachedSizesToArray(
     bool deterministic, ::google::protobuf::uint8* target) const {
-  (void)deterministic; // Unused
+  (void)deterministic;  // Unused
   // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Mixin)
   // string name = 1;
   if (this->name().size() > 0) {
@@ -1877,8 +1917,8 @@ void Mixin::InternalSwap(Mixin* other) {
 }
 
 ::google::protobuf::Metadata Mixin::GetMetadata() const {
-  protobuf_AssignDescriptorsOnce();
-  return file_level_metadata[2];
+  protobuf_google_2fprotobuf_2fapi_2eproto::protobuf_AssignDescriptorsOnce();
+  return protobuf_google_2fprotobuf_2fapi_2eproto::file_level_metadata[2];
 }
 
 #if PROTOBUF_INLINE_NOT_IN_HEADERS
@@ -1897,6 +1937,14 @@ void Mixin::set_name(const ::std::string& value) {
   name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
   // @@protoc_insertion_point(field_set:google.protobuf.Mixin.name)
 }
+#if LANG_CXX11
+void Mixin::set_name(::std::string&& value) {
+  
+  name_.SetNoArena(
+    &::google::protobuf::internal::GetEmptyStringAlreadyInited(), std::move(value));
+  // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Mixin.name)
+}
+#endif
 void Mixin::set_name(const char* value) {
   
   name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -1941,6 +1989,14 @@ void Mixin::set_root(const ::std::string& value) {
   root_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
   // @@protoc_insertion_point(field_set:google.protobuf.Mixin.root)
 }
+#if LANG_CXX11
+void Mixin::set_root(::std::string&& value) {
+  
+  root_.SetNoArena(
+    &::google::protobuf::internal::GetEmptyStringAlreadyInited(), std::move(value));
+  // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Mixin.root)
+}
+#endif
 void Mixin::set_root(const char* value) {
   
   root_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));

+ 137 - 61
src/google/protobuf/api.pb.h

@@ -19,6 +19,7 @@
 #error regenerate this file with a newer version of protoc.
 #endif
 
+#include <google/protobuf/io/coded_stream.h>
 #include <google/protobuf/arena.h>
 #include <google/protobuf/arenastring.h>
 #include <google/protobuf/generated_message_util.h>
@@ -65,9 +66,16 @@ LIBPROTOBUF_EXPORT extern TypeDefaultTypeInternal _Type_default_instance_;
 namespace google {
 namespace protobuf {
 
+namespace protobuf_google_2fprotobuf_2fapi_2eproto {
 // Internal implementation detail -- do not call these.
-void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto();
-void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto();
+struct LIBPROTOBUF_EXPORT TableStruct {
+  static const ::google::protobuf::uint32 offsets[];
+  static void InitDefaultsImpl();
+  static void Shutdown();
+};
+void LIBPROTOBUF_EXPORT AddDescriptors();
+void LIBPROTOBUF_EXPORT InitDefaults();
+}  // namespace protobuf_google_2fprotobuf_2fapi_2eproto
 
 // ===================================================================
 
@@ -114,7 +122,8 @@ class LIBPROTOBUF_EXPORT Api : public ::google::protobuf::Message /* @@protoc_in
       bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
   ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
       const PROTOBUF_FINAL {
-    return InternalSerializeWithCachedSizesToArray(false, output);
+    return InternalSerializeWithCachedSizesToArray(
+        ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
   }
   int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
   private:
@@ -137,17 +146,6 @@ class LIBPROTOBUF_EXPORT Api : public ::google::protobuf::Message /* @@protoc_in
 
   // accessors -------------------------------------------------------
 
-  // string name = 1;
-  void clear_name();
-  static const int kNameFieldNumber = 1;
-  const ::std::string& name() const;
-  void set_name(const ::std::string& value);
-  void set_name(const char* value);
-  void set_name(const char* value, size_t size);
-  ::std::string* mutable_name();
-  ::std::string* release_name();
-  void set_allocated_name(::std::string* name);
-
   // repeated .google.protobuf.Method methods = 2;
   int methods_size() const;
   void clear_methods();
@@ -172,11 +170,40 @@ class LIBPROTOBUF_EXPORT Api : public ::google::protobuf::Message /* @@protoc_in
   const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >&
       options() const;
 
+  // repeated .google.protobuf.Mixin mixins = 6;
+  int mixins_size() const;
+  void clear_mixins();
+  static const int kMixinsFieldNumber = 6;
+  const ::google::protobuf::Mixin& mixins(int index) const;
+  ::google::protobuf::Mixin* mutable_mixins(int index);
+  ::google::protobuf::Mixin* add_mixins();
+  ::google::protobuf::RepeatedPtrField< ::google::protobuf::Mixin >*
+      mutable_mixins();
+  const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Mixin >&
+      mixins() const;
+
+  // string name = 1;
+  void clear_name();
+  static const int kNameFieldNumber = 1;
+  const ::std::string& name() const;
+  void set_name(const ::std::string& value);
+  #if LANG_CXX11
+  void set_name(::std::string&& value);
+  #endif
+  void set_name(const char* value);
+  void set_name(const char* value, size_t size);
+  ::std::string* mutable_name();
+  ::std::string* release_name();
+  void set_allocated_name(::std::string* name);
+
   // string version = 4;
   void clear_version();
   static const int kVersionFieldNumber = 4;
   const ::std::string& version() const;
   void set_version(const ::std::string& value);
+  #if LANG_CXX11
+  void set_version(::std::string&& value);
+  #endif
   void set_version(const char* value);
   void set_version(const char* value, size_t size);
   ::std::string* mutable_version();
@@ -192,18 +219,6 @@ class LIBPROTOBUF_EXPORT Api : public ::google::protobuf::Message /* @@protoc_in
   ::google::protobuf::SourceContext* release_source_context();
   void set_allocated_source_context(::google::protobuf::SourceContext* source_context);
 
-  // repeated .google.protobuf.Mixin mixins = 6;
-  int mixins_size() const;
-  void clear_mixins();
-  static const int kMixinsFieldNumber = 6;
-  const ::google::protobuf::Mixin& mixins(int index) const;
-  ::google::protobuf::Mixin* mutable_mixins(int index);
-  ::google::protobuf::Mixin* add_mixins();
-  ::google::protobuf::RepeatedPtrField< ::google::protobuf::Mixin >*
-      mutable_mixins();
-  const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Mixin >&
-      mixins() const;
-
   // .google.protobuf.Syntax syntax = 7;
   void clear_syntax();
   static const int kSyntaxFieldNumber = 7;
@@ -222,11 +237,7 @@ class LIBPROTOBUF_EXPORT Api : public ::google::protobuf::Message /* @@protoc_in
   ::google::protobuf::SourceContext* source_context_;
   int syntax_;
   mutable int _cached_size_;
-  friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto_impl();
-  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto_impl();
-  friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fapi_2eproto();
-  friend void protobuf_ShutdownFile_google_2fprotobuf_2fapi_2eproto();
-
+  friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fapi_2eproto::TableStruct;
 };
 // -------------------------------------------------------------------
 
@@ -273,7 +284,8 @@ class LIBPROTOBUF_EXPORT Method : public ::google::protobuf::Message /* @@protoc
       bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
   ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
       const PROTOBUF_FINAL {
-    return InternalSerializeWithCachedSizesToArray(false, output);
+    return InternalSerializeWithCachedSizesToArray(
+        ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
   }
   int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
   private:
@@ -296,11 +308,26 @@ class LIBPROTOBUF_EXPORT Method : public ::google::protobuf::Message /* @@protoc
 
   // accessors -------------------------------------------------------
 
+  // repeated .google.protobuf.Option options = 6;
+  int options_size() const;
+  void clear_options();
+  static const int kOptionsFieldNumber = 6;
+  const ::google::protobuf::Option& options(int index) const;
+  ::google::protobuf::Option* mutable_options(int index);
+  ::google::protobuf::Option* add_options();
+  ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >*
+      mutable_options();
+  const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >&
+      options() const;
+
   // string name = 1;
   void clear_name();
   static const int kNameFieldNumber = 1;
   const ::std::string& name() const;
   void set_name(const ::std::string& value);
+  #if LANG_CXX11
+  void set_name(::std::string&& value);
+  #endif
   void set_name(const char* value);
   void set_name(const char* value, size_t size);
   ::std::string* mutable_name();
@@ -312,47 +339,41 @@ class LIBPROTOBUF_EXPORT Method : public ::google::protobuf::Message /* @@protoc
   static const int kRequestTypeUrlFieldNumber = 2;
   const ::std::string& request_type_url() const;
   void set_request_type_url(const ::std::string& value);
+  #if LANG_CXX11
+  void set_request_type_url(::std::string&& value);
+  #endif
   void set_request_type_url(const char* value);
   void set_request_type_url(const char* value, size_t size);
   ::std::string* mutable_request_type_url();
   ::std::string* release_request_type_url();
   void set_allocated_request_type_url(::std::string* request_type_url);
 
-  // bool request_streaming = 3;
-  void clear_request_streaming();
-  static const int kRequestStreamingFieldNumber = 3;
-  bool request_streaming() const;
-  void set_request_streaming(bool value);
-
   // string response_type_url = 4;
   void clear_response_type_url();
   static const int kResponseTypeUrlFieldNumber = 4;
   const ::std::string& response_type_url() const;
   void set_response_type_url(const ::std::string& value);
+  #if LANG_CXX11
+  void set_response_type_url(::std::string&& value);
+  #endif
   void set_response_type_url(const char* value);
   void set_response_type_url(const char* value, size_t size);
   ::std::string* mutable_response_type_url();
   ::std::string* release_response_type_url();
   void set_allocated_response_type_url(::std::string* response_type_url);
 
+  // bool request_streaming = 3;
+  void clear_request_streaming();
+  static const int kRequestStreamingFieldNumber = 3;
+  bool request_streaming() const;
+  void set_request_streaming(bool value);
+
   // bool response_streaming = 5;
   void clear_response_streaming();
   static const int kResponseStreamingFieldNumber = 5;
   bool response_streaming() const;
   void set_response_streaming(bool value);
 
-  // repeated .google.protobuf.Option options = 6;
-  int options_size() const;
-  void clear_options();
-  static const int kOptionsFieldNumber = 6;
-  const ::google::protobuf::Option& options(int index) const;
-  ::google::protobuf::Option* mutable_options(int index);
-  ::google::protobuf::Option* add_options();
-  ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >*
-      mutable_options();
-  const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >&
-      options() const;
-
   // .google.protobuf.Syntax syntax = 7;
   void clear_syntax();
   static const int kSyntaxFieldNumber = 7;
@@ -371,11 +392,7 @@ class LIBPROTOBUF_EXPORT Method : public ::google::protobuf::Message /* @@protoc
   bool response_streaming_;
   int syntax_;
   mutable int _cached_size_;
-  friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto_impl();
-  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto_impl();
-  friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fapi_2eproto();
-  friend void protobuf_ShutdownFile_google_2fprotobuf_2fapi_2eproto();
-
+  friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fapi_2eproto::TableStruct;
 };
 // -------------------------------------------------------------------
 
@@ -422,7 +439,8 @@ class LIBPROTOBUF_EXPORT Mixin : public ::google::protobuf::Message /* @@protoc_
       bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
   ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
       const PROTOBUF_FINAL {
-    return InternalSerializeWithCachedSizesToArray(false, output);
+    return InternalSerializeWithCachedSizesToArray(
+        ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
   }
   int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
   private:
@@ -450,6 +468,9 @@ class LIBPROTOBUF_EXPORT Mixin : public ::google::protobuf::Message /* @@protoc_
   static const int kNameFieldNumber = 1;
   const ::std::string& name() const;
   void set_name(const ::std::string& value);
+  #if LANG_CXX11
+  void set_name(::std::string&& value);
+  #endif
   void set_name(const char* value);
   void set_name(const char* value, size_t size);
   ::std::string* mutable_name();
@@ -461,6 +482,9 @@ class LIBPROTOBUF_EXPORT Mixin : public ::google::protobuf::Message /* @@protoc_
   static const int kRootFieldNumber = 2;
   const ::std::string& root() const;
   void set_root(const ::std::string& value);
+  #if LANG_CXX11
+  void set_root(::std::string&& value);
+  #endif
   void set_root(const char* value);
   void set_root(const char* value, size_t size);
   ::std::string* mutable_root();
@@ -474,11 +498,7 @@ class LIBPROTOBUF_EXPORT Mixin : public ::google::protobuf::Message /* @@protoc_
   ::google::protobuf::internal::ArenaStringPtr name_;
   ::google::protobuf::internal::ArenaStringPtr root_;
   mutable int _cached_size_;
-  friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto_impl();
-  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto_impl();
-  friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fapi_2eproto();
-  friend void protobuf_ShutdownFile_google_2fprotobuf_2fapi_2eproto();
-
+  friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fapi_2eproto::TableStruct;
 };
 // ===================================================================
 
@@ -501,6 +521,14 @@ inline void Api::set_name(const ::std::string& value) {
   name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
   // @@protoc_insertion_point(field_set:google.protobuf.Api.name)
 }
+#if LANG_CXX11
+inline void Api::set_name(::std::string&& value) {
+  
+  name_.SetNoArena(
+    &::google::protobuf::internal::GetEmptyStringAlreadyInited(), std::move(value));
+  // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Api.name)
+}
+#endif
 inline void Api::set_name(const char* value) {
   
   name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -605,6 +633,14 @@ inline void Api::set_version(const ::std::string& value) {
   version_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
   // @@protoc_insertion_point(field_set:google.protobuf.Api.version)
 }
+#if LANG_CXX11
+inline void Api::set_version(::std::string&& value) {
+  
+  version_.SetNoArena(
+    &::google::protobuf::internal::GetEmptyStringAlreadyInited(), std::move(value));
+  // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Api.version)
+}
+#endif
 inline void Api::set_version(const char* value) {
   
   version_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -736,6 +772,14 @@ inline void Method::set_name(const ::std::string& value) {
   name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
   // @@protoc_insertion_point(field_set:google.protobuf.Method.name)
 }
+#if LANG_CXX11
+inline void Method::set_name(::std::string&& value) {
+  
+  name_.SetNoArena(
+    &::google::protobuf::internal::GetEmptyStringAlreadyInited(), std::move(value));
+  // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Method.name)
+}
+#endif
 inline void Method::set_name(const char* value) {
   
   name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -780,6 +824,14 @@ inline void Method::set_request_type_url(const ::std::string& value) {
   request_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
   // @@protoc_insertion_point(field_set:google.protobuf.Method.request_type_url)
 }
+#if LANG_CXX11
+inline void Method::set_request_type_url(::std::string&& value) {
+  
+  request_type_url_.SetNoArena(
+    &::google::protobuf::internal::GetEmptyStringAlreadyInited(), std::move(value));
+  // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Method.request_type_url)
+}
+#endif
 inline void Method::set_request_type_url(const char* value) {
   
   request_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -838,6 +890,14 @@ inline void Method::set_response_type_url(const ::std::string& value) {
   response_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
   // @@protoc_insertion_point(field_set:google.protobuf.Method.response_type_url)
 }
+#if LANG_CXX11
+inline void Method::set_response_type_url(::std::string&& value) {
+  
+  response_type_url_.SetNoArena(
+    &::google::protobuf::internal::GetEmptyStringAlreadyInited(), std::move(value));
+  // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Method.response_type_url)
+}
+#endif
 inline void Method::set_response_type_url(const char* value) {
   
   response_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -944,6 +1004,14 @@ inline void Mixin::set_name(const ::std::string& value) {
   name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
   // @@protoc_insertion_point(field_set:google.protobuf.Mixin.name)
 }
+#if LANG_CXX11
+inline void Mixin::set_name(::std::string&& value) {
+  
+  name_.SetNoArena(
+    &::google::protobuf::internal::GetEmptyStringAlreadyInited(), std::move(value));
+  // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Mixin.name)
+}
+#endif
 inline void Mixin::set_name(const char* value) {
   
   name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -988,6 +1056,14 @@ inline void Mixin::set_root(const ::std::string& value) {
   root_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
   // @@protoc_insertion_point(field_set:google.protobuf.Mixin.root)
 }
+#if LANG_CXX11
+inline void Mixin::set_root(::std::string&& value) {
+  
+  root_.SetNoArena(
+    &::google::protobuf::internal::GetEmptyStringAlreadyInited(), std::move(value));
+  // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Mixin.root)
+}
+#endif
 inline void Mixin::set_root(const char* value) {
   
   root_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));

+ 6 - 17
src/google/protobuf/arena.cc

@@ -62,6 +62,7 @@ void Arena::Init() {
   lifecycle_id_ = lifecycle_id_generator_.GetNext();
   blocks_ = 0;
   hint_ = 0;
+  space_allocated_ = 0;
   owns_first_block_ = true;
   cleanup_list_ = 0;
 
@@ -157,6 +158,7 @@ void Arena::AddBlockInternal(Block* b) {
     // Direct future allocations to this block.
     google::protobuf::internal::Release_Store(&hint_, reinterpret_cast<google::protobuf::internal::AtomicWord>(b));
   }
+  space_allocated_ += b->size;
 }
 
 void Arena::AddListNode(void* elem, void (*cleanup)(void*)) {
@@ -225,13 +227,8 @@ void* Arena::SlowAlloc(size_t n) {
 }
 
 uint64 Arena::SpaceAllocated() const {
-  uint64 space_allocated = 0;
-  Block* b = reinterpret_cast<Block*>(google::protobuf::internal::NoBarrier_Load(&blocks_));
-  while (b != NULL) {
-    space_allocated += (b->size);
-    b = b->next;
-  }
-  return space_allocated;
+  MutexLock l(&blocks_lock_);
+  return space_allocated_;
 }
 
 uint64 Arena::SpaceUsed() const {
@@ -245,16 +242,7 @@ uint64 Arena::SpaceUsed() const {
 }
 
 std::pair<uint64, uint64> Arena::SpaceAllocatedAndUsed() const {
-  uint64 allocated = 0;
-  uint64 used = 0;
-
-  Block* b = reinterpret_cast<Block*>(google::protobuf::internal::NoBarrier_Load(&blocks_));
-  while (b != NULL) {
-    allocated += b->size;
-    used += (b->pos - kHeaderSize);
-    b = b->next;
-  }
-  return std::make_pair(allocated, used);
+  return std::make_pair(SpaceAllocated(), SpaceUsed());
 }
 
 uint64 Arena::FreeBlocks() {
@@ -288,6 +276,7 @@ uint64 Arena::FreeBlocks() {
   }
   blocks_ = 0;
   hint_ = 0;
+  space_allocated_ = 0;
   if (!owns_first_block_) {
     // Make the first block that was passed in through ArenaOptions
     // available for reuse.

+ 14 - 10
src/google/protobuf/arena.h

@@ -449,14 +449,17 @@ class LIBPROTOBUF_EXPORT Arena {
     }
   }
 
-  // Returns the total space used by the arena, which is the sums of the sizes
-  // of the underlying blocks. The total space used may not include the new
-  // blocks that are allocated by this arena from other threads concurrently
-  // with the call to this method.
-  GOOGLE_ATTRIBUTE_NOINLINE uint64 SpaceAllocated() const;
-  // As above, but does not include any free space in underlying blocks.
+  // Returns the total space allocated by the arena, which is the sum of the
+  // sizes of the underlying blocks. This method is relatively fast; a counter
+  // is kept as blocks are allocated.
+  uint64 SpaceAllocated() const;
+  // Returns the total space used by the arena. Similar to SpaceAllocated but
+  // does not include free space and block overhead. The total space returned
+  // may not include space used by other threads executing concurrently with
+  // the call to this method.
   GOOGLE_ATTRIBUTE_NOINLINE uint64 SpaceUsed() const;
-
+  // DEPRECATED. Please use SpaceAllocated() and SpaceUsed().
+  //
   // Combines SpaceAllocated and SpaceUsed. Returns a pair of
   // <space_allocated, space_used>.
   GOOGLE_ATTRIBUTE_NOINLINE std::pair<uint64, uint64> SpaceAllocatedAndUsed() const;
@@ -884,8 +887,9 @@ class LIBPROTOBUF_EXPORT Arena {
 
   int64 lifecycle_id_;  // Unique for each arena. Changes on Reset().
 
-  google::protobuf::internal::AtomicWord blocks_;  // Head of linked list of all allocated blocks
-  google::protobuf::internal::AtomicWord hint_;    // Fast thread-local block access
+  google::protobuf::internal::AtomicWord blocks_;       // Head of linked list of all allocated blocks
+  google::protobuf::internal::AtomicWord hint_;         // Fast thread-local block access
+  uint64 space_allocated_;  // Sum of sizes of all allocated blocks.
 
   // Node contains the ptr of the object to be cleaned up and the associated
   // cleanup function ptr.
@@ -899,7 +903,7 @@ class LIBPROTOBUF_EXPORT Arena {
                              // ptrs and cleanup methods.
 
   bool owns_first_block_;    // Indicates that arena owns the first block
-  Mutex blocks_lock_;
+  mutable Mutex blocks_lock_;
 
   void AddBlock(Block* b);
   // Access must be synchronized, either by blocks_lock_ or by being called from

+ 14 - 11
src/google/protobuf/arenastring.h

@@ -210,6 +210,16 @@ struct LIBPROTOBUF_EXPORT ArenaStringPtr {
     }
   }
 
+#if LANG_CXX11
+  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);
+    }
+  }
+#endif
+
   void AssignWithDefault(const ::std::string* default_value, ArenaStringPtr value);
 
   inline const ::std::string& GetNoArena() const { return *ptr_; }
@@ -283,22 +293,15 @@ struct LIBPROTOBUF_EXPORT ArenaStringPtr {
 
   GOOGLE_ATTRIBUTE_NOINLINE void CreateInstance(::google::protobuf::Arena* arena,
                                          const ::std::string* initial_value) {
-    // Assumes ptr_ is not NULL.
-    if (initial_value != NULL) {
-      ptr_ = new ::std::string(*initial_value);
-    } else {
-      ptr_ = new ::std::string();
-    }
+    GOOGLE_DCHECK(initial_value != NULL);
+    ptr_ = new ::std::string(*initial_value);
     if (arena != NULL) {
       arena->Own(ptr_);
     }
   }
   GOOGLE_ATTRIBUTE_NOINLINE void CreateInstanceNoArena(const ::std::string* initial_value) {
-    if (initial_value != NULL) {
-      ptr_ = new ::std::string(*initial_value);
-    } else {
-      ptr_ = new ::std::string();
-    }
+    GOOGLE_DCHECK(initial_value != NULL);
+    ptr_ = new ::std::string(*initial_value);
   }
 };
 

+ 35 - 16
src/google/protobuf/compiler/command_line_interface.cc

@@ -116,6 +116,9 @@ static const char* kPathSeparator = ";";
 static const char* kPathSeparator = ":";
 #endif
 
+static const char* kDefaultDirectDependenciesViolationMsg =
+    "File is imported but not declared in --direct_dependencies: %s";
+
 // Returns true if the text looks like a Windows-style absolute path, starting
 // with a drive letter.  Example:  "C:\foo".  TODO(kenton):  Share this with
 // copy in importer.cc?
@@ -276,12 +279,13 @@ class CommandLineInterface::ErrorPrinter : public MultiFileErrorCollector,
                                            public io::ErrorCollector {
  public:
   ErrorPrinter(ErrorFormat format, DiskSourceTree *tree = NULL)
-    : format_(format), tree_(tree) {}
+    : format_(format), tree_(tree), found_errors_(false) {}
   ~ErrorPrinter() {}
 
   // implements MultiFileErrorCollector ------------------------------
   void AddError(const string& filename, int line, int column,
                 const string& message) {
+    found_errors_ = true;
     AddErrorOrWarning(filename, line, column, message, "error", std::cerr);
   }
 
@@ -299,10 +303,12 @@ class CommandLineInterface::ErrorPrinter : public MultiFileErrorCollector,
     AddErrorOrWarning("input", line, column, message, "warning", std::clog);
   }
 
+  bool FoundErrors() const { return found_errors_; }
+
  private:
-  void AddErrorOrWarning(
-      const string& filename, int line, int column,
-      const string& message, const string& type, ostream& out) {
+  void AddErrorOrWarning(const string& filename, int line, int column,
+                         const string& message, const string& type,
+                         std::ostream& out) {
     // Print full path when running under MSVS
     string dfile;
     if (format_ == CommandLineInterface::ERROR_FORMAT_MSVS &&
@@ -337,6 +343,7 @@ class CommandLineInterface::ErrorPrinter : public MultiFileErrorCollector,
 
   const ErrorFormat format_;
   DiskSourceTree *tree_;
+  bool found_errors_;
 };
 
 // -------------------------------------------------------------------
@@ -708,14 +715,17 @@ CommandLineInterface::MemoryOutputStream::~MemoryOutputStream() {
 // ===================================================================
 
 CommandLineInterface::CommandLineInterface()
-  : mode_(MODE_COMPILE),
-    print_mode_(PRINT_NONE),
-    error_format_(ERROR_FORMAT_GCC),
-    direct_dependencies_explicitly_set_(false),
-    imports_in_descriptor_set_(false),
-    source_info_in_descriptor_set_(false),
-    disallow_services_(false),
-    inputs_are_proto_path_relative_(false) {}
+    : mode_(MODE_COMPILE),
+      print_mode_(PRINT_NONE),
+      error_format_(ERROR_FORMAT_GCC),
+      direct_dependencies_explicitly_set_(false),
+      direct_dependencies_violation_msg_(
+          kDefaultDirectDependenciesViolationMsg),
+      imports_in_descriptor_set_(false),
+      source_info_in_descriptor_set_(false),
+      disallow_services_(false),
+      inputs_are_proto_path_relative_(false) {
+}
 CommandLineInterface::~CommandLineInterface() {}
 
 void CommandLineInterface::RegisterGenerator(const string& flag_name,
@@ -800,10 +810,11 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) {
         if (direct_dependencies_.find(parsed_file->dependency(i)->name()) ==
             direct_dependencies_.end()) {
           indirect_imports = true;
-          cerr << parsed_file->name()
-               << ": File is imported but not declared in "
-               << "--direct_dependencies: "
-               << parsed_file->dependency(i)->name() << std::endl;
+          cerr << parsed_file->name() << ": "
+               << StringReplace(direct_dependencies_violation_msg_, "%s",
+                                parsed_file->dependency(i)->name(),
+                                true /* replace_all */)
+               << std::endl;
         }
       }
       if (indirect_imports) {
@@ -895,6 +906,10 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) {
     }
   }
 
+  if (error_collector.FoundErrors()) {
+    return 1;
+  }
+
   if (mode_ == MODE_PRINT) {
     switch (print_mode_) {
       case PRINT_FREE_FIELDS:
@@ -924,6 +939,7 @@ void CommandLineInterface::Clear() {
   proto_path_.clear();
   input_files_.clear();
   direct_dependencies_.clear();
+  direct_dependencies_violation_msg_ = kDefaultDirectDependenciesViolationMsg;
   output_directives_.clear();
   codec_type_.clear();
   descriptor_set_name_.clear();
@@ -1209,6 +1225,9 @@ CommandLineInterface::InterpretArgument(const string& name,
     GOOGLE_DCHECK(direct_dependencies_.empty());
     direct_dependencies_.insert(direct.begin(), direct.end());
 
+  } else if (name == "--direct_dependencies_violation_msg") {
+    direct_dependencies_violation_msg_ = value;
+
   } else if (name == "-o" || name == "--descriptor_set_out") {
     if (!descriptor_set_name_.empty()) {
       std::cerr << name << " may only be passed once." << std::endl;

+ 4 - 0
src/google/protobuf/compiler/command_line_interface.h

@@ -365,6 +365,10 @@ class LIBPROTOC_EXPORT CommandLineInterface {
   std::set<string> direct_dependencies_;
   bool direct_dependencies_explicitly_set_;
 
+  // If there's a violation of depend-on-what-you-import, this string will be
+  // presented to the user. "%s" will be replaced with the violating import.
+  string direct_dependencies_violation_msg_;
+
   // output_directives_ lists all the files we are supposed to output and what
   // generator to use for each.
   struct OutputDirective {

+ 38 - 1
src/google/protobuf/compiler/command_line_interface_unittest.cc

@@ -101,6 +101,7 @@ class CommandLineInterfaceTest : public testing::Test {
   // command is automatically split on spaces, and the string "$tmpdir"
   // is replaced with TestTempDir().
   void Run(const string& command);
+  void RunWithArgs(vector<string> args);
 
   // -----------------------------------------------------------------
   // Methods to set up the test (called before Run()).
@@ -292,8 +293,10 @@ void CommandLineInterfaceTest::TearDown() {
 }
 
 void CommandLineInterfaceTest::Run(const string& command) {
-  std::vector<string> args = Split(command, " ", true);
+  RunWithArgs(Split(command, " ", true));
+}
 
+void CommandLineInterfaceTest::RunWithArgs(vector<string> args) {
   if (!disallow_plugins_) {
     cli_.AllowPlugins("prefix-");
 #ifndef GOOGLE_THIRD_PARTY_PROTOBUF
@@ -996,6 +999,27 @@ TEST_F(CommandLineInterfaceTest, DirectDependencies_ProvidedMultipleTimes) {
       "':'.\n");
 }
 
+TEST_F(CommandLineInterfaceTest, DirectDependencies_CustomErrorMessage) {
+  CreateTempFile("foo.proto",
+                 "syntax = \"proto2\";\n"
+                 "import \"bar.proto\";\n"
+                 "message Foo { optional Bar bar = 1; }");
+  CreateTempFile("bar.proto",
+                 "syntax = \"proto2\";\n"
+                 "message Bar { optional string text = 1; }");
+
+  vector<string> commands;
+  commands.push_back("protocol_compiler");
+  commands.push_back("--test_out=$tmpdir");
+  commands.push_back("--proto_path=$tmpdir");
+  commands.push_back("--direct_dependencies=");
+  commands.push_back("--direct_dependencies_violation_msg=Bla \"%s\" Bla");
+  commands.push_back("foo.proto");
+  RunWithArgs(commands);
+
+  ExpectErrorText("foo.proto: Bla \"bar.proto\" Bla\n");
+}
+
 TEST_F(CommandLineInterfaceTest, CwdRelativeInputs) {
   // Test that we can accept working-directory-relative input files.
 
@@ -1283,6 +1307,19 @@ TEST_F(CommandLineInterfaceTest, ParseErrorsMultipleFiles) {
     "foo.proto: Import \"baz.proto\" was not found or had errors.\n");
 }
 
+TEST_F(CommandLineInterfaceTest, RecursiveImportFails) {
+  // Create a proto file that imports itself.
+  CreateTempFile("foo.proto",
+    "syntax = \"proto2\";\n"
+    "import \"foo.proto\";\n");
+
+  Run("protocol_compiler --test_out=$tmpdir "
+      "--proto_path=$tmpdir foo.proto");
+
+  ExpectErrorSubstring(
+    "foo.proto: File recursively imports itself: foo.proto -> foo.proto\n");
+}
+
 TEST_F(CommandLineInterfaceTest, InputNotFoundError) {
   // Test what happens if the input file is not found.
 

+ 4 - 2
src/google/protobuf/compiler/cpp/cpp_enum.cc

@@ -251,13 +251,15 @@ void EnumGenerator::GenerateMethods(io::Printer* printer) {
   vars["classname"] = classname_;
   vars["index_in_metadata"] = SimpleItoa(index_in_metadata_);
   vars["constexpr"] = options_.proto_h ? "constexpr " : "";
+  vars["file_namespace"] = FileLevelNamespace(descriptor_->file()->name());
 
   if (HasDescriptorMethods(descriptor_->file(), options_)) {
     printer->Print(
         vars,
         "const ::google::protobuf::EnumDescriptor* $classname$_descriptor() {\n"
-        "  protobuf_AssignDescriptorsOnce();\n"
-        "  return file_level_enum_descriptors[$index_in_metadata$];\n"
+        "  $file_namespace$::protobuf_AssignDescriptorsOnce();\n"
+        "  return "
+        "$file_namespace$::file_level_enum_descriptors[$index_in_metadata$];\n"
         "}\n");
   }
 

+ 1 - 1
src/google/protobuf/compiler/cpp/cpp_enum_field.cc

@@ -230,7 +230,7 @@ void EnumOneofFieldGenerator::
 GenerateConstructorCode(io::Printer* printer) const {
   printer->Print(
       variables_,
-      "  $classname$_default_oneof_instance_.$name$_ = $default$;\n");
+      "_$classname$_default_instance_.$name$_ = $default$;\n");
 }
 
 // ===================================================================

+ 82 - 100
src/google/protobuf/compiler/cpp/cpp_file.cc

@@ -284,11 +284,22 @@ void FileGenerator::GenerateSource(io::Printer* printer) {
     if (IsMapEntryMessage(message_generators_[i]->descriptor_)) continue;
     printer->Print(
         "class $classname$DefaultTypeInternal : "
-        "public ::google::protobuf::internal::ExplicitlyConstructed<$classname$> {};\n"
-        "$classname$DefaultTypeInternal _$classname$_default_instance_;\n",
+        "public ::google::protobuf::internal::ExplicitlyConstructed<$classname$> {\n",
+        "classname", message_generators_[i]->classname_);
+    printer->Indent();
+    message_generators_[i]->GenerateExtraDefaultFields(printer);
+    printer->Outdent();
+    printer->Print(
+        "} _$classname$_default_instance_;\n",
         "classname", message_generators_[i]->classname_);
   }
 
+  printer->Print(
+      "\n"
+      "namespace $file_namespace$ {\n"
+      "\n",
+      "file_namespace", FileLevelNamespace(file_->name()));
+
   if (HasDescriptorMethods(file_, options_)) {
     printer->Print(
       "\n"
@@ -314,7 +325,6 @@ void FileGenerator::GenerateSource(io::Printer* printer) {
 
     for (int i = 0; i < message_generators_.size(); i++) {
       message_generators_[i]->index_in_metadata_ = i;
-      message_generators_[i]->GenerateDescriptorDeclarations(printer);
     }
     for (int i = 0; i < enum_generators_.size(); i++) {
       enum_generators_[i]->index_in_metadata_ = i;
@@ -335,6 +345,12 @@ void FileGenerator::GenerateSource(io::Printer* printer) {
   // library, all this does is initialize default instances.)
   GenerateBuildDescriptors(printer);
 
+  printer->Print(
+      "\n"
+      "}  // namespace $file_namespace$\n"
+      "\n",
+      "file_namespace", FileLevelNamespace(file_->name()));
+
   // Generate enums.
   for (int i = 0; i < enum_generators_.size(); i++) {
     enum_generators_[i]->GenerateMethods(printer);
@@ -470,28 +486,16 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) {
 
   if (HasDescriptorMethods(file_, options_)) {
     if (!message_generators_.empty()) {
-      printer->Print(
-          "\n"
-          "const ::google::protobuf::uint32* $offsetfunname$() GOOGLE_ATTRIBUTE_COLD;\n"
-          "const ::google::protobuf::uint32* $offsetfunname$() {\n",
-          "offsetfunname", GlobalOffsetTableName(file_->name()));
-      printer->Indent();
-
-      printer->Print("static const ::google::protobuf::uint32 offsets[] = {\n");
+      printer->Print("const ::google::protobuf::uint32 TableStruct::offsets[] = {\n");
       printer->Indent();
       std::vector<std::pair<size_t, size_t> > pairs;
       for (int i = 0; i < message_generators_.size(); i++) {
         pairs.push_back(message_generators_[i]->GenerateOffsets(printer));
       }
       printer->Outdent();
-      printer->Outdent();
-      printer->Print(
-          "  };\n"
-          "  return offsets;\n"
-          "}\n"
-          "\n");
-
       printer->Print(
+          "};\n"
+          "\n"
           "static const ::google::protobuf::internal::MigrationSchema schemas[] = {\n");
       printer->Indent();
       {
@@ -505,25 +509,17 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) {
       printer->Outdent();
       printer->Print(
           "};\n"
-          "\n"
-          "static const ::google::protobuf::internal::DefaultInstanceData "
-          "file_default_instances[] = {\n");
+          "\nstatic "
+          "::google::protobuf::Message const * const file_default_instances[] = {\n");
       printer->Indent();
       for (int i = 0; i < message_generators_.size(); i++) {
         const Descriptor* descriptor = message_generators_[i]->descriptor_;
         if (IsMapEntryMessage(descriptor)) continue;
 
-        string oneof_default = "NULL";
-        if (message_generators_[i]->descriptor_->oneof_decl_count()) {
-          oneof_default =
-              "&" + ClassName(descriptor, false) + "_default_oneof_instance_";
-        }
         printer->Print(
-            "{reinterpret_cast<const "
-            "::google::protobuf::Message*>(&_$classname$_default_instance_), "
-            "$oneof_default$},\n",
-            "classname", ClassName(descriptor, false), "oneof_default",
-            oneof_default);
+            "reinterpret_cast<const "
+            "::google::protobuf::Message*>(&_$classname$_default_instance_),\n",
+            "classname", ClassName(descriptor, false));
       }
       printer->Outdent();
       printer->Print(
@@ -532,12 +528,11 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) {
     } else {
       // we still need these symbols to exist
       printer->Print(
-          "inline ::google::protobuf::uint32* $offsetfunname$() { return NULL; }\n"
+          // MSVC doesn't like empty arrays, so we add a dummy.
+          "const ::google::protobuf::uint32 TableStruct::offsets[] = { ~0u };\n"
           "static const ::google::protobuf::internal::MigrationSchema* schemas = NULL;\n"
-          "static const ::google::protobuf::internal::DefaultInstanceData* "
-          "file_default_instances = NULL;\n",
-          "offsetfunname",
-          GlobalOffsetTableName(file_->name()));
+          "static const ::google::protobuf::Message* const* "
+          "file_default_instances = NULL;\n");
     }
 
     // ---------------------------------------------------------------
@@ -554,11 +549,11 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) {
         // is requested *during* static init then AddDescriptors() may not have
         // been called yet, so we call it manually.  Note that it's fine if
         // AddDescriptors() is called multiple times.
-        "  $adddescriptorsname$();\n"
+        "  AddDescriptors();\n"
         "  ::google::protobuf::MessageFactory* factory = $factory$;\n"
         "  AssignDescriptors(\n"
         "      \"$filename$\", schemas, file_default_instances, "
-        "$offsetfunname$(), factory,\n"
+        "TableStruct::offsets, factory,\n"
         "      $metadata$, $enum_descriptors$, $service_descriptors$);\n"
         "}\n"
         "\n"
@@ -567,9 +562,7 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) {
         "  ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors);\n"
         "}\n"
         "\n",
-        "adddescriptorsname", GlobalAddDescriptorsName(file_->name()),
-        "offsetfunname", GlobalOffsetTableName(file_->name()), "filename",
-        file_->name(), "metadata",
+        "filename", file_->name(), "metadata",
         !message_generators_.empty() ? "file_level_metadata" : "NULL",
         "enum_descriptors",
         !enum_generators_.empty() ? "file_level_enum_descriptors" : "NULL",
@@ -613,8 +606,7 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) {
   // ShutdownFile():  Deletes descriptors, default instances, etc. on shutdown.
   printer->Print(
     "\n"
-    "void $shutdownfilename$() {\n",
-    "shutdownfilename", GlobalShutdownFileName(file_->name()));
+    "void TableStruct::Shutdown() {\n");
   printer->Indent();
 
   for (int i = 0; i < message_generators_.size(); i++) {
@@ -627,13 +619,12 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) {
 
   // -----------------------------------------------------------------
 
-  // Now generate the InitDefaults() function.
+  // Now generate the InitDefaultsImpl() function.
   printer->Print(
-      "void $initdefaultsname$_impl() {\n"
+      "void TableStruct::InitDefaultsImpl() {\n"
       "  GOOGLE_PROTOBUF_VERIFY_VERSION;\n\n"
-      "",
-      // Vars.
-      "initdefaultsname", GlobalInitDefaultsName(file_->name()));
+      // Force initialization of primitive values we depend on.
+      "  ::google::protobuf::internal::InitProtobufDefaults();\n");
 
   printer->Indent();
 
@@ -642,17 +633,13 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) {
   for (int i = 0; i < file_->dependency_count(); i++) {
     const FileDescriptor* dependency = file_->dependency(i);
     // Print the namespace prefix for the dependency.
-    string add_desc_name = QualifiedFileLevelSymbol(
-        dependency->package(), GlobalInitDefaultsName(dependency->name()));
+    string file_namespace = QualifiedFileLevelSymbol(
+        dependency->package(), FileLevelNamespace(dependency->name()));
     // Call its AddDescriptors function.
-    printer->Print(
-      "$name$();\n",
-      "name", add_desc_name);
+    printer->Print("$file_namespace$::InitDefaults();\n", "file_namespace",
+                   file_namespace);
   }
 
-  // Force initialization of primitive values we depend on.
-  printer->Print("::google::protobuf::internal::InitProtobufDefaults();\n");
-
   // Allocate and initialize default instances.  This can't be done lazily
   // since default instances are returned by simple accessors and are used with
   // extensions.  Speaking of which, we also register extensions at this time.
@@ -669,21 +656,17 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) {
   printer->Print(
       "}\n"
       "\n"
-      "void $initdefaultsname$() {\n"
+      "void InitDefaults() {\n"
       "  static GOOGLE_PROTOBUF_DECLARE_ONCE(once);\n"
-      "  ::google::protobuf::GoogleOnceInit(&once, &$initdefaultsname$_impl);\n"
-      "}\n",
-      "initdefaultsname", GlobalInitDefaultsName(file_->name()));
+      "  ::google::protobuf::GoogleOnceInit(&once, &TableStruct::InitDefaultsImpl);\n"
+      "}\n");
 
   // -----------------------------------------------------------------
 
   // Now generate the AddDescriptors() function.
   printer->Print(
-      "void $adddescriptorsname$_impl() {\n"
-      "  $initdefaultsname$();\n",
-      // Vars.
-      "adddescriptorsname", GlobalAddDescriptorsName(file_->name()),
-      "initdefaultsname", GlobalInitDefaultsName(file_->name()));
+      "void AddDescriptorsImpl() {\n"
+      "  InitDefaults();\n");
 
   printer->Indent();
   if (HasDescriptorMethods(file_, options_)) {
@@ -699,12 +682,7 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) {
     printer->Print("static const char descriptor[] = {\n");
     printer->Indent();
 
-#ifdef _MSC_VER
-    bool breakdown_large_file = true;
-#else
-    bool breakdown_large_file = false;
-#endif
-    if (breakdown_large_file && file_data.size() > 66538) {
+    if (file_data.size() > 66535) {
       // Workaround for MSVC: "Error C1091: compiler limit: string exceeds 65535
       // bytes in length". Declare a static array of characters rather than use
       // a string literal. Only write 25 bytes per line.
@@ -745,42 +723,36 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) {
   for (int i = 0; i < file_->dependency_count(); i++) {
     const FileDescriptor* dependency = file_->dependency(i);
     // Print the namespace prefix for the dependency.
-    string add_desc_name = QualifiedFileLevelSymbol(
-        dependency->package(), GlobalAddDescriptorsName(dependency->name()));
+    string file_namespace = QualifiedFileLevelSymbol(
+        dependency->package(), FileLevelNamespace(dependency->name()));
     // Call its AddDescriptors function.
-    printer->Print("$adddescriptorsname$();\n", "adddescriptorsname",
-                   add_desc_name);
+    printer->Print("$file_namespace$::AddDescriptors();\n", "file_namespace",
+                   file_namespace);
   }
 
   printer->Print(
-      "::google::protobuf::internal::OnShutdown(&$shutdownfilename$);\n",
-      "shutdownfilename", GlobalShutdownFileName(file_->name()));
+      "::google::protobuf::internal::OnShutdown(&TableStruct::Shutdown);\n");
 
   printer->Outdent();
   printer->Print(
       "}\n"
       "\n"
-      "GOOGLE_PROTOBUF_DECLARE_ONCE($adddescriptorsname$_once_);\n"
-      "void $adddescriptorsname$() {\n"
-      "  ::google::protobuf::GoogleOnceInit(&$adddescriptorsname$_once_,\n"
-      "                 &$adddescriptorsname$_impl);\n"
-      "}\n",
-      "adddescriptorsname", GlobalAddDescriptorsName(file_->name()));
+      "void AddDescriptors() {\n"
+      "  static GOOGLE_PROTOBUF_DECLARE_ONCE(once);\n"
+      "  ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl);\n"
+      "}\n");
 
   if (!StaticInitializersForced(file_, options_)) {
-    printer->Print("#ifndef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER\n");
+    printer->Print("#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER\n");
   }
   printer->Print(
       // With static initializers.
       "// Force AddDescriptors() to be called at static initialization time.\n"
-      "struct StaticDescriptorInitializer_$filename$ {\n"
-      "  StaticDescriptorInitializer_$filename$() {\n"
-      "    $adddescriptorsname$();\n"
+      "struct StaticDescriptorInitializer {\n"
+      "  StaticDescriptorInitializer() {\n"
+      "    AddDescriptors();\n"
       "  }\n"
-      "} static_descriptor_initializer_$filename$_;\n",
-      // Vars.
-      "adddescriptorsname", GlobalAddDescriptorsName(file_->name()), "filename",
-      FilenameIdentifier(file_->name()));
+      "} static_descriptor_initializer;\n");
   if (!StaticInitializersForced(file_, options_)) {
     printer->Print("#endif  // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER\n");
   }
@@ -881,10 +853,11 @@ void FileGenerator::GenerateLibraryIncludes(io::Printer* printer) {
 
   // OK, it's now safe to #include other files.
   printer->Print(
-    "#include <google/protobuf/arena.h>\n"
-    "#include <google/protobuf/arenastring.h>\n"
-    "#include <google/protobuf/generated_message_util.h>\n"
-    "#include <google/protobuf/metadata.h>\n");
+      "#include <google/protobuf/io/coded_stream.h>\n"
+      "#include <google/protobuf/arena.h>\n"
+      "#include <google/protobuf/arenastring.h>\n"
+      "#include <google/protobuf/generated_message_util.h>\n"
+      "#include <google/protobuf/metadata.h>\n");
 
   if (!message_generators_.empty()) {
     if (HasDescriptorMethods(file_, options_)) {
@@ -979,12 +952,21 @@ void FileGenerator::GenerateGlobalStateFunctionDeclarations(
   // functions, so that we can declare them to be friends of each class.
   printer->Print(
       "\n"
+      "namespace $file_namespace$ {\n"
       "// Internal implementation detail -- do not call these.\n"
-      "void $dllexport_decl$$adddescriptorsname$();\n"
-      "void $dllexport_decl$$initdefaultsname$();\n",
-      "initdefaultsname", GlobalInitDefaultsName(file_->name()),
-      "adddescriptorsname", GlobalAddDescriptorsName(file_->name()),
-      "dllexport_decl",
+      "struct $dllexport_decl$TableStruct {\n"
+      "  static const ::google::protobuf::uint32 offsets[];\n"
+      // The following function(s) need to be able to access private members of
+      // the messages defined in the file. So we make them static members.
+      // This is the internal implementation of InitDefaults. It should only
+      // be called by InitDefaults which makes sure it will be called only once.
+      "  static void InitDefaultsImpl();\n"
+      "  static void Shutdown();\n"
+      "};\n"
+      "void $dllexport_decl$AddDescriptors();\n"
+      "void $dllexport_decl$InitDefaults();\n"
+      "}  // namespace $file_namespace$\n",
+      "file_namespace", FileLevelNamespace(file_->name()), "dllexport_decl",
       options_.dllexport_decl.empty() ? "" : options_.dllexport_decl + " ");
 }
 

+ 2 - 17
src/google/protobuf/compiler/cpp/cpp_helpers.cc

@@ -440,23 +440,8 @@ string FilenameIdentifier(const string& filename) {
   return result;
 }
 
-// Return the name of the AddDescriptors() function for a given file.
-string GlobalAddDescriptorsName(const string& filename) {
-  return "protobuf_AddDesc_" + FilenameIdentifier(filename);
-}
-
-string GlobalInitDefaultsName(const string& filename) {
-  return "protobuf_InitDefaults_" + FilenameIdentifier(filename);
-}
-
-// Return the name of the AssignDescriptors() function for a given file.
-string GlobalOffsetTableName(const string& filename) {
-  return "protobuf_Offsets_" + FilenameIdentifier(filename);
-}
-
-// Return the name of the ShutdownFile() function for a given file.
-string GlobalShutdownFileName(const string& filename) {
-  return "protobuf_ShutdownFile_" + FilenameIdentifier(filename);
+string FileLevelNamespace(const string& filename) {
+  return "protobuf_" + FilenameIdentifier(filename);
 }
 
 // Return the qualified C++ name for a file level symbol.

+ 3 - 11
src/google/protobuf/compiler/cpp/cpp_helpers.h

@@ -144,21 +144,13 @@ string DefaultValue(const FieldDescriptor* field);
 // Convert a file name into a valid identifier.
 string FilenameIdentifier(const string& filename);
 
-// Return the name of the AddDescriptors() function for a given file.
-string GlobalAddDescriptorsName(const string& filename);
-
-// Return the name of the InitDefaults() function for a given file.
-string GlobalInitDefaultsName(const string& filename);
-
-// Return the name of the offset table function for a given file.
-string GlobalOffsetTableName(const string& filename);
+// For each .proto file generates a unique namespace. In this namespace global
+// definitions are put to prevent collisions.
+string FileLevelNamespace(const string& filename);
 
 // Return the qualified C++ name for a file level symbol.
 string QualifiedFileLevelSymbol(const string& package, const string& name);
 
-// Return the name of the ShutdownFile() function for a given file.
-string GlobalShutdownFileName(const string& filename);
-
 // Escape C++ trigraphs by escaping question marks to \?
 string EscapeTrigraphs(const string& to_escape);
 

+ 3 - 1
src/google/protobuf/compiler/cpp/cpp_map_field.cc

@@ -49,6 +49,8 @@ void SetMessageVariables(const FieldDescriptor* descriptor,
                          const Options& options) {
   SetCommonFieldVariables(descriptor, variables, options);
   (*variables)["type"] = ClassName(descriptor->message_type(), false);
+  (*variables)["file_namespace"] =
+      FileLevelNamespace(descriptor->file()->name());
   (*variables)["stream_writer"] =
       (*variables)["declared_type"] +
       (HasFastArraySerialization(descriptor->message_type()->file(), options)
@@ -174,7 +176,7 @@ GenerateConstructorCode(io::Printer* printer) const {
   if (HasDescriptorMethods(descriptor_->file(), options_)) {
     printer->Print(variables_,
                    "$name$_.SetAssignDescriptorCallback(\n"
-                   "    protobuf_AssignDescriptorsOnce);\n"
+                   "    $file_namespace$::protobuf_AssignDescriptorsOnce);\n"
                    "$name$_.SetEntryDescriptor(\n"
                    "    &$type$_descriptor);\n");
   }

+ 75 - 72
src/google/protobuf/compiler/cpp/cpp_message.cc

@@ -505,6 +505,7 @@ MessageGenerator::MessageGenerator(const Descriptor* descriptor,
       classname_(ClassName(descriptor, false)),
       options_(options),
       field_generators_(descriptor, options),
+      max_has_bit_index_(0),
       nested_generators_(new google::protobuf::scoped_ptr<
           MessageGenerator>[descriptor->nested_type_count()]),
       enum_generators_(
@@ -523,7 +524,7 @@ MessageGenerator::MessageGenerator(const Descriptor* descriptor,
   OptimizePadding(&optimized_order_, options_);
 
   if (HasFieldPresence(descriptor_->file())) {
-    int has_bit_index = 0;
+    // We use -1 as a sentinel.
     has_bit_indices_.resize(descriptor_->field_count(), -1);
     for (int i = 0; i < optimized_order_.size(); i++) {
       const FieldDescriptor* field = optimized_order_[i];
@@ -532,19 +533,7 @@ MessageGenerator::MessageGenerator(const Descriptor* descriptor,
         continue;
       }
 
-      has_bit_indices_[field->index()] = has_bit_index;
-      has_bit_index++;
-    }
-
-    // Assign fields that do not use has bits to be at the end.  This can be
-    // removed once we shrink the has bits we assign.
-    //
-    // TODO(ckennelly):  Shrink the has bits for these fields.
-    for (int i = 0; i < descriptor_->field_count(); i++) {
-      const FieldDescriptor* field = descriptor_->field(i);
-      if (has_bit_indices_[field->index()] < 0) {
-        has_bit_indices_[field->index()] = has_bit_index++;
-      }
+      has_bit_indices_[field->index()] = max_has_bit_index_++;
     }
   }
 
@@ -581,9 +570,8 @@ MessageGenerator::MessageGenerator(const Descriptor* descriptor,
 MessageGenerator::~MessageGenerator() {}
 
 size_t MessageGenerator::HasBitsSize() const {
-  // TODO(jieluo) - Optimize _has_bits_ for repeated and oneof fields.
-  size_t sizeof_has_bits = (descriptor_->field_count() + 31) / 32 * 4;
-  if (descriptor_->field_count() == 0) {
+  size_t sizeof_has_bits = (max_has_bit_index_ + 31) / 32 * 4;
+  if (sizeof_has_bits == 0) {
     // Zero-size arrays aren't technically allowed, and MSVC in particular
     // doesn't like them.  We still need to declare these arrays to make
     // other code compile.  Since this is an uncommon case, we'll just declare
@@ -642,8 +630,28 @@ GenerateDependentFieldAccessorDeclarations(io::Printer* printer) {
 
 void MessageGenerator::
 GenerateFieldAccessorDeclarations(io::Printer* printer) {
+  // optimized_fields_ does not contain fields where
+  //    field->containing_oneof() != NULL
+  // so we need to iterate over those as well.
+  //
+  // We place the non-oneof fields in optimized_order_, as that controls the
+  // order of the _has_bits_ entries and we want GDB's pretty printers to be
+  // able to infer these indices from the k[FIELDNAME]FieldNumber order.
+  std::vector<const FieldDescriptor*> ordered_fields;
+  ordered_fields.reserve(descriptor_->field_count());
+
+  ordered_fields.insert(
+      ordered_fields.begin(), optimized_order_.begin(), optimized_order_.end());
   for (int i = 0; i < descriptor_->field_count(); i++) {
     const FieldDescriptor* field = descriptor_->field(i);
+    if (field->containing_oneof() == NULL) {
+      continue;
+    }
+    ordered_fields.push_back(field);
+  }
+
+  for (int i = 0; i < ordered_fields.size(); i++) {
+    const FieldDescriptor* field = ordered_fields[i];
 
     PrintFieldComment(printer, field);
 
@@ -1191,12 +1199,14 @@ GenerateClassDefinition(io::Printer* printer) {
     }
     if (HasFastArraySerialization(descriptor_->file(), options_)) {
       printer->Print(
-        "::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(\n"
-        "    bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;\n"
-        "::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)\n"
-        "    const PROTOBUF_FINAL {\n"
-        "  return InternalSerializeWithCachedSizesToArray(false, output);\n"
-        "}\n");
+          "::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(\n"
+          "    bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;\n"
+          "::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)\n"
+          "    const PROTOBUF_FINAL {\n"
+          "  return InternalSerializeWithCachedSizesToArray(\n"
+          "      ::google::protobuf::io::CodedOutputStream::"
+          "IsDefaultSerializationDeterministic(), output);\n"
+          "}\n");
     }
   }
 
@@ -1447,25 +1457,15 @@ GenerateClassDefinition(io::Printer* printer) {
       "::google::protobuf::internal::AnyMetadata _any_metadata_;\n");
   }
 
-  // Declare AddDescriptors(), BuildDescriptors(), and ShutdownFile() as
-  // friends so that they can access private static variables like
-  // default_instance_ and reflection_.
-  printer->Print("friend void $dllexport_decl$ $initdefaultsname$_impl();\n",
-                 // Vars.
-                 "dllexport_decl", options_.dllexport_decl, "initdefaultsname",
-                 GlobalInitDefaultsName(descriptor_->file()->name()));
-  printer->Print("friend void $dllexport_decl$ $adddescriptorsname$_impl();\n",
-                 // Vars.
-                 "dllexport_decl", options_.dllexport_decl,
-                 "adddescriptorsname",
-                 GlobalAddDescriptorsName(descriptor_->file()->name()));
-
+  // The TableStruct struct needs access to the private parts, in order to
+  // construct the offsets of all members.
+  // Some InitDefault and Shutdown are defined as static member functions of
+  // TableStruct such that they are also allowed to access private members.
   printer->Print(
-      "friend const ::google::protobuf::uint32* $offsetfunname$();\n"
-      "friend void $shutdownfilename$();\n"
-      "\n",
-      "offsetfunname", GlobalOffsetTableName(descriptor_->file()->name()),
-      "shutdownfilename", GlobalShutdownFileName(descriptor_->file()->name()));
+      "friend struct $dllexport_decl$ $file_namespace$::TableStruct;\n",
+      // Vars.
+      "dllexport_decl", options_.dllexport_decl, "file_namespace",
+      FileLevelNamespace(descriptor_->file()->name()));
 
   printer->Outdent();
   printer->Print("};");
@@ -1510,15 +1510,13 @@ GenerateInlineMethods(io::Printer* printer, bool is_inline) {
 }
 
 void MessageGenerator::
-GenerateDescriptorDeclarations(io::Printer* printer) {
+GenerateExtraDefaultFields(io::Printer* printer) {
   // Generate oneof default instance for reflection usage.
   if (descriptor_->oneof_decl_count() > 0) {
-    printer->Print("struct $name$OneofInstance {\n",
-                   "name", classname_);
+    printer->Print("public:\n");
     for (int i = 0; i < descriptor_->oneof_decl_count(); i++) {
       for (int j = 0; j < descriptor_->oneof_decl(i)->field_count(); j++) {
         const FieldDescriptor* field = descriptor_->oneof_decl(i)->field(j);
-        printer->Print("  ");
         if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE ||
             (field->cpp_type() == FieldDescriptor::CPPTYPE_STRING &&
              EffectiveStringCType(field) != FieldOptions::STRING)) {
@@ -1527,8 +1525,6 @@ GenerateDescriptorDeclarations(io::Printer* printer) {
         field_generators_.get(field).GeneratePrivateMembers(printer);
       }
     }
-
-    printer->Print("} $name$_default_oneof_instance_;\n", "name", classname_);
   }
 }
 
@@ -1555,6 +1551,7 @@ GenerateTypeRegistrations(io::Printer* printer) {
     std::map<string, string> vars;
     CollectMapInfo(descriptor_, &vars);
     vars["classname"] = classname_;
+    vars["file_namespace"] = FileLevelNamespace(descriptor_->file()->name());
 
     const FieldDescriptor* val = descriptor_->FindFieldByName("value");
     if (descriptor_->file()->syntax() == FileDescriptor::SYNTAX_PROTO2 &&
@@ -1570,7 +1567,8 @@ GenerateTypeRegistrations(io::Printer* printer) {
     printer->Print(
         vars,
         "const ::google::protobuf::Descriptor* $classname$_descriptor = "
-        "file_level_metadata[$index_in_metadata$].descriptor;\n"
+        "$file_namespace$::file_level_metadata[$index_in_metadata$].descriptor;"
+        "\n"
         "::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n"
         "      $classname$_descriptor,\n"
         "      ::google::protobuf::internal::MapEntry<\n"
@@ -1620,7 +1618,7 @@ GenerateDefaultInstanceInitializer(io::Printer* printer) {
          HasDescriptorMethods(descriptor_->file(), options_))) {
       string name;
       if (field->containing_oneof()) {
-        name = classname_ + "_default_oneof_instance_.";
+        name = "_" + classname_ + "_default_instance_.";
       } else {
         name = "_" + classname_ + "_default_instance_.get_mutable()->";
       }
@@ -1752,11 +1750,12 @@ GenerateClassMethods(io::Printer* printer) {
   if (HasDescriptorMethods(descriptor_->file(), options_)) {
     printer->Print(
         "::google::protobuf::Metadata $classname$::GetMetadata() const {\n"
-        "  protobuf_AssignDescriptorsOnce();\n"
-        "  return file_level_metadata[$index$];\n"
+        "  $file_namespace$::protobuf_AssignDescriptorsOnce();\n"
+        "  return $file_namespace$::file_level_metadata[$index$];\n"
         "}\n"
         "\n",
-        "classname", classname_, "index", SimpleItoa(index_in_metadata_));
+        "classname", classname_, "index", SimpleItoa(index_in_metadata_),
+        "file_namespace", FileLevelNamespace(descriptor_->file()->name()));
   } else {
     printer->Print(
       "::std::string $classname$::GetTypeName() const {\n"
@@ -1810,7 +1809,7 @@ std::pair<size_t, size_t> MessageGenerator::GenerateOffsets(
     if (field->containing_oneof()) {
       printer->Print(
           "PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET("
-          "(&$classname$_default_oneof_instance_), $name$_),\n",
+          "(&_$classname$_default_instance_), $name$_),\n",
           "classname", classname_, "name", FieldName(field));
     } else {
       printer->Print(
@@ -1832,7 +1831,9 @@ std::pair<size_t, size_t> MessageGenerator::GenerateOffsets(
   if (HasFieldPresence(descriptor_->file())) {
     entries += has_bit_indices_.size();
     for (int i = 0; i < has_bit_indices_.size(); i++) {
-      printer->Print("$index$,\n", "index", SimpleItoa(has_bit_indices_[i]));
+      const string index = has_bit_indices_[i] >= 0 ?
+        SimpleItoa(has_bit_indices_[i]) : "~0u";
+      printer->Print("$index$,\n", "index", index);
     }
   }
 
@@ -1861,9 +1862,10 @@ GenerateSharedConstructorCode(io::Printer* printer) {
         IsMapEntryMessage(descriptor_->nested_type(i))) {
       printer->Print(
           "const ::google::protobuf::Descriptor*& $type$_descriptor = "
-          "file_level_metadata[$index$].descriptor;\n",
+          "$file_namespace$::file_level_metadata[$index$].descriptor;\n",
           "type", ClassName(descriptor_->nested_type(i), false), "index",
-          SimpleItoa(nested_generators_[i]->index_in_metadata_));
+          SimpleItoa(nested_generators_[i]->index_in_metadata_),
+          "file_namespace", FileLevelNamespace(descriptor_->file()->name()));
     }
   }
 
@@ -2098,14 +2100,14 @@ GenerateStructors(io::Printer* printer) {
       "$classname$::$classname$()\n"
       "  : $superclass$()$initializer$ {\n"
       "  if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {\n"
-      "    $initdefaultsname$();\n"
+      "    $file_namespace$::InitDefaults();\n"
       "  }\n"
       "  SharedCtor();\n"
       "  // @@protoc_insertion_point(constructor:$full_name$)\n"
       "}\n",
       "classname", classname_, "superclass", superclass, "full_name",
       descriptor_->full_name(), "initializer", initializer_null,
-      "initdefaultsname", GlobalInitDefaultsName(descriptor_->file()->name()));
+      "file_namespace", FileLevelNamespace(descriptor_->file()->name()));
 
   if (SupportsArenas(descriptor_)) {
     printer->Print(
@@ -2114,7 +2116,7 @@ GenerateStructors(io::Printer* printer) {
         // When arenas are used it's safe to assume we have finished
         // static init time (protos with arenas are unsafe during static init)
         "#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER\n"
-        "  $initdefaultsname$();\n"
+        "  $file_namespace$::InitDefaults();\n"
         "#endif  // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER\n"
         "  SharedCtor();\n"
         "  RegisterArenaDtor(arena);\n"
@@ -2122,8 +2124,7 @@ GenerateStructors(io::Printer* printer) {
         "}\n",
         "initializer", initializer_with_arena, "classname", classname_,
         "superclass", superclass, "full_name", descriptor_->full_name(),
-        "initdefaultsname",
-        GlobalInitDefaultsName(descriptor_->file()->name()));
+        "file_namespace", FileLevelNamespace(descriptor_->file()->name()));
   }
 
   // Generate the copy constructor.
@@ -2194,9 +2195,10 @@ GenerateStructors(io::Printer* printer) {
         IsMapEntryMessage(descriptor_->nested_type(i))) {
       printer->Print(
           "const ::google::protobuf::Descriptor*& $type$_descriptor = "
-          "file_level_metadata[$index$].descriptor;\n",
+          "$file_namespace$::file_level_metadata[$index$].descriptor;\n",
           "type", ClassName(descriptor_->nested_type(i), false), "index",
-          SimpleItoa(nested_generators_[i]->index_in_metadata_));
+          SimpleItoa(nested_generators_[i]->index_in_metadata_),
+          "file_namespace", FileLevelNamespace(descriptor_->file()->name()));
     }
   }
 
@@ -2277,20 +2279,21 @@ GenerateStructors(io::Printer* printer) {
       !descriptor_->options().no_standard_descriptor_accessor()) {
     printer->Print(
         "const ::google::protobuf::Descriptor* $classname$::descriptor() {\n"
-        "  protobuf_AssignDescriptorsOnce();\n"
-        "  return file_level_metadata[$index$].descriptor;\n"
+        "  $file_namespace$::protobuf_AssignDescriptorsOnce();\n"
+        "  return $file_namespace$::file_level_metadata[$index$].descriptor;\n"
         "}\n"
         "\n",
-        "index", SimpleItoa(index_in_metadata_), "classname", classname_);
+        "index", SimpleItoa(index_in_metadata_), "classname", classname_,
+        "file_namespace", FileLevelNamespace(descriptor_->file()->name()));
   }
 
   printer->Print(
       "const $classname$& $classname$::default_instance() {\n"
-      "  $initdefaultsname$();\n"
+      "  $file_namespace$::InitDefaults();\n"
       "  return *internal_default_instance();\n"
       "}\n\n",
-      "classname", classname_, "initdefaultsname",
-      GlobalInitDefaultsName(descriptor_->file()->name()));
+      "classname", classname_, "file_namespace",
+      FileLevelNamespace(descriptor_->file()->name()));
 
   if (SupportsArenas(descriptor_)) {
     printer->Print(
@@ -2642,7 +2645,7 @@ GenerateSwap(io::Printer* printer) {
     }
 
     if (HasFieldPresence(descriptor_->file())) {
-      for (int i = 0; i < (descriptor_->field_count() + 31) / 32; ++i) {
+      for (int i = 0; i < HasBitsSize() / 4; ++i) {
         printer->Print("std::swap(_has_bits_[$i$], other->_has_bits_[$i$]);\n",
                        "i", SimpleItoa(i));
       }
@@ -3272,7 +3275,7 @@ void MessageGenerator::GenerateSerializeOneExtensionRange(
   if (to_array) {
     printer->Print(vars,
       "target = _extensions_.InternalSerializeWithCachedSizesToArray(\n"
-      "    $start$, $end$, false, target);\n\n");
+      "    $start$, $end$, deterministic, target);\n\n");
   } else {
     printer->Print(vars,
       "_extensions_.SerializeWithCachedSizes(\n"
@@ -3347,7 +3350,7 @@ GenerateSerializeWithCachedSizesToArray(io::Printer* printer) {
     "classname", classname_);
   printer->Indent();
 
-  printer->Print("(void)deterministic; // Unused\n");
+  printer->Print("(void)deterministic;  // Unused\n");
   printer->Print(
     "// @@protoc_insertion_point(serialize_to_array_start:$full_name$)\n",
     "full_name", descriptor_->full_name());

+ 3 - 3
src/google/protobuf/compiler/cpp/cpp_message.h

@@ -91,9 +91,8 @@ class MessageGenerator {
 
   // Source file stuff.
 
-  // Generate code which declares all the global descriptor pointers which
-  // will be initialized by the methods below.
-  void GenerateDescriptorDeclarations(io::Printer* printer);
+  // Generate extra fields
+  void GenerateExtraDefaultFields(io::Printer* printer);
 
   // Generate code that calls MessageFactory::InternalRegisterGeneratedMessage()
   // for all types.
@@ -201,6 +200,7 @@ class MessageGenerator {
   // optimized_order_ excludes oneof fields.
   std::vector<const FieldDescriptor *> optimized_order_;
   std::vector<int> has_bit_indices_;
+  int max_has_bit_index_;
   google::protobuf::scoped_array<google::protobuf::scoped_ptr<MessageGenerator> > nested_generators_;
   google::protobuf::scoped_array<google::protobuf::scoped_ptr<EnumGenerator> > enum_generators_;
   google::protobuf::scoped_array<google::protobuf::scoped_ptr<ExtensionGenerator> > extension_generators_;

+ 0 - 4
src/google/protobuf/compiler/cpp/cpp_message_field.cc

@@ -487,9 +487,6 @@ GenerateClearingCode(io::Printer* printer) const {
 
 void MessageFieldGenerator::
 GenerateMessageClearingCode(io::Printer* printer) const {
-  std::map<string, string> variables(variables_);
-  variables["type"] = FieldMessageTypeName(descriptor_);
-
   if (!HasFieldPresence(descriptor_->file())) {
     // If we don't have has-bits, message presence is indicated only by ptr !=
     // NULL. Thus on clear, we need to delete the object.
@@ -1035,7 +1032,6 @@ GenerateInlineAccessorDefinitions(io::Printer* printer,
       "}\n");
   }
 
-
   if (!dependent_field_) {
     printer->Print(variables,
       "$inline$"

+ 28 - 22
src/google/protobuf/compiler/cpp/cpp_primitive_field.cc

@@ -245,7 +245,7 @@ void PrimitiveOneofFieldGenerator::
 GenerateConstructorCode(io::Printer* printer) const {
   printer->Print(
       variables_,
-      "  $classname$_default_oneof_instance_.$name$_ = $default$;\n");
+      "_$classname$_default_instance_.$name$_ = $default$;\n");
 }
 
 void PrimitiveOneofFieldGenerator::
@@ -373,6 +373,7 @@ GenerateMergeFromCodedStreamWithPacking(io::Printer* printer) const {
 
 void RepeatedPrimitiveFieldGenerator::
 GenerateSerializeWithCachedSizes(io::Printer* printer) const {
+  bool array_written = false;
   if (descriptor_->is_packed()) {
     // Write the tag and the size.
     printer->Print(variables_,
@@ -381,21 +382,30 @@ GenerateSerializeWithCachedSizes(io::Printer* printer) const {
           "$number$, "
           "::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED, "
           "output);\n"
-      "  output->WriteVarint32(_$name$_cached_byte_size_);\n"
-      "}\n");
+      "  output->WriteVarint32(_$name$_cached_byte_size_);\n");
+
+    if (FixedSize(descriptor_->type()) > 0) {
+      printer->Print(variables_,
+        "  ::google::protobuf::internal::WireFormatLite::Write$declared_type$Array(\n"
+        "    this->$name$().data(), this->$name$_size(), output);\n");
+      array_written = true;  // Wrote array all at once
+    }
+    printer->Print(variables_, "}\n");
   }
-  printer->Print(variables_,
-      "for (int i = 0; i < this->$name$_size(); i++) {\n");
-  if (descriptor_->is_packed()) {
+  if (!array_written) {
     printer->Print(variables_,
-      "  ::google::protobuf::internal::WireFormatLite::Write$declared_type$NoTag(\n"
-      "    this->$name$(i), output);\n");
-  } else {
-    printer->Print(variables_,
-      "  ::google::protobuf::internal::WireFormatLite::Write$declared_type$(\n"
-      "    $number$, this->$name$(i), output);\n");
+        "for (int i = 0; i < this->$name$_size(); i++) {\n");
+    if (descriptor_->is_packed()) {
+      printer->Print(variables_,
+        "  ::google::protobuf::internal::WireFormatLite::Write$declared_type$NoTag(\n"
+        "    this->$name$(i), output);\n");
+    } else {
+      printer->Print(variables_,
+        "  ::google::protobuf::internal::WireFormatLite::Write$declared_type$(\n"
+        "    $number$, this->$name$(i), output);\n");
+    }
+    printer->Print("}\n");
   }
-  printer->Print("}\n");
 }
 
 void RepeatedPrimitiveFieldGenerator::
@@ -428,21 +438,17 @@ GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const {
 
 void RepeatedPrimitiveFieldGenerator::
 GenerateByteSize(io::Printer* printer) const {
-  printer->Print(variables_,
-    "{\n"
-    "  size_t data_size = 0;\n"
-    "  unsigned int count = this->$name$_size();\n");
+  printer->Print(variables_, "{\n");
   printer->Indent();
   int fixed_size = FixedSize(descriptor_->type());
   if (fixed_size == -1) {
     printer->Print(variables_,
-      "for (unsigned int i = 0; i < count; i++) {\n"
-      "  data_size += ::google::protobuf::internal::WireFormatLite::\n"
-      "    $declared_type$Size(this->$name$(i));\n"
-      "}\n");
+      "size_t data_size = ::google::protobuf::internal::WireFormatLite::\n"
+      "  $declared_type$Size(this->$name$_);\n");
   } else {
     printer->Print(variables_,
-      "data_size = $fixed_size$UL * count;\n");
+      "unsigned int count = this->$name$_size();\n"
+      "size_t data_size = $fixed_size$UL * count;\n");
   }
 
   if (descriptor_->is_packed()) {

+ 4 - 3
src/google/protobuf/compiler/cpp/cpp_service.cc

@@ -46,6 +46,7 @@ ServiceGenerator::ServiceGenerator(const ServiceDescriptor* descriptor,
                                    const Options& options)
   : descriptor_(descriptor) {
   vars_["classname"] = descriptor_->name();
+  vars_["file_namespace"] = FileLevelNamespace(descriptor_->file()->name());
   vars_["full_name"] = descriptor_->full_name();
   if (options.dllexport_decl.empty()) {
     vars_["dllexport"] = "";
@@ -178,8 +179,8 @@ void ServiceGenerator::GenerateImplementation(io::Printer* printer) {
       "$classname$::~$classname$() {}\n"
       "\n"
       "const ::google::protobuf::ServiceDescriptor* $classname$::descriptor() {\n"
-      "  protobuf_AssignDescriptorsOnce();\n"
-      "  return file_level_service_descriptors[$index$];\n"
+      "  $file_namespace$::protobuf_AssignDescriptorsOnce();\n"
+      "  return $file_namespace$::file_level_service_descriptors[$index$];\n"
       "}\n"
       "\n"
       "const ::google::protobuf::ServiceDescriptor* $classname$::GetDescriptor() {\n"
@@ -241,7 +242,7 @@ void ServiceGenerator::GenerateCallMethod(io::Printer* printer) {
       "                             ::google::protobuf::Message* response,\n"
       "                             ::google::protobuf::Closure* done) {\n"
       "  GOOGLE_DCHECK_EQ(method->service(), "
-      "file_level_service_descriptors[$index$]);\n"
+      "$file_namespace$::file_level_service_descriptors[$index$]);\n"
       "  switch(method->index()) {\n");
 
   for (int i = 0; i < descriptor_->method_count(); i++) {

+ 34 - 7
src/google/protobuf/compiler/cpp/cpp_string_field.cc

@@ -141,7 +141,16 @@ GenerateAccessorDeclarations(io::Printer* printer) const {
 
   printer->Print(variables_,
     "$deprecated_attr$const ::std::string& $name$() const;\n"
-    "$deprecated_attr$void set_$name$(const ::std::string& value);\n"
+    "$deprecated_attr$void set_$name$(const ::std::string& value);\n");
+
+  if (!SupportsArenas(descriptor_)) {
+    printer->Print(variables_,
+      "#if LANG_CXX11\n"
+      "$deprecated_attr$void set_$name$(::std::string&& value);\n"
+      "#endif\n");
+  }
+
+  printer->Print(variables_,
     "$deprecated_attr$void set_$name$(const char* value);\n"
     "$deprecated_attr$void set_$name$(const $pointer_type$* value, size_t size)"
                  ";\n"
@@ -249,6 +258,14 @@ GenerateInlineAccessorDefinitions(io::Printer* printer,
         "  $name$_.SetNoArena($default_variable$, value);\n"
         "  // @@protoc_insertion_point(field_set:$full_name$)\n"
         "}\n"
+        "#if LANG_CXX11\n"
+        "$inline$void $classname$::set_$name$(::std::string&& value) {\n"
+        "  $set_hasbit$\n"
+        "  $name$_.SetNoArena(\n"
+        "    $default_variable$, std::move(value));\n"
+        "  // @@protoc_insertion_point(field_set_rvalue:$full_name$)\n"
+        "}\n"
+        "#endif\n"
         "$inline$void $classname$::set_$name$(const char* value) {\n"
         "  $set_hasbit$\n"
         "  $name$_.SetNoArena($default_variable$, $string_piece$(value));\n"
@@ -633,6 +650,19 @@ GenerateInlineAccessorDefinitions(io::Printer* printer,
         "  $oneof_prefix$$name$_.SetNoArena($default_variable$, value);\n"
         "  // @@protoc_insertion_point(field_set:$full_name$)\n"
         "}\n"
+        "#if LANG_CXX11\n"
+        "$inline$void $classname$::set_$name$(::std::string&& value) {\n"
+        "  // @@protoc_insertion_point(field_set:$full_name$)\n"
+        "  if (!has_$name$()) {\n"
+        "    clear_$oneof_name$();\n"
+        "    set_has_$name$();\n"
+        "    $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n"
+        "  }\n"
+        "  $oneof_prefix$$name$_.SetNoArena(\n"
+        "    $default_variable$, std::move(value));\n"
+        "  // @@protoc_insertion_point(field_set_rvalue:$full_name$)\n"
+        "}\n"
+        "#endif\n"
         "$inline$void $classname$::set_$name$(const char* value) {\n"
         "  if (!has_$name$()) {\n"
         "    clear_$oneof_name$();\n"
@@ -732,7 +762,7 @@ void StringOneofFieldGenerator::
 GenerateConstructorCode(io::Printer* printer) const {
   printer->Print(
       variables_,
-      "$classname$_default_oneof_instance_.$name$_.UnsafeSetDefault(\n"
+      "_$classname$_default_instance_.$name$_.UnsafeSetDefault(\n"
       "    $default_variable$);\n");
 }
 
@@ -808,9 +838,7 @@ GenerateAccessorDeclarations(io::Printer* printer) const {
     "$deprecated_attr$void add_$name$(const ::std::string& value);\n"
     "$deprecated_attr$void add_$name$(const char* value);\n"
     "$deprecated_attr$void add_$name$(const $pointer_type$* value, size_t size)"
-                 ";\n");
-
-  printer->Print(variables_,
+                 ";\n"
     "$deprecated_attr$const ::google::protobuf::RepeatedPtrField< ::std::string>& $name$() "
                  "const;\n"
     "$deprecated_attr$::google::protobuf::RepeatedPtrField< ::std::string>* mutable_$name$()"
@@ -868,8 +896,7 @@ GenerateInlineAccessorDefinitions(io::Printer* printer,
     "$classname$::add_$name$(const $pointer_type$* value, size_t size) {\n"
     "  $name$_.Add()->assign(reinterpret_cast<const char*>(value), size);\n"
     "  // @@protoc_insertion_point(field_add_pointer:$full_name$)\n"
-    "}\n");
-  printer->Print(variables,
+    "}\n"
     "$inline$const ::google::protobuf::RepeatedPtrField< ::std::string>&\n"
     "$classname$::$name$() const {\n"
     "  // @@protoc_insertion_point(field_list:$full_name$)\n"

+ 46 - 0
src/google/protobuf/compiler/cpp/cpp_unittest.cc

@@ -53,6 +53,7 @@
 #include <vector>
 
 #include <google/protobuf/unittest.pb.h>
+#include <google/protobuf/unittest_no_arena.pb.h>
 #include <google/protobuf/unittest_optimize_for.pb.h>
 #include <google/protobuf/unittest_embed_optimize_for.pb.h>
 #if !defined(GOOGLE_PROTOBUF_CMAKE_BUILD) && !defined(_MSC_VER)
@@ -420,6 +421,51 @@ TEST(GeneratedMessageTest, StringCharStarLength) {
   EXPECT_EQ("wx", message.repeated_string(0));
 }
 
+#if LANG_CXX11
+TEST(GeneratedMessageTest, StringMove) {
+  // Verify that we trigger the move behavior on a scalar setter.
+  protobuf_unittest_no_arena::TestAllTypes message;
+  {
+    string tmp(32, 'a');
+
+    const char* old_data = tmp.data();
+    message.set_optional_string(std::move(tmp));
+    const char* new_data = message.optional_string().data();
+
+    EXPECT_EQ(old_data, new_data);
+    EXPECT_EQ(string(32, 'a'), message.optional_string());
+
+    string tmp2(32, 'b');
+    old_data = tmp2.data();
+    message.set_optional_string(std::move(tmp2));
+    new_data = message.optional_string().data();
+
+    EXPECT_EQ(old_data, new_data);
+    EXPECT_EQ(string(32, 'b'), message.optional_string());
+  }
+
+  // Verify that we trigger the move behavior on a oneof setter.
+  {
+    string tmp(32, 'a');
+
+    const char* old_data = tmp.data();
+    message.set_oneof_string(std::move(tmp));
+    const char* new_data = message.oneof_string().data();
+
+    EXPECT_EQ(old_data, new_data);
+    EXPECT_EQ(string(32, 'a'), message.oneof_string());
+
+    string tmp2(32, 'b');
+    old_data = tmp2.data();
+    message.set_oneof_string(std::move(tmp2));
+    new_data = message.oneof_string().data();
+
+    EXPECT_EQ(old_data, new_data);
+    EXPECT_EQ(string(32, 'b'), message.oneof_string());
+  }
+}
+#endif
+
 
 TEST(GeneratedMessageTest, CopyFrom) {
   unittest::TestAllTypes message1, message2;

+ 1 - 0
src/google/protobuf/compiler/java/java_enum_field_lite.cc

@@ -76,6 +76,7 @@ void SetEnumVariables(const FieldDescriptor* descriptor,
   // by the proto compiler
   (*variables)["deprecation"] = descriptor->options().deprecated()
       ? "@java.lang.Deprecated " : "";
+  (*variables)["required"] = descriptor->is_required() ? "true" : "false";
 
   if (SupportFieldPresence(descriptor->file())) {
     // For singular messages and builders, one bit is used for the hasField bit.

+ 1 - 0
src/google/protobuf/compiler/java/java_message_field_lite.cc

@@ -70,6 +70,7 @@ void SetMessageVariables(const FieldDescriptor* descriptor,
   // by the proto compiler
   (*variables)["deprecation"] = descriptor->options().deprecated()
       ? "@java.lang.Deprecated " : "";
+  (*variables)["required"] = descriptor->is_required() ? "true" : "false";
 
   if (SupportFieldPresence(descriptor->file())) {
     // For singular messages and builders, one bit is used for the hasField bit.

+ 2 - 2
src/google/protobuf/compiler/java/java_message_lite.cc

@@ -928,10 +928,10 @@ void ImmutableMessageLiteGenerator::GenerateDynamicMethodMergeFromStream(
       "com.google.protobuf.CodedInputStream input =\n"
       "    (com.google.protobuf.CodedInputStream) arg0;\n"
       "com.google.protobuf.ExtensionRegistryLite extensionRegistry =\n"
-      "    (com.google.protobuf.ExtensionRegistryLite) arg1;\n"
+      "    (com.google.protobuf.ExtensionRegistryLite) arg1;\n");
+  printer->Print(
       "try {\n");
   printer->Indent();
-
   printer->Print(
     "boolean done = false;\n"
     "while (!done) {\n");

+ 1 - 0
src/google/protobuf/compiler/java/java_primitive_field_lite.cc

@@ -74,6 +74,7 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor,
       SimpleItoa(static_cast<int32>(WireFormat::MakeTag(descriptor)));
   (*variables)["tag_size"] = SimpleItoa(
       WireFormat::TagSize(descriptor->number(), GetType(descriptor)));
+  (*variables)["required"] = descriptor->is_required() ? "true" : "false";
 
   string capitalized_type = UnderscoresToCamelCase(PrimitiveTypeName(javaType),
                                                    true /* cap_next_letter */);

+ 5 - 12
src/google/protobuf/compiler/java/java_shared_code_generator.cc

@@ -181,13 +181,11 @@ void SharedCodeGenerator::GenerateDescriptors(io::Printer* printer) {
   // Find out all dependencies.
   std::vector<std::pair<string, string> > dependencies;
   for (int i = 0; i < file_->dependency_count(); i++) {
-    if (ShouldIncludeDependency(file_->dependency(i))) {
-      string filename = file_->dependency(i)->name();
-      string classname = FileJavaPackage(file_->dependency(i)) + "." +
-                         name_resolver_->GetDescriptorClassName(
-                             file_->dependency(i));
-      dependencies.push_back(std::make_pair(filename, classname));
-    }
+    string filename = file_->dependency(i)->name();
+    string classname = FileJavaPackage(file_->dependency(i)) + "." +
+                       name_resolver_->GetDescriptorClassName(
+                           file_->dependency(i));
+    dependencies.push_back(std::make_pair(filename, classname));
   }
 
   // -----------------------------------------------------------------
@@ -209,11 +207,6 @@ void SharedCodeGenerator::GenerateDescriptors(io::Printer* printer) {
     "    }, assigner);\n");
 }
 
-bool SharedCodeGenerator::ShouldIncludeDependency(
-    const FileDescriptor* descriptor) {
-  return true;
-}
-
 }  // namespace java
 }  // namespace compiler
 }  // namespace protobuf

+ 0 - 5
src/google/protobuf/compiler/java/java_shared_code_generator.h

@@ -77,11 +77,6 @@ class SharedCodeGenerator {
   void GenerateDescriptors(io::Printer* printer);
 
  private:
-  // Returns whether the dependency should be included in the output file.
-  // Always returns true for opensource, but used internally at Google to help
-  // improve compatibility with version 1 of protocol buffers.
-  bool ShouldIncludeDependency(const FileDescriptor* descriptor);
-
   google::protobuf::scoped_ptr<ClassNameResolver> name_resolver_;
   const FileDescriptor* file_;
   const Options options_;

+ 1 - 0
src/google/protobuf/compiler/java/java_string_field_lite.cc

@@ -85,6 +85,7 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor,
   // by the proto compiler
   (*variables)["deprecation"] = descriptor->options().deprecated()
       ? "@java.lang.Deprecated " : "";
+  (*variables)["required"] = descriptor->is_required() ? "true" : "false";
 
   if (SupportFieldPresence(descriptor->file())) {
     // For singular messages and builders, one bit is used for the hasField bit.

+ 6 - 6
src/google/protobuf/compiler/parser.cc

@@ -249,11 +249,11 @@ bool Parser::ConsumeNumber(double* output, const char* error) {
     input_->Next();
     return true;
   } else if (LookingAt("inf")) {
-    *output = numeric_limits<double>::infinity();
+    *output = std::numeric_limits<double>::infinity();
     input_->Next();
     return true;
   } else if (LookingAt("nan")) {
-    *output = numeric_limits<double>::quiet_NaN();
+    *output = std::numeric_limits<double>::quiet_NaN();
     input_->Next();
     return true;
   } else {
@@ -282,7 +282,7 @@ bool Parser::TryConsumeEndOfDeclaration(
     const char* text, const LocationRecorder* location) {
   if (LookingAt(text)) {
     string leading, trailing;
-    vector<string> detached;
+    std::vector<string> detached;
     input_->NextWithComments(&trailing, &detached, &leading);
 
     // Save the leading comments for next time, and recall the leading comments
@@ -404,7 +404,7 @@ void Parser::LocationRecorder::RecordLegacyLocation(const Message* descriptor,
 
 void Parser::LocationRecorder::AttachComments(
     string* leading, string* trailing,
-    vector<string>* detached_comments) const {
+    std::vector<string>* detached_comments) const {
   GOOGLE_CHECK(!location_->has_leading_comments());
   GOOGLE_CHECK(!location_->has_trailing_comments());
 
@@ -487,7 +487,7 @@ bool Parser::ValidateEnum(const EnumDescriptorProto* proto) {
     return false;
   }
 
-  set<int> used_values;
+  std::set<int> used_values;
   bool has_duplicates = false;
   for (int i = 0; i < proto->value_size(); ++i) {
     const EnumValueDescriptorProto enum_value = proto->value(i);
@@ -2089,7 +2089,7 @@ bool SourceLocationTable::Find(
     const Message* descriptor,
     DescriptorPool::ErrorCollector::ErrorLocation location,
     int* line, int* column) const {
-  const pair<int, int>* result =
+  const std::pair<int, int>* result =
       FindOrNull(location_map_, std::make_pair(descriptor, location));
   if (result == NULL) {
     *line   = -1;

+ 157 - 109
src/google/protobuf/compiler/plugin.pb.cc

@@ -20,14 +20,17 @@
 namespace google {
 namespace protobuf {
 namespace compiler {
-class VersionDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Version> {};
-VersionDefaultTypeInternal _Version_default_instance_;
-class CodeGeneratorRequestDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorRequest> {};
-CodeGeneratorRequestDefaultTypeInternal _CodeGeneratorRequest_default_instance_;
-class CodeGeneratorResponse_FileDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorResponse_File> {};
-CodeGeneratorResponse_FileDefaultTypeInternal _CodeGeneratorResponse_File_default_instance_;
-class CodeGeneratorResponseDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorResponse> {};
-CodeGeneratorResponseDefaultTypeInternal _CodeGeneratorResponse_default_instance_;
+class VersionDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Version> {
+} _Version_default_instance_;
+class CodeGeneratorRequestDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorRequest> {
+} _CodeGeneratorRequest_default_instance_;
+class CodeGeneratorResponse_FileDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorResponse_File> {
+} _CodeGeneratorResponse_File_default_instance_;
+class CodeGeneratorResponseDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorResponse> {
+} _CodeGeneratorResponse_default_instance_;
+
+namespace protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto {
+
 
 namespace {
 
@@ -35,55 +38,50 @@ namespace {
 
 }  // namespace
 
-
-const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fcompiler_2fplugin_2eproto() GOOGLE_ATTRIBUTE_COLD;
-const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fcompiler_2fplugin_2eproto() {
-  static const ::google::protobuf::uint32 offsets[] = {
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Version, _has_bits_),
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Version, _internal_metadata_),
-    ~0u,  // no _extensions_
-    ~0u,  // no _oneof_case_
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Version, major_),
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Version, minor_),
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Version, patch_),
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Version, suffix_),
-    1,
-    2,
-    3,
-    0,
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, _has_bits_),
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, _internal_metadata_),
-    ~0u,  // no _extensions_
-    ~0u,  // no _oneof_case_
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, file_to_generate_),
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, parameter_),
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, proto_file_),
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, compiler_version_),
-    2,
-    0,
-    3,
-    1,
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse_File, _has_bits_),
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse_File, _internal_metadata_),
-    ~0u,  // no _extensions_
-    ~0u,  // no _oneof_case_
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse_File, name_),
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse_File, insertion_point_),
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse_File, content_),
-    0,
-    1,
-    2,
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse, _has_bits_),
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse, _internal_metadata_),
-    ~0u,  // no _extensions_
-    ~0u,  // no _oneof_case_
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse, error_),
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse, file_),
-    0,
-    1,
-  };
-  return offsets;
-}
+const ::google::protobuf::uint32 TableStruct::offsets[] = {
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Version, _has_bits_),
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Version, _internal_metadata_),
+  ~0u,  // no _extensions_
+  ~0u,  // no _oneof_case_
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Version, major_),
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Version, minor_),
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Version, patch_),
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Version, suffix_),
+  1,
+  2,
+  3,
+  0,
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, _has_bits_),
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, _internal_metadata_),
+  ~0u,  // no _extensions_
+  ~0u,  // no _oneof_case_
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, file_to_generate_),
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, parameter_),
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, proto_file_),
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, compiler_version_),
+  ~0u,
+  0,
+  ~0u,
+  1,
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse_File, _has_bits_),
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse_File, _internal_metadata_),
+  ~0u,  // no _extensions_
+  ~0u,  // no _oneof_case_
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse_File, name_),
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse_File, insertion_point_),
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse_File, content_),
+  0,
+  1,
+  2,
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse, _has_bits_),
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse, _internal_metadata_),
+  ~0u,  // no _extensions_
+  ~0u,  // no _oneof_case_
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse, error_),
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse, file_),
+  0,
+  ~0u,
+};
 
 static const ::google::protobuf::internal::MigrationSchema schemas[] = {
   { 0, 8, sizeof(Version)},
@@ -92,20 +90,20 @@ static const ::google::protobuf::internal::MigrationSchema schemas[] = {
   { 34, 40, sizeof(CodeGeneratorResponse)},
 };
 
-static const ::google::protobuf::internal::DefaultInstanceData file_default_instances[] = {
-  {reinterpret_cast<const ::google::protobuf::Message*>(&_Version_default_instance_), NULL},
-  {reinterpret_cast<const ::google::protobuf::Message*>(&_CodeGeneratorRequest_default_instance_), NULL},
-  {reinterpret_cast<const ::google::protobuf::Message*>(&_CodeGeneratorResponse_File_default_instance_), NULL},
-  {reinterpret_cast<const ::google::protobuf::Message*>(&_CodeGeneratorResponse_default_instance_), NULL},
+static ::google::protobuf::Message const * const file_default_instances[] = {
+  reinterpret_cast<const ::google::protobuf::Message*>(&_Version_default_instance_),
+  reinterpret_cast<const ::google::protobuf::Message*>(&_CodeGeneratorRequest_default_instance_),
+  reinterpret_cast<const ::google::protobuf::Message*>(&_CodeGeneratorResponse_File_default_instance_),
+  reinterpret_cast<const ::google::protobuf::Message*>(&_CodeGeneratorResponse_default_instance_),
 };
 
 namespace {
 
 void protobuf_AssignDescriptors() {
-  protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto();
+  AddDescriptors();
   ::google::protobuf::MessageFactory* factory = NULL;
   AssignDescriptors(
-      "google/protobuf/compiler/plugin.proto", schemas, file_default_instances, protobuf_Offsets_google_2fprotobuf_2fcompiler_2fplugin_2eproto(), factory,
+      "google/protobuf/compiler/plugin.proto", schemas, file_default_instances, TableStruct::offsets, factory,
       file_level_metadata, NULL, NULL);
 }
 
@@ -122,7 +120,7 @@ void protobuf_RegisterTypes(const ::std::string&) {
 
 }  // namespace
 
-void protobuf_ShutdownFile_google_2fprotobuf_2fcompiler_2fplugin_2eproto() {
+void TableStruct::Shutdown() {
   _Version_default_instance_.Shutdown();
   delete file_level_metadata[0].reflection;
   _CodeGeneratorRequest_default_instance_.Shutdown();
@@ -133,11 +131,11 @@ void protobuf_ShutdownFile_google_2fprotobuf_2fcompiler_2fplugin_2eproto() {
   delete file_level_metadata[3].reflection;
 }
 
-void protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl() {
+void TableStruct::InitDefaultsImpl() {
   GOOGLE_PROTOBUF_VERIFY_VERSION;
 
-  ::google::protobuf::protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto();
   ::google::protobuf::internal::InitProtobufDefaults();
+  ::google::protobuf::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
   _Version_default_instance_.DefaultConstruct();
   _CodeGeneratorRequest_default_instance_.DefaultConstruct();
   _CodeGeneratorResponse_File_default_instance_.DefaultConstruct();
@@ -146,12 +144,12 @@ void protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl()
       ::google::protobuf::compiler::Version::internal_default_instance());
 }
 
-void protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto() {
+void InitDefaults() {
   static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
-  ::google::protobuf::GoogleOnceInit(&once, &protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl);
+  ::google::protobuf::GoogleOnceInit(&once, &TableStruct::InitDefaultsImpl);
 }
-void protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl() {
-  protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto();
+void AddDescriptorsImpl() {
+  InitDefaults();
   static const char descriptor[] = {
       "\n%google/protobuf/compiler/plugin.proto\022"
       "\030google.protobuf.compiler\032 google/protob"
@@ -173,21 +171,23 @@ void protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl() {
       descriptor, 590);
   ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
     "google/protobuf/compiler/plugin.proto", &protobuf_RegisterTypes);
-  ::google::protobuf::protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto();
-  ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fcompiler_2fplugin_2eproto);
+  ::google::protobuf::protobuf_google_2fprotobuf_2fdescriptor_2eproto::AddDescriptors();
+  ::google::protobuf::internal::OnShutdown(&TableStruct::Shutdown);
 }
 
-GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once_);
-void protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto() {
-  ::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once_,
-                 &protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl);
+void AddDescriptors() {
+  static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
+  ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl);
 }
 // Force AddDescriptors() to be called at static initialization time.
-struct StaticDescriptorInitializer_google_2fprotobuf_2fcompiler_2fplugin_2eproto {
-  StaticDescriptorInitializer_google_2fprotobuf_2fcompiler_2fplugin_2eproto() {
-    protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto();
+struct StaticDescriptorInitializer {
+  StaticDescriptorInitializer() {
+    AddDescriptors();
   }
-} static_descriptor_initializer_google_2fprotobuf_2fcompiler_2fplugin_2eproto_;
+} static_descriptor_initializer;
+
+}  // namespace protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto
+
 
 // ===================================================================
 
@@ -201,7 +201,7 @@ const int Version::kSuffixFieldNumber;
 Version::Version()
   : ::google::protobuf::Message(), _internal_metadata_(NULL) {
   if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
-    protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto();
+    protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::InitDefaults();
   }
   SharedCtor();
   // @@protoc_insertion_point(constructor:google.protobuf.compiler.Version)
@@ -244,12 +244,12 @@ void Version::SetCachedSize(int size) const {
   GOOGLE_SAFE_CONCURRENT_WRITES_END();
 }
 const ::google::protobuf::Descriptor* Version::descriptor() {
-  protobuf_AssignDescriptorsOnce();
-  return file_level_metadata[0].descriptor;
+  protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::protobuf_AssignDescriptorsOnce();
+  return protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::file_level_metadata[0].descriptor;
 }
 
 const Version& Version::default_instance() {
-  protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto();
+  protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::InitDefaults();
   return *internal_default_instance();
 }
 
@@ -398,7 +398,7 @@ void Version::SerializeWithCachedSizes(
 
 ::google::protobuf::uint8* Version::InternalSerializeWithCachedSizesToArray(
     bool deterministic, ::google::protobuf::uint8* target) const {
-  (void)deterministic; // Unused
+  (void)deterministic;  // Unused
   // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.compiler.Version)
   // optional int32 major = 1;
   if (has_major()) {
@@ -549,8 +549,8 @@ void Version::InternalSwap(Version* other) {
 }
 
 ::google::protobuf::Metadata Version::GetMetadata() const {
-  protobuf_AssignDescriptorsOnce();
-  return file_level_metadata[0];
+  protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::protobuf_AssignDescriptorsOnce();
+  return protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::file_level_metadata[0];
 }
 
 #if PROTOBUF_INLINE_NOT_IN_HEADERS
@@ -651,6 +651,14 @@ void Version::set_suffix(const ::std::string& value) {
   suffix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
   // @@protoc_insertion_point(field_set:google.protobuf.compiler.Version.suffix)
 }
+#if LANG_CXX11
+void Version::set_suffix(::std::string&& value) {
+  set_has_suffix();
+  suffix_.SetNoArena(
+    &::google::protobuf::internal::GetEmptyStringAlreadyInited(), std::move(value));
+  // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.Version.suffix)
+}
+#endif
 void Version::set_suffix(const char* value) {
   set_has_suffix();
   suffix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -696,7 +704,7 @@ const int CodeGeneratorRequest::kCompilerVersionFieldNumber;
 CodeGeneratorRequest::CodeGeneratorRequest()
   : ::google::protobuf::Message(), _internal_metadata_(NULL) {
   if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
-    protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto();
+    protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::InitDefaults();
   }
   SharedCtor();
   // @@protoc_insertion_point(constructor:google.protobuf.compiler.CodeGeneratorRequest)
@@ -745,12 +753,12 @@ void CodeGeneratorRequest::SetCachedSize(int size) const {
   GOOGLE_SAFE_CONCURRENT_WRITES_END();
 }
 const ::google::protobuf::Descriptor* CodeGeneratorRequest::descriptor() {
-  protobuf_AssignDescriptorsOnce();
-  return file_level_metadata[1].descriptor;
+  protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::protobuf_AssignDescriptorsOnce();
+  return protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::file_level_metadata[1].descriptor;
 }
 
 const CodeGeneratorRequest& CodeGeneratorRequest::default_instance() {
-  protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto();
+  protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::InitDefaults();
   return *internal_default_instance();
 }
 
@@ -911,7 +919,7 @@ void CodeGeneratorRequest::SerializeWithCachedSizes(
 
 ::google::protobuf::uint8* CodeGeneratorRequest::InternalSerializeWithCachedSizesToArray(
     bool deterministic, ::google::protobuf::uint8* target) const {
-  (void)deterministic; // Unused
+  (void)deterministic;  // Unused
   // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.compiler.CodeGeneratorRequest)
   // repeated string file_to_generate = 1;
   for (int i = 0; i < this->file_to_generate_size(); i++) {
@@ -1073,8 +1081,8 @@ void CodeGeneratorRequest::InternalSwap(CodeGeneratorRequest* other) {
 }
 
 ::google::protobuf::Metadata CodeGeneratorRequest::GetMetadata() const {
-  protobuf_AssignDescriptorsOnce();
-  return file_level_metadata[1];
+  protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::protobuf_AssignDescriptorsOnce();
+  return protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::file_level_metadata[1];
 }
 
 #if PROTOBUF_INLINE_NOT_IN_HEADERS
@@ -1158,6 +1166,14 @@ void CodeGeneratorRequest::set_parameter(const ::std::string& value) {
   parameter_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
   // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorRequest.parameter)
 }
+#if LANG_CXX11
+void CodeGeneratorRequest::set_parameter(::std::string&& value) {
+  set_has_parameter();
+  parameter_.SetNoArena(
+    &::google::protobuf::internal::GetEmptyStringAlreadyInited(), std::move(value));
+  // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.CodeGeneratorRequest.parameter)
+}
+#endif
 void CodeGeneratorRequest::set_parameter(const char* value) {
   set_has_parameter();
   parameter_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -1277,7 +1293,7 @@ const int CodeGeneratorResponse_File::kContentFieldNumber;
 CodeGeneratorResponse_File::CodeGeneratorResponse_File()
   : ::google::protobuf::Message(), _internal_metadata_(NULL) {
   if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
-    protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto();
+    protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::InitDefaults();
   }
   SharedCtor();
   // @@protoc_insertion_point(constructor:google.protobuf.compiler.CodeGeneratorResponse.File)
@@ -1327,12 +1343,12 @@ void CodeGeneratorResponse_File::SetCachedSize(int size) const {
   GOOGLE_SAFE_CONCURRENT_WRITES_END();
 }
 const ::google::protobuf::Descriptor* CodeGeneratorResponse_File::descriptor() {
-  protobuf_AssignDescriptorsOnce();
-  return file_level_metadata[2].descriptor;
+  protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::protobuf_AssignDescriptorsOnce();
+  return protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::file_level_metadata[2].descriptor;
 }
 
 const CodeGeneratorResponse_File& CodeGeneratorResponse_File::default_instance() {
-  protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto();
+  protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::InitDefaults();
   return *internal_default_instance();
 }
 
@@ -1483,7 +1499,7 @@ void CodeGeneratorResponse_File::SerializeWithCachedSizes(
 
 ::google::protobuf::uint8* CodeGeneratorResponse_File::InternalSerializeWithCachedSizesToArray(
     bool deterministic, ::google::protobuf::uint8* target) const {
-  (void)deterministic; // Unused
+  (void)deterministic;  // Unused
   // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.compiler.CodeGeneratorResponse.File)
   // optional string name = 1;
   if (has_name()) {
@@ -1632,8 +1648,8 @@ void CodeGeneratorResponse_File::InternalSwap(CodeGeneratorResponse_File* other)
 }
 
 ::google::protobuf::Metadata CodeGeneratorResponse_File::GetMetadata() const {
-  protobuf_AssignDescriptorsOnce();
-  return file_level_metadata[2];
+  protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::protobuf_AssignDescriptorsOnce();
+  return protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::file_level_metadata[2];
 }
 
 #if PROTOBUF_INLINE_NOT_IN_HEADERS
@@ -1662,6 +1678,14 @@ void CodeGeneratorResponse_File::set_name(const ::std::string& value) {
   name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
   // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.name)
 }
+#if LANG_CXX11
+void CodeGeneratorResponse_File::set_name(::std::string&& value) {
+  set_has_name();
+  name_.SetNoArena(
+    &::google::protobuf::internal::GetEmptyStringAlreadyInited(), std::move(value));
+  // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.CodeGeneratorResponse.File.name)
+}
+#endif
 void CodeGeneratorResponse_File::set_name(const char* value) {
   set_has_name();
   name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -1716,6 +1740,14 @@ void CodeGeneratorResponse_File::set_insertion_point(const ::std::string& value)
   insertion_point_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
   // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)
 }
+#if LANG_CXX11
+void CodeGeneratorResponse_File::set_insertion_point(::std::string&& value) {
+  set_has_insertion_point();
+  insertion_point_.SetNoArena(
+    &::google::protobuf::internal::GetEmptyStringAlreadyInited(), std::move(value));
+  // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)
+}
+#endif
 void CodeGeneratorResponse_File::set_insertion_point(const char* value) {
   set_has_insertion_point();
   insertion_point_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -1770,6 +1802,14 @@ void CodeGeneratorResponse_File::set_content(const ::std::string& value) {
   content_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
   // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.content)
 }
+#if LANG_CXX11
+void CodeGeneratorResponse_File::set_content(::std::string&& value) {
+  set_has_content();
+  content_.SetNoArena(
+    &::google::protobuf::internal::GetEmptyStringAlreadyInited(), std::move(value));
+  // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.CodeGeneratorResponse.File.content)
+}
+#endif
 void CodeGeneratorResponse_File::set_content(const char* value) {
   set_has_content();
   content_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -1813,7 +1853,7 @@ const int CodeGeneratorResponse::kFileFieldNumber;
 CodeGeneratorResponse::CodeGeneratorResponse()
   : ::google::protobuf::Message(), _internal_metadata_(NULL) {
   if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
-    protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto();
+    protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::InitDefaults();
   }
   SharedCtor();
   // @@protoc_insertion_point(constructor:google.protobuf.compiler.CodeGeneratorResponse)
@@ -1852,12 +1892,12 @@ void CodeGeneratorResponse::SetCachedSize(int size) const {
   GOOGLE_SAFE_CONCURRENT_WRITES_END();
 }
 const ::google::protobuf::Descriptor* CodeGeneratorResponse::descriptor() {
-  protobuf_AssignDescriptorsOnce();
-  return file_level_metadata[3].descriptor;
+  protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::protobuf_AssignDescriptorsOnce();
+  return protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::file_level_metadata[3].descriptor;
 }
 
 const CodeGeneratorResponse& CodeGeneratorResponse::default_instance() {
-  protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto();
+  protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::InitDefaults();
   return *internal_default_instance();
 }
 
@@ -1968,7 +2008,7 @@ void CodeGeneratorResponse::SerializeWithCachedSizes(
 
 ::google::protobuf::uint8* CodeGeneratorResponse::InternalSerializeWithCachedSizesToArray(
     bool deterministic, ::google::protobuf::uint8* target) const {
-  (void)deterministic; // Unused
+  (void)deterministic;  // Unused
   // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.compiler.CodeGeneratorResponse)
   // optional string error = 1;
   if (has_error()) {
@@ -2087,8 +2127,8 @@ void CodeGeneratorResponse::InternalSwap(CodeGeneratorResponse* other) {
 }
 
 ::google::protobuf::Metadata CodeGeneratorResponse::GetMetadata() const {
-  protobuf_AssignDescriptorsOnce();
-  return file_level_metadata[3];
+  protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::protobuf_AssignDescriptorsOnce();
+  return protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::file_level_metadata[3];
 }
 
 #if PROTOBUF_INLINE_NOT_IN_HEADERS
@@ -2117,6 +2157,14 @@ void CodeGeneratorResponse::set_error(const ::std::string& value) {
   error_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
   // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.error)
 }
+#if LANG_CXX11
+void CodeGeneratorResponse::set_error(::std::string&& value) {
+  set_has_error();
+  error_.SetNoArena(
+    &::google::protobuf::internal::GetEmptyStringAlreadyInited(), std::move(value));
+  // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.CodeGeneratorResponse.error)
+}
+#endif
 void CodeGeneratorResponse::set_error(const char* value) {
   set_has_error();
   error_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));

+ 124 - 62
src/google/protobuf/compiler/plugin.pb.h

@@ -19,6 +19,7 @@
 #error regenerate this file with a newer version of protoc.
 #endif
 
+#include <google/protobuf/io/coded_stream.h>
 #include <google/protobuf/arena.h>
 #include <google/protobuf/arenastring.h>
 #include <google/protobuf/generated_message_util.h>
@@ -127,9 +128,16 @@ namespace google {
 namespace protobuf {
 namespace compiler {
 
+namespace protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto {
 // Internal implementation detail -- do not call these.
-void LIBPROTOC_EXPORT protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto();
-void LIBPROTOC_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto();
+struct LIBPROTOC_EXPORT TableStruct {
+  static const ::google::protobuf::uint32 offsets[];
+  static void InitDefaultsImpl();
+  static void Shutdown();
+};
+void LIBPROTOC_EXPORT AddDescriptors();
+void LIBPROTOC_EXPORT InitDefaults();
+}  // namespace protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto
 
 // ===================================================================
 
@@ -184,7 +192,8 @@ class LIBPROTOC_EXPORT Version : public ::google::protobuf::Message /* @@protoc_
       bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
   ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
       const PROTOBUF_FINAL {
-    return InternalSerializeWithCachedSizesToArray(false, output);
+    return InternalSerializeWithCachedSizesToArray(
+        ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
   }
   int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
   private:
@@ -207,6 +216,21 @@ class LIBPROTOC_EXPORT Version : public ::google::protobuf::Message /* @@protoc_
 
   // accessors -------------------------------------------------------
 
+  // optional string suffix = 4;
+  bool has_suffix() const;
+  void clear_suffix();
+  static const int kSuffixFieldNumber = 4;
+  const ::std::string& suffix() const;
+  void set_suffix(const ::std::string& value);
+  #if LANG_CXX11
+  void set_suffix(::std::string&& value);
+  #endif
+  void set_suffix(const char* value);
+  void set_suffix(const char* value, size_t size);
+  ::std::string* mutable_suffix();
+  ::std::string* release_suffix();
+  void set_allocated_suffix(::std::string* suffix);
+
   // optional int32 major = 1;
   bool has_major() const;
   void clear_major();
@@ -228,18 +252,6 @@ class LIBPROTOC_EXPORT Version : public ::google::protobuf::Message /* @@protoc_
   ::google::protobuf::int32 patch() const;
   void set_patch(::google::protobuf::int32 value);
 
-  // optional string suffix = 4;
-  bool has_suffix() const;
-  void clear_suffix();
-  static const int kSuffixFieldNumber = 4;
-  const ::std::string& suffix() const;
-  void set_suffix(const ::std::string& value);
-  void set_suffix(const char* value);
-  void set_suffix(const char* value, size_t size);
-  ::std::string* mutable_suffix();
-  ::std::string* release_suffix();
-  void set_allocated_suffix(::std::string* suffix);
-
   // @@protoc_insertion_point(class_scope:google.protobuf.compiler.Version)
  private:
   void set_has_major();
@@ -258,11 +270,7 @@ class LIBPROTOC_EXPORT Version : public ::google::protobuf::Message /* @@protoc_
   ::google::protobuf::int32 major_;
   ::google::protobuf::int32 minor_;
   ::google::protobuf::int32 patch_;
-  friend void LIBPROTOC_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl();
-  friend void LIBPROTOC_EXPORT protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl();
-  friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fcompiler_2fplugin_2eproto();
-  friend void protobuf_ShutdownFile_google_2fprotobuf_2fcompiler_2fplugin_2eproto();
-
+  friend struct LIBPROTOC_EXPORT protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::TableStruct;
 };
 // -------------------------------------------------------------------
 
@@ -317,7 +325,8 @@ class LIBPROTOC_EXPORT CodeGeneratorRequest : public ::google::protobuf::Message
       bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
   ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
       const PROTOBUF_FINAL {
-    return InternalSerializeWithCachedSizesToArray(false, output);
+    return InternalSerializeWithCachedSizesToArray(
+        ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
   }
   int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
   private:
@@ -356,18 +365,6 @@ class LIBPROTOC_EXPORT CodeGeneratorRequest : public ::google::protobuf::Message
   const ::google::protobuf::RepeatedPtrField< ::std::string>& file_to_generate() const;
   ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_file_to_generate();
 
-  // optional string parameter = 2;
-  bool has_parameter() const;
-  void clear_parameter();
-  static const int kParameterFieldNumber = 2;
-  const ::std::string& parameter() const;
-  void set_parameter(const ::std::string& value);
-  void set_parameter(const char* value);
-  void set_parameter(const char* value, size_t size);
-  ::std::string* mutable_parameter();
-  ::std::string* release_parameter();
-  void set_allocated_parameter(::std::string* parameter);
-
   // repeated .google.protobuf.FileDescriptorProto proto_file = 15;
   int proto_file_size() const;
   void clear_proto_file();
@@ -380,6 +377,21 @@ class LIBPROTOC_EXPORT CodeGeneratorRequest : public ::google::protobuf::Message
   const ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto >&
       proto_file() const;
 
+  // optional string parameter = 2;
+  bool has_parameter() const;
+  void clear_parameter();
+  static const int kParameterFieldNumber = 2;
+  const ::std::string& parameter() const;
+  void set_parameter(const ::std::string& value);
+  #if LANG_CXX11
+  void set_parameter(::std::string&& value);
+  #endif
+  void set_parameter(const char* value);
+  void set_parameter(const char* value, size_t size);
+  ::std::string* mutable_parameter();
+  ::std::string* release_parameter();
+  void set_allocated_parameter(::std::string* parameter);
+
   // optional .google.protobuf.compiler.Version compiler_version = 3;
   bool has_compiler_version() const;
   void clear_compiler_version();
@@ -403,11 +415,7 @@ class LIBPROTOC_EXPORT CodeGeneratorRequest : public ::google::protobuf::Message
   ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto > proto_file_;
   ::google::protobuf::internal::ArenaStringPtr parameter_;
   ::google::protobuf::compiler::Version* compiler_version_;
-  friend void LIBPROTOC_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl();
-  friend void LIBPROTOC_EXPORT protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl();
-  friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fcompiler_2fplugin_2eproto();
-  friend void protobuf_ShutdownFile_google_2fprotobuf_2fcompiler_2fplugin_2eproto();
-
+  friend struct LIBPROTOC_EXPORT protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::TableStruct;
 };
 // -------------------------------------------------------------------
 
@@ -462,7 +470,8 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse_File : public ::google::protobuf::M
       bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
   ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
       const PROTOBUF_FINAL {
-    return InternalSerializeWithCachedSizesToArray(false, output);
+    return InternalSerializeWithCachedSizesToArray(
+        ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
   }
   int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
   private:
@@ -491,6 +500,9 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse_File : public ::google::protobuf::M
   static const int kNameFieldNumber = 1;
   const ::std::string& name() const;
   void set_name(const ::std::string& value);
+  #if LANG_CXX11
+  void set_name(::std::string&& value);
+  #endif
   void set_name(const char* value);
   void set_name(const char* value, size_t size);
   ::std::string* mutable_name();
@@ -503,6 +515,9 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse_File : public ::google::protobuf::M
   static const int kInsertionPointFieldNumber = 2;
   const ::std::string& insertion_point() const;
   void set_insertion_point(const ::std::string& value);
+  #if LANG_CXX11
+  void set_insertion_point(::std::string&& value);
+  #endif
   void set_insertion_point(const char* value);
   void set_insertion_point(const char* value, size_t size);
   ::std::string* mutable_insertion_point();
@@ -515,6 +530,9 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse_File : public ::google::protobuf::M
   static const int kContentFieldNumber = 15;
   const ::std::string& content() const;
   void set_content(const ::std::string& value);
+  #if LANG_CXX11
+  void set_content(::std::string&& value);
+  #endif
   void set_content(const char* value);
   void set_content(const char* value, size_t size);
   ::std::string* mutable_content();
@@ -536,11 +554,7 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse_File : public ::google::protobuf::M
   ::google::protobuf::internal::ArenaStringPtr name_;
   ::google::protobuf::internal::ArenaStringPtr insertion_point_;
   ::google::protobuf::internal::ArenaStringPtr content_;
-  friend void LIBPROTOC_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl();
-  friend void LIBPROTOC_EXPORT protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl();
-  friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fcompiler_2fplugin_2eproto();
-  friend void protobuf_ShutdownFile_google_2fprotobuf_2fcompiler_2fplugin_2eproto();
-
+  friend struct LIBPROTOC_EXPORT protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::TableStruct;
 };
 // -------------------------------------------------------------------
 
@@ -595,7 +609,8 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse : public ::google::protobuf::Messag
       bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
   ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
       const PROTOBUF_FINAL {
-    return InternalSerializeWithCachedSizesToArray(false, output);
+    return InternalSerializeWithCachedSizesToArray(
+        ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
   }
   int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
   private:
@@ -620,18 +635,6 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse : public ::google::protobuf::Messag
 
   // accessors -------------------------------------------------------
 
-  // optional string error = 1;
-  bool has_error() const;
-  void clear_error();
-  static const int kErrorFieldNumber = 1;
-  const ::std::string& error() const;
-  void set_error(const ::std::string& value);
-  void set_error(const char* value);
-  void set_error(const char* value, size_t size);
-  ::std::string* mutable_error();
-  ::std::string* release_error();
-  void set_allocated_error(::std::string* error);
-
   // repeated .google.protobuf.compiler.CodeGeneratorResponse.File file = 15;
   int file_size() const;
   void clear_file();
@@ -644,6 +647,21 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse : public ::google::protobuf::Messag
   const ::google::protobuf::RepeatedPtrField< ::google::protobuf::compiler::CodeGeneratorResponse_File >&
       file() const;
 
+  // optional string error = 1;
+  bool has_error() const;
+  void clear_error();
+  static const int kErrorFieldNumber = 1;
+  const ::std::string& error() const;
+  void set_error(const ::std::string& value);
+  #if LANG_CXX11
+  void set_error(::std::string&& value);
+  #endif
+  void set_error(const char* value);
+  void set_error(const char* value, size_t size);
+  ::std::string* mutable_error();
+  ::std::string* release_error();
+  void set_allocated_error(::std::string* error);
+
   // @@protoc_insertion_point(class_scope:google.protobuf.compiler.CodeGeneratorResponse)
  private:
   void set_has_error();
@@ -654,11 +672,7 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse : public ::google::protobuf::Messag
   mutable int _cached_size_;
   ::google::protobuf::RepeatedPtrField< ::google::protobuf::compiler::CodeGeneratorResponse_File > file_;
   ::google::protobuf::internal::ArenaStringPtr error_;
-  friend void LIBPROTOC_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl();
-  friend void LIBPROTOC_EXPORT protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl();
-  friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fcompiler_2fplugin_2eproto();
-  friend void protobuf_ShutdownFile_google_2fprotobuf_2fcompiler_2fplugin_2eproto();
-
+  friend struct LIBPROTOC_EXPORT protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::TableStruct;
 };
 // ===================================================================
 
@@ -763,6 +777,14 @@ inline void Version::set_suffix(const ::std::string& value) {
   suffix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
   // @@protoc_insertion_point(field_set:google.protobuf.compiler.Version.suffix)
 }
+#if LANG_CXX11
+inline void Version::set_suffix(::std::string&& value) {
+  set_has_suffix();
+  suffix_.SetNoArena(
+    &::google::protobuf::internal::GetEmptyStringAlreadyInited(), std::move(value));
+  // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.Version.suffix)
+}
+#endif
 inline void Version::set_suffix(const char* value) {
   set_has_suffix();
   suffix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -876,6 +898,14 @@ inline void CodeGeneratorRequest::set_parameter(const ::std::string& value) {
   parameter_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
   // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorRequest.parameter)
 }
+#if LANG_CXX11
+inline void CodeGeneratorRequest::set_parameter(::std::string&& value) {
+  set_has_parameter();
+  parameter_.SetNoArena(
+    &::google::protobuf::internal::GetEmptyStringAlreadyInited(), std::move(value));
+  // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.CodeGeneratorRequest.parameter)
+}
+#endif
 inline void CodeGeneratorRequest::set_parameter(const char* value) {
   set_has_parameter();
   parameter_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -1009,6 +1039,14 @@ inline void CodeGeneratorResponse_File::set_name(const ::std::string& value) {
   name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
   // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.name)
 }
+#if LANG_CXX11
+inline void CodeGeneratorResponse_File::set_name(::std::string&& value) {
+  set_has_name();
+  name_.SetNoArena(
+    &::google::protobuf::internal::GetEmptyStringAlreadyInited(), std::move(value));
+  // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.CodeGeneratorResponse.File.name)
+}
+#endif
 inline void CodeGeneratorResponse_File::set_name(const char* value) {
   set_has_name();
   name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -1063,6 +1101,14 @@ inline void CodeGeneratorResponse_File::set_insertion_point(const ::std::string&
   insertion_point_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
   // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)
 }
+#if LANG_CXX11
+inline void CodeGeneratorResponse_File::set_insertion_point(::std::string&& value) {
+  set_has_insertion_point();
+  insertion_point_.SetNoArena(
+    &::google::protobuf::internal::GetEmptyStringAlreadyInited(), std::move(value));
+  // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)
+}
+#endif
 inline void CodeGeneratorResponse_File::set_insertion_point(const char* value) {
   set_has_insertion_point();
   insertion_point_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -1117,6 +1163,14 @@ inline void CodeGeneratorResponse_File::set_content(const ::std::string& value)
   content_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
   // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.content)
 }
+#if LANG_CXX11
+inline void CodeGeneratorResponse_File::set_content(::std::string&& value) {
+  set_has_content();
+  content_.SetNoArena(
+    &::google::protobuf::internal::GetEmptyStringAlreadyInited(), std::move(value));
+  // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.CodeGeneratorResponse.File.content)
+}
+#endif
 inline void CodeGeneratorResponse_File::set_content(const char* value) {
   set_has_content();
   content_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -1175,6 +1229,14 @@ inline void CodeGeneratorResponse::set_error(const ::std::string& value) {
   error_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
   // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.error)
 }
+#if LANG_CXX11
+inline void CodeGeneratorResponse::set_error(::std::string&& value) {
+  set_has_error();
+  error_.SetNoArena(
+    &::google::protobuf::internal::GetEmptyStringAlreadyInited(), std::move(value));
+  // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.CodeGeneratorResponse.error)
+}
+#endif
 inline void CodeGeneratorResponse::set_error(const char* value) {
   set_has_error();
   error_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));

+ 8 - 0
src/google/protobuf/descriptor.cc

@@ -4114,6 +4114,14 @@ const FileDescriptor* DescriptorBuilder::BuildFileImpl(
       dependency = pool_->underlay_->FindFileByName(proto.dependency(i));
     }
 
+    if (dependency == result) {
+      // Recursive import.  dependency/result is not fully initialized, and it's
+      // dangerous to try to do anything with it.  The recursive import error
+      // will be detected and reported in DescriptorBuilder::BuildFile().
+      tables_->RollbackToLastCheckpoint();
+      return NULL;
+    }
+
     if (dependency == NULL) {
       if (pool_->allow_unknown_ ||
           (!pool_->enforce_weak_ && weak_deps.find(i) != weak_deps.end())) {

Різницю між файлами не показано, бо вона завелика
+ 443 - 443
src/google/protobuf/descriptor.pb.cc


Різницю між файлами не показано, бо вона завелика
+ 309 - 274
src/google/protobuf/descriptor.pb.h


+ 5 - 1
src/google/protobuf/descriptor.proto

@@ -139,7 +139,11 @@ message FieldDescriptorProto {
     TYPE_FIXED32        = 7;
     TYPE_BOOL           = 8;
     TYPE_STRING         = 9;
-    TYPE_GROUP          = 10;  // Tag-delimited aggregate.
+    // Tag-delimited aggregate.
+    // Group type is deprecated and not supported in proto3. However, Proto3
+    // implementations should still be able to parse the group wire format and
+    // treat group fields as unknown fields.
+    TYPE_GROUP          = 10;
     TYPE_MESSAGE        = 11;  // Length-delimited aggregate.
 
     // New in version 2.

+ 42 - 42
src/google/protobuf/duration.pb.cc

@@ -19,8 +19,11 @@
 
 namespace google {
 namespace protobuf {
-class DurationDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Duration> {};
-DurationDefaultTypeInternal _Duration_default_instance_;
+class DurationDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Duration> {
+} _Duration_default_instance_;
+
+namespace protobuf_google_2fprotobuf_2fduration_2eproto {
+
 
 namespace {
 
@@ -28,35 +31,30 @@ namespace {
 
 }  // namespace
 
-
-const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fduration_2eproto() GOOGLE_ATTRIBUTE_COLD;
-const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fduration_2eproto() {
-  static const ::google::protobuf::uint32 offsets[] = {
-    ~0u,  // no _has_bits_
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Duration, _internal_metadata_),
-    ~0u,  // no _extensions_
-    ~0u,  // no _oneof_case_
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Duration, seconds_),
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Duration, nanos_),
-  };
-  return offsets;
-}
+const ::google::protobuf::uint32 TableStruct::offsets[] = {
+  ~0u,  // no _has_bits_
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Duration, _internal_metadata_),
+  ~0u,  // no _extensions_
+  ~0u,  // no _oneof_case_
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Duration, seconds_),
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Duration, nanos_),
+};
 
 static const ::google::protobuf::internal::MigrationSchema schemas[] = {
   { 0, -1, sizeof(Duration)},
 };
 
-static const ::google::protobuf::internal::DefaultInstanceData file_default_instances[] = {
-  {reinterpret_cast<const ::google::protobuf::Message*>(&_Duration_default_instance_), NULL},
+static ::google::protobuf::Message const * const file_default_instances[] = {
+  reinterpret_cast<const ::google::protobuf::Message*>(&_Duration_default_instance_),
 };
 
 namespace {
 
 void protobuf_AssignDescriptors() {
-  protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto();
+  AddDescriptors();
   ::google::protobuf::MessageFactory* factory = NULL;
   AssignDescriptors(
-      "google/protobuf/duration.proto", schemas, file_default_instances, protobuf_Offsets_google_2fprotobuf_2fduration_2eproto(), factory,
+      "google/protobuf/duration.proto", schemas, file_default_instances, TableStruct::offsets, factory,
       file_level_metadata, NULL, NULL);
 }
 
@@ -73,24 +71,24 @@ void protobuf_RegisterTypes(const ::std::string&) {
 
 }  // namespace
 
-void protobuf_ShutdownFile_google_2fprotobuf_2fduration_2eproto() {
+void TableStruct::Shutdown() {
   _Duration_default_instance_.Shutdown();
   delete file_level_metadata[0].reflection;
 }
 
-void protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto_impl() {
+void TableStruct::InitDefaultsImpl() {
   GOOGLE_PROTOBUF_VERIFY_VERSION;
 
   ::google::protobuf::internal::InitProtobufDefaults();
   _Duration_default_instance_.DefaultConstruct();
 }
 
-void protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto() {
+void InitDefaults() {
   static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
-  ::google::protobuf::GoogleOnceInit(&once, &protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto_impl);
+  ::google::protobuf::GoogleOnceInit(&once, &TableStruct::InitDefaultsImpl);
 }
-void protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto_impl() {
-  protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto();
+void AddDescriptorsImpl() {
+  InitDefaults();
   static const char descriptor[] = {
       "\n\036google/protobuf/duration.proto\022\017google"
       ".protobuf\"*\n\010Duration\022\017\n\007seconds\030\001 \001(\003\022\r"
@@ -103,20 +101,22 @@ void protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto_impl() {
       descriptor, 227);
   ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
     "google/protobuf/duration.proto", &protobuf_RegisterTypes);
-  ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fduration_2eproto);
+  ::google::protobuf::internal::OnShutdown(&TableStruct::Shutdown);
 }
 
-GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto_once_);
-void protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto() {
-  ::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto_once_,
-                 &protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto_impl);
+void AddDescriptors() {
+  static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
+  ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl);
 }
 // Force AddDescriptors() to be called at static initialization time.
-struct StaticDescriptorInitializer_google_2fprotobuf_2fduration_2eproto {
-  StaticDescriptorInitializer_google_2fprotobuf_2fduration_2eproto() {
-    protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto();
+struct StaticDescriptorInitializer {
+  StaticDescriptorInitializer() {
+    AddDescriptors();
   }
-} static_descriptor_initializer_google_2fprotobuf_2fduration_2eproto_;
+} static_descriptor_initializer;
+
+}  // namespace protobuf_google_2fprotobuf_2fduration_2eproto
+
 
 // ===================================================================
 
@@ -128,7 +128,7 @@ const int Duration::kNanosFieldNumber;
 Duration::Duration()
   : ::google::protobuf::Message(), _internal_metadata_(NULL) {
   if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
-    protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto();
+    protobuf_google_2fprotobuf_2fduration_2eproto::InitDefaults();
   }
   SharedCtor();
   // @@protoc_insertion_point(constructor:google.protobuf.Duration)
@@ -137,7 +137,7 @@ Duration::Duration(::google::protobuf::Arena* arena)
   : ::google::protobuf::Message(),
   _internal_metadata_(arena) {
 #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
-  protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto();
+  protobuf_google_2fprotobuf_2fduration_2eproto::InitDefaults();
 #endif  // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
   SharedCtor();
   RegisterArenaDtor(arena);
@@ -185,12 +185,12 @@ void Duration::SetCachedSize(int size) const {
   GOOGLE_SAFE_CONCURRENT_WRITES_END();
 }
 const ::google::protobuf::Descriptor* Duration::descriptor() {
-  protobuf_AssignDescriptorsOnce();
-  return file_level_metadata[0].descriptor;
+  protobuf_google_2fprotobuf_2fduration_2eproto::protobuf_AssignDescriptorsOnce();
+  return protobuf_google_2fprotobuf_2fduration_2eproto::file_level_metadata[0].descriptor;
 }
 
 const Duration& Duration::default_instance() {
-  protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto();
+  protobuf_google_2fprotobuf_2fduration_2eproto::InitDefaults();
   return *internal_default_instance();
 }
 
@@ -279,7 +279,7 @@ void Duration::SerializeWithCachedSizes(
 
 ::google::protobuf::uint8* Duration::InternalSerializeWithCachedSizesToArray(
     bool deterministic, ::google::protobuf::uint8* target) const {
-  (void)deterministic; // Unused
+  (void)deterministic;  // Unused
   // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Duration)
   // int64 seconds = 1;
   if (this->seconds() != 0) {
@@ -391,8 +391,8 @@ void Duration::InternalSwap(Duration* other) {
 }
 
 ::google::protobuf::Metadata Duration::GetMetadata() const {
-  protobuf_AssignDescriptorsOnce();
-  return file_level_metadata[0];
+  protobuf_google_2fprotobuf_2fduration_2eproto::protobuf_AssignDescriptorsOnce();
+  return protobuf_google_2fprotobuf_2fduration_2eproto::file_level_metadata[0];
 }
 
 #if PROTOBUF_INLINE_NOT_IN_HEADERS

+ 13 - 8
src/google/protobuf/duration.pb.h

@@ -19,6 +19,7 @@
 #error regenerate this file with a newer version of protoc.
 #endif
 
+#include <google/protobuf/io/coded_stream.h>
 #include <google/protobuf/arena.h>
 #include <google/protobuf/arenastring.h>
 #include <google/protobuf/generated_message_util.h>
@@ -39,9 +40,16 @@ LIBPROTOBUF_EXPORT extern DurationDefaultTypeInternal _Duration_default_instance
 namespace google {
 namespace protobuf {
 
+namespace protobuf_google_2fprotobuf_2fduration_2eproto {
 // Internal implementation detail -- do not call these.
-void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto();
-void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto();
+struct LIBPROTOBUF_EXPORT TableStruct {
+  static const ::google::protobuf::uint32 offsets[];
+  static void InitDefaultsImpl();
+  static void Shutdown();
+};
+void LIBPROTOBUF_EXPORT AddDescriptors();
+void LIBPROTOBUF_EXPORT InitDefaults();
+}  // namespace protobuf_google_2fprotobuf_2fduration_2eproto
 
 // ===================================================================
 
@@ -95,7 +103,8 @@ class LIBPROTOBUF_EXPORT Duration : public ::google::protobuf::Message /* @@prot
       bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
   ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
       const PROTOBUF_FINAL {
-    return InternalSerializeWithCachedSizesToArray(false, output);
+    return InternalSerializeWithCachedSizesToArray(
+        ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
   }
   int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
   private:
@@ -145,11 +154,7 @@ class LIBPROTOBUF_EXPORT Duration : public ::google::protobuf::Message /* @@prot
   ::google::protobuf::int64 seconds_;
   ::google::protobuf::int32 nanos_;
   mutable int _cached_size_;
-  friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto_impl();
-  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto_impl();
-  friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fduration_2eproto();
-  friend void protobuf_ShutdownFile_google_2fprotobuf_2fduration_2eproto();
-
+  friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fduration_2eproto::TableStruct;
 };
 // ===================================================================
 

+ 27 - 36
src/google/protobuf/dynamic_message.cc

@@ -239,13 +239,11 @@ class DynamicMessage : public Message {
     // looking back at this field. This would assume details about the
     // implementation of scoped_ptr.
     const DynamicMessage* prototype;
-    void* default_oneof_instance;
 
-    TypeInfo() : prototype(NULL), default_oneof_instance(NULL) {}
+    TypeInfo() : prototype(NULL) {}
 
     ~TypeInfo() {
       delete prototype;
-      operator delete(default_oneof_instance);
     }
   };
 
@@ -448,8 +446,8 @@ DynamicMessage::~DynamicMessage() {
             case FieldOptions::STRING: {
               const ::std::string* default_value =
                   &(reinterpret_cast<const ArenaStringPtr*>(
-                        reinterpret_cast<uint8*>(
-                            type_info_->default_oneof_instance) +
+                        reinterpret_cast<const uint8*>(
+                            type_info_->prototype) +
                         type_info_->offsets[i])
                         ->Get());
               reinterpret_cast<ArenaStringPtr*>(field_ptr)->Destroy(
@@ -539,10 +537,6 @@ void DynamicMessage::CrossLinkPrototypes() {
   for (int i = 0; i < descriptor->field_count(); i++) {
     const FieldDescriptor* field = descriptor->field(i);
     void* field_ptr = OffsetToPointer(type_info_->offsets[i]);
-    if (field->containing_oneof()) {
-      field_ptr = reinterpret_cast<uint8*>(
-          type_info_->default_oneof_instance) + type_info_->offsets[i];
-    }
 
     if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE &&
         !field->is_repeated()) {
@@ -614,7 +608,7 @@ DynamicMessageFactory::~DynamicMessageFactory() {
        iter != prototypes_->map_.end(); ++iter) {
     DeleteDefaultOneofInstance(iter->second->type,
                                iter->second->offsets.get(),
-                               iter->second->default_oneof_instance);
+                               iter->second->prototype);
     delete iter->second;
   }
 }
@@ -725,46 +719,44 @@ const Message* DynamicMessageFactory::GetPrototypeNoLock(
 
   // Align the final size to make sure no clever allocators think that
   // alignment is not necessary.
-  size = AlignOffset(size);
   type_info->size = size;
 
-  // Allocate the prototype.
-  void* base = operator new(size);
-  memset(base, 0, size);
-  // The prototype in type_info has to be set before creating the prototype
-  // instance on memory. e.g., message Foo { map<int32, Foo> a = 1; }. When
-  // creating prototype for Foo, prototype of the map entry will also be
-  // created, which needs the address of the prototype of Foo (the value in
-  // map). To break the cyclic dependency, we have to assgin the address of
-  // prototype into type_info first.
-  type_info->prototype = static_cast<DynamicMessage*>(base);
-  DynamicMessage* prototype = new(base) DynamicMessage(type_info);
 
   // Construct the reflection object.
 
-  void* default_oneof_instance = NULL;
-  int oneof_case_offset = -1;
-
   if (type->oneof_decl_count() > 0) {
     // Compute the size of default oneof instance and offsets of default
     // oneof fields.
-    int oneof_size = 0;
     for (int i = 0; i < type->oneof_decl_count(); i++) {
       for (int j = 0; j < type->oneof_decl(i)->field_count(); j++) {
         const FieldDescriptor* field = type->oneof_decl(i)->field(j);
         int field_size = OneofFieldSpaceUsed(field);
-        oneof_size = AlignTo(oneof_size, std::min(kSafeAlignment, field_size));
-        offsets[field->index()] = oneof_size;
-        oneof_size += field_size;
+        size = AlignTo(size, std::min(kSafeAlignment, field_size));
+        offsets[field->index()] = size;
+        size += field_size;
       }
     }
+  }
+  size = AlignOffset(size);
+
+  // Allocate the prototype + oneof fields.
+  void* base = operator new(size);
+  memset(base, 0, size);
+
+  // The prototype in type_info has to be set before creating the prototype
+  // instance on memory. e.g., message Foo { map<int32, Foo> a = 1; }. When
+  // creating prototype for Foo, prototype of the map entry will also be
+  // created, which needs the address of the prototype of Foo (the value in
+  // map). To break the cyclic dependency, we have to assgin the address of
+  // prototype into type_info first.
+  type_info->prototype = static_cast<DynamicMessage*>(base);
+  DynamicMessage* prototype = new(base) DynamicMessage(type_info);
+
+  if (type->oneof_decl_count() > 0) {
     // Construct default oneof instance.
-    type_info->default_oneof_instance = ::operator new(oneof_size);
     ConstructDefaultOneofInstance(type_info->type,
                                   type_info->offsets.get(),
-                                  type_info->default_oneof_instance);
-    default_oneof_instance = type_info->default_oneof_instance;
-    oneof_case_offset = type_info->oneof_case_offset;
+                                  prototype);
   }
 
   internal::ReflectionSchema schema = {
@@ -774,8 +766,7 @@ const Message* DynamicMessageFactory::GetPrototypeNoLock(
       type_info->has_bits_offset,
       type_info->internal_metadata_offset,
       type_info->extensions_offset,
-      default_oneof_instance,
-      oneof_case_offset,
+      type_info->oneof_case_offset,
       type_info->size};
 
   type_info->reflection.reset(new GeneratedMessageReflection(
@@ -836,7 +827,7 @@ void DynamicMessageFactory::ConstructDefaultOneofInstance(
 void DynamicMessageFactory::DeleteDefaultOneofInstance(
     const Descriptor* type,
     const uint32 offsets[],
-    void* default_oneof_instance) {
+    const void* default_oneof_instance) {
   for (int i = 0; i < type->oneof_decl_count(); i++) {
     for (int j = 0; j < type->oneof_decl(i)->field_count(); j++) {
       const FieldDescriptor* field = type->oneof_decl(i)->field(j);

+ 85 - 1
src/google/protobuf/dynamic_message.h

@@ -38,12 +38,15 @@
 #ifndef GOOGLE_PROTOBUF_DYNAMIC_MESSAGE_H__
 #define GOOGLE_PROTOBUF_DYNAMIC_MESSAGE_H__
 
+#include <algorithm>
 #include <memory>
 #ifndef _SHARED_PTR_H
 #include <google/protobuf/stubs/shared_ptr.h>
 #endif
+#include <vector>
 
 #include <google/protobuf/message.h>
+#include <google/protobuf/repeated_field.h>
 #include <google/protobuf/stubs/common.h>
 #include <google/protobuf/stubs/mutex.h>
 
@@ -141,11 +144,92 @@ class LIBPROTOBUF_EXPORT DynamicMessageFactory : public MessageFactory {
   // Delete default oneof instance. Called by ~DynamicMessageFactory.
   static void DeleteDefaultOneofInstance(const Descriptor* type,
                                          const uint32 offsets[],
-                                         void* default_oneof_instance);
+                                         const void* default_oneof_instance);
 
   GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(DynamicMessageFactory);
 };
 
+// Helper for computing a sorted list of map entries via reflection.
+class LIBPROTOBUF_EXPORT DynamicMapSorter {
+ public:
+  static std::vector<const Message*> Sort(const Message& message,
+                                          int map_size,
+                                          const Reflection* reflection,
+                                          const FieldDescriptor* field) {
+    std::vector<const Message*> result(map_size);
+    const RepeatedPtrField<Message>& map_field =
+        reflection->GetRepeatedPtrField<Message>(message, field);
+    int i = 0;
+    for (RepeatedPtrField<Message>::const_pointer_iterator it =
+             map_field.pointer_begin(); it != map_field.pointer_end(); ) {
+      result[i++] = *it++;
+    }
+    GOOGLE_DCHECK_EQ(result.size(), static_cast<size_t>(i));
+    MapEntryMessageComparator comparator(field->message_type());
+    std::sort(result.begin(), result.end(), comparator);
+    // Complain if the keys aren't in ascending order.
+#ifndef NDEBUG
+    for (int j = 1; j < map_size; j++) {
+      if (!comparator(result[j - 1], result[j])) {
+        GOOGLE_LOG(ERROR) << (comparator(result[j], result[j - 1]) ?
+                       "internal error in map key sorting" :
+                       "map keys are not unique");
+      }
+    }
+#endif
+    return result;
+  }
+
+ private:
+  class LIBPROTOBUF_EXPORT MapEntryMessageComparator {
+   public:
+    explicit MapEntryMessageComparator(const Descriptor* descriptor)
+        : field_(descriptor->field(0)) {}
+
+    bool operator()(const Message* a, const Message* b) {
+      const Reflection* reflection = a->GetReflection();
+      switch (field_->cpp_type()) {
+        case FieldDescriptor::CPPTYPE_BOOL: {
+          bool first = reflection->GetBool(*a, field_);
+          bool second = reflection->GetBool(*b, field_);
+          return first < second;
+        }
+        case FieldDescriptor::CPPTYPE_INT32: {
+          int32 first = reflection->GetInt32(*a, field_);
+          int32 second = reflection->GetInt32(*b, field_);
+          return first < second;
+        }
+        case FieldDescriptor::CPPTYPE_INT64: {
+          int64 first = reflection->GetInt64(*a, field_);
+          int64 second = reflection->GetInt64(*b, field_);
+          return first < second;
+        }
+        case FieldDescriptor::CPPTYPE_UINT32: {
+          uint32 first = reflection->GetUInt32(*a, field_);
+          uint32 second = reflection->GetUInt32(*b, field_);
+          return first < second;
+        }
+        case FieldDescriptor::CPPTYPE_UINT64: {
+          uint64 first = reflection->GetUInt64(*a, field_);
+          uint64 second = reflection->GetUInt64(*b, field_);
+          return first < second;
+        }
+        case FieldDescriptor::CPPTYPE_STRING: {
+          string first = reflection->GetString(*a, field_);
+          string second = reflection->GetString(*b, field_);
+          return first < second;
+        }
+        default:
+          GOOGLE_LOG(DFATAL) << "Invalid key for map field.";
+          return true;
+      }
+    }
+
+   private:
+    const FieldDescriptor* field_;
+  };
+};
+
 }  // namespace protobuf
 
 }  // namespace google

+ 40 - 40
src/google/protobuf/empty.pb.cc

@@ -19,8 +19,11 @@
 
 namespace google {
 namespace protobuf {
-class EmptyDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Empty> {};
-EmptyDefaultTypeInternal _Empty_default_instance_;
+class EmptyDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Empty> {
+} _Empty_default_instance_;
+
+namespace protobuf_google_2fprotobuf_2fempty_2eproto {
+
 
 namespace {
 
@@ -28,33 +31,28 @@ namespace {
 
 }  // namespace
 
-
-const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fempty_2eproto() GOOGLE_ATTRIBUTE_COLD;
-const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fempty_2eproto() {
-  static const ::google::protobuf::uint32 offsets[] = {
-    ~0u,  // no _has_bits_
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Empty, _internal_metadata_),
-    ~0u,  // no _extensions_
-    ~0u,  // no _oneof_case_
-  };
-  return offsets;
-}
+const ::google::protobuf::uint32 TableStruct::offsets[] = {
+  ~0u,  // no _has_bits_
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Empty, _internal_metadata_),
+  ~0u,  // no _extensions_
+  ~0u,  // no _oneof_case_
+};
 
 static const ::google::protobuf::internal::MigrationSchema schemas[] = {
   { 0, -1, sizeof(Empty)},
 };
 
-static const ::google::protobuf::internal::DefaultInstanceData file_default_instances[] = {
-  {reinterpret_cast<const ::google::protobuf::Message*>(&_Empty_default_instance_), NULL},
+static ::google::protobuf::Message const * const file_default_instances[] = {
+  reinterpret_cast<const ::google::protobuf::Message*>(&_Empty_default_instance_),
 };
 
 namespace {
 
 void protobuf_AssignDescriptors() {
-  protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto();
+  AddDescriptors();
   ::google::protobuf::MessageFactory* factory = NULL;
   AssignDescriptors(
-      "google/protobuf/empty.proto", schemas, file_default_instances, protobuf_Offsets_google_2fprotobuf_2fempty_2eproto(), factory,
+      "google/protobuf/empty.proto", schemas, file_default_instances, TableStruct::offsets, factory,
       file_level_metadata, NULL, NULL);
 }
 
@@ -71,24 +69,24 @@ void protobuf_RegisterTypes(const ::std::string&) {
 
 }  // namespace
 
-void protobuf_ShutdownFile_google_2fprotobuf_2fempty_2eproto() {
+void TableStruct::Shutdown() {
   _Empty_default_instance_.Shutdown();
   delete file_level_metadata[0].reflection;
 }
 
-void protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto_impl() {
+void TableStruct::InitDefaultsImpl() {
   GOOGLE_PROTOBUF_VERIFY_VERSION;
 
   ::google::protobuf::internal::InitProtobufDefaults();
   _Empty_default_instance_.DefaultConstruct();
 }
 
-void protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto() {
+void InitDefaults() {
   static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
-  ::google::protobuf::GoogleOnceInit(&once, &protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto_impl);
+  ::google::protobuf::GoogleOnceInit(&once, &TableStruct::InitDefaultsImpl);
 }
-void protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto_impl() {
-  protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto();
+void AddDescriptorsImpl() {
+  InitDefaults();
   static const char descriptor[] = {
       "\n\033google/protobuf/empty.proto\022\017google.pr"
       "otobuf\"\007\n\005EmptyBv\n\023com.google.protobufB\n"
@@ -100,20 +98,22 @@ void protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto_impl() {
       descriptor, 183);
   ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
     "google/protobuf/empty.proto", &protobuf_RegisterTypes);
-  ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fempty_2eproto);
+  ::google::protobuf::internal::OnShutdown(&TableStruct::Shutdown);
 }
 
-GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto_once_);
-void protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto() {
-  ::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto_once_,
-                 &protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto_impl);
+void AddDescriptors() {
+  static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
+  ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl);
 }
 // Force AddDescriptors() to be called at static initialization time.
-struct StaticDescriptorInitializer_google_2fprotobuf_2fempty_2eproto {
-  StaticDescriptorInitializer_google_2fprotobuf_2fempty_2eproto() {
-    protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto();
+struct StaticDescriptorInitializer {
+  StaticDescriptorInitializer() {
+    AddDescriptors();
   }
-} static_descriptor_initializer_google_2fprotobuf_2fempty_2eproto_;
+} static_descriptor_initializer;
+
+}  // namespace protobuf_google_2fprotobuf_2fempty_2eproto
+
 
 // ===================================================================
 
@@ -123,7 +123,7 @@ struct StaticDescriptorInitializer_google_2fprotobuf_2fempty_2eproto {
 Empty::Empty()
   : ::google::protobuf::Message(), _internal_metadata_(NULL) {
   if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
-    protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto();
+    protobuf_google_2fprotobuf_2fempty_2eproto::InitDefaults();
   }
   SharedCtor();
   // @@protoc_insertion_point(constructor:google.protobuf.Empty)
@@ -132,7 +132,7 @@ Empty::Empty(::google::protobuf::Arena* arena)
   : ::google::protobuf::Message(),
   _internal_metadata_(arena) {
 #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
-  protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto();
+  protobuf_google_2fprotobuf_2fempty_2eproto::InitDefaults();
 #endif  // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
   SharedCtor();
   RegisterArenaDtor(arena);
@@ -175,12 +175,12 @@ void Empty::SetCachedSize(int size) const {
   GOOGLE_SAFE_CONCURRENT_WRITES_END();
 }
 const ::google::protobuf::Descriptor* Empty::descriptor() {
-  protobuf_AssignDescriptorsOnce();
-  return file_level_metadata[0].descriptor;
+  protobuf_google_2fprotobuf_2fempty_2eproto::protobuf_AssignDescriptorsOnce();
+  return protobuf_google_2fprotobuf_2fempty_2eproto::file_level_metadata[0].descriptor;
 }
 
 const Empty& Empty::default_instance() {
-  protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto();
+  protobuf_google_2fprotobuf_2fempty_2eproto::InitDefaults();
   return *internal_default_instance();
 }
 
@@ -226,7 +226,7 @@ void Empty::SerializeWithCachedSizes(
 
 ::google::protobuf::uint8* Empty::InternalSerializeWithCachedSizesToArray(
     bool deterministic, ::google::protobuf::uint8* target) const {
-  (void)deterministic; // Unused
+  (void)deterministic;  // Unused
   // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Empty)
   // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Empty)
   return target;
@@ -306,8 +306,8 @@ void Empty::InternalSwap(Empty* other) {
 }
 
 ::google::protobuf::Metadata Empty::GetMetadata() const {
-  protobuf_AssignDescriptorsOnce();
-  return file_level_metadata[0];
+  protobuf_google_2fprotobuf_2fempty_2eproto::protobuf_AssignDescriptorsOnce();
+  return protobuf_google_2fprotobuf_2fempty_2eproto::file_level_metadata[0];
 }
 
 #if PROTOBUF_INLINE_NOT_IN_HEADERS

+ 13 - 8
src/google/protobuf/empty.pb.h

@@ -19,6 +19,7 @@
 #error regenerate this file with a newer version of protoc.
 #endif
 
+#include <google/protobuf/io/coded_stream.h>
 #include <google/protobuf/arena.h>
 #include <google/protobuf/arenastring.h>
 #include <google/protobuf/generated_message_util.h>
@@ -39,9 +40,16 @@ LIBPROTOBUF_EXPORT extern EmptyDefaultTypeInternal _Empty_default_instance_;
 namespace google {
 namespace protobuf {
 
+namespace protobuf_google_2fprotobuf_2fempty_2eproto {
 // Internal implementation detail -- do not call these.
-void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto();
-void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto();
+struct LIBPROTOBUF_EXPORT TableStruct {
+  static const ::google::protobuf::uint32 offsets[];
+  static void InitDefaultsImpl();
+  static void Shutdown();
+};
+void LIBPROTOBUF_EXPORT AddDescriptors();
+void LIBPROTOBUF_EXPORT InitDefaults();
+}  // namespace protobuf_google_2fprotobuf_2fempty_2eproto
 
 // ===================================================================
 
@@ -95,7 +103,8 @@ class LIBPROTOBUF_EXPORT Empty : public ::google::protobuf::Message /* @@protoc_
       bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
   ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
       const PROTOBUF_FINAL {
-    return InternalSerializeWithCachedSizesToArray(false, output);
+    return InternalSerializeWithCachedSizesToArray(
+        ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
   }
   int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
   private:
@@ -131,11 +140,7 @@ class LIBPROTOBUF_EXPORT Empty : public ::google::protobuf::Message /* @@protoc_
   typedef void InternalArenaConstructable_;
   typedef void DestructorSkippable_;
   mutable int _cached_size_;
-  friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto_impl();
-  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto_impl();
-  friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fempty_2eproto();
-  friend void protobuf_ShutdownFile_google_2fprotobuf_2fempty_2eproto();
-
+  friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fempty_2eproto::TableStruct;
 };
 // ===================================================================
 

+ 12 - 6
src/google/protobuf/extension_set_heavy.cc

@@ -35,6 +35,7 @@
 // Contains methods defined in extension_set.h which cannot be part of the
 // lite library because they use descriptors or reflection.
 
+#include <google/protobuf/io/coded_stream.h>
 #include <google/protobuf/io/zero_copy_stream_impl_lite.h>
 #include <google/protobuf/descriptor.h>
 #include <google/protobuf/extension_set.h>
@@ -413,12 +414,16 @@ uint8* ExtensionSet::SerializeWithCachedSizesToArray(int start_field_number,
                                                      int end_field_number,
                                                      uint8* target) const {
   return InternalSerializeWithCachedSizesToArray(
-      start_field_number, end_field_number, false, target);
+      start_field_number, end_field_number,
+      google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(),
+      target);
 }
 
 uint8* ExtensionSet::SerializeMessageSetWithCachedSizesToArray(
     uint8* target) const {
-  return InternalSerializeMessageSetWithCachedSizesToArray(false, target);
+  return InternalSerializeMessageSetWithCachedSizesToArray(
+      google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(),
+      target);
 }
 
 uint8* ExtensionSet::InternalSerializeWithCachedSizesToArray(
@@ -587,11 +592,12 @@ ExtensionSet::Extension::InternalSerializeMessageSetItemWithCachedSizesToArray(
       WireFormatLite::kMessageSetTypeIdNumber, number, target);
   // Write message.
   if (is_lazy) {
-    target = lazymessage_value->WriteMessageToArray(
-        WireFormatLite::kMessageSetMessageNumber, target);
+    target = lazymessage_value->InternalWriteMessageToArray(
+        WireFormatLite::kMessageSetMessageNumber, deterministic, target);
   } else {
-    target = WireFormatLite::WriteMessageToArray(
-        WireFormatLite::kMessageSetMessageNumber, *message_value, target);
+    target = WireFormatLite::InternalWriteMessageToArray(
+        WireFormatLite::kMessageSetMessageNumber, *message_value, deterministic,
+        target);
   }
   // End group.
   target = io::CodedOutputStream::WriteTagToArray(

+ 40 - 40
src/google/protobuf/field_mask.pb.cc

@@ -19,8 +19,11 @@
 
 namespace google {
 namespace protobuf {
-class FieldMaskDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<FieldMask> {};
-FieldMaskDefaultTypeInternal _FieldMask_default_instance_;
+class FieldMaskDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<FieldMask> {
+} _FieldMask_default_instance_;
+
+namespace protobuf_google_2fprotobuf_2ffield_5fmask_2eproto {
+
 
 namespace {
 
@@ -28,34 +31,29 @@ namespace {
 
 }  // namespace
 
-
-const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2ffield_5fmask_2eproto() GOOGLE_ATTRIBUTE_COLD;
-const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2ffield_5fmask_2eproto() {
-  static const ::google::protobuf::uint32 offsets[] = {
-    ~0u,  // no _has_bits_
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldMask, _internal_metadata_),
-    ~0u,  // no _extensions_
-    ~0u,  // no _oneof_case_
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldMask, paths_),
-  };
-  return offsets;
-}
+const ::google::protobuf::uint32 TableStruct::offsets[] = {
+  ~0u,  // no _has_bits_
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldMask, _internal_metadata_),
+  ~0u,  // no _extensions_
+  ~0u,  // no _oneof_case_
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldMask, paths_),
+};
 
 static const ::google::protobuf::internal::MigrationSchema schemas[] = {
   { 0, -1, sizeof(FieldMask)},
 };
 
-static const ::google::protobuf::internal::DefaultInstanceData file_default_instances[] = {
-  {reinterpret_cast<const ::google::protobuf::Message*>(&_FieldMask_default_instance_), NULL},
+static ::google::protobuf::Message const * const file_default_instances[] = {
+  reinterpret_cast<const ::google::protobuf::Message*>(&_FieldMask_default_instance_),
 };
 
 namespace {
 
 void protobuf_AssignDescriptors() {
-  protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto();
+  AddDescriptors();
   ::google::protobuf::MessageFactory* factory = NULL;
   AssignDescriptors(
-      "google/protobuf/field_mask.proto", schemas, file_default_instances, protobuf_Offsets_google_2fprotobuf_2ffield_5fmask_2eproto(), factory,
+      "google/protobuf/field_mask.proto", schemas, file_default_instances, TableStruct::offsets, factory,
       file_level_metadata, NULL, NULL);
 }
 
@@ -72,24 +70,24 @@ void protobuf_RegisterTypes(const ::std::string&) {
 
 }  // namespace
 
-void protobuf_ShutdownFile_google_2fprotobuf_2ffield_5fmask_2eproto() {
+void TableStruct::Shutdown() {
   _FieldMask_default_instance_.Shutdown();
   delete file_level_metadata[0].reflection;
 }
 
-void protobuf_InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto_impl() {
+void TableStruct::InitDefaultsImpl() {
   GOOGLE_PROTOBUF_VERIFY_VERSION;
 
   ::google::protobuf::internal::InitProtobufDefaults();
   _FieldMask_default_instance_.DefaultConstruct();
 }
 
-void protobuf_InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto() {
+void InitDefaults() {
   static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
-  ::google::protobuf::GoogleOnceInit(&once, &protobuf_InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto_impl);
+  ::google::protobuf::GoogleOnceInit(&once, &TableStruct::InitDefaultsImpl);
 }
-void protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto_impl() {
-  protobuf_InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto();
+void AddDescriptorsImpl() {
+  InitDefaults();
   static const char descriptor[] = {
       "\n google/protobuf/field_mask.proto\022\017goog"
       "le.protobuf\"\032\n\tFieldMask\022\r\n\005paths\030\001 \003(\tB"
@@ -102,20 +100,22 @@ void protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto_impl() {
       descriptor, 227);
   ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
     "google/protobuf/field_mask.proto", &protobuf_RegisterTypes);
-  ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2ffield_5fmask_2eproto);
+  ::google::protobuf::internal::OnShutdown(&TableStruct::Shutdown);
 }
 
-GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto_once_);
-void protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto() {
-  ::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto_once_,
-                 &protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto_impl);
+void AddDescriptors() {
+  static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
+  ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl);
 }
 // Force AddDescriptors() to be called at static initialization time.
-struct StaticDescriptorInitializer_google_2fprotobuf_2ffield_5fmask_2eproto {
-  StaticDescriptorInitializer_google_2fprotobuf_2ffield_5fmask_2eproto() {
-    protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto();
+struct StaticDescriptorInitializer {
+  StaticDescriptorInitializer() {
+    AddDescriptors();
   }
-} static_descriptor_initializer_google_2fprotobuf_2ffield_5fmask_2eproto_;
+} static_descriptor_initializer;
+
+}  // namespace protobuf_google_2fprotobuf_2ffield_5fmask_2eproto
+
 
 // ===================================================================
 
@@ -126,7 +126,7 @@ const int FieldMask::kPathsFieldNumber;
 FieldMask::FieldMask()
   : ::google::protobuf::Message(), _internal_metadata_(NULL) {
   if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
-    protobuf_InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto();
+    protobuf_google_2fprotobuf_2ffield_5fmask_2eproto::InitDefaults();
   }
   SharedCtor();
   // @@protoc_insertion_point(constructor:google.protobuf.FieldMask)
@@ -158,12 +158,12 @@ void FieldMask::SetCachedSize(int size) const {
   GOOGLE_SAFE_CONCURRENT_WRITES_END();
 }
 const ::google::protobuf::Descriptor* FieldMask::descriptor() {
-  protobuf_AssignDescriptorsOnce();
-  return file_level_metadata[0].descriptor;
+  protobuf_google_2fprotobuf_2ffield_5fmask_2eproto::protobuf_AssignDescriptorsOnce();
+  return protobuf_google_2fprotobuf_2ffield_5fmask_2eproto::file_level_metadata[0].descriptor;
 }
 
 const FieldMask& FieldMask::default_instance() {
-  protobuf_InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto();
+  protobuf_google_2fprotobuf_2ffield_5fmask_2eproto::InitDefaults();
   return *internal_default_instance();
 }
 
@@ -245,7 +245,7 @@ void FieldMask::SerializeWithCachedSizes(
 
 ::google::protobuf::uint8* FieldMask::InternalSerializeWithCachedSizesToArray(
     bool deterministic, ::google::protobuf::uint8* target) const {
-  (void)deterministic; // Unused
+  (void)deterministic;  // Unused
   // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.FieldMask)
   // repeated string paths = 1;
   for (int i = 0; i < this->paths_size(); i++) {
@@ -330,8 +330,8 @@ void FieldMask::InternalSwap(FieldMask* other) {
 }
 
 ::google::protobuf::Metadata FieldMask::GetMetadata() const {
-  protobuf_AssignDescriptorsOnce();
-  return file_level_metadata[0];
+  protobuf_google_2fprotobuf_2ffield_5fmask_2eproto::protobuf_AssignDescriptorsOnce();
+  return protobuf_google_2fprotobuf_2ffield_5fmask_2eproto::file_level_metadata[0];
 }
 
 #if PROTOBUF_INLINE_NOT_IN_HEADERS

+ 13 - 8
src/google/protobuf/field_mask.pb.h

@@ -19,6 +19,7 @@
 #error regenerate this file with a newer version of protoc.
 #endif
 
+#include <google/protobuf/io/coded_stream.h>
 #include <google/protobuf/arena.h>
 #include <google/protobuf/arenastring.h>
 #include <google/protobuf/generated_message_util.h>
@@ -39,9 +40,16 @@ LIBPROTOBUF_EXPORT extern FieldMaskDefaultTypeInternal _FieldMask_default_instan
 namespace google {
 namespace protobuf {
 
+namespace protobuf_google_2fprotobuf_2ffield_5fmask_2eproto {
 // Internal implementation detail -- do not call these.
-void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto();
-void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto();
+struct LIBPROTOBUF_EXPORT TableStruct {
+  static const ::google::protobuf::uint32 offsets[];
+  static void InitDefaultsImpl();
+  static void Shutdown();
+};
+void LIBPROTOBUF_EXPORT AddDescriptors();
+void LIBPROTOBUF_EXPORT InitDefaults();
+}  // namespace protobuf_google_2fprotobuf_2ffield_5fmask_2eproto
 
 // ===================================================================
 
@@ -88,7 +96,8 @@ class LIBPROTOBUF_EXPORT FieldMask : public ::google::protobuf::Message /* @@pro
       bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
   ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
       const PROTOBUF_FINAL {
-    return InternalSerializeWithCachedSizesToArray(false, output);
+    return InternalSerializeWithCachedSizesToArray(
+        ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
   }
   int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
   private:
@@ -133,11 +142,7 @@ class LIBPROTOBUF_EXPORT FieldMask : public ::google::protobuf::Message /* @@pro
   ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
   ::google::protobuf::RepeatedPtrField< ::std::string> paths_;
   mutable int _cached_size_;
-  friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto_impl();
-  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto_impl();
-  friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2ffield_5fmask_2eproto();
-  friend void protobuf_ShutdownFile_google_2fprotobuf_2ffield_5fmask_2eproto();
-
+  friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2ffield_5fmask_2eproto::TableStruct;
 };
 // ===================================================================
 

+ 29 - 67
src/google/protobuf/generated_message_reflection.cc

@@ -73,12 +73,6 @@ const string& NameOfEnum(const EnumDescriptor* descriptor, int value) {
   return (d == NULL ? GetEmptyString() : d->name());
 }
 
-namespace {
-inline bool SupportsArenas(const Descriptor* descriptor) {
-  return descriptor->file()->options().cc_enable_arenas();
-}
-}  // anonymous namespace
-
 // ===================================================================
 // Helpers for reporting usage errors (e.g. trying to use GetInt32() on
 // a string field).
@@ -196,18 +190,7 @@ GeneratedMessageReflection::GeneratedMessageReflection(
       schema_(schema),
       descriptor_pool_((pool == NULL) ? DescriptorPool::generated_pool()
                                       : pool),
-      message_factory_(factory),
-      // TODO(haberman) remove this when upb is using our table driven.
-      default_instance_(schema_.default_instance_),
-      default_oneof_instance_(schema_.default_oneof_instance_),
-      offsets_(schema_.offsets_),
-      has_bits_indices_(schema_.has_bit_indices_),
-      has_bits_offset_(schema_.has_bits_offset_),
-      oneof_case_offset_(schema_.oneof_case_offset_),
-      unknown_fields_offset_(-1),
-      extensions_offset_(schema_.extensions_offset_),
-      arena_offset_(schema_.metadata_offset_),
-      object_size_(schema_.object_size_) {
+      message_factory_(factory) {
 }
 
 GeneratedMessageReflection::~GeneratedMessageReflection() {}
@@ -643,7 +626,17 @@ void GeneratedMessageReflection::Swap(
   if (schema_.HasHasbits()) {
     uint32* has_bits1 = MutableHasBits(message1);
     uint32* has_bits2 = MutableHasBits(message2);
-    int has_bits_size = (descriptor_->field_count() + 31) / 32;
+
+    int fields_with_has_bits = 0;
+    for (int i = 0; i < descriptor_->field_count(); i++) {
+      const FieldDescriptor* field = descriptor_->field(i);
+      if (field->is_repeated() || field->containing_oneof()) {
+        continue;
+      }
+      fields_with_has_bits++;
+    }
+
+    int has_bits_size = (fields_with_has_bits + 31) / 32;
 
     for (int i = 0; i < has_bits_size; i++) {
       std::swap(has_bits1[i], has_bits2[i]);
@@ -711,8 +704,11 @@ void GeneratedMessageReflection::SwapFields(
         swapped_oneof.insert(oneof_index);
         SwapOneofField(message1, message2, field->containing_oneof());
       } else {
-        // Swap has bit.
-        SwapBit(message1, message2, field);
+        // Swap has bit for non-repeated fields.  We have already checked for
+        // oneof already.
+        if (!field->is_repeated()) {
+          SwapBit(message1, message2, field);
+        }
         // Swap field.
         SwapField(message1, message2, field);
       }
@@ -1006,6 +1002,7 @@ struct FieldNumberSorter {
 
 inline bool IsIndexInHasBitSet(
     const uint32* has_bit_set, uint32 has_bit_index) {
+  GOOGLE_DCHECK_NE(has_bit_index, ~0u);
   return ((has_bit_set[has_bit_index / 32] >> (has_bit_index % 32)) &
           static_cast<uint32>(1)) != 0;
 }
@@ -1511,7 +1508,7 @@ void GeneratedMessageReflection::UnsafeArenaSetAllocatedMessage(
   USAGE_CHECK_ALL(SetAllocatedMessage, SINGULAR, MESSAGE);
 
   if (field->is_extension()) {
-    MutableExtensionSet(message)->SetAllocatedMessage(
+    MutableExtensionSet(message)->UnsafeArenaSetAllocatedMessage(
         field->number(), field->type(), field, sub_message);
   } else {
     if (field->containing_oneof()) {
@@ -1579,7 +1576,9 @@ Message* GeneratedMessageReflection::UnsafeArenaReleaseMessage(
         MutableExtensionSet(message)->UnsafeArenaReleaseMessage(field,
                                                                 factory));
   } else {
-    ClearBit(message, field);
+    if (!(field->is_repeated() || field->containing_oneof())) {
+      ClearBit(message, field);
+    }
     if (field->containing_oneof()) {
       if (HasOneofField(*message, field)) {
         *MutableOneofCase(message, field->containing_oneof()) = 0;
@@ -2233,10 +2232,10 @@ namespace {
 
 // Helper function to transform migration schema into reflection schema.
 ReflectionSchema MigrationToReflectionSchema(
-    const DefaultInstanceData* default_instance_data, const uint32* offsets,
+    const Message* const* default_instance, const uint32* offsets,
     MigrationSchema migration_schema) {
   ReflectionSchema result;
-  result.default_instance_ = default_instance_data->default_instance;
+  result.default_instance_ = *default_instance;
   // First 5 offsets are offsets to the special fields. The following offsets
   // are the proto fields.
   result.offsets_ = offsets + migration_schema.offsets_index + 4;
@@ -2244,18 +2243,12 @@ ReflectionSchema MigrationToReflectionSchema(
   result.has_bits_offset_ = offsets[migration_schema.offsets_index + 0];
   result.metadata_offset_ = offsets[migration_schema.offsets_index + 1];
   result.extensions_offset_ = offsets[migration_schema.offsets_index + 2];
-  result.default_oneof_instance_ = default_instance_data->default_oneof_instance;
   result.oneof_case_offset_ = offsets[migration_schema.offsets_index + 3];
   result.object_size_ = migration_schema.object_size;
+  result.weak_field_map_offset_ = 0;
   return result;
 }
 
-ReflectionSchema MigrationToReflectionSchema(
-    const DefaultInstanceData* default_instance_data, const uint32* offsets,
-    ReflectionSchema schema) {
-  return schema;
-}
-
 template<typename Schema>
 class AssignDescriptorsHelper {
  public:
@@ -2263,7 +2256,7 @@ class AssignDescriptorsHelper {
                           Metadata* file_level_metadata,
                           const EnumDescriptor** file_level_enum_descriptors,
                           const Schema* schemas,
-                          const DefaultInstanceData* default_instance_data,
+                          const Message* const* default_instance_data,
                           const uint32* offsets)
       : factory_(factory),
         file_level_metadata_(file_level_metadata),
@@ -2303,7 +2296,7 @@ class AssignDescriptorsHelper {
   Metadata* file_level_metadata_;
   const EnumDescriptor** file_level_enum_descriptors_;
   const Schema* schemas_;
-  const DefaultInstanceData* default_instance_data_;
+  const Message* const * default_instance_data_;
   const uint32* offsets_;
 };
 
@@ -2311,7 +2304,7 @@ class AssignDescriptorsHelper {
 
 void AssignDescriptors(
     const string& filename, const MigrationSchema* schemas,
-    const DefaultInstanceData* default_instance_data, const uint32* offsets,
+    const Message* const* default_instances_, const uint32* offsets,
     MessageFactory* factory,
     // update the following descriptor arrays.
     Metadata* file_level_metadata,
@@ -2325,38 +2318,7 @@ void AssignDescriptors(
 
   AssignDescriptorsHelper<MigrationSchema> helper(factory, file_level_metadata,
                                  file_level_enum_descriptors, schemas,
-                                 default_instance_data, offsets);
-
-  for (int i = 0; i < file->message_type_count(); i++) {
-    helper.AssignMessageDescriptor(file->message_type(i));
-  }
-
-  for (int i = 0; i < file->enum_type_count(); i++) {
-    helper.AssignEnumDescriptor(file->enum_type(i));
-  }
-  if (file->options().cc_generic_services()) {
-    for (int i = 0; i < file->service_count(); i++) {
-      file_level_service_descriptors[i] = file->service(i);
-    }
-  }
-}
-
-void AssignDescriptors(
-    const string& filename, const ReflectionSchema* schemas,
-    MessageFactory* factory,
-    // update the following descriptor arrays.
-    Metadata* file_level_metadata,
-    const EnumDescriptor** file_level_enum_descriptors,
-    const ServiceDescriptor** file_level_service_descriptors) {
-  const ::google::protobuf::FileDescriptor* file =
-      ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(filename);
-  GOOGLE_CHECK(file != NULL);
-
-  if (!factory) factory = MessageFactory::generated_factory();
-
-  AssignDescriptorsHelper<ReflectionSchema> helper(factory, file_level_metadata,
-                                 file_level_enum_descriptors, schemas,
-                                 NULL, NULL);
+                                 default_instances_, offsets);
 
   for (int i = 0; i < file->message_type_count(); i++) {
     helper.AssignMessageDescriptor(file->message_type(i));

+ 11 - 42
src/google/protobuf/generated_message_reflection.h

@@ -107,11 +107,6 @@ class ExtensionSet;             // extension_set.h
 //   extensions_offset:  Offset in the message of the ExtensionSet for the
 //                  message, or -1 if the message type has no extension
 //                  ranges.
-//   default_oneof_instance: The default instance of the oneofs. It is a
-//                  struct holding the default value of all oneof fields
-//                  for this message. It is only used to obtain pointers
-//                  to default instances of oneof fields, which Get
-//                  methods will return if the field is not set.
 //   oneof_case_offset:  Offset in the message of an array of uint32s of
 //                  size descriptor->oneof_decl_count().  Each uint32
 //                  indicates what field is set for each oneof.
@@ -160,8 +155,8 @@ struct ReflectionSchema {
     return has_bits_offset_;
   }
 
-  // The offset of the InternalMetadataWithArenaOffset member.
-  // For Lite this will actually be an InternalMetadataWithArenaOffsetLite.
+  // The offset of the InternalMetadataWithArena member.
+  // For Lite this will actually be an InternalMetadataWithArenaLite.
   // The schema doesn't contain enough information to distinguish between
   // these two cases.
   uint32 GetMetadataOffset() const {
@@ -177,6 +172,10 @@ struct ReflectionSchema {
     return extensions_offset_;
   }
 
+  // The off set of WeakFieldMap when the message contains weak fields.
+  // The default is 0 for now.
+  int GetWeakFieldMapOffset() const { return weak_field_map_offset_; }
+
   bool IsDefaultInstance(const Message& message) const {
     return &message == default_instance_;
   }
@@ -184,10 +183,7 @@ struct ReflectionSchema {
   // Returns a pointer to the default value for this field.  The size and type
   // of the underlying data depends on the field's type.
   const void *GetFieldDefault(const FieldDescriptor* field) const {
-    return field->containing_oneof()
-               ? reinterpret_cast<const uint8*>(default_oneof_instance_) +
-                     offsets_[field->index()]
-               : reinterpret_cast<const uint8*>(default_instance_) +
+    return reinterpret_cast<const uint8*>(default_instance_) +
                      offsets_[field->index()];
   }
 
@@ -203,9 +199,9 @@ struct ReflectionSchema {
   int has_bits_offset_;
   int metadata_offset_;
   int extensions_offset_;
-  const void* default_oneof_instance_;
   int oneof_case_offset_;
   int object_size_;
+  int weak_field_map_offset_;
 };
 
 // Structs that the code generator emits directly to describe a message.
@@ -214,11 +210,6 @@ struct ReflectionSchema {
 //
 // EXPERIMENTAL: these are changing rapidly, and may completely disappear
 // or merge with ReflectionSchema.
-struct DefaultInstanceData {
-  const Message* default_instance;
-  const void* default_oneof_instance;
-};
-
 struct MigrationSchema {
   int32 offsets_index;
   int32 has_bit_indices_index;
@@ -249,7 +240,8 @@ struct MigrationSchema {
 //    of whatever type the individual field would be.  Strings and
 //    Messages use RepeatedPtrFields while everything else uses
 //    RepeatedFields.
-class LIBPROTOBUF_EXPORT GeneratedMessageReflection PROTOBUF_FINAL : public Reflection {
+class LIBPROTOBUF_EXPORT GeneratedMessageReflection PROTOBUF_FINAL
+    : public Reflection {
  public:
   // Constructs a GeneratedMessageReflection.
   // Parameters:
@@ -497,21 +489,6 @@ class LIBPROTOBUF_EXPORT GeneratedMessageReflection PROTOBUF_FINAL : public Refl
   const DescriptorPool* const descriptor_pool_;
   MessageFactory* const message_factory_;
 
-  // To parse directly into a proto2 generated class, the class GMR_Handlers
-  // needs access to member offsets and hasbits.
-  // upb still needs these.
-  // TODO(haberman) clean this up.
-  const Message* const default_instance_;
-  const void* const default_oneof_instance_;
-  const uint32* const offsets_;
-  const uint32* const has_bits_indices_;
-  const int has_bits_offset_;
-  const int oneof_case_offset_;
-  const int unknown_fields_offset_;
-  const int extensions_offset_;
-  const int arena_offset_;
-  const int object_size_;
-
   template <class T>
   const T& GetRawNonOneof(const Message& message,
                           const FieldDescriptor* field) const;
@@ -741,15 +718,7 @@ T* DynamicCastToGenerated(Message* from) {
 
 LIBPROTOBUF_EXPORT void AssignDescriptors(
     const string& filename, const MigrationSchema* schemas,
-    const DefaultInstanceData* default_instance_data, const uint32* offsets,
-    MessageFactory* factory,
-    // update the following descriptor arrays.
-    Metadata* file_level_metadata,
-    const EnumDescriptor** file_level_enum_descriptors,
-    const ServiceDescriptor** file_level_service_descriptors);
-
-LIBPROTOBUF_EXPORT void AssignDescriptors(
-    const string& filename, const ReflectionSchema* schemas,
+    const Message* const* default_instances_, const uint32* offsets,
     MessageFactory* factory,
     // update the following descriptor arrays.
     Metadata* file_level_metadata,

+ 125 - 1
src/google/protobuf/generated_message_reflection_unittest.cc

@@ -48,9 +48,10 @@
 #include <google/protobuf/stubs/shared_ptr.h>
 #endif
 
-#include <google/protobuf/descriptor.h>
 #include <google/protobuf/test_util.h>
 #include <google/protobuf/unittest.pb.h>
+#include <google/protobuf/arena.h>
+#include <google/protobuf/descriptor.h>
 
 #include <google/protobuf/stubs/logging.h>
 #include <google/protobuf/stubs/common.h>
@@ -519,6 +520,41 @@ TEST(GeneratedMessageReflectionTest, SetAllocatedMessageTest) {
       &to_message, TestUtil::ReflectionTester::IS_NULL);
 }
 
+TEST(GeneratedMessageReflectionTest, SetAllocatedMessageOnArenaTest) {
+  unittest::TestAllTypes from_message1;
+  unittest::TestAllTypes from_message2;
+  ::google::protobuf::Arena arena;
+  unittest::TestAllTypes* to_message =
+      ::google::protobuf::Arena::CreateMessage<unittest::TestAllTypes>(&arena);
+  TestUtil::ReflectionTester reflection_tester(
+    unittest::TestAllTypes::descriptor());
+  reflection_tester.SetAllFieldsViaReflection(&from_message1);
+  reflection_tester.SetAllFieldsViaReflection(&from_message2);
+
+  // Before moving fields, we expect the nested messages to be NULL.
+  reflection_tester.ExpectMessagesReleasedViaReflection(
+      to_message, TestUtil::ReflectionTester::IS_NULL);
+
+  // After fields are moved we should get non-NULL releases.
+  reflection_tester.SetAllocatedOptionalMessageFieldsToMessageViaReflection(
+      &from_message1, to_message);
+  reflection_tester.ExpectMessagesReleasedViaReflection(
+      to_message, TestUtil::ReflectionTester::NOT_NULL);
+
+  // Another move to make sure that we can SetAllocated several times.
+  reflection_tester.SetAllocatedOptionalMessageFieldsToMessageViaReflection(
+      &from_message2, to_message);
+  reflection_tester.ExpectMessagesReleasedViaReflection(
+      to_message, TestUtil::ReflectionTester::NOT_NULL);
+
+  // After SetAllocatedOptionalMessageFieldsToNullViaReflection() we expect the
+  // releases to be NULL again.
+  reflection_tester.SetAllocatedOptionalMessageFieldsToNullViaReflection(
+      to_message);
+  reflection_tester.ExpectMessagesReleasedViaReflection(
+      to_message, TestUtil::ReflectionTester::IS_NULL);
+}
+
 TEST(GeneratedMessageReflectionTest, SetAllocatedExtensionMessageTest) {
   unittest::TestAllExtensions from_message1;
   unittest::TestAllExtensions from_message2;
@@ -552,6 +588,41 @@ TEST(GeneratedMessageReflectionTest, SetAllocatedExtensionMessageTest) {
       &to_message, TestUtil::ReflectionTester::IS_NULL);
 }
 
+TEST(GeneratedMessageReflectionTest, SetAllocatedExtensionMessageOnArenaTest) {
+  ::google::protobuf::Arena arena;
+  unittest::TestAllExtensions* to_message =
+      ::google::protobuf::Arena::CreateMessage<unittest::TestAllExtensions>(&arena);
+  unittest::TestAllExtensions from_message1;
+  unittest::TestAllExtensions from_message2;
+  TestUtil::ReflectionTester reflection_tester(
+    unittest::TestAllExtensions::descriptor());
+  reflection_tester.SetAllFieldsViaReflection(&from_message1);
+  reflection_tester.SetAllFieldsViaReflection(&from_message2);
+
+  // Before moving fields, we expect the nested messages to be NULL.
+  reflection_tester.ExpectMessagesReleasedViaReflection(
+      to_message, TestUtil::ReflectionTester::IS_NULL);
+
+  // After fields are moved we should get non-NULL releases.
+  reflection_tester.SetAllocatedOptionalMessageFieldsToMessageViaReflection(
+      &from_message1, to_message);
+  reflection_tester.ExpectMessagesReleasedViaReflection(
+      to_message, TestUtil::ReflectionTester::NOT_NULL);
+
+  // Another move to make sure that we can SetAllocated several times.
+  reflection_tester.SetAllocatedOptionalMessageFieldsToMessageViaReflection(
+      &from_message2, to_message);
+  reflection_tester.ExpectMessagesReleasedViaReflection(
+      to_message, TestUtil::ReflectionTester::NOT_NULL);
+
+  // After SetAllocatedOptionalMessageFieldsToNullViaReflection() we expect the
+  // releases to be NULL again.
+  reflection_tester.SetAllocatedOptionalMessageFieldsToNullViaReflection(
+      to_message);
+  reflection_tester.ExpectMessagesReleasedViaReflection(
+      to_message, TestUtil::ReflectionTester::IS_NULL);
+}
+
 TEST(GeneratedMessageReflectionTest, AddRepeatedMessage) {
   unittest::TestAllTypes message;
 
@@ -723,6 +794,59 @@ TEST(GeneratedMessageReflectionTest, SetAllocatedOneofMessageTest) {
   delete released;
 }
 
+TEST(GeneratedMessageReflectionTest, SetAllocatedOneofMessageOnArenaTest) {
+  unittest::TestOneof2 from_message1;
+  unittest::TestOneof2 from_message2;
+  ::google::protobuf::Arena arena;
+  unittest::TestOneof2* to_message =
+      ::google::protobuf::Arena::CreateMessage<unittest::TestOneof2>(&arena);
+  const Descriptor* descriptor = unittest::TestOneof2::descriptor();
+  const Reflection* reflection = to_message->GetReflection();
+
+  Message* released = reflection->ReleaseMessage(
+      to_message, descriptor->FindFieldByName("foo_lazy_message"));
+  EXPECT_TRUE(released == NULL);
+  released = reflection->ReleaseMessage(
+      to_message, descriptor->FindFieldByName("foo_message"));
+  EXPECT_TRUE(released == NULL);
+
+  TestUtil::ReflectionTester::SetOneofViaReflection(&from_message1);
+  TestUtil::ReflectionTester::ExpectOneofSetViaReflection(from_message1);
+
+  TestUtil::ReflectionTester::
+      SetAllocatedOptionalMessageFieldsToMessageViaReflection(
+          &from_message1, to_message);
+  const Message& sub_message = reflection->GetMessage(
+      *to_message, descriptor->FindFieldByName("foo_lazy_message"));
+  released = reflection->ReleaseMessage(
+      to_message, descriptor->FindFieldByName("foo_lazy_message"));
+  EXPECT_TRUE(released != NULL);
+  // Since sub_message is arena allocated, releasing it results in copying it
+  // into new heap-allocated memory.
+  EXPECT_NE(&sub_message, released);
+  delete released;
+
+  TestUtil::ReflectionTester::SetOneofViaReflection(&from_message2);
+
+  reflection->MutableMessage(
+      &from_message2, descriptor->FindFieldByName("foo_message"));
+
+  TestUtil::ReflectionTester::
+      SetAllocatedOptionalMessageFieldsToMessageViaReflection(
+          &from_message2, to_message);
+
+  const Message& sub_message2 = reflection->GetMessage(
+      *to_message, descriptor->FindFieldByName("foo_message"));
+  released = reflection->ReleaseMessage(
+      to_message, descriptor->FindFieldByName("foo_message"));
+  EXPECT_TRUE(released != NULL);
+  // Since sub_message2 is arena allocated, releasing it results in copying it
+  // into new heap-allocated memory.
+  EXPECT_NE(&sub_message2, released);
+  delete released;
+}
+
+
 TEST(GeneratedMessageReflectionTest, ReleaseMessageTest) {
   unittest::TestAllTypes message;
   TestUtil::ReflectionTester reflection_tester(

+ 31 - 0
src/google/protobuf/has_bits.h

@@ -61,10 +61,41 @@ class HasBits {
   bool operator!=(const HasBits<doublewords>& rhs) const {
     return !(*this == rhs);
   }
+
+  bool empty() const;
+
  private:
   ::google::protobuf::uint32 has_bits_[doublewords];
 };
 
+template <>
+inline bool HasBits<1>::empty() const {
+  return !has_bits_[0];
+}
+
+template <>
+inline bool HasBits<2>::empty() const {
+  return !(has_bits_[0] | has_bits_[1]);
+}
+
+template <>
+inline bool HasBits<3>::empty() const {
+  return !(has_bits_[0] | has_bits_[1] | has_bits_[2]);
+}
+
+template <>
+inline bool HasBits<4>::empty() const {
+  return !(has_bits_[0] | has_bits_[1] | has_bits_[2] | has_bits_[3]);
+}
+
+template <size_t doublewords>
+inline bool HasBits<doublewords>::empty() const {
+  for (size_t i = 0; i < doublewords; ++i) {
+    if (has_bits_[i]) return false;
+  }
+  return true;
+}
+
 }  // namespace internal
 }  // namespace protobuf
 

+ 8 - 0
src/google/protobuf/io/coded_stream.h

@@ -140,6 +140,8 @@ namespace protobuf {
 class DescriptorPool;
 class MessageFactory;
 
+namespace internal { void MapTestForceDeterministic(); }
+
 namespace io {
 
 // Defined in this file.
@@ -867,6 +869,10 @@ class LIBPROTOBUF_EXPORT CodedOutputStream {
         default_serialization_deterministic_;
   }
 
+  static bool IsDefaultSerializationDeterministic() {
+    return default_serialization_deterministic_;
+  }
+
  private:
   GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CodedOutputStream);
 
@@ -900,6 +906,8 @@ class LIBPROTOBUF_EXPORT CodedOutputStream {
   static size_t VarintSize32Fallback(uint32 value);
 
   // See above.  Other projects may use "friend" to allow them to call this.
+  // Requires: no protocol buffer serialization in progress.
+  friend void ::google::protobuf::internal::MapTestForceDeterministic();
   static void SetDefaultSerializationDeterministic() {
     default_serialization_deterministic_ = true;
   }

+ 7 - 8
src/google/protobuf/io/tokenizer_unittest.cc

@@ -199,8 +199,8 @@ struct SimpleTokenCase {
   Tokenizer::TokenType type;
 };
 
-inline ostream& operator<<(ostream& out,
-                           const SimpleTokenCase& test_case) {
+inline std::ostream& operator<<(std::ostream& out,
+                                const SimpleTokenCase& test_case) {
   return out << CEscape(test_case.input);
 }
 
@@ -333,8 +333,8 @@ struct MultiTokenCase {
                                 // needed.
 };
 
-inline ostream& operator<<(ostream& out,
-                           const MultiTokenCase& test_case) {
+inline std::ostream& operator<<(std::ostream& out,
+                                const MultiTokenCase& test_case) {
   return out << CEscape(test_case.input);
 }
 
@@ -520,8 +520,8 @@ struct DocCommentCase {
   const char* next_leading_comments;
 };
 
-inline ostream& operator<<(ostream& out,
-                           const DocCommentCase& test_case) {
+inline std::ostream& operator<<(std::ostream& out,
+                                const DocCommentCase& test_case) {
   return out << CEscape(test_case.input);
 }
 
@@ -860,8 +860,7 @@ struct ErrorCase {
   const char* errors;
 };
 
-inline ostream& operator<<(ostream& out,
-                           const ErrorCase& test_case) {
+inline std::ostream& operator<<(std::ostream& out, const ErrorCase& test_case) {
   return out << CEscape(test_case.input);
 }
 

+ 8 - 14
src/google/protobuf/io/zero_copy_stream_impl.cc

@@ -270,10 +270,8 @@ bool FileOutputStream::CopyingFileOutputStream::Write(
 
 // ===================================================================
 
-IstreamInputStream::IstreamInputStream(istream* input, int block_size)
-  : copying_input_(input),
-    impl_(&copying_input_, block_size) {
-}
+IstreamInputStream::IstreamInputStream(std::istream* input, int block_size)
+    : copying_input_(input), impl_(&copying_input_, block_size) {}
 
 IstreamInputStream::~IstreamInputStream() {}
 
@@ -294,9 +292,8 @@ int64 IstreamInputStream::ByteCount() const {
 }
 
 IstreamInputStream::CopyingIstreamInputStream::CopyingIstreamInputStream(
-    istream* input)
-  : input_(input) {
-}
+    std::istream* input)
+    : input_(input) {}
 
 IstreamInputStream::CopyingIstreamInputStream::~CopyingIstreamInputStream() {}
 
@@ -312,10 +309,8 @@ int IstreamInputStream::CopyingIstreamInputStream::Read(
 
 // ===================================================================
 
-OstreamOutputStream::OstreamOutputStream(ostream* output, int block_size)
-  : copying_output_(output),
-    impl_(&copying_output_, block_size) {
-}
+OstreamOutputStream::OstreamOutputStream(std::ostream* output, int block_size)
+    : copying_output_(output), impl_(&copying_output_, block_size) {}
 
 OstreamOutputStream::~OstreamOutputStream() {
   impl_.Flush();
@@ -334,9 +329,8 @@ int64 OstreamOutputStream::ByteCount() const {
 }
 
 OstreamOutputStream::CopyingOstreamOutputStream::CopyingOstreamOutputStream(
-    ostream* output)
-  : output_(output) {
-}
+    std::ostream* output)
+    : output_(output) {}
 
 OstreamOutputStream::CopyingOstreamOutputStream::~CopyingOstreamOutputStream() {
 }

+ 2 - 2
src/google/protobuf/io/zero_copy_stream_unittest.cc

@@ -882,7 +882,7 @@ TEST_F(IoTest, IostreamIo) {
   for (int i = 0; i < kBlockSizeCount; i++) {
     for (int j = 0; j < kBlockSizeCount; j++) {
       {
-        stringstream stream;
+        std::stringstream stream;
 
         {
           OstreamOutputStream output(&stream, kBlockSizes[i]);
@@ -898,7 +898,7 @@ TEST_F(IoTest, IostreamIo) {
       }
 
       {
-        stringstream stream;
+        std::stringstream stream;
 
         {
           OstreamOutputStream output(&stream, kBlockSizes[i]);

+ 3 - 2
src/google/protobuf/map.h

@@ -1533,8 +1533,9 @@ class Map {
 
   // Lookup
   size_type count(const key_type& key) const {
-    if (find(key) != end()) assert(key == find(key)->first);
-    return find(key) == end() ? 0 : 1;
+    const_iterator it = find(key);
+    GOOGLE_DCHECK(it == end() || key == it->first);
+    return it == end() ? 0 : 1;
   }
   const_iterator find(const key_type& key) const {
     return old_style_ ? const_iterator(deprecated_elements_->find(key))

+ 0 - 1
src/google/protobuf/map_entry.h

@@ -251,7 +251,6 @@ class MapEntry : public MapEntryBase {
         GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MapEntry, entry_lite_._has_bits_),
         GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MapEntry, _internal_metadata_),
         -1,
-        NULL,
         -1,
         sizeof(MapEntry)};
     const Reflection* reflection = new GeneratedMessageReflection(

+ 2 - 3
src/google/protobuf/map_entry_lite.h

@@ -221,9 +221,8 @@ class MapEntryLite : public MessageLite {
                                                     deterministic, output);
     return output;
   }
-  ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
-    return InternalSerializeWithCachedSizesToArray(false, output);
-  }
+
+  // Don't override SerializeWithCachedSizesToArray.  Use MessageLite's.
 
   int GetCachedSize() const {
     int size = 0;

+ 5 - 1
src/google/protobuf/map_test.cc

@@ -91,6 +91,10 @@ using google::protobuf::unittest::TestRecursiveMapMessage;
 namespace protobuf {
 namespace internal {
 
+void MapTestForceDeterministic() {
+  ::google::protobuf::io::CodedOutputStream::SetDefaultSerializationDeterministic();
+}
+
 // Map API Test =====================================================
 
 // Parameterized tests on whether to use old style maps.
@@ -2844,7 +2848,7 @@ TEST(WireFormatForMapFieldTest, MapParseHelpers) {
   {
     // Test ParseFromIstream.
     protobuf_unittest::TestMap message;
-    stringstream stream(data);
+    std::stringstream stream(data);
     EXPECT_TRUE(message.ParseFromIstream(&stream));
     EXPECT_TRUE(stream.eof());
     MapTestUtil::ExpectMapFieldsSet(message);

+ 4 - 4
src/google/protobuf/message.cc

@@ -130,12 +130,12 @@ bool Message::ParsePartialFromFileDescriptor(int file_descriptor) {
   return ParsePartialFromZeroCopyStream(&input) && input.GetErrno() == 0;
 }
 
-bool Message::ParseFromIstream(istream* input) {
+bool Message::ParseFromIstream(std::istream* input) {
   io::IstreamInputStream zero_copy_input(input);
   return ParseFromZeroCopyStream(&zero_copy_input) && input->eof();
 }
 
-bool Message::ParsePartialFromIstream(istream* input) {
+bool Message::ParsePartialFromIstream(std::istream* input) {
   io::IstreamInputStream zero_copy_input(input);
   return ParsePartialFromZeroCopyStream(&zero_copy_input) && input->eof();
 }
@@ -172,7 +172,7 @@ bool Message::SerializePartialToFileDescriptor(int file_descriptor) const {
   return SerializePartialToZeroCopyStream(&output);
 }
 
-bool Message::SerializeToOstream(ostream* output) const {
+bool Message::SerializeToOstream(std::ostream* output) const {
   {
     io::OstreamOutputStream zero_copy_output(output);
     if (!SerializeToZeroCopyStream(&zero_copy_output)) return false;
@@ -180,7 +180,7 @@ bool Message::SerializeToOstream(ostream* output) const {
   return output->good();
 }
 
-bool Message::SerializePartialToOstream(ostream* output) const {
+bool Message::SerializePartialToOstream(std::ostream* output) const {
   io::OstreamOutputStream zero_copy_output(output);
   return SerializePartialToZeroCopyStream(&zero_copy_output);
 }

+ 1 - 1
src/google/protobuf/message.h

@@ -853,7 +853,7 @@ class LIBPROTOBUF_EXPORT Reflection {
   //     reflection->SetEnumValue(message, field, new_value);
   //   } else {
   //     if (field_descriptor->enum_type()->
-  //             FindValueByNumver(new_value) != NULL) {
+  //             FindValueByNumber(new_value) != NULL) {
   //       reflection->SetEnumValue(message, field, new_value);
   //     } else if (emit_unknown_enum_values) {
   //       reflection->MutableUnknownFields(message)->AddVarint(

+ 1 - 0
src/google/protobuf/message_lite.cc

@@ -229,6 +229,7 @@ uint8* MessageLite::InternalSerializeWithCachedSizesToArray(
   int size = GetCachedSize();
   io::ArrayOutputStream out(target, size);
   io::CodedOutputStream coded_out(&out);
+  coded_out.SetSerializationDeterministic(deterministic);
   SerializeWithCachedSizes(&coded_out);
   GOOGLE_CHECK(!coded_out.HadError());
   return target + size;

+ 3 - 3
src/google/protobuf/message_unittest.cc

@@ -77,7 +77,7 @@ TEST(MessageTest, SerializeHelpers) {
 
   protobuf_unittest::TestAllTypes message;
   TestUtil::SetAllFields(&message);
-  stringstream stream;
+  std::stringstream stream;
 
   string str1("foo");
   string str2("bar");
@@ -101,7 +101,7 @@ TEST(MessageTest, SerializeHelpers) {
 }
 
 TEST(MessageTest, SerializeToBrokenOstream) {
-  ofstream out;
+  std::ofstream out;
   protobuf_unittest::TestAllTypes message;
   message.set_optional_int32(123);
 
@@ -155,7 +155,7 @@ TEST(MessageTest, ParseHelpers) {
   {
     // Test ParseFromIstream.
     protobuf_unittest::TestAllTypes message;
-    stringstream stream(data);
+    std::stringstream stream(data);
     EXPECT_TRUE(message.ParseFromIstream(&stream));
     EXPECT_TRUE(stream.eof());
     TestUtil::ExpectAllFieldsSet(message);

+ 9 - 8
src/google/protobuf/repeated_field.h

@@ -686,7 +686,8 @@ inline const Message& GenericTypeHandler<Message>::default_instance() {
   return *null;
 }
 
-class LIBPROTOBUF_EXPORT StringTypeHandler {
+
+class StringTypeHandler {
  public:
   typedef string Type;
 
@@ -983,13 +984,13 @@ inline RepeatedField<Element>::RepeatedField(Arena* arena)
   : current_size_(0),
     total_size_(0),
     rep_(NULL) {
- // In case arena is NULL, then we do not create rep_, as code has an invariant
- // `rep_ == NULL then arena == NULL`.
- if (arena != NULL) {
-  rep_ = reinterpret_cast<Rep*>(
-      ::google::protobuf::Arena::CreateArray<char>(arena, kRepHeaderSize));
-  rep_->arena = arena;
- }
+  // In case arena is NULL, then we do not create rep_, as code has an invariant
+  // `rep_ == NULL then arena == NULL`.
+  if (arena != NULL) {
+    rep_ = reinterpret_cast<Rep*>(
+        ::google::protobuf::Arena::CreateArray<char>(arena, kRepHeaderSize));
+    rep_->arena = arena;
+  }
 }
 
 template <typename Element>

+ 48 - 40
src/google/protobuf/source_context.pb.cc

@@ -19,8 +19,11 @@
 
 namespace google {
 namespace protobuf {
-class SourceContextDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<SourceContext> {};
-SourceContextDefaultTypeInternal _SourceContext_default_instance_;
+class SourceContextDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<SourceContext> {
+} _SourceContext_default_instance_;
+
+namespace protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto {
+
 
 namespace {
 
@@ -28,34 +31,29 @@ namespace {
 
 }  // namespace
 
-
-const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fsource_5fcontext_2eproto() GOOGLE_ATTRIBUTE_COLD;
-const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fsource_5fcontext_2eproto() {
-  static const ::google::protobuf::uint32 offsets[] = {
-    ~0u,  // no _has_bits_
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceContext, _internal_metadata_),
-    ~0u,  // no _extensions_
-    ~0u,  // no _oneof_case_
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceContext, file_name_),
-  };
-  return offsets;
-}
+const ::google::protobuf::uint32 TableStruct::offsets[] = {
+  ~0u,  // no _has_bits_
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceContext, _internal_metadata_),
+  ~0u,  // no _extensions_
+  ~0u,  // no _oneof_case_
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceContext, file_name_),
+};
 
 static const ::google::protobuf::internal::MigrationSchema schemas[] = {
   { 0, -1, sizeof(SourceContext)},
 };
 
-static const ::google::protobuf::internal::DefaultInstanceData file_default_instances[] = {
-  {reinterpret_cast<const ::google::protobuf::Message*>(&_SourceContext_default_instance_), NULL},
+static ::google::protobuf::Message const * const file_default_instances[] = {
+  reinterpret_cast<const ::google::protobuf::Message*>(&_SourceContext_default_instance_),
 };
 
 namespace {
 
 void protobuf_AssignDescriptors() {
-  protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto();
+  AddDescriptors();
   ::google::protobuf::MessageFactory* factory = NULL;
   AssignDescriptors(
-      "google/protobuf/source_context.proto", schemas, file_default_instances, protobuf_Offsets_google_2fprotobuf_2fsource_5fcontext_2eproto(), factory,
+      "google/protobuf/source_context.proto", schemas, file_default_instances, TableStruct::offsets, factory,
       file_level_metadata, NULL, NULL);
 }
 
@@ -72,24 +70,24 @@ void protobuf_RegisterTypes(const ::std::string&) {
 
 }  // namespace
 
-void protobuf_ShutdownFile_google_2fprotobuf_2fsource_5fcontext_2eproto() {
+void TableStruct::Shutdown() {
   _SourceContext_default_instance_.Shutdown();
   delete file_level_metadata[0].reflection;
 }
 
-void protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto_impl() {
+void TableStruct::InitDefaultsImpl() {
   GOOGLE_PROTOBUF_VERIFY_VERSION;
 
   ::google::protobuf::internal::InitProtobufDefaults();
   _SourceContext_default_instance_.DefaultConstruct();
 }
 
-void protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto() {
+void InitDefaults() {
   static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
-  ::google::protobuf::GoogleOnceInit(&once, &protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto_impl);
+  ::google::protobuf::GoogleOnceInit(&once, &TableStruct::InitDefaultsImpl);
 }
-void protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto_impl() {
-  protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto();
+void AddDescriptorsImpl() {
+  InitDefaults();
   static const char descriptor[] = {
       "\n$google/protobuf/source_context.proto\022\017"
       "google.protobuf\"\"\n\rSourceContext\022\021\n\tfile"
@@ -103,20 +101,22 @@ void protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto_impl() {
       descriptor, 251);
   ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
     "google/protobuf/source_context.proto", &protobuf_RegisterTypes);
-  ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fsource_5fcontext_2eproto);
+  ::google::protobuf::internal::OnShutdown(&TableStruct::Shutdown);
 }
 
-GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto_once_);
-void protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto() {
-  ::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto_once_,
-                 &protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto_impl);
+void AddDescriptors() {
+  static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
+  ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl);
 }
 // Force AddDescriptors() to be called at static initialization time.
-struct StaticDescriptorInitializer_google_2fprotobuf_2fsource_5fcontext_2eproto {
-  StaticDescriptorInitializer_google_2fprotobuf_2fsource_5fcontext_2eproto() {
-    protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto();
+struct StaticDescriptorInitializer {
+  StaticDescriptorInitializer() {
+    AddDescriptors();
   }
-} static_descriptor_initializer_google_2fprotobuf_2fsource_5fcontext_2eproto_;
+} static_descriptor_initializer;
+
+}  // namespace protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto
+
 
 // ===================================================================
 
@@ -127,7 +127,7 @@ const int SourceContext::kFileNameFieldNumber;
 SourceContext::SourceContext()
   : ::google::protobuf::Message(), _internal_metadata_(NULL) {
   if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
-    protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto();
+    protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto::InitDefaults();
   }
   SharedCtor();
   // @@protoc_insertion_point(constructor:google.protobuf.SourceContext)
@@ -164,12 +164,12 @@ void SourceContext::SetCachedSize(int size) const {
   GOOGLE_SAFE_CONCURRENT_WRITES_END();
 }
 const ::google::protobuf::Descriptor* SourceContext::descriptor() {
-  protobuf_AssignDescriptorsOnce();
-  return file_level_metadata[0].descriptor;
+  protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto::protobuf_AssignDescriptorsOnce();
+  return protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto::file_level_metadata[0].descriptor;
 }
 
 const SourceContext& SourceContext::default_instance() {
-  protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto();
+  protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto::InitDefaults();
   return *internal_default_instance();
 }
 
@@ -250,7 +250,7 @@ void SourceContext::SerializeWithCachedSizes(
 
 ::google::protobuf::uint8* SourceContext::InternalSerializeWithCachedSizesToArray(
     bool deterministic, ::google::protobuf::uint8* target) const {
-  (void)deterministic; // Unused
+  (void)deterministic;  // Unused
   // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.SourceContext)
   // string file_name = 1;
   if (this->file_name().size() > 0) {
@@ -338,8 +338,8 @@ void SourceContext::InternalSwap(SourceContext* other) {
 }
 
 ::google::protobuf::Metadata SourceContext::GetMetadata() const {
-  protobuf_AssignDescriptorsOnce();
-  return file_level_metadata[0];
+  protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto::protobuf_AssignDescriptorsOnce();
+  return protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto::file_level_metadata[0];
 }
 
 #if PROTOBUF_INLINE_NOT_IN_HEADERS
@@ -358,6 +358,14 @@ void SourceContext::set_file_name(const ::std::string& value) {
   file_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
   // @@protoc_insertion_point(field_set:google.protobuf.SourceContext.file_name)
 }
+#if LANG_CXX11
+void SourceContext::set_file_name(::std::string&& value) {
+  
+  file_name_.SetNoArena(
+    &::google::protobuf::internal::GetEmptyStringAlreadyInited(), std::move(value));
+  // @@protoc_insertion_point(field_set_rvalue:google.protobuf.SourceContext.file_name)
+}
+#endif
 void SourceContext::set_file_name(const char* value) {
   
   file_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));

+ 24 - 8
src/google/protobuf/source_context.pb.h

@@ -19,6 +19,7 @@
 #error regenerate this file with a newer version of protoc.
 #endif
 
+#include <google/protobuf/io/coded_stream.h>
 #include <google/protobuf/arena.h>
 #include <google/protobuf/arenastring.h>
 #include <google/protobuf/generated_message_util.h>
@@ -39,9 +40,16 @@ LIBPROTOBUF_EXPORT extern SourceContextDefaultTypeInternal _SourceContext_defaul
 namespace google {
 namespace protobuf {
 
+namespace protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto {
 // Internal implementation detail -- do not call these.
-void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto();
-void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto();
+struct LIBPROTOBUF_EXPORT TableStruct {
+  static const ::google::protobuf::uint32 offsets[];
+  static void InitDefaultsImpl();
+  static void Shutdown();
+};
+void LIBPROTOBUF_EXPORT AddDescriptors();
+void LIBPROTOBUF_EXPORT InitDefaults();
+}  // namespace protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto
 
 // ===================================================================
 
@@ -88,7 +96,8 @@ class LIBPROTOBUF_EXPORT SourceContext : public ::google::protobuf::Message /* @
       bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
   ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
       const PROTOBUF_FINAL {
-    return InternalSerializeWithCachedSizesToArray(false, output);
+    return InternalSerializeWithCachedSizesToArray(
+        ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
   }
   int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
   private:
@@ -116,6 +125,9 @@ class LIBPROTOBUF_EXPORT SourceContext : public ::google::protobuf::Message /* @
   static const int kFileNameFieldNumber = 1;
   const ::std::string& file_name() const;
   void set_file_name(const ::std::string& value);
+  #if LANG_CXX11
+  void set_file_name(::std::string&& value);
+  #endif
   void set_file_name(const char* value);
   void set_file_name(const char* value, size_t size);
   ::std::string* mutable_file_name();
@@ -128,11 +140,7 @@ class LIBPROTOBUF_EXPORT SourceContext : public ::google::protobuf::Message /* @
   ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
   ::google::protobuf::internal::ArenaStringPtr file_name_;
   mutable int _cached_size_;
-  friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto_impl();
-  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto_impl();
-  friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fsource_5fcontext_2eproto();
-  friend void protobuf_ShutdownFile_google_2fprotobuf_2fsource_5fcontext_2eproto();
-
+  friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto::TableStruct;
 };
 // ===================================================================
 
@@ -155,6 +163,14 @@ inline void SourceContext::set_file_name(const ::std::string& value) {
   file_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
   // @@protoc_insertion_point(field_set:google.protobuf.SourceContext.file_name)
 }
+#if LANG_CXX11
+inline void SourceContext::set_file_name(::std::string&& value) {
+  
+  file_name_.SetNoArena(
+    &::google::protobuf::internal::GetEmptyStringAlreadyInited(), std::move(value));
+  // @@protoc_insertion_point(field_set_rvalue:google.protobuf.SourceContext.file_name)
+}
+#endif
 inline void SourceContext::set_file_name(const char* value) {
   
   file_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));

+ 98 - 99
src/google/protobuf/struct.pb.cc

@@ -19,56 +19,53 @@
 
 namespace google {
 namespace protobuf {
-class StructDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Struct> {};
-StructDefaultTypeInternal _Struct_default_instance_;
-class ValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Value> {};
-ValueDefaultTypeInternal _Value_default_instance_;
-class ListValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<ListValue> {};
-ListValueDefaultTypeInternal _ListValue_default_instance_;
-
-namespace {
-
-::google::protobuf::Metadata file_level_metadata[4];
-const ::google::protobuf::EnumDescriptor* file_level_enum_descriptors[1];
-struct ValueOneofInstance {
+class StructDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Struct> {
+} _Struct_default_instance_;
+class ValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Value> {
+  public:
   int null_value_;
   double number_value_;
   ::google::protobuf::internal::ArenaStringPtr string_value_;
   bool bool_value_;
   const ::google::protobuf::Struct* struct_value_;
   const ::google::protobuf::ListValue* list_value_;
-} Value_default_oneof_instance_;
+} _Value_default_instance_;
+class ListValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<ListValue> {
+} _ListValue_default_instance_;
 
-}  // namespace
+namespace protobuf_google_2fprotobuf_2fstruct_2eproto {
 
 
-const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fstruct_2eproto() GOOGLE_ATTRIBUTE_COLD;
-const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fstruct_2eproto() {
-  static const ::google::protobuf::uint32 offsets[] = {
-    ~0u,  // no _has_bits_
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Struct, _internal_metadata_),
-    ~0u,  // no _extensions_
-    ~0u,  // no _oneof_case_
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Struct, fields_),
-    ~0u,  // no _has_bits_
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Value, _internal_metadata_),
-    ~0u,  // no _extensions_
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Value, _oneof_case_[0]),
-    PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET((&Value_default_oneof_instance_), null_value_),
-    PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET((&Value_default_oneof_instance_), number_value_),
-    PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET((&Value_default_oneof_instance_), string_value_),
-    PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET((&Value_default_oneof_instance_), bool_value_),
-    PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET((&Value_default_oneof_instance_), struct_value_),
-    PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET((&Value_default_oneof_instance_), list_value_),
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Value, kind_),
-    ~0u,  // no _has_bits_
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ListValue, _internal_metadata_),
-    ~0u,  // no _extensions_
-    ~0u,  // no _oneof_case_
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ListValue, values_),
-  };
-  return offsets;
-}
+namespace {
+
+::google::protobuf::Metadata file_level_metadata[4];
+const ::google::protobuf::EnumDescriptor* file_level_enum_descriptors[1];
+
+}  // namespace
+
+const ::google::protobuf::uint32 TableStruct::offsets[] = {
+  ~0u,  // no _has_bits_
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Struct, _internal_metadata_),
+  ~0u,  // no _extensions_
+  ~0u,  // no _oneof_case_
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Struct, fields_),
+  ~0u,  // no _has_bits_
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Value, _internal_metadata_),
+  ~0u,  // no _extensions_
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Value, _oneof_case_[0]),
+  PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET((&_Value_default_instance_), null_value_),
+  PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET((&_Value_default_instance_), number_value_),
+  PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET((&_Value_default_instance_), string_value_),
+  PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET((&_Value_default_instance_), bool_value_),
+  PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET((&_Value_default_instance_), struct_value_),
+  PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET((&_Value_default_instance_), list_value_),
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Value, kind_),
+  ~0u,  // no _has_bits_
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ListValue, _internal_metadata_),
+  ~0u,  // no _extensions_
+  ~0u,  // no _oneof_case_
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ListValue, values_),
+};
 
 static const ::google::protobuf::internal::MigrationSchema schemas[] = {
   { 0, -1, sizeof(Struct)},
@@ -76,19 +73,19 @@ static const ::google::protobuf::internal::MigrationSchema schemas[] = {
   { 16, -1, sizeof(ListValue)},
 };
 
-static const ::google::protobuf::internal::DefaultInstanceData file_default_instances[] = {
-  {reinterpret_cast<const ::google::protobuf::Message*>(&_Struct_default_instance_), NULL},
-  {reinterpret_cast<const ::google::protobuf::Message*>(&_Value_default_instance_), &Value_default_oneof_instance_},
-  {reinterpret_cast<const ::google::protobuf::Message*>(&_ListValue_default_instance_), NULL},
+static ::google::protobuf::Message const * const file_default_instances[] = {
+  reinterpret_cast<const ::google::protobuf::Message*>(&_Struct_default_instance_),
+  reinterpret_cast<const ::google::protobuf::Message*>(&_Value_default_instance_),
+  reinterpret_cast<const ::google::protobuf::Message*>(&_ListValue_default_instance_),
 };
 
 namespace {
 
 void protobuf_AssignDescriptors() {
-  protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto();
+  AddDescriptors();
   ::google::protobuf::MessageFactory* factory = NULL;
   AssignDescriptors(
-      "google/protobuf/struct.proto", schemas, file_default_instances, protobuf_Offsets_google_2fprotobuf_2fstruct_2eproto(), factory,
+      "google/protobuf/struct.proto", schemas, file_default_instances, TableStruct::offsets, factory,
       file_level_metadata, file_level_enum_descriptors, NULL);
 }
 
@@ -101,7 +98,7 @@ void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD;
 void protobuf_RegisterTypes(const ::std::string&) {
   protobuf_AssignDescriptorsOnce();
   ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 4);
-  const ::google::protobuf::Descriptor* Struct_FieldsEntry_descriptor = file_level_metadata[0].descriptor;
+  const ::google::protobuf::Descriptor* Struct_FieldsEntry_descriptor = protobuf_google_2fprotobuf_2fstruct_2eproto::file_level_metadata[0].descriptor;
   ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
         Struct_FieldsEntry_descriptor,
         ::google::protobuf::internal::MapEntry<
@@ -115,7 +112,7 @@ void protobuf_RegisterTypes(const ::std::string&) {
 
 }  // namespace
 
-void protobuf_ShutdownFile_google_2fprotobuf_2fstruct_2eproto() {
+void TableStruct::Shutdown() {
   _Struct_default_instance_.Shutdown();
   delete file_level_metadata[1].reflection;
   _Value_default_instance_.Shutdown();
@@ -124,30 +121,30 @@ void protobuf_ShutdownFile_google_2fprotobuf_2fstruct_2eproto() {
   delete file_level_metadata[3].reflection;
 }
 
-void protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto_impl() {
+void TableStruct::InitDefaultsImpl() {
   GOOGLE_PROTOBUF_VERIFY_VERSION;
 
   ::google::protobuf::internal::InitProtobufDefaults();
   _Struct_default_instance_.DefaultConstruct();
   _Value_default_instance_.DefaultConstruct();
   _ListValue_default_instance_.DefaultConstruct();
-    Value_default_oneof_instance_.null_value_ = 0;
-    Value_default_oneof_instance_.number_value_ = 0;
-  Value_default_oneof_instance_.string_value_.UnsafeSetDefault(
+  _Value_default_instance_.null_value_ = 0;
+  _Value_default_instance_.number_value_ = 0;
+  _Value_default_instance_.string_value_.UnsafeSetDefault(
       &::google::protobuf::internal::GetEmptyStringAlreadyInited());
-    Value_default_oneof_instance_.bool_value_ = false;
-  Value_default_oneof_instance_.struct_value_ = const_cast< ::google::protobuf::Struct*>(
+  _Value_default_instance_.bool_value_ = false;
+  _Value_default_instance_.struct_value_ = const_cast< ::google::protobuf::Struct*>(
       ::google::protobuf::Struct::internal_default_instance());
-  Value_default_oneof_instance_.list_value_ = const_cast< ::google::protobuf::ListValue*>(
+  _Value_default_instance_.list_value_ = const_cast< ::google::protobuf::ListValue*>(
       ::google::protobuf::ListValue::internal_default_instance());
 }
 
-void protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto() {
+void InitDefaults() {
   static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
-  ::google::protobuf::GoogleOnceInit(&once, &protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto_impl);
+  ::google::protobuf::GoogleOnceInit(&once, &TableStruct::InitDefaultsImpl);
 }
-void protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto_impl() {
-  protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto();
+void AddDescriptorsImpl() {
+  InitDefaults();
   static const char descriptor[] = {
       "\n\034google/protobuf/struct.proto\022\017google.p"
       "rotobuf\"\204\001\n\006Struct\0223\n\006fields\030\001 \003(\0132#.goo"
@@ -171,23 +168,25 @@ void protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto_impl() {
       descriptor, 641);
   ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
     "google/protobuf/struct.proto", &protobuf_RegisterTypes);
-  ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fstruct_2eproto);
+  ::google::protobuf::internal::OnShutdown(&TableStruct::Shutdown);
 }
 
-GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto_once_);
-void protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto() {
-  ::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto_once_,
-                 &protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto_impl);
+void AddDescriptors() {
+  static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
+  ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl);
 }
 // Force AddDescriptors() to be called at static initialization time.
-struct StaticDescriptorInitializer_google_2fprotobuf_2fstruct_2eproto {
-  StaticDescriptorInitializer_google_2fprotobuf_2fstruct_2eproto() {
-    protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto();
+struct StaticDescriptorInitializer {
+  StaticDescriptorInitializer() {
+    AddDescriptors();
   }
-} static_descriptor_initializer_google_2fprotobuf_2fstruct_2eproto_;
+} static_descriptor_initializer;
+
+}  // namespace protobuf_google_2fprotobuf_2fstruct_2eproto
+
 const ::google::protobuf::EnumDescriptor* NullValue_descriptor() {
-  protobuf_AssignDescriptorsOnce();
-  return file_level_enum_descriptors[0];
+  protobuf_google_2fprotobuf_2fstruct_2eproto::protobuf_AssignDescriptorsOnce();
+  return protobuf_google_2fprotobuf_2fstruct_2eproto::file_level_enum_descriptors[0];
 }
 bool NullValue_IsValid(int value) {
   switch (value) {
@@ -213,7 +212,7 @@ const int Struct::kFieldsFieldNumber;
 Struct::Struct()
   : ::google::protobuf::Message(), _internal_metadata_(NULL) {
   if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
-    protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto();
+    protobuf_google_2fprotobuf_2fstruct_2eproto::InitDefaults();
   }
   SharedCtor();
   // @@protoc_insertion_point(constructor:google.protobuf.Struct)
@@ -223,7 +222,7 @@ Struct::Struct(::google::protobuf::Arena* arena)
   _internal_metadata_(arena),
   fields_(arena) {
 #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
-  protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto();
+  protobuf_google_2fprotobuf_2fstruct_2eproto::InitDefaults();
 #endif  // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
   SharedCtor();
   RegisterArenaDtor(arena);
@@ -234,9 +233,9 @@ Struct::Struct(const Struct& from)
       _internal_metadata_(NULL),
       _cached_size_(0) {
   _internal_metadata_.MergeFrom(from._internal_metadata_);
-  const ::google::protobuf::Descriptor*& Struct_FieldsEntry_descriptor = file_level_metadata[0].descriptor;
+  const ::google::protobuf::Descriptor*& Struct_FieldsEntry_descriptor = protobuf_google_2fprotobuf_2fstruct_2eproto::file_level_metadata[0].descriptor;
   fields_.SetAssignDescriptorCallback(
-      protobuf_AssignDescriptorsOnce);
+      protobuf_google_2fprotobuf_2fstruct_2eproto::protobuf_AssignDescriptorsOnce);
   fields_.SetEntryDescriptor(
       &Struct_FieldsEntry_descriptor);
   fields_.MergeFrom(from.fields_);
@@ -244,9 +243,9 @@ Struct::Struct(const Struct& from)
 }
 
 void Struct::SharedCtor() {
-  const ::google::protobuf::Descriptor*& Struct_FieldsEntry_descriptor = file_level_metadata[0].descriptor;
+  const ::google::protobuf::Descriptor*& Struct_FieldsEntry_descriptor = protobuf_google_2fprotobuf_2fstruct_2eproto::file_level_metadata[0].descriptor;
   fields_.SetAssignDescriptorCallback(
-      protobuf_AssignDescriptorsOnce);
+      protobuf_google_2fprotobuf_2fstruct_2eproto::protobuf_AssignDescriptorsOnce);
   fields_.SetEntryDescriptor(
       &Struct_FieldsEntry_descriptor);
   _cached_size_ = 0;
@@ -277,12 +276,12 @@ void Struct::SetCachedSize(int size) const {
   GOOGLE_SAFE_CONCURRENT_WRITES_END();
 }
 const ::google::protobuf::Descriptor* Struct::descriptor() {
-  protobuf_AssignDescriptorsOnce();
-  return file_level_metadata[1].descriptor;
+  protobuf_google_2fprotobuf_2fstruct_2eproto::protobuf_AssignDescriptorsOnce();
+  return protobuf_google_2fprotobuf_2fstruct_2eproto::file_level_metadata[1].descriptor;
 }
 
 const Struct& Struct::default_instance() {
-  protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto();
+  protobuf_google_2fprotobuf_2fstruct_2eproto::InitDefaults();
   return *internal_default_instance();
 }
 
@@ -412,7 +411,7 @@ void Struct::SerializeWithCachedSizes(
 
 ::google::protobuf::uint8* Struct::InternalSerializeWithCachedSizesToArray(
     bool deterministic, ::google::protobuf::uint8* target) const {
-  (void)deterministic; // Unused
+  (void)deterministic;  // Unused
   // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Struct)
   // map<string, .google.protobuf.Value> fields = 1;
   if (!this->fields().empty()) {
@@ -573,8 +572,8 @@ void Struct::InternalSwap(Struct* other) {
 }
 
 ::google::protobuf::Metadata Struct::GetMetadata() const {
-  protobuf_AssignDescriptorsOnce();
-  return file_level_metadata[1];
+  protobuf_google_2fprotobuf_2fstruct_2eproto::protobuf_AssignDescriptorsOnce();
+  return protobuf_google_2fprotobuf_2fstruct_2eproto::file_level_metadata[1];
 }
 
 #if PROTOBUF_INLINE_NOT_IN_HEADERS
@@ -614,7 +613,7 @@ const int Value::kListValueFieldNumber;
 Value::Value()
   : ::google::protobuf::Message(), _internal_metadata_(NULL) {
   if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
-    protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto();
+    protobuf_google_2fprotobuf_2fstruct_2eproto::InitDefaults();
   }
   SharedCtor();
   // @@protoc_insertion_point(constructor:google.protobuf.Value)
@@ -623,7 +622,7 @@ Value::Value(::google::protobuf::Arena* arena)
   : ::google::protobuf::Message(),
   _internal_metadata_(arena) {
 #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
-  protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto();
+  protobuf_google_2fprotobuf_2fstruct_2eproto::InitDefaults();
 #endif  // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
   SharedCtor();
   RegisterArenaDtor(arena);
@@ -700,12 +699,12 @@ void Value::SetCachedSize(int size) const {
   GOOGLE_SAFE_CONCURRENT_WRITES_END();
 }
 const ::google::protobuf::Descriptor* Value::descriptor() {
-  protobuf_AssignDescriptorsOnce();
-  return file_level_metadata[2].descriptor;
+  protobuf_google_2fprotobuf_2fstruct_2eproto::protobuf_AssignDescriptorsOnce();
+  return protobuf_google_2fprotobuf_2fstruct_2eproto::file_level_metadata[2].descriptor;
 }
 
 const Value& Value::default_instance() {
-  protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto();
+  protobuf_google_2fprotobuf_2fstruct_2eproto::InitDefaults();
   return *internal_default_instance();
 }
 
@@ -914,7 +913,7 @@ void Value::SerializeWithCachedSizes(
 
 ::google::protobuf::uint8* Value::InternalSerializeWithCachedSizesToArray(
     bool deterministic, ::google::protobuf::uint8* target) const {
-  (void)deterministic; // Unused
+  (void)deterministic;  // Unused
   // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Value)
   // .google.protobuf.NullValue null_value = 1;
   if (has_null_value()) {
@@ -1108,8 +1107,8 @@ void Value::InternalSwap(Value* other) {
 }
 
 ::google::protobuf::Metadata Value::GetMetadata() const {
-  protobuf_AssignDescriptorsOnce();
-  return file_level_metadata[2];
+  protobuf_google_2fprotobuf_2fstruct_2eproto::protobuf_AssignDescriptorsOnce();
+  return protobuf_google_2fprotobuf_2fstruct_2eproto::file_level_metadata[2];
 }
 
 #if PROTOBUF_INLINE_NOT_IN_HEADERS
@@ -1507,7 +1506,7 @@ const int ListValue::kValuesFieldNumber;
 ListValue::ListValue()
   : ::google::protobuf::Message(), _internal_metadata_(NULL) {
   if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
-    protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto();
+    protobuf_google_2fprotobuf_2fstruct_2eproto::InitDefaults();
   }
   SharedCtor();
   // @@protoc_insertion_point(constructor:google.protobuf.ListValue)
@@ -1517,7 +1516,7 @@ ListValue::ListValue(::google::protobuf::Arena* arena)
   _internal_metadata_(arena),
   values_(arena) {
 #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
-  protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto();
+  protobuf_google_2fprotobuf_2fstruct_2eproto::InitDefaults();
 #endif  // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
   SharedCtor();
   RegisterArenaDtor(arena);
@@ -1561,12 +1560,12 @@ void ListValue::SetCachedSize(int size) const {
   GOOGLE_SAFE_CONCURRENT_WRITES_END();
 }
 const ::google::protobuf::Descriptor* ListValue::descriptor() {
-  protobuf_AssignDescriptorsOnce();
-  return file_level_metadata[3].descriptor;
+  protobuf_google_2fprotobuf_2fstruct_2eproto::protobuf_AssignDescriptorsOnce();
+  return protobuf_google_2fprotobuf_2fstruct_2eproto::file_level_metadata[3].descriptor;
 }
 
 const ListValue& ListValue::default_instance() {
-  protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto();
+  protobuf_google_2fprotobuf_2fstruct_2eproto::InitDefaults();
   return *internal_default_instance();
 }
 
@@ -1637,7 +1636,7 @@ void ListValue::SerializeWithCachedSizes(
 
 ::google::protobuf::uint8* ListValue::InternalSerializeWithCachedSizesToArray(
     bool deterministic, ::google::protobuf::uint8* target) const {
-  (void)deterministic; // Unused
+  (void)deterministic;  // Unused
   // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.ListValue)
   // repeated .google.protobuf.Value values = 1;
   for (unsigned int i = 0, n = this->values_size(); i < n; i++) {
@@ -1737,8 +1736,8 @@ void ListValue::InternalSwap(ListValue* other) {
 }
 
 ::google::protobuf::Metadata ListValue::GetMetadata() const {
-  protobuf_AssignDescriptorsOnce();
-  return file_level_metadata[3];
+  protobuf_google_2fprotobuf_2fstruct_2eproto::protobuf_AssignDescriptorsOnce();
+  return protobuf_google_2fprotobuf_2fstruct_2eproto::file_level_metadata[3];
 }
 
 #if PROTOBUF_INLINE_NOT_IN_HEADERS

+ 19 - 20
src/google/protobuf/struct.pb.h

@@ -19,6 +19,7 @@
 #error regenerate this file with a newer version of protoc.
 #endif
 
+#include <google/protobuf/io/coded_stream.h>
 #include <google/protobuf/arena.h>
 #include <google/protobuf/arenastring.h>
 #include <google/protobuf/generated_message_util.h>
@@ -48,9 +49,16 @@ LIBPROTOBUF_EXPORT extern ValueDefaultTypeInternal _Value_default_instance_;
 namespace google {
 namespace protobuf {
 
+namespace protobuf_google_2fprotobuf_2fstruct_2eproto {
 // Internal implementation detail -- do not call these.
-void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto();
-void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto();
+struct LIBPROTOBUF_EXPORT TableStruct {
+  static const ::google::protobuf::uint32 offsets[];
+  static void InitDefaultsImpl();
+  static void Shutdown();
+};
+void LIBPROTOBUF_EXPORT AddDescriptors();
+void LIBPROTOBUF_EXPORT InitDefaults();
+}  // namespace protobuf_google_2fprotobuf_2fstruct_2eproto
 
 enum NullValue {
   NULL_VALUE = 0,
@@ -127,7 +135,8 @@ class LIBPROTOBUF_EXPORT Struct : public ::google::protobuf::Message /* @@protoc
       bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
   ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
       const PROTOBUF_FINAL {
-    return InternalSerializeWithCachedSizesToArray(false, output);
+    return InternalSerializeWithCachedSizesToArray(
+        ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
   }
   int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
   private:
@@ -184,11 +193,7 @@ class LIBPROTOBUF_EXPORT Struct : public ::google::protobuf::Message /* @@protoc
       ::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE,
       0 > fields_;
   mutable int _cached_size_;
-  friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto_impl();
-  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto_impl();
-  friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fstruct_2eproto();
-  friend void protobuf_ShutdownFile_google_2fprotobuf_2fstruct_2eproto();
-
+  friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fstruct_2eproto::TableStruct;
 };
 // -------------------------------------------------------------------
 
@@ -252,7 +257,8 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_
       bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
   ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
       const PROTOBUF_FINAL {
-    return InternalSerializeWithCachedSizesToArray(false, output);
+    return InternalSerializeWithCachedSizesToArray(
+        ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
   }
   int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
   private:
@@ -390,11 +396,7 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_
   mutable int _cached_size_;
   ::google::protobuf::uint32 _oneof_case_[1];
 
-  friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto_impl();
-  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto_impl();
-  friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fstruct_2eproto();
-  friend void protobuf_ShutdownFile_google_2fprotobuf_2fstruct_2eproto();
-
+  friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fstruct_2eproto::TableStruct;
 };
 // -------------------------------------------------------------------
 
@@ -448,7 +450,8 @@ class LIBPROTOBUF_EXPORT ListValue : public ::google::protobuf::Message /* @@pro
       bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
   ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
       const PROTOBUF_FINAL {
-    return InternalSerializeWithCachedSizesToArray(false, output);
+    return InternalSerializeWithCachedSizesToArray(
+        ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
   }
   int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
   private:
@@ -497,11 +500,7 @@ class LIBPROTOBUF_EXPORT ListValue : public ::google::protobuf::Message /* @@pro
   typedef void DestructorSkippable_;
   ::google::protobuf::RepeatedPtrField< ::google::protobuf::Value > values_;
   mutable int _cached_size_;
-  friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto_impl();
-  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto_impl();
-  friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fstruct_2eproto();
-  friend void protobuf_ShutdownFile_google_2fprotobuf_2fstruct_2eproto();
-
+  friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fstruct_2eproto::TableStruct;
 };
 // ===================================================================
 

+ 0 - 1
src/google/protobuf/stubs/port.h

@@ -454,7 +454,6 @@ class BigEndian {
   }
 };
 
-
 }  // namespace protobuf
 }  // namespace google
 

+ 6 - 64
src/google/protobuf/text_format.cc

@@ -1646,54 +1646,6 @@ void TextFormat::Printer::PrintFieldValueToString(
   PrintFieldValue(message, message.GetReflection(), field, index, generator);
 }
 
-class MapEntryMessageComparator {
- public:
-  explicit MapEntryMessageComparator(const Descriptor* descriptor)
-      : field_(descriptor->field(0)) {}
-
-  bool operator()(const Message* a, const Message* b) {
-    const Reflection* reflection = a->GetReflection();
-    switch (field_->cpp_type()) {
-      case FieldDescriptor::CPPTYPE_BOOL: {
-          bool first = reflection->GetBool(*a, field_);
-          bool second = reflection->GetBool(*b, field_);
-          return first < second;
-      }
-      case FieldDescriptor::CPPTYPE_INT32: {
-          int32 first = reflection->GetInt32(*a, field_);
-          int32 second = reflection->GetInt32(*b, field_);
-          return first < second;
-      }
-      case FieldDescriptor::CPPTYPE_INT64: {
-          int64 first = reflection->GetInt64(*a, field_);
-          int64 second = reflection->GetInt64(*b, field_);
-          return first < second;
-      }
-      case FieldDescriptor::CPPTYPE_UINT32: {
-          uint32 first = reflection->GetUInt32(*a, field_);
-          uint32 second = reflection->GetUInt32(*b, field_);
-          return first < second;
-      }
-      case FieldDescriptor::CPPTYPE_UINT64: {
-          uint64 first = reflection->GetUInt64(*a, field_);
-          uint64 second = reflection->GetUInt64(*b, field_);
-          return first < second;
-      }
-      case FieldDescriptor::CPPTYPE_STRING: {
-          string first = reflection->GetString(*a, field_);
-          string second = reflection->GetString(*b, field_);
-          return first < second;
-      }
-      default:
-        GOOGLE_LOG(DFATAL) << "Invalid key for map field.";
-        return true;
-    }
-  }
-
- private:
-  const FieldDescriptor* field_;
-};
-
 void TextFormat::Printer::PrintField(const Message& message,
                                      const Reflection* reflection,
                                      const FieldDescriptor* field,
@@ -1714,19 +1666,10 @@ void TextFormat::Printer::PrintField(const Message& message,
     count = 1;
   }
 
-  std::vector<const Message*> sorted_map_field;
-  if (field->is_map()) {
-    const RepeatedPtrField<Message>& map_field =
-        reflection->GetRepeatedPtrField<Message>(message, field);
-    for (RepeatedPtrField<Message>::const_pointer_iterator it =
-             map_field.pointer_begin();
-         it != map_field.pointer_end(); ++it) {
-      sorted_map_field.push_back(*it);
-    }
-
-    MapEntryMessageComparator comparator(field->message_type());
-    std::stable_sort(sorted_map_field.begin(), sorted_map_field.end(),
-                     comparator);
+  std::vector<const Message*> map_entries;
+  const bool is_map = field->is_map();
+  if (is_map) {
+    map_entries = DynamicMapSorter::Sort(message, count, reflection, field);
   }
 
   for (int j = 0; j < count; ++j) {
@@ -1739,9 +1682,8 @@ void TextFormat::Printer::PrintField(const Message& message,
           custom_printers_, field, default_field_value_printer_.get());
       const Message& sub_message =
           field->is_repeated()
-              ? (field->is_map()
-                     ? *sorted_map_field[j]
-                     : reflection->GetRepeatedMessage(message, field, j))
+              ? (is_map ? *map_entries[j]
+                        : reflection->GetRepeatedMessage(message, field, j))
               : reflection->GetMessage(message, field);
       generator.Print(
           printer->PrintMessageStart(

+ 42 - 42
src/google/protobuf/timestamp.pb.cc

@@ -19,8 +19,11 @@
 
 namespace google {
 namespace protobuf {
-class TimestampDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Timestamp> {};
-TimestampDefaultTypeInternal _Timestamp_default_instance_;
+class TimestampDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Timestamp> {
+} _Timestamp_default_instance_;
+
+namespace protobuf_google_2fprotobuf_2ftimestamp_2eproto {
+
 
 namespace {
 
@@ -28,35 +31,30 @@ namespace {
 
 }  // namespace
 
-
-const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2ftimestamp_2eproto() GOOGLE_ATTRIBUTE_COLD;
-const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2ftimestamp_2eproto() {
-  static const ::google::protobuf::uint32 offsets[] = {
-    ~0u,  // no _has_bits_
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Timestamp, _internal_metadata_),
-    ~0u,  // no _extensions_
-    ~0u,  // no _oneof_case_
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Timestamp, seconds_),
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Timestamp, nanos_),
-  };
-  return offsets;
-}
+const ::google::protobuf::uint32 TableStruct::offsets[] = {
+  ~0u,  // no _has_bits_
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Timestamp, _internal_metadata_),
+  ~0u,  // no _extensions_
+  ~0u,  // no _oneof_case_
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Timestamp, seconds_),
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Timestamp, nanos_),
+};
 
 static const ::google::protobuf::internal::MigrationSchema schemas[] = {
   { 0, -1, sizeof(Timestamp)},
 };
 
-static const ::google::protobuf::internal::DefaultInstanceData file_default_instances[] = {
-  {reinterpret_cast<const ::google::protobuf::Message*>(&_Timestamp_default_instance_), NULL},
+static ::google::protobuf::Message const * const file_default_instances[] = {
+  reinterpret_cast<const ::google::protobuf::Message*>(&_Timestamp_default_instance_),
 };
 
 namespace {
 
 void protobuf_AssignDescriptors() {
-  protobuf_AddDesc_google_2fprotobuf_2ftimestamp_2eproto();
+  AddDescriptors();
   ::google::protobuf::MessageFactory* factory = NULL;
   AssignDescriptors(
-      "google/protobuf/timestamp.proto", schemas, file_default_instances, protobuf_Offsets_google_2fprotobuf_2ftimestamp_2eproto(), factory,
+      "google/protobuf/timestamp.proto", schemas, file_default_instances, TableStruct::offsets, factory,
       file_level_metadata, NULL, NULL);
 }
 
@@ -73,24 +71,24 @@ void protobuf_RegisterTypes(const ::std::string&) {
 
 }  // namespace
 
-void protobuf_ShutdownFile_google_2fprotobuf_2ftimestamp_2eproto() {
+void TableStruct::Shutdown() {
   _Timestamp_default_instance_.Shutdown();
   delete file_level_metadata[0].reflection;
 }
 
-void protobuf_InitDefaults_google_2fprotobuf_2ftimestamp_2eproto_impl() {
+void TableStruct::InitDefaultsImpl() {
   GOOGLE_PROTOBUF_VERIFY_VERSION;
 
   ::google::protobuf::internal::InitProtobufDefaults();
   _Timestamp_default_instance_.DefaultConstruct();
 }
 
-void protobuf_InitDefaults_google_2fprotobuf_2ftimestamp_2eproto() {
+void InitDefaults() {
   static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
-  ::google::protobuf::GoogleOnceInit(&once, &protobuf_InitDefaults_google_2fprotobuf_2ftimestamp_2eproto_impl);
+  ::google::protobuf::GoogleOnceInit(&once, &TableStruct::InitDefaultsImpl);
 }
-void protobuf_AddDesc_google_2fprotobuf_2ftimestamp_2eproto_impl() {
-  protobuf_InitDefaults_google_2fprotobuf_2ftimestamp_2eproto();
+void AddDescriptorsImpl() {
+  InitDefaults();
   static const char descriptor[] = {
       "\n\037google/protobuf/timestamp.proto\022\017googl"
       "e.protobuf\"+\n\tTimestamp\022\017\n\007seconds\030\001 \001(\003"
@@ -103,20 +101,22 @@ void protobuf_AddDesc_google_2fprotobuf_2ftimestamp_2eproto_impl() {
       descriptor, 231);
   ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
     "google/protobuf/timestamp.proto", &protobuf_RegisterTypes);
-  ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2ftimestamp_2eproto);
+  ::google::protobuf::internal::OnShutdown(&TableStruct::Shutdown);
 }
 
-GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_google_2fprotobuf_2ftimestamp_2eproto_once_);
-void protobuf_AddDesc_google_2fprotobuf_2ftimestamp_2eproto() {
-  ::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_google_2fprotobuf_2ftimestamp_2eproto_once_,
-                 &protobuf_AddDesc_google_2fprotobuf_2ftimestamp_2eproto_impl);
+void AddDescriptors() {
+  static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
+  ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl);
 }
 // Force AddDescriptors() to be called at static initialization time.
-struct StaticDescriptorInitializer_google_2fprotobuf_2ftimestamp_2eproto {
-  StaticDescriptorInitializer_google_2fprotobuf_2ftimestamp_2eproto() {
-    protobuf_AddDesc_google_2fprotobuf_2ftimestamp_2eproto();
+struct StaticDescriptorInitializer {
+  StaticDescriptorInitializer() {
+    AddDescriptors();
   }
-} static_descriptor_initializer_google_2fprotobuf_2ftimestamp_2eproto_;
+} static_descriptor_initializer;
+
+}  // namespace protobuf_google_2fprotobuf_2ftimestamp_2eproto
+
 
 // ===================================================================
 
@@ -128,7 +128,7 @@ const int Timestamp::kNanosFieldNumber;
 Timestamp::Timestamp()
   : ::google::protobuf::Message(), _internal_metadata_(NULL) {
   if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
-    protobuf_InitDefaults_google_2fprotobuf_2ftimestamp_2eproto();
+    protobuf_google_2fprotobuf_2ftimestamp_2eproto::InitDefaults();
   }
   SharedCtor();
   // @@protoc_insertion_point(constructor:google.protobuf.Timestamp)
@@ -137,7 +137,7 @@ Timestamp::Timestamp(::google::protobuf::Arena* arena)
   : ::google::protobuf::Message(),
   _internal_metadata_(arena) {
 #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
-  protobuf_InitDefaults_google_2fprotobuf_2ftimestamp_2eproto();
+  protobuf_google_2fprotobuf_2ftimestamp_2eproto::InitDefaults();
 #endif  // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
   SharedCtor();
   RegisterArenaDtor(arena);
@@ -185,12 +185,12 @@ void Timestamp::SetCachedSize(int size) const {
   GOOGLE_SAFE_CONCURRENT_WRITES_END();
 }
 const ::google::protobuf::Descriptor* Timestamp::descriptor() {
-  protobuf_AssignDescriptorsOnce();
-  return file_level_metadata[0].descriptor;
+  protobuf_google_2fprotobuf_2ftimestamp_2eproto::protobuf_AssignDescriptorsOnce();
+  return protobuf_google_2fprotobuf_2ftimestamp_2eproto::file_level_metadata[0].descriptor;
 }
 
 const Timestamp& Timestamp::default_instance() {
-  protobuf_InitDefaults_google_2fprotobuf_2ftimestamp_2eproto();
+  protobuf_google_2fprotobuf_2ftimestamp_2eproto::InitDefaults();
   return *internal_default_instance();
 }
 
@@ -279,7 +279,7 @@ void Timestamp::SerializeWithCachedSizes(
 
 ::google::protobuf::uint8* Timestamp::InternalSerializeWithCachedSizesToArray(
     bool deterministic, ::google::protobuf::uint8* target) const {
-  (void)deterministic; // Unused
+  (void)deterministic;  // Unused
   // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Timestamp)
   // int64 seconds = 1;
   if (this->seconds() != 0) {
@@ -391,8 +391,8 @@ void Timestamp::InternalSwap(Timestamp* other) {
 }
 
 ::google::protobuf::Metadata Timestamp::GetMetadata() const {
-  protobuf_AssignDescriptorsOnce();
-  return file_level_metadata[0];
+  protobuf_google_2fprotobuf_2ftimestamp_2eproto::protobuf_AssignDescriptorsOnce();
+  return protobuf_google_2fprotobuf_2ftimestamp_2eproto::file_level_metadata[0];
 }
 
 #if PROTOBUF_INLINE_NOT_IN_HEADERS

+ 13 - 8
src/google/protobuf/timestamp.pb.h

@@ -19,6 +19,7 @@
 #error regenerate this file with a newer version of protoc.
 #endif
 
+#include <google/protobuf/io/coded_stream.h>
 #include <google/protobuf/arena.h>
 #include <google/protobuf/arenastring.h>
 #include <google/protobuf/generated_message_util.h>
@@ -39,9 +40,16 @@ LIBPROTOBUF_EXPORT extern TimestampDefaultTypeInternal _Timestamp_default_instan
 namespace google {
 namespace protobuf {
 
+namespace protobuf_google_2fprotobuf_2ftimestamp_2eproto {
 // Internal implementation detail -- do not call these.
-void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ftimestamp_2eproto();
-void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2ftimestamp_2eproto();
+struct LIBPROTOBUF_EXPORT TableStruct {
+  static const ::google::protobuf::uint32 offsets[];
+  static void InitDefaultsImpl();
+  static void Shutdown();
+};
+void LIBPROTOBUF_EXPORT AddDescriptors();
+void LIBPROTOBUF_EXPORT InitDefaults();
+}  // namespace protobuf_google_2fprotobuf_2ftimestamp_2eproto
 
 // ===================================================================
 
@@ -95,7 +103,8 @@ class LIBPROTOBUF_EXPORT Timestamp : public ::google::protobuf::Message /* @@pro
       bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
   ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
       const PROTOBUF_FINAL {
-    return InternalSerializeWithCachedSizesToArray(false, output);
+    return InternalSerializeWithCachedSizesToArray(
+        ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
   }
   int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
   private:
@@ -145,11 +154,7 @@ class LIBPROTOBUF_EXPORT Timestamp : public ::google::protobuf::Message /* @@pro
   ::google::protobuf::int64 seconds_;
   ::google::protobuf::int32 nanos_;
   mutable int _cached_size_;
-  friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2ftimestamp_2eproto_impl();
-  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ftimestamp_2eproto_impl();
-  friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2ftimestamp_2eproto();
-  friend void protobuf_ShutdownFile_google_2fprotobuf_2ftimestamp_2eproto();
-
+  friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2ftimestamp_2eproto::TableStruct;
 };
 // ===================================================================
 

+ 136 - 136
src/google/protobuf/type.pb.cc

@@ -19,16 +19,19 @@
 
 namespace google {
 namespace protobuf {
-class TypeDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Type> {};
-TypeDefaultTypeInternal _Type_default_instance_;
-class FieldDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Field> {};
-FieldDefaultTypeInternal _Field_default_instance_;
-class EnumDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Enum> {};
-EnumDefaultTypeInternal _Enum_default_instance_;
-class EnumValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<EnumValue> {};
-EnumValueDefaultTypeInternal _EnumValue_default_instance_;
-class OptionDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Option> {};
-OptionDefaultTypeInternal _Option_default_instance_;
+class TypeDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Type> {
+} _Type_default_instance_;
+class FieldDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Field> {
+} _Field_default_instance_;
+class EnumDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Enum> {
+} _Enum_default_instance_;
+class EnumValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<EnumValue> {
+} _EnumValue_default_instance_;
+class OptionDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Option> {
+} _Option_default_instance_;
+
+namespace protobuf_google_2fprotobuf_2ftype_2eproto {
+
 
 namespace {
 
@@ -37,59 +40,54 @@ const ::google::protobuf::EnumDescriptor* file_level_enum_descriptors[3];
 
 }  // namespace
 
-
-const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2ftype_2eproto() GOOGLE_ATTRIBUTE_COLD;
-const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2ftype_2eproto() {
-  static const ::google::protobuf::uint32 offsets[] = {
-    ~0u,  // no _has_bits_
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Type, _internal_metadata_),
-    ~0u,  // no _extensions_
-    ~0u,  // no _oneof_case_
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Type, name_),
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Type, fields_),
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Type, oneofs_),
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Type, options_),
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Type, source_context_),
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Type, syntax_),
-    ~0u,  // no _has_bits_
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, _internal_metadata_),
-    ~0u,  // no _extensions_
-    ~0u,  // no _oneof_case_
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, kind_),
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, cardinality_),
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, number_),
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, name_),
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, type_url_),
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, oneof_index_),
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, packed_),
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, options_),
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, json_name_),
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, default_value_),
-    ~0u,  // no _has_bits_
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Enum, _internal_metadata_),
-    ~0u,  // no _extensions_
-    ~0u,  // no _oneof_case_
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Enum, name_),
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Enum, enumvalue_),
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Enum, options_),
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Enum, source_context_),
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Enum, syntax_),
-    ~0u,  // no _has_bits_
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValue, _internal_metadata_),
-    ~0u,  // no _extensions_
-    ~0u,  // no _oneof_case_
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValue, name_),
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValue, number_),
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValue, options_),
-    ~0u,  // no _has_bits_
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Option, _internal_metadata_),
-    ~0u,  // no _extensions_
-    ~0u,  // no _oneof_case_
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Option, name_),
-    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Option, value_),
-  };
-  return offsets;
-}
+const ::google::protobuf::uint32 TableStruct::offsets[] = {
+  ~0u,  // no _has_bits_
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Type, _internal_metadata_),
+  ~0u,  // no _extensions_
+  ~0u,  // no _oneof_case_
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Type, name_),
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Type, fields_),
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Type, oneofs_),
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Type, options_),
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Type, source_context_),
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Type, syntax_),
+  ~0u,  // no _has_bits_
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, _internal_metadata_),
+  ~0u,  // no _extensions_
+  ~0u,  // no _oneof_case_
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, kind_),
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, cardinality_),
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, number_),
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, name_),
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, type_url_),
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, oneof_index_),
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, packed_),
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, options_),
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, json_name_),
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, default_value_),
+  ~0u,  // no _has_bits_
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Enum, _internal_metadata_),
+  ~0u,  // no _extensions_
+  ~0u,  // no _oneof_case_
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Enum, name_),
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Enum, enumvalue_),
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Enum, options_),
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Enum, source_context_),
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Enum, syntax_),
+  ~0u,  // no _has_bits_
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValue, _internal_metadata_),
+  ~0u,  // no _extensions_
+  ~0u,  // no _oneof_case_
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValue, name_),
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValue, number_),
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValue, options_),
+  ~0u,  // no _has_bits_
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Option, _internal_metadata_),
+  ~0u,  // no _extensions_
+  ~0u,  // no _oneof_case_
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Option, name_),
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Option, value_),
+};
 
 static const ::google::protobuf::internal::MigrationSchema schemas[] = {
   { 0, -1, sizeof(Type)},
@@ -99,21 +97,21 @@ static const ::google::protobuf::internal::MigrationSchema schemas[] = {
   { 40, -1, sizeof(Option)},
 };
 
-static const ::google::protobuf::internal::DefaultInstanceData file_default_instances[] = {
-  {reinterpret_cast<const ::google::protobuf::Message*>(&_Type_default_instance_), NULL},
-  {reinterpret_cast<const ::google::protobuf::Message*>(&_Field_default_instance_), NULL},
-  {reinterpret_cast<const ::google::protobuf::Message*>(&_Enum_default_instance_), NULL},
-  {reinterpret_cast<const ::google::protobuf::Message*>(&_EnumValue_default_instance_), NULL},
-  {reinterpret_cast<const ::google::protobuf::Message*>(&_Option_default_instance_), NULL},
+static ::google::protobuf::Message const * const file_default_instances[] = {
+  reinterpret_cast<const ::google::protobuf::Message*>(&_Type_default_instance_),
+  reinterpret_cast<const ::google::protobuf::Message*>(&_Field_default_instance_),
+  reinterpret_cast<const ::google::protobuf::Message*>(&_Enum_default_instance_),
+  reinterpret_cast<const ::google::protobuf::Message*>(&_EnumValue_default_instance_),
+  reinterpret_cast<const ::google::protobuf::Message*>(&_Option_default_instance_),
 };
 
 namespace {
 
 void protobuf_AssignDescriptors() {
-  protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto();
+  AddDescriptors();
   ::google::protobuf::MessageFactory* factory = NULL;
   AssignDescriptors(
-      "google/protobuf/type.proto", schemas, file_default_instances, protobuf_Offsets_google_2fprotobuf_2ftype_2eproto(), factory,
+      "google/protobuf/type.proto", schemas, file_default_instances, TableStruct::offsets, factory,
       file_level_metadata, file_level_enum_descriptors, NULL);
 }
 
@@ -130,7 +128,7 @@ void protobuf_RegisterTypes(const ::std::string&) {
 
 }  // namespace
 
-void protobuf_ShutdownFile_google_2fprotobuf_2ftype_2eproto() {
+void TableStruct::Shutdown() {
   _Type_default_instance_.Shutdown();
   delete file_level_metadata[0].reflection;
   _Field_default_instance_.Shutdown();
@@ -143,12 +141,12 @@ void protobuf_ShutdownFile_google_2fprotobuf_2ftype_2eproto() {
   delete file_level_metadata[4].reflection;
 }
 
-void protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto_impl() {
+void TableStruct::InitDefaultsImpl() {
   GOOGLE_PROTOBUF_VERIFY_VERSION;
 
-  ::google::protobuf::protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto();
-  ::google::protobuf::protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto();
   ::google::protobuf::internal::InitProtobufDefaults();
+  ::google::protobuf::protobuf_google_2fprotobuf_2fany_2eproto::InitDefaults();
+  ::google::protobuf::protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto::InitDefaults();
   _Type_default_instance_.DefaultConstruct();
   _Field_default_instance_.DefaultConstruct();
   _Enum_default_instance_.DefaultConstruct();
@@ -162,12 +160,12 @@ void protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto_impl() {
       ::google::protobuf::Any::internal_default_instance());
 }
 
-void protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto() {
+void InitDefaults() {
   static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
-  ::google::protobuf::GoogleOnceInit(&once, &protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto_impl);
+  ::google::protobuf::GoogleOnceInit(&once, &TableStruct::InitDefaultsImpl);
 }
-void protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto_impl() {
-  protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto();
+void AddDescriptorsImpl() {
+  InitDefaults();
   static const char descriptor[] = {
       "\n\032google/protobuf/type.proto\022\017google.pro"
       "tobuf\032\031google/protobuf/any.proto\032$google"
@@ -214,25 +212,27 @@ void protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto_impl() {
       descriptor, 1594);
   ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
     "google/protobuf/type.proto", &protobuf_RegisterTypes);
-  ::google::protobuf::protobuf_AddDesc_google_2fprotobuf_2fany_2eproto();
-  ::google::protobuf::protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto();
-  ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2ftype_2eproto);
+  ::google::protobuf::protobuf_google_2fprotobuf_2fany_2eproto::AddDescriptors();
+  ::google::protobuf::protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto::AddDescriptors();
+  ::google::protobuf::internal::OnShutdown(&TableStruct::Shutdown);
 }
 
-GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto_once_);
-void protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto() {
-  ::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto_once_,
-                 &protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto_impl);
+void AddDescriptors() {
+  static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
+  ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl);
 }
 // Force AddDescriptors() to be called at static initialization time.
-struct StaticDescriptorInitializer_google_2fprotobuf_2ftype_2eproto {
-  StaticDescriptorInitializer_google_2fprotobuf_2ftype_2eproto() {
-    protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto();
+struct StaticDescriptorInitializer {
+  StaticDescriptorInitializer() {
+    AddDescriptors();
   }
-} static_descriptor_initializer_google_2fprotobuf_2ftype_2eproto_;
+} static_descriptor_initializer;
+
+}  // namespace protobuf_google_2fprotobuf_2ftype_2eproto
+
 const ::google::protobuf::EnumDescriptor* Field_Kind_descriptor() {
-  protobuf_AssignDescriptorsOnce();
-  return file_level_enum_descriptors[0];
+  protobuf_google_2fprotobuf_2ftype_2eproto::protobuf_AssignDescriptorsOnce();
+  return protobuf_google_2fprotobuf_2ftype_2eproto::file_level_enum_descriptors[0];
 }
 bool Field_Kind_IsValid(int value) {
   switch (value) {
@@ -286,8 +286,8 @@ const Field_Kind Field::Kind_MAX;
 const int Field::Kind_ARRAYSIZE;
 #endif  // !defined(_MSC_VER) || _MSC_VER >= 1900
 const ::google::protobuf::EnumDescriptor* Field_Cardinality_descriptor() {
-  protobuf_AssignDescriptorsOnce();
-  return file_level_enum_descriptors[1];
+  protobuf_google_2fprotobuf_2ftype_2eproto::protobuf_AssignDescriptorsOnce();
+  return protobuf_google_2fprotobuf_2ftype_2eproto::file_level_enum_descriptors[1];
 }
 bool Field_Cardinality_IsValid(int value) {
   switch (value) {
@@ -311,8 +311,8 @@ const Field_Cardinality Field::Cardinality_MAX;
 const int Field::Cardinality_ARRAYSIZE;
 #endif  // !defined(_MSC_VER) || _MSC_VER >= 1900
 const ::google::protobuf::EnumDescriptor* Syntax_descriptor() {
-  protobuf_AssignDescriptorsOnce();
-  return file_level_enum_descriptors[2];
+  protobuf_google_2fprotobuf_2ftype_2eproto::protobuf_AssignDescriptorsOnce();
+  return protobuf_google_2fprotobuf_2ftype_2eproto::file_level_enum_descriptors[2];
 }
 bool Syntax_IsValid(int value) {
   switch (value) {
@@ -372,7 +372,7 @@ const int Type::kSyntaxFieldNumber;
 Type::Type()
   : ::google::protobuf::Message(), _internal_metadata_(NULL) {
   if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
-    protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto();
+    protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaults();
   }
   SharedCtor();
   // @@protoc_insertion_point(constructor:google.protobuf.Type)
@@ -384,7 +384,7 @@ Type::Type(::google::protobuf::Arena* arena)
   oneofs_(arena),
   options_(arena) {
 #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
-  protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto();
+  protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaults();
 #endif  // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
   SharedCtor();
   RegisterArenaDtor(arena);
@@ -448,12 +448,12 @@ void Type::SetCachedSize(int size) const {
   GOOGLE_SAFE_CONCURRENT_WRITES_END();
 }
 const ::google::protobuf::Descriptor* Type::descriptor() {
-  protobuf_AssignDescriptorsOnce();
-  return file_level_metadata[0].descriptor;
+  protobuf_google_2fprotobuf_2ftype_2eproto::protobuf_AssignDescriptorsOnce();
+  return protobuf_google_2fprotobuf_2ftype_2eproto::file_level_metadata[0].descriptor;
 }
 
 const Type& Type::default_instance() {
-  protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto();
+  protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaults();
   return *internal_default_instance();
 }
 
@@ -639,7 +639,7 @@ void Type::SerializeWithCachedSizes(
 
 ::google::protobuf::uint8* Type::InternalSerializeWithCachedSizesToArray(
     bool deterministic, ::google::protobuf::uint8* target) const {
-  (void)deterministic; // Unused
+  (void)deterministic;  // Unused
   // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Type)
   // string name = 1;
   if (this->name().size() > 0) {
@@ -835,8 +835,8 @@ void Type::InternalSwap(Type* other) {
 }
 
 ::google::protobuf::Metadata Type::GetMetadata() const {
-  protobuf_AssignDescriptorsOnce();
-  return file_level_metadata[0];
+  protobuf_google_2fprotobuf_2ftype_2eproto::protobuf_AssignDescriptorsOnce();
+  return protobuf_google_2fprotobuf_2ftype_2eproto::file_level_metadata[0];
 }
 
 #if PROTOBUF_INLINE_NOT_IN_HEADERS
@@ -1108,7 +1108,7 @@ const int Field::kDefaultValueFieldNumber;
 Field::Field()
   : ::google::protobuf::Message(), _internal_metadata_(NULL) {
   if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
-    protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto();
+    protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaults();
   }
   SharedCtor();
   // @@protoc_insertion_point(constructor:google.protobuf.Field)
@@ -1118,7 +1118,7 @@ Field::Field(::google::protobuf::Arena* arena)
   _internal_metadata_(arena),
   options_(arena) {
 #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
-  protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto();
+  protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaults();
 #endif  // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
   SharedCtor();
   RegisterArenaDtor(arena);
@@ -1195,12 +1195,12 @@ void Field::SetCachedSize(int size) const {
   GOOGLE_SAFE_CONCURRENT_WRITES_END();
 }
 const ::google::protobuf::Descriptor* Field::descriptor() {
-  protobuf_AssignDescriptorsOnce();
-  return file_level_metadata[1].descriptor;
+  protobuf_google_2fprotobuf_2ftype_2eproto::protobuf_AssignDescriptorsOnce();
+  return protobuf_google_2fprotobuf_2ftype_2eproto::file_level_metadata[1].descriptor;
 }
 
 const Field& Field::default_instance() {
-  protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto();
+  protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaults();
   return *internal_default_instance();
 }
 
@@ -1471,7 +1471,7 @@ void Field::SerializeWithCachedSizes(
 
 ::google::protobuf::uint8* Field::InternalSerializeWithCachedSizesToArray(
     bool deterministic, ::google::protobuf::uint8* target) const {
-  (void)deterministic; // Unused
+  (void)deterministic;  // Unused
   // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Field)
   // .google.protobuf.Field.Kind kind = 1;
   if (this->kind() != 0) {
@@ -1737,8 +1737,8 @@ void Field::InternalSwap(Field* other) {
 }
 
 ::google::protobuf::Metadata Field::GetMetadata() const {
-  protobuf_AssignDescriptorsOnce();
-  return file_level_metadata[1];
+  protobuf_google_2fprotobuf_2ftype_2eproto::protobuf_AssignDescriptorsOnce();
+  return protobuf_google_2fprotobuf_2ftype_2eproto::file_level_metadata[1];
 }
 
 #if PROTOBUF_INLINE_NOT_IN_HEADERS
@@ -2156,7 +2156,7 @@ const int Enum::kSyntaxFieldNumber;
 Enum::Enum()
   : ::google::protobuf::Message(), _internal_metadata_(NULL) {
   if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
-    protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto();
+    protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaults();
   }
   SharedCtor();
   // @@protoc_insertion_point(constructor:google.protobuf.Enum)
@@ -2167,7 +2167,7 @@ Enum::Enum(::google::protobuf::Arena* arena)
   enumvalue_(arena),
   options_(arena) {
 #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
-  protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto();
+  protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaults();
 #endif  // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
   SharedCtor();
   RegisterArenaDtor(arena);
@@ -2230,12 +2230,12 @@ void Enum::SetCachedSize(int size) const {
   GOOGLE_SAFE_CONCURRENT_WRITES_END();
 }
 const ::google::protobuf::Descriptor* Enum::descriptor() {
-  protobuf_AssignDescriptorsOnce();
-  return file_level_metadata[2].descriptor;
+  protobuf_google_2fprotobuf_2ftype_2eproto::protobuf_AssignDescriptorsOnce();
+  return protobuf_google_2fprotobuf_2ftype_2eproto::file_level_metadata[2].descriptor;
 }
 
 const Enum& Enum::default_instance() {
-  protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto();
+  protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaults();
   return *internal_default_instance();
 }
 
@@ -2394,7 +2394,7 @@ void Enum::SerializeWithCachedSizes(
 
 ::google::protobuf::uint8* Enum::InternalSerializeWithCachedSizesToArray(
     bool deterministic, ::google::protobuf::uint8* target) const {
-  (void)deterministic; // Unused
+  (void)deterministic;  // Unused
   // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Enum)
   // string name = 1;
   if (this->name().size() > 0) {
@@ -2570,8 +2570,8 @@ void Enum::InternalSwap(Enum* other) {
 }
 
 ::google::protobuf::Metadata Enum::GetMetadata() const {
-  protobuf_AssignDescriptorsOnce();
-  return file_level_metadata[2];
+  protobuf_google_2fprotobuf_2ftype_2eproto::protobuf_AssignDescriptorsOnce();
+  return protobuf_google_2fprotobuf_2ftype_2eproto::file_level_metadata[2];
 }
 
 #if PROTOBUF_INLINE_NOT_IN_HEADERS
@@ -2781,7 +2781,7 @@ const int EnumValue::kOptionsFieldNumber;
 EnumValue::EnumValue()
   : ::google::protobuf::Message(), _internal_metadata_(NULL) {
   if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
-    protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto();
+    protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaults();
   }
   SharedCtor();
   // @@protoc_insertion_point(constructor:google.protobuf.EnumValue)
@@ -2791,7 +2791,7 @@ EnumValue::EnumValue(::google::protobuf::Arena* arena)
   _internal_metadata_(arena),
   options_(arena) {
 #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
-  protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto();
+  protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaults();
 #endif  // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
   SharedCtor();
   RegisterArenaDtor(arena);
@@ -2844,12 +2844,12 @@ void EnumValue::SetCachedSize(int size) const {
   GOOGLE_SAFE_CONCURRENT_WRITES_END();
 }
 const ::google::protobuf::Descriptor* EnumValue::descriptor() {
-  protobuf_AssignDescriptorsOnce();
-  return file_level_metadata[3].descriptor;
+  protobuf_google_2fprotobuf_2ftype_2eproto::protobuf_AssignDescriptorsOnce();
+  return protobuf_google_2fprotobuf_2ftype_2eproto::file_level_metadata[3].descriptor;
 }
 
 const EnumValue& EnumValue::default_instance() {
-  protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto();
+  protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaults();
   return *internal_default_instance();
 }
 
@@ -2965,7 +2965,7 @@ void EnumValue::SerializeWithCachedSizes(
 
 ::google::protobuf::uint8* EnumValue::InternalSerializeWithCachedSizesToArray(
     bool deterministic, ::google::protobuf::uint8* target) const {
-  (void)deterministic; // Unused
+  (void)deterministic;  // Unused
   // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.EnumValue)
   // string name = 1;
   if (this->name().size() > 0) {
@@ -3103,8 +3103,8 @@ void EnumValue::InternalSwap(EnumValue* other) {
 }
 
 ::google::protobuf::Metadata EnumValue::GetMetadata() const {
-  protobuf_AssignDescriptorsOnce();
-  return file_level_metadata[3];
+  protobuf_google_2fprotobuf_2ftype_2eproto::protobuf_AssignDescriptorsOnce();
+  return protobuf_google_2fprotobuf_2ftype_2eproto::file_level_metadata[3];
 }
 
 #if PROTOBUF_INLINE_NOT_IN_HEADERS
@@ -3265,7 +3265,7 @@ const int Option::kValueFieldNumber;
 Option::Option()
   : ::google::protobuf::Message(), _internal_metadata_(NULL) {
   if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
-    protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto();
+    protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaults();
   }
   SharedCtor();
   // @@protoc_insertion_point(constructor:google.protobuf.Option)
@@ -3274,7 +3274,7 @@ Option::Option(::google::protobuf::Arena* arena)
   : ::google::protobuf::Message(),
   _internal_metadata_(arena) {
 #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
-  protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto();
+  protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaults();
 #endif  // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
   SharedCtor();
   RegisterArenaDtor(arena);
@@ -3333,12 +3333,12 @@ void Option::SetCachedSize(int size) const {
   GOOGLE_SAFE_CONCURRENT_WRITES_END();
 }
 const ::google::protobuf::Descriptor* Option::descriptor() {
-  protobuf_AssignDescriptorsOnce();
-  return file_level_metadata[4].descriptor;
+  protobuf_google_2fprotobuf_2ftype_2eproto::protobuf_AssignDescriptorsOnce();
+  return protobuf_google_2fprotobuf_2ftype_2eproto::file_level_metadata[4].descriptor;
 }
 
 const Option& Option::default_instance() {
-  protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto();
+  protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaults();
   return *internal_default_instance();
 }
 
@@ -3436,7 +3436,7 @@ void Option::SerializeWithCachedSizes(
 
 ::google::protobuf::uint8* Option::InternalSerializeWithCachedSizesToArray(
     bool deterministic, ::google::protobuf::uint8* target) const {
-  (void)deterministic; // Unused
+  (void)deterministic;  // Unused
   // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Option)
   // string name = 1;
   if (this->name().size() > 0) {
@@ -3556,8 +3556,8 @@ void Option::InternalSwap(Option* other) {
 }
 
 ::google::protobuf::Metadata Option::GetMetadata() const {
-  protobuf_AssignDescriptorsOnce();
-  return file_level_metadata[4];
+  protobuf_google_2fprotobuf_2ftype_2eproto::protobuf_AssignDescriptorsOnce();
+  return protobuf_google_2fprotobuf_2ftype_2eproto::file_level_metadata[4];
 }
 
 #if PROTOBUF_INLINE_NOT_IN_HEADERS

+ 106 - 113
src/google/protobuf/type.pb.h

@@ -19,6 +19,7 @@
 #error regenerate this file with a newer version of protoc.
 #endif
 
+#include <google/protobuf/io/coded_stream.h>
 #include <google/protobuf/arena.h>
 #include <google/protobuf/arenastring.h>
 #include <google/protobuf/generated_message_util.h>
@@ -60,9 +61,16 @@ LIBPROTOBUF_EXPORT extern TypeDefaultTypeInternal _Type_default_instance_;
 namespace google {
 namespace protobuf {
 
+namespace protobuf_google_2fprotobuf_2ftype_2eproto {
 // Internal implementation detail -- do not call these.
-void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto();
-void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto();
+struct LIBPROTOBUF_EXPORT TableStruct {
+  static const ::google::protobuf::uint32 offsets[];
+  static void InitDefaultsImpl();
+  static void Shutdown();
+};
+void LIBPROTOBUF_EXPORT AddDescriptors();
+void LIBPROTOBUF_EXPORT InitDefaults();
+}  // namespace protobuf_google_2fprotobuf_2ftype_2eproto
 
 enum Field_Kind {
   Field_Kind_TYPE_UNKNOWN = 0,
@@ -198,7 +206,8 @@ class LIBPROTOBUF_EXPORT Type : public ::google::protobuf::Message /* @@protoc_i
       bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
   ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
       const PROTOBUF_FINAL {
-    return InternalSerializeWithCachedSizesToArray(false, output);
+    return InternalSerializeWithCachedSizesToArray(
+        ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
   }
   int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
   private:
@@ -226,20 +235,6 @@ class LIBPROTOBUF_EXPORT Type : public ::google::protobuf::Message /* @@protoc_i
 
   // accessors -------------------------------------------------------
 
-  // string name = 1;
-  void clear_name();
-  static const int kNameFieldNumber = 1;
-  const ::std::string& name() const;
-  void set_name(const ::std::string& value);
-  void set_name(const char* value);
-  void set_name(const char* value, size_t size);
-  ::std::string* mutable_name();
-  ::std::string* release_name();
-  void set_allocated_name(::std::string* name);
-  ::std::string* unsafe_arena_release_name();
-  void unsafe_arena_set_allocated_name(
-      ::std::string* name);
-
   // repeated .google.protobuf.Field fields = 2;
   int fields_size() const;
   void clear_fields();
@@ -280,6 +275,20 @@ class LIBPROTOBUF_EXPORT Type : public ::google::protobuf::Message /* @@protoc_i
   const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >&
       options() const;
 
+  // string name = 1;
+  void clear_name();
+  static const int kNameFieldNumber = 1;
+  const ::std::string& name() const;
+  void set_name(const ::std::string& value);
+  void set_name(const char* value);
+  void set_name(const char* value, size_t size);
+  ::std::string* mutable_name();
+  ::std::string* release_name();
+  void set_allocated_name(::std::string* name);
+  ::std::string* unsafe_arena_release_name();
+  void unsafe_arena_set_allocated_name(
+      ::std::string* name);
+
   // .google.protobuf.SourceContext source_context = 5;
   bool has_source_context() const;
   void clear_source_context();
@@ -316,11 +325,7 @@ class LIBPROTOBUF_EXPORT Type : public ::google::protobuf::Message /* @@protoc_i
   ::google::protobuf::SourceContext* source_context_;
   int syntax_;
   mutable int _cached_size_;
-  friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto_impl();
-  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto_impl();
-  friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2ftype_2eproto();
-  friend void protobuf_ShutdownFile_google_2fprotobuf_2ftype_2eproto();
-
+  friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2ftype_2eproto::TableStruct;
 };
 // -------------------------------------------------------------------
 
@@ -374,7 +379,8 @@ class LIBPROTOBUF_EXPORT Field : public ::google::protobuf::Message /* @@protoc_
       bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
   ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
       const PROTOBUF_FINAL {
-    return InternalSerializeWithCachedSizesToArray(false, output);
+    return InternalSerializeWithCachedSizesToArray(
+        ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
   }
   int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
   private:
@@ -492,23 +498,17 @@ class LIBPROTOBUF_EXPORT Field : public ::google::protobuf::Message /* @@protoc_
 
   // accessors -------------------------------------------------------
 
-  // .google.protobuf.Field.Kind kind = 1;
-  void clear_kind();
-  static const int kKindFieldNumber = 1;
-  ::google::protobuf::Field_Kind kind() const;
-  void set_kind(::google::protobuf::Field_Kind value);
-
-  // .google.protobuf.Field.Cardinality cardinality = 2;
-  void clear_cardinality();
-  static const int kCardinalityFieldNumber = 2;
-  ::google::protobuf::Field_Cardinality cardinality() const;
-  void set_cardinality(::google::protobuf::Field_Cardinality value);
-
-  // int32 number = 3;
-  void clear_number();
-  static const int kNumberFieldNumber = 3;
-  ::google::protobuf::int32 number() const;
-  void set_number(::google::protobuf::int32 value);
+  // repeated .google.protobuf.Option options = 9;
+  int options_size() const;
+  void clear_options();
+  static const int kOptionsFieldNumber = 9;
+  const ::google::protobuf::Option& options(int index) const;
+  ::google::protobuf::Option* mutable_options(int index);
+  ::google::protobuf::Option* add_options();
+  ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >*
+      mutable_options();
+  const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >&
+      options() const;
 
   // string name = 4;
   void clear_name();
@@ -538,30 +538,6 @@ class LIBPROTOBUF_EXPORT Field : public ::google::protobuf::Message /* @@protoc_
   void unsafe_arena_set_allocated_type_url(
       ::std::string* type_url);
 
-  // int32 oneof_index = 7;
-  void clear_oneof_index();
-  static const int kOneofIndexFieldNumber = 7;
-  ::google::protobuf::int32 oneof_index() const;
-  void set_oneof_index(::google::protobuf::int32 value);
-
-  // bool packed = 8;
-  void clear_packed();
-  static const int kPackedFieldNumber = 8;
-  bool packed() const;
-  void set_packed(bool value);
-
-  // repeated .google.protobuf.Option options = 9;
-  int options_size() const;
-  void clear_options();
-  static const int kOptionsFieldNumber = 9;
-  const ::google::protobuf::Option& options(int index) const;
-  ::google::protobuf::Option* mutable_options(int index);
-  ::google::protobuf::Option* add_options();
-  ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >*
-      mutable_options();
-  const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >&
-      options() const;
-
   // string json_name = 10;
   void clear_json_name();
   static const int kJsonNameFieldNumber = 10;
@@ -590,6 +566,36 @@ class LIBPROTOBUF_EXPORT Field : public ::google::protobuf::Message /* @@protoc_
   void unsafe_arena_set_allocated_default_value(
       ::std::string* default_value);
 
+  // .google.protobuf.Field.Kind kind = 1;
+  void clear_kind();
+  static const int kKindFieldNumber = 1;
+  ::google::protobuf::Field_Kind kind() const;
+  void set_kind(::google::protobuf::Field_Kind value);
+
+  // .google.protobuf.Field.Cardinality cardinality = 2;
+  void clear_cardinality();
+  static const int kCardinalityFieldNumber = 2;
+  ::google::protobuf::Field_Cardinality cardinality() const;
+  void set_cardinality(::google::protobuf::Field_Cardinality value);
+
+  // int32 number = 3;
+  void clear_number();
+  static const int kNumberFieldNumber = 3;
+  ::google::protobuf::int32 number() const;
+  void set_number(::google::protobuf::int32 value);
+
+  // int32 oneof_index = 7;
+  void clear_oneof_index();
+  static const int kOneofIndexFieldNumber = 7;
+  ::google::protobuf::int32 oneof_index() const;
+  void set_oneof_index(::google::protobuf::int32 value);
+
+  // bool packed = 8;
+  void clear_packed();
+  static const int kPackedFieldNumber = 8;
+  bool packed() const;
+  void set_packed(bool value);
+
   // @@protoc_insertion_point(class_scope:google.protobuf.Field)
  private:
 
@@ -608,11 +614,7 @@ class LIBPROTOBUF_EXPORT Field : public ::google::protobuf::Message /* @@protoc_
   ::google::protobuf::int32 oneof_index_;
   bool packed_;
   mutable int _cached_size_;
-  friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto_impl();
-  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto_impl();
-  friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2ftype_2eproto();
-  friend void protobuf_ShutdownFile_google_2fprotobuf_2ftype_2eproto();
-
+  friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2ftype_2eproto::TableStruct;
 };
 // -------------------------------------------------------------------
 
@@ -666,7 +668,8 @@ class LIBPROTOBUF_EXPORT Enum : public ::google::protobuf::Message /* @@protoc_i
       bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
   ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
       const PROTOBUF_FINAL {
-    return InternalSerializeWithCachedSizesToArray(false, output);
+    return InternalSerializeWithCachedSizesToArray(
+        ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
   }
   int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
   private:
@@ -694,20 +697,6 @@ class LIBPROTOBUF_EXPORT Enum : public ::google::protobuf::Message /* @@protoc_i
 
   // accessors -------------------------------------------------------
 
-  // string name = 1;
-  void clear_name();
-  static const int kNameFieldNumber = 1;
-  const ::std::string& name() const;
-  void set_name(const ::std::string& value);
-  void set_name(const char* value);
-  void set_name(const char* value, size_t size);
-  ::std::string* mutable_name();
-  ::std::string* release_name();
-  void set_allocated_name(::std::string* name);
-  ::std::string* unsafe_arena_release_name();
-  void unsafe_arena_set_allocated_name(
-      ::std::string* name);
-
   // repeated .google.protobuf.EnumValue enumvalue = 2;
   int enumvalue_size() const;
   void clear_enumvalue();
@@ -732,6 +721,20 @@ class LIBPROTOBUF_EXPORT Enum : public ::google::protobuf::Message /* @@protoc_i
   const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >&
       options() const;
 
+  // string name = 1;
+  void clear_name();
+  static const int kNameFieldNumber = 1;
+  const ::std::string& name() const;
+  void set_name(const ::std::string& value);
+  void set_name(const char* value);
+  void set_name(const char* value, size_t size);
+  ::std::string* mutable_name();
+  ::std::string* release_name();
+  void set_allocated_name(::std::string* name);
+  ::std::string* unsafe_arena_release_name();
+  void unsafe_arena_set_allocated_name(
+      ::std::string* name);
+
   // .google.protobuf.SourceContext source_context = 4;
   bool has_source_context() const;
   void clear_source_context();
@@ -767,11 +770,7 @@ class LIBPROTOBUF_EXPORT Enum : public ::google::protobuf::Message /* @@protoc_i
   ::google::protobuf::SourceContext* source_context_;
   int syntax_;
   mutable int _cached_size_;
-  friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto_impl();
-  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto_impl();
-  friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2ftype_2eproto();
-  friend void protobuf_ShutdownFile_google_2fprotobuf_2ftype_2eproto();
-
+  friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2ftype_2eproto::TableStruct;
 };
 // -------------------------------------------------------------------
 
@@ -825,7 +824,8 @@ class LIBPROTOBUF_EXPORT EnumValue : public ::google::protobuf::Message /* @@pro
       bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
   ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
       const PROTOBUF_FINAL {
-    return InternalSerializeWithCachedSizesToArray(false, output);
+    return InternalSerializeWithCachedSizesToArray(
+        ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
   }
   int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
   private:
@@ -853,6 +853,18 @@ class LIBPROTOBUF_EXPORT EnumValue : public ::google::protobuf::Message /* @@pro
 
   // accessors -------------------------------------------------------
 
+  // repeated .google.protobuf.Option options = 3;
+  int options_size() const;
+  void clear_options();
+  static const int kOptionsFieldNumber = 3;
+  const ::google::protobuf::Option& options(int index) const;
+  ::google::protobuf::Option* mutable_options(int index);
+  ::google::protobuf::Option* add_options();
+  ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >*
+      mutable_options();
+  const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >&
+      options() const;
+
   // string name = 1;
   void clear_name();
   static const int kNameFieldNumber = 1;
@@ -873,18 +885,6 @@ class LIBPROTOBUF_EXPORT EnumValue : public ::google::protobuf::Message /* @@pro
   ::google::protobuf::int32 number() const;
   void set_number(::google::protobuf::int32 value);
 
-  // repeated .google.protobuf.Option options = 3;
-  int options_size() const;
-  void clear_options();
-  static const int kOptionsFieldNumber = 3;
-  const ::google::protobuf::Option& options(int index) const;
-  ::google::protobuf::Option* mutable_options(int index);
-  ::google::protobuf::Option* add_options();
-  ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >*
-      mutable_options();
-  const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >&
-      options() const;
-
   // @@protoc_insertion_point(class_scope:google.protobuf.EnumValue)
  private:
 
@@ -896,11 +896,7 @@ class LIBPROTOBUF_EXPORT EnumValue : public ::google::protobuf::Message /* @@pro
   ::google::protobuf::internal::ArenaStringPtr name_;
   ::google::protobuf::int32 number_;
   mutable int _cached_size_;
-  friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto_impl();
-  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto_impl();
-  friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2ftype_2eproto();
-  friend void protobuf_ShutdownFile_google_2fprotobuf_2ftype_2eproto();
-
+  friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2ftype_2eproto::TableStruct;
 };
 // -------------------------------------------------------------------
 
@@ -954,7 +950,8 @@ class LIBPROTOBUF_EXPORT Option : public ::google::protobuf::Message /* @@protoc
       bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
   ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
       const PROTOBUF_FINAL {
-    return InternalSerializeWithCachedSizesToArray(false, output);
+    return InternalSerializeWithCachedSizesToArray(
+        ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
   }
   int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
   private:
@@ -1022,11 +1019,7 @@ class LIBPROTOBUF_EXPORT Option : public ::google::protobuf::Message /* @@protoc
   ::google::protobuf::internal::ArenaStringPtr name_;
   ::google::protobuf::Any* value_;
   mutable int _cached_size_;
-  friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto_impl();
-  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto_impl();
-  friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2ftype_2eproto();
-  friend void protobuf_ShutdownFile_google_2fprotobuf_2ftype_2eproto();
-
+  friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2ftype_2eproto::TableStruct;
 };
 // ===================================================================
 

+ 8 - 2
src/google/protobuf/type.proto

@@ -166,9 +166,15 @@ message EnumValue {
 // A protocol buffer option, which can be attached to a message, field,
 // enumeration, etc.
 message Option {
-  // The option's name. For example, `"java_package"`.
+  // The option's name. For protobuf built-in options (options defined in
+  // descriptor.proto), this is the short name. For example, `"map_entry"`.
+  // For custom options, it should be the fully-qualified name. For example,
+  // `"google.api.http"`.
   string name = 1;
-  // The option's value. For example, `"com.google.protobuf"`.
+  // The option's value packed in an Any message. If the value is a primitive,
+  // the corresponding wrapper type defined in google/protobuf/wrappers.proto
+  // should be used. If the value is an enum, it should be stored as an int32
+  // value using the google.protobuf.Int32Value type.
   Any value = 2;
 }
 

+ 2 - 1
src/google/protobuf/util/field_mask_util.cc

@@ -463,7 +463,8 @@ void FieldMaskTree::TrimMessage(const Node* node, Message* message) {
   const int32 field_count = descriptor->field_count();
   for (int index = 0; index < field_count; ++index) {
     const FieldDescriptor* field = descriptor->field(index);
-    map<string, Node*>::const_iterator it = node->children.find(field->name());
+    std::map<string, Node*>::const_iterator it =
+        node->children.find(field->name());
     if (it == node->children.end()) {
       reflection->ClearField(message, field);
     } else {

+ 3 - 3
src/google/protobuf/util/internal/json_escaping.cc

@@ -336,19 +336,19 @@ StringPiece EscapeCodePoint(uint32 cp, char* buffer, bool force_output) {
     cp >>= 6;
     if (cp <= 0x1f) {
       buffer[4] = cp | 0xc0;
-      sp.set(buffer + 4, 2);
+      sp = StringPiece(buffer + 4, 2);
       return sp;
     }
     buffer[4] = (cp & 0x3f) | 0x80;
     cp >>= 6;
     if (cp <= 0x0f) {
       buffer[3] = cp | 0xe0;
-      sp.set(buffer + 3, 3);
+      sp = StringPiece(buffer + 3, 3);
       return sp;
     }
     buffer[3] = (cp & 0x3f) | 0x80;
     buffer[2] = ((cp >> 6) & 0x07) | 0xf0;
-    sp.set(buffer + 2, 4);
+    sp = StringPiece(buffer + 2, 4);
   }
   return sp;
 }

+ 11 - 10
src/google/protobuf/util/internal/json_stream_parser.cc

@@ -56,6 +56,7 @@ namespace util {
 // this file.
 using util::Status;
 namespace error {
+using util::error::CANCELLED;
 using util::error::INTERNAL;
 using util::error::INVALID_ARGUMENT;
 }  // namespace error
@@ -246,7 +247,7 @@ util::Status JsonStreamParser::RunParser() {
     }
     if (!result.ok()) {
       // If we were cancelled, save our state and try again later.
-      if (!finishing_ && result == util::Status::CANCELLED) {
+      if (!finishing_ && result == util::Status(error::CANCELLED, "")) {
         stack_.push(type);
         // If we have a key we still need to render, make sure to save off the
         // contents in our own storage.
@@ -290,7 +291,7 @@ util::Status JsonStreamParser::ParseValue(TokenType type) {
       // don't know if the next char would be e, completing it, or something
       // else, making it invalid.
       if (!finishing_ && p_.length() < false_len) {
-        return util::Status::CANCELLED;
+        return util::Status(error::CANCELLED, "");
       }
       return ReportFailure("Unexpected token.");
     }
@@ -328,7 +329,7 @@ util::Status JsonStreamParser::ParseStringHelper() {
       // depending on if we expect more data later.
       if (p_.length() == 1) {
         if (!finishing_) {
-          return util::Status::CANCELLED;
+          return util::Status(error::CANCELLED, "");
         }
         return ReportFailure("Closing quote expected in string.");
       }
@@ -396,7 +397,7 @@ util::Status JsonStreamParser::ParseStringHelper() {
   }
   // If we didn't find the closing quote but we expect more data, cancel for now
   if (!finishing_) {
-    return util::Status::CANCELLED;
+    return util::Status(error::CANCELLED, "");
   }
   // End of string reached without a closing quote, report an error.
   string_open_ = 0;
@@ -413,7 +414,7 @@ util::Status JsonStreamParser::ParseStringHelper() {
 util::Status JsonStreamParser::ParseUnicodeEscape() {
   if (p_.length() < kUnicodeEscapedLength) {
     if (!finishing_) {
-      return util::Status::CANCELLED;
+      return util::Status(error::CANCELLED, "");
     }
     return ReportFailure("Illegal hex string.");
   }
@@ -430,7 +431,7 @@ util::Status JsonStreamParser::ParseUnicodeEscape() {
       code <= JsonEscaping::kMaxHighSurrogate) {
     if (p_.length() < 2 * kUnicodeEscapedLength) {
       if (!finishing_) {
-        return util::Status::CANCELLED;
+        return util::Status(error::CANCELLED, "");
       }
       if (!coerce_to_utf8_) {
         return ReportFailure("Missing low surrogate.");
@@ -524,7 +525,7 @@ util::Status JsonStreamParser::ParseNumberHelper(NumberResult* result) {
   // If the entire input is a valid number, and we may have more content in the
   // future, we abort for now and resume when we know more.
   if (index == length && !finishing_) {
-    return util::Status::CANCELLED;
+    return util::Status(error::CANCELLED, "");
   }
 
   // Create a string containing just the number, so we can use safe_strtoX
@@ -679,7 +680,7 @@ util::Status JsonStreamParser::ParseArrayValue(TokenType type) {
   // empty-null array value is relying on this ARRAY_MID token.
   stack_.push(ARRAY_MID);
   util::Status result = ParseValue(type);
-  if (result == util::Status::CANCELLED) {
+  if (result == util::Status(error::CANCELLED, "")) {
     // If we were cancelled, pop back off the ARRAY_MID so we don't try to
     // push it on again when we try over.
     stack_.pop();
@@ -758,7 +759,7 @@ util::Status JsonStreamParser::ReportFailure(StringPiece message) {
 util::Status JsonStreamParser::ReportUnknown(StringPiece message) {
   // If we aren't finishing the parse, cancel parsing and try later.
   if (!finishing_) {
-    return util::Status::CANCELLED;
+    return util::Status(error::CANCELLED, "");
   }
   if (p_.empty()) {
     return ReportFailure(StrCat("Unexpected end of string. ", message));
@@ -788,7 +789,7 @@ util::Status JsonStreamParser::ParseKey() {
   // we can't know if the key was complete or not.
   if (!finishing_ && p_.empty()) {
     p_ = original;
-    return util::Status::CANCELLED;
+    return util::Status(error::CANCELLED, "");
   }
   // Since we aren't using the key storage, clear it out.
   key_storage_.clear();

+ 1 - 9
src/google/protobuf/util/internal/protostream_objectsource.cc

@@ -1024,15 +1024,8 @@ bool ProtoStreamObjectSource::IsMap(
     const google::protobuf::Field& field) const {
   const google::protobuf::Type* field_type =
       typeinfo_->GetTypeByTypeUrl(field.type_url());
-
-  // TODO(xiaofeng): Unify option names.
   return field.kind() == google::protobuf::Field_Kind_TYPE_MESSAGE &&
-         (GetBoolOptionOrDefault(field_type->options(),
-                                 "google.protobuf.MessageOptions.map_entry",
-                                 false) ||
-          GetBoolOptionOrDefault(field_type->options(), "map_entry", false) ||
-          GetBoolOptionOrDefault(field_type->options(),
-                                 "proto2.MessageOptions.map_entry", false));
+         google::protobuf::util::converter::IsMap(field, *field_type);
 }
 
 std::pair<int64, int32> ProtoStreamObjectSource::ReadSecondsAndNanos(
@@ -1128,4 +1121,3 @@ const string FormatNanos(uint32 nanos, bool with_trailing_zeros) {
 }  // namespace util
 }  // namespace protobuf
 }  // namespace google
-

Деякі файли не було показано, через те що забагато файлів було змінено