Merge branch 'master' into integration

pull/5765/head
Yilun Chong 6 years ago committed by GitHub
commit 429d2ae19f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      Makefile.am
  2. 12
      csharp/src/AddressBook/Addressbook.cs
  3. 16
      csharp/src/Google.Protobuf.Conformance/Conformance.cs
  4. 28
      csharp/src/Google.Protobuf.Test/TestProtos/MapUnittestProto3.cs
  5. 12
      csharp/src/Google.Protobuf.Test/TestProtos/TestMessagesProto3.cs
  6. 84
      csharp/src/Google.Protobuf.Test/TestProtos/UnittestCustomOptionsProto3.cs
  7. 4
      csharp/src/Google.Protobuf.Test/TestProtos/UnittestImportProto3.cs
  8. 4
      csharp/src/Google.Protobuf.Test/TestProtos/UnittestImportPublicProto3.cs
  9. 52
      csharp/src/Google.Protobuf.Test/TestProtos/UnittestIssues.cs
  10. 156
      csharp/src/Google.Protobuf.Test/TestProtos/UnittestProto3.cs
  11. 16
      csharp/src/Google.Protobuf.Test/TestProtos/UnittestWellKnownTypes.cs
  12. 4
      csharp/src/Google.Protobuf/MessageExtensions.cs
  13. 76
      csharp/src/Google.Protobuf/Reflection/Descriptor.cs
  14. 23
      csharp/src/Google.Protobuf/UnknownFieldSet.cs
  15. 4
      csharp/src/Google.Protobuf/WellKnownTypes/Any.cs
  16. 12
      csharp/src/Google.Protobuf/WellKnownTypes/Api.cs
  17. 4
      csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs
  18. 4
      csharp/src/Google.Protobuf/WellKnownTypes/Empty.cs
  19. 4
      csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs
  20. 4
      csharp/src/Google.Protobuf/WellKnownTypes/SourceContext.cs
  21. 12
      csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs
  22. 4
      csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs
  23. 20
      csharp/src/Google.Protobuf/WellKnownTypes/Type.cs
  24. 36
      csharp/src/Google.Protobuf/WellKnownTypes/Wrappers.cs
  25. 3
      docs/third_party.md
  26. 2
      examples/list_people_test.go
  27. 4
      java/lite.md
  28. 110
      php/ext/google/protobuf/message.c
  29. 55
      php/src/Google/Protobuf/Internal/Message.php
  30. 4
      php/tests/proto/test_wrapper_type_setters.proto
  31. 84
      php/tests/wrapper_type_setters_test.php
  32. 2
      protobuf-lite.pc.in
  33. 4
      protobuf.pc.in
  34. 4
      ruby/ext/google/protobuf_c/map.c
  35. 8
      ruby/ext/google/protobuf_c/message.c
  36. 8
      ruby/ext/google/protobuf_c/protobuf.h
  37. 4
      ruby/ext/google/protobuf_c/repeated_field.c
  38. 57
      ruby/ext/google/protobuf_c/storage.c
  39. 4
      ruby/tests/basic.rb
  40. 2
      ruby/tests/basic_proto2.rb
  41. 25
      ruby/tests/common_tests.rb
  42. 173
      ruby/tests/type_errors.rb
  43. 13
      src/google/protobuf/compiler/csharp/csharp_helpers.cc
  44. 3
      src/google/protobuf/compiler/csharp/csharp_helpers.h
  45. 13
      src/google/protobuf/compiler/csharp/csharp_message.cc
  46. 1
      src/google/protobuf/compiler/csharp/csharp_message.h
  47. 12
      src/google/protobuf/compiler/java/java_message.cc
  48. 14
      src/google/protobuf/compiler/objectivec/objectivec_enum.cc
  49. 2
      third_party/googletest
  50. 63
      update_version.py

@ -951,6 +951,7 @@ ruby_EXTRA_DIST= \
ruby/tests/test_ruby_package.proto \
ruby/tests/generated_code_test.rb \
ruby/tests/well_known_types_test.rb \
ruby/tests/type_errors.rb \
ruby/travis-test.sh
js_EXTRA_DIST= \

@ -260,9 +260,7 @@ namespace Google.Protobuf.Examples.AddressBook {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
Name = input.ReadString();
@ -442,9 +440,7 @@ namespace Google.Protobuf.Examples.AddressBook {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
Number = input.ReadString();
@ -577,9 +573,7 @@ namespace Google.Protobuf.Examples.AddressBook {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
people_.AddEntriesFrom(input, _repeated_people_codec);

@ -216,9 +216,7 @@ namespace Conformance {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
failure_.AddEntriesFrom(input, _repeated_failure_codec);
@ -581,9 +579,7 @@ namespace Conformance {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
ProtobufPayload = input.ReadBytes();
@ -1001,9 +997,7 @@ namespace Conformance {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
ParseError = input.ReadString();
@ -1166,9 +1160,7 @@ namespace Conformance {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 8: {
UseJspbArrayAnyFormat = input.ReadBool();

@ -541,9 +541,7 @@ namespace Google.Protobuf.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
mapInt32Int32_.AddEntriesFrom(input, _map_mapInt32Int32_codec);
@ -739,9 +737,7 @@ namespace Google.Protobuf.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
if (testMap_ == null) {
@ -865,9 +861,7 @@ namespace Google.Protobuf.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
mapInt32Message_.AddEntriesFrom(input, _map_mapInt32Message_codec);
@ -1007,9 +1001,7 @@ namespace Google.Protobuf.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
map1_.AddEntriesFrom(input, _map_map1_codec);
@ -1358,9 +1350,7 @@ namespace Google.Protobuf.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
mapInt32Int32_.AddEntriesFrom(input, _map_mapInt32Int32_codec);
@ -1541,9 +1531,7 @@ namespace Google.Protobuf.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
type_.AddEntriesFrom(input, _map_type_codec);
@ -1678,9 +1666,7 @@ namespace Google.Protobuf.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
entry_.AddEntriesFrom(input, _map_entry_codec);

@ -2895,9 +2895,7 @@ namespace ProtobufTestMessages.Proto3 {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 8: {
OptionalInt32 = input.ReadInt32();
@ -3625,9 +3623,7 @@ namespace ProtobufTestMessages.Proto3 {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 8: {
A = input.ReadInt32();
@ -3768,9 +3764,7 @@ namespace ProtobufTestMessages.Proto3 {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 8: {
C = input.ReadInt32();

@ -352,9 +352,7 @@ namespace UnitTest.Issues.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
Field1 = input.ReadString();
@ -480,9 +478,7 @@ namespace UnitTest.Issues.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
}
}
@ -583,9 +579,7 @@ namespace UnitTest.Issues.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
}
}
@ -686,9 +680,7 @@ namespace UnitTest.Issues.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
}
}
@ -789,9 +781,7 @@ namespace UnitTest.Issues.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
}
}
@ -892,9 +882,7 @@ namespace UnitTest.Issues.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
}
}
@ -1008,9 +996,7 @@ namespace UnitTest.Issues.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
}
}
@ -1111,9 +1097,7 @@ namespace UnitTest.Issues.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
}
}
@ -1214,9 +1198,7 @@ namespace UnitTest.Issues.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
}
}
@ -1317,9 +1299,7 @@ namespace UnitTest.Issues.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
}
}
@ -1420,9 +1400,7 @@ namespace UnitTest.Issues.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
}
}
@ -1523,9 +1501,7 @@ namespace UnitTest.Issues.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
}
}
@ -1714,9 +1690,7 @@ namespace UnitTest.Issues.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 8: {
Foo = input.ReadInt32();
@ -1928,9 +1902,7 @@ namespace UnitTest.Issues.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
if (bar_ == null) {
@ -2079,9 +2051,7 @@ namespace UnitTest.Issues.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 8: {
Waldo = input.ReadInt32();
@ -2215,9 +2185,7 @@ namespace UnitTest.Issues.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 8: {
Qux = input.ReadInt32();
@ -2325,9 +2293,7 @@ namespace UnitTest.Issues.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
}
}
@ -2509,9 +2475,7 @@ namespace UnitTest.Issues.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 8: {
I = input.ReadInt32();
@ -2651,9 +2615,7 @@ namespace UnitTest.Issues.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 8: {
Fieldname = input.ReadInt32();
@ -2761,9 +2723,7 @@ namespace UnitTest.Issues.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
}
}
@ -2895,9 +2855,7 @@ namespace UnitTest.Issues.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 8: {
NestedField = input.ReadInt32();

@ -167,9 +167,7 @@ namespace Google.Protobuf.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 8: {
D = input.ReadInt32();

@ -155,9 +155,7 @@ namespace Google.Protobuf.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 8: {
E = input.ReadInt32();

@ -181,9 +181,7 @@ namespace UnitTest.Issues.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
}
}
@ -286,9 +284,7 @@ namespace UnitTest.Issues.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
}
}
@ -391,9 +387,7 @@ namespace UnitTest.Issues.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
}
}
@ -560,9 +554,7 @@ namespace UnitTest.Issues.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 8: {
Value = (global::UnitTest.Issues.TestProtos.NegativeEnum) input.ReadEnum();
@ -677,9 +669,7 @@ namespace UnitTest.Issues.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
}
}
@ -909,9 +899,7 @@ namespace UnitTest.Issues.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 8: {
PrimitiveValue = input.ReadInt32();
@ -1068,9 +1056,7 @@ namespace UnitTest.Issues.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 8: {
Item = input.ReadInt32();
@ -1223,9 +1209,7 @@ namespace UnitTest.Issues.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 8: {
Types_ = input.ReadInt32();
@ -1339,9 +1323,7 @@ namespace UnitTest.Issues.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
}
}
@ -1665,9 +1647,7 @@ namespace UnitTest.Issues.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
PlainString = input.ReadString();
@ -1867,9 +1847,7 @@ namespace UnitTest.Issues.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
Name = input.ReadString();
@ -2069,9 +2047,7 @@ namespace UnitTest.Issues.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
Text = input.ReadString();
@ -2235,9 +2211,7 @@ namespace UnitTest.Issues.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 8: {
X = input.ReadInt32();

@ -1387,9 +1387,7 @@ namespace Google.Protobuf.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 8: {
SingleInt32 = input.ReadInt32();
@ -1757,9 +1755,7 @@ namespace Google.Protobuf.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 8: {
Bb = input.ReadInt32();
@ -1942,9 +1938,7 @@ namespace Google.Protobuf.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
if (child_ == null) {
@ -2088,9 +2082,7 @@ namespace Google.Protobuf.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 8: {
DeprecatedInt32 = input.ReadInt32();
@ -2223,9 +2215,7 @@ namespace Google.Protobuf.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 8: {
C = input.ReadInt32();
@ -2330,9 +2320,7 @@ namespace Google.Protobuf.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
}
}
@ -2463,9 +2451,7 @@ namespace Google.Protobuf.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
if (foreignNested_ == null) {
@ -2628,9 +2614,7 @@ namespace Google.Protobuf.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 8: {
A = input.ReadInt32();
@ -2790,9 +2774,7 @@ namespace Google.Protobuf.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
if (a_ == null) {
@ -2934,9 +2916,7 @@ namespace Google.Protobuf.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
if (bb_ == null) {
@ -3095,9 +3075,7 @@ namespace Google.Protobuf.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
if (a_ == null) {
@ -3233,9 +3211,7 @@ namespace Google.Protobuf.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 8: {
Value = (global::Google.Protobuf.TestProtos.TestEnumWithDupValue) input.ReadEnum();
@ -3507,9 +3483,7 @@ namespace Google.Protobuf.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 8: {
PrimitiveField = input.ReadInt32();
@ -3750,9 +3724,7 @@ namespace Google.Protobuf.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 8: {
MyInt = input.ReadInt64();
@ -3927,9 +3899,7 @@ namespace Google.Protobuf.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 8: {
Bb = input.ReadInt32();
@ -4067,9 +4037,7 @@ namespace Google.Protobuf.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 8: {
SparseEnum = (global::Google.Protobuf.TestProtos.TestSparseEnum) input.ReadEnum();
@ -4201,9 +4169,7 @@ namespace Google.Protobuf.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
Data = input.ReadString();
@ -4324,9 +4290,7 @@ namespace Google.Protobuf.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
data_.AddEntriesFrom(input, _repeated_data_codec);
@ -4455,9 +4419,7 @@ namespace Google.Protobuf.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
Data = input.ReadBytes();
@ -4586,9 +4548,7 @@ namespace Google.Protobuf.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
Data = input.ReadBytes();
@ -4720,9 +4680,7 @@ namespace Google.Protobuf.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 8: {
Data = input.ReadInt32();
@ -4851,9 +4809,7 @@ namespace Google.Protobuf.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 8: {
Data = input.ReadUInt32();
@ -4982,9 +4938,7 @@ namespace Google.Protobuf.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 8: {
Data = input.ReadInt64();
@ -5113,9 +5067,7 @@ namespace Google.Protobuf.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 8: {
Data = input.ReadUInt64();
@ -5244,9 +5196,7 @@ namespace Google.Protobuf.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 8: {
Data = input.ReadBool();
@ -5463,9 +5413,7 @@ namespace Google.Protobuf.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 8: {
FooInt = input.ReadInt32();
@ -5807,9 +5755,7 @@ namespace Google.Protobuf.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 722:
case 720: {
@ -6208,9 +6154,7 @@ namespace Google.Protobuf.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 722:
case 720: {
@ -6491,9 +6435,7 @@ namespace Google.Protobuf.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 98:
case 101: {
@ -6651,9 +6593,7 @@ namespace Google.Protobuf.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
A = input.ReadString();
@ -6761,9 +6701,7 @@ namespace Google.Protobuf.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
}
}
@ -6864,9 +6802,7 @@ namespace Google.Protobuf.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
}
}
@ -6967,9 +6903,7 @@ namespace Google.Protobuf.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
}
}
@ -7070,9 +7004,7 @@ namespace Google.Protobuf.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
}
}
@ -7173,9 +7105,7 @@ namespace Google.Protobuf.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
}
}
@ -7276,9 +7206,7 @@ namespace Google.Protobuf.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
}
}
@ -7379,9 +7307,7 @@ namespace Google.Protobuf.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
}
}
@ -7512,9 +7438,7 @@ namespace Google.Protobuf.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
Text = input.ReadString();
@ -7661,9 +7585,7 @@ namespace Google.Protobuf.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
NestedText = input.ReadString();

@ -788,9 +788,7 @@ namespace Google.Protobuf.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
if (anyField_ == null) {
@ -1318,9 +1316,7 @@ namespace Google.Protobuf.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
anyField_.AddEntriesFrom(input, _repeated_anyField_codec);
@ -2031,9 +2027,7 @@ namespace Google.Protobuf.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
global::Google.Protobuf.WellKnownTypes.Any subBuilder = new global::Google.Protobuf.WellKnownTypes.Any();
@ -2544,9 +2538,7 @@ namespace Google.Protobuf.TestProtos {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
anyField_.AddEntriesFrom(input, _map_anyField_codec);

@ -163,12 +163,12 @@ namespace Google.Protobuf
var map = (IDictionary)f.Accessor.GetValue(message);
return map.Values.OfType<IMessage>().All(IsInitialized);
}
else if (f.IsRepeated && f.MessageType != null)
else if (f.IsRepeated && f.FieldType == FieldType.Message || f.FieldType == FieldType.Group)
{
var enumerable = (IEnumerable)f.Accessor.GetValue(message);
return enumerable.Cast<IMessage>().All(IsInitialized);
}
else if (f.MessageType != null)
else if (f.FieldType == FieldType.Message || f.FieldType == FieldType.Group)
{
if (f.Accessor.HasValue(message))
{

@ -302,9 +302,7 @@ namespace Google.Protobuf.Reflection {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
file_.AddEntriesFrom(input, _repeated_file_codec);
@ -735,9 +733,7 @@ namespace Google.Protobuf.Reflection {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
Name = input.ReadString();
@ -1102,9 +1098,7 @@ namespace Google.Protobuf.Reflection {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
Name = input.ReadString();
@ -1363,9 +1357,7 @@ namespace Google.Protobuf.Reflection {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 8: {
Start = input.ReadInt32();
@ -1568,9 +1560,7 @@ namespace Google.Protobuf.Reflection {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 8: {
Start = input.ReadInt32();
@ -1703,9 +1693,7 @@ namespace Google.Protobuf.Reflection {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 7994: {
uninterpretedOption_.AddEntriesFrom(input, _repeated_uninterpretedOption_codec);
@ -2212,9 +2200,7 @@ namespace Google.Protobuf.Reflection {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
Name = input.ReadString();
@ -2501,9 +2487,7 @@ namespace Google.Protobuf.Reflection {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
Name = input.ReadString();
@ -2748,9 +2732,7 @@ namespace Google.Protobuf.Reflection {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
Name = input.ReadString();
@ -2966,9 +2948,7 @@ namespace Google.Protobuf.Reflection {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 8: {
Start = input.ReadInt32();
@ -3197,9 +3177,7 @@ namespace Google.Protobuf.Reflection {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
Name = input.ReadString();
@ -3407,9 +3385,7 @@ namespace Google.Protobuf.Reflection {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
Name = input.ReadString();
@ -3759,9 +3735,7 @@ namespace Google.Protobuf.Reflection {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
Name = input.ReadString();
@ -6949,9 +6923,7 @@ namespace Google.Protobuf.Reflection {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 18: {
name_.AddEntriesFrom(input, _repeated_name_codec);
@ -7164,9 +7136,7 @@ namespace Google.Protobuf.Reflection {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
NamePart_ = input.ReadString();
@ -7345,9 +7315,7 @@ namespace Google.Protobuf.Reflection {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
location_.AddEntriesFrom(input, _repeated_location_codec);
@ -7655,9 +7623,7 @@ namespace Google.Protobuf.Reflection {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10:
case 8: {
@ -7810,9 +7776,7 @@ namespace Google.Protobuf.Reflection {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
annotation_.AddEntriesFrom(input, _repeated_annotation_codec);
@ -8063,9 +8027,7 @@ namespace Google.Protobuf.Reflection {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10:
case 8: {

@ -261,29 +261,6 @@ namespace Google.Protobuf
return unknownFields;
}
/// <summary>
/// Create a new UnknownFieldSet if unknownFields is null.
/// Parse a single field from <paramref name="input"/> and merge it
/// into unknownFields. If <paramref name="input"/> is configured to discard unknown fields,
/// <paramref name="unknownFields"/> will be returned as-is and the field will be skipped.
/// </summary>
/// <param name="unknownFields">The UnknownFieldSet which need to be merged</param>
/// <param name="input">The coded input stream containing the field</param>
/// <returns>The merged UnknownFieldSet</returns>
public static bool MergeFieldFrom(ref UnknownFieldSet unknownFields, CodedInputStream input)
{
if (input.DiscardUnknownFields)
{
input.SkipLastField();
return true;
}
if (unknownFields == null)
{
unknownFields = new UnknownFieldSet();
}
return unknownFields.MergeFieldFrom(input);
}
/// <summary>
/// Merges the fields from <paramref name="other"/> into this set.
/// If a field number exists in both sets, the values in <paramref name="other"/>

@ -292,9 +292,7 @@ namespace Google.Protobuf.WellKnownTypes {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
TypeUrl = input.ReadString();

@ -345,9 +345,7 @@ namespace Google.Protobuf.WellKnownTypes {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
Name = input.ReadString();
@ -663,9 +661,7 @@ namespace Google.Protobuf.WellKnownTypes {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
Name = input.ReadString();
@ -929,9 +925,7 @@ namespace Google.Protobuf.WellKnownTypes {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
Name = input.ReadString();

@ -254,9 +254,7 @@ namespace Google.Protobuf.WellKnownTypes {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 8: {
Seconds = input.ReadInt64();

@ -143,9 +143,7 @@ namespace Google.Protobuf.WellKnownTypes {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
}
}

@ -352,9 +352,7 @@ namespace Google.Protobuf.WellKnownTypes {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
paths_.AddEntriesFrom(input, _repeated_paths_codec);

@ -165,9 +165,7 @@ namespace Google.Protobuf.WellKnownTypes {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
FileName = input.ReadString();

@ -189,9 +189,7 @@ namespace Google.Protobuf.WellKnownTypes {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
fields_.AddEntriesFrom(input, _map_fields_codec);
@ -515,9 +513,7 @@ namespace Google.Protobuf.WellKnownTypes {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 8: {
kind_ = input.ReadEnum();
@ -677,9 +673,7 @@ namespace Google.Protobuf.WellKnownTypes {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
values_.AddEntriesFrom(input, _repeated_values_codec);

@ -273,9 +273,7 @@ namespace Google.Protobuf.WellKnownTypes {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 8: {
Seconds = input.ReadInt64();

@ -328,9 +328,7 @@ namespace Google.Protobuf.WellKnownTypes {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
Name = input.ReadString();
@ -725,9 +723,7 @@ namespace Google.Protobuf.WellKnownTypes {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 8: {
Kind = (global::Google.Protobuf.WellKnownTypes.Field.Types.Kind) input.ReadEnum();
@ -1104,9 +1100,7 @@ namespace Google.Protobuf.WellKnownTypes {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
Name = input.ReadString();
@ -1306,9 +1300,7 @@ namespace Google.Protobuf.WellKnownTypes {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
Name = input.ReadString();
@ -1488,9 +1480,7 @@ namespace Google.Protobuf.WellKnownTypes {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
Name = input.ReadString();

@ -177,9 +177,7 @@ namespace Google.Protobuf.WellKnownTypes {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 9: {
Value = input.ReadDouble();
@ -316,9 +314,7 @@ namespace Google.Protobuf.WellKnownTypes {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 13: {
Value = input.ReadFloat();
@ -455,9 +451,7 @@ namespace Google.Protobuf.WellKnownTypes {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 8: {
Value = input.ReadInt64();
@ -594,9 +588,7 @@ namespace Google.Protobuf.WellKnownTypes {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 8: {
Value = input.ReadUInt64();
@ -733,9 +725,7 @@ namespace Google.Protobuf.WellKnownTypes {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 8: {
Value = input.ReadInt32();
@ -872,9 +862,7 @@ namespace Google.Protobuf.WellKnownTypes {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 8: {
Value = input.ReadUInt32();
@ -1011,9 +999,7 @@ namespace Google.Protobuf.WellKnownTypes {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 8: {
Value = input.ReadBool();
@ -1150,9 +1136,7 @@ namespace Google.Protobuf.WellKnownTypes {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
Value = input.ReadString();
@ -1289,9 +1273,7 @@ namespace Google.Protobuf.WellKnownTypes {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
return;
}
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
Value = input.ReadBytes();

@ -19,7 +19,6 @@ These are projects we know about implementing Protocol Buffers for other program
* C++: https://github.com/google/protobuf (Google-official implementation)
* C/C++: http://spbc.sf.net/
* C#: http://code.google.com/p/protobuf-csharp-port
* C#: http://code.google.com/p/protosharp/
* C#: https://silentorbit.com/protobuf/
* C#/.NET/WCF/VB: http://code.google.com/p/protobuf-net/
* Clojure: http://github.com/ninjudd/clojure-protobuf
@ -39,6 +38,7 @@ These are projects we know about implementing Protocol Buffers for other program
* Erlang: https://github.com/tomas-abrahamsson/gpb
* Erlang: http://piqi.org/
* Erlang: https://github.com/basho/erlang_protobuffs (no longer maintained, use gpb instead)
* Hacklang/HHVM: https://github.com/y3llowcake/proto-hack
* GDScript: https://github.com/oniksan/godobuf (Godot v3 engine plugin)
* Go: https://github.com/golang/protobuf (Google-official implementation)
* Go: https://github.com/akunspy/gopbuf
@ -92,6 +92,7 @@ These are projects we know about implementing Protocol Buffers for other program
* Solidity: https://github.com/celer-network/pb3-gen-sol
* Swift: https://github.com/alexeyxo/protobuf-swift
* Swift: https://github.com/apple/swift-protobuf/
* Typescript: https://github.com/y3llowcake/protoc-gen-ts
* Vala: https://launchpad.net/protobuf-vala
* Visual Basic: http://code.google.com/p/protobuf-net/

@ -34,7 +34,7 @@ func TestWritePersonWritesPerson(t *testing.T) {
func TestListPeopleWritesList(t *testing.T) {
buf := new(bytes.Buffer)
in := pb.AddressBook{People: []*pb.Person {
in := pb.AddressBook{People: []*pb.Person{
{
Name: "John Doe",
Id: 101,

@ -21,7 +21,9 @@ download it from maven:
Choose the version that works on your platform (e.g., on windows you can
download `protoc-gen-javalite-3.0.0-windows-x86_32.exe`), rename it to
protoc-gen-javalite (or protoc-gen-javalite.exe on windows) and place it
in a directory where it can be find in PATH.
in a directory where it can be find in PATH. If you are using unix like OS
then make sure to convert `protoc-gen-javalite` to unix executable. For example
`chmod +x protoc-gen-javalite`
Once you have the protoc and protoc plugin, you can generate Java Lite code
for your .proto files:

@ -294,6 +294,57 @@ void build_class_from_descriptor(
// PHP Methods
// -----------------------------------------------------------------------------
static bool is_wrapper_msg(const upb_msgdef* m) {
upb_wellknowntype_t type = upb_msgdef_wellknowntype(m);
return type >= UPB_WELLKNOWN_DOUBLEVALUE &&
type <= UPB_WELLKNOWN_BOOLVALUE;
}
static void append_wrapper_message(
zend_class_entry* subklass, RepeatedField* intern, zval* value TSRMLS_DC) {
MessageHeader* submsg;
const upb_fielddef* field;
#if PHP_MAJOR_VERSION < 7
zval* val = NULL;
MAKE_STD_ZVAL(val);
ZVAL_OBJ(val, subklass->create_object(subklass TSRMLS_CC));
repeated_field_push_native(intern, &val);
submsg = UNBOX(MessageHeader, val);
#else
zend_object* obj = subklass->create_object(subklass TSRMLS_CC);
repeated_field_push_native(intern, &obj);
submsg = (MessageHeader*)((char*)obj - XtOffsetOf(MessageHeader, std));
#endif
custom_data_init(subklass, submsg PHP_PROTO_TSRMLS_CC);
field = upb_msgdef_itof(submsg->descriptor->msgdef, 1);
layout_set(submsg->descriptor->layout, submsg, field, value TSRMLS_CC);
}
static void set_wrapper_message_as_map_value(
zend_class_entry* subklass, zval* map, zval* key, zval* value TSRMLS_DC) {
MessageHeader* submsg;
const upb_fielddef* field;
#if PHP_MAJOR_VERSION < 7
zval* val = NULL;
MAKE_STD_ZVAL(val);
ZVAL_OBJ(val, subklass->create_object(subklass TSRMLS_CC));
map_field_handlers->write_dimension(
map, key, val TSRMLS_CC);
submsg = UNBOX(MessageHeader, val);
#else
zval val;
zend_object* obj = subklass->create_object(subklass TSRMLS_CC);
ZVAL_OBJ(&val, obj);
map_field_handlers->write_dimension(map, key, &val TSRMLS_CC);
submsg = (MessageHeader*)((char*)obj - XtOffsetOf(MessageHeader, std));
#endif
custom_data_init(subklass, submsg PHP_PROTO_TSRMLS_CC);
field = upb_msgdef_itof(submsg->descriptor->msgdef, 1);
layout_set(submsg->descriptor->layout, submsg, field, value TSRMLS_CC);
}
void Message_construct(zval* msg, zval* array_wrapper) {
TSRMLS_FETCH();
zend_class_entry* ce = Z_OBJCE_P(msg);
@ -336,14 +387,38 @@ void Message_construct(zval* msg, zval* array_wrapper) {
HashPosition subpointer;
zval subkey;
void* memory;
bool is_wrapper = false;
zend_class_entry* subklass = NULL;
const upb_msgdef* mapentry = upb_fielddef_msgsubdef(field);
const upb_fielddef *value_field = upb_msgdef_itof(mapentry, 2);
if (upb_fielddef_issubmsg(value_field)) {
const upb_msgdef* submsgdef = upb_fielddef_msgsubdef(value_field);
upb_wellknowntype_t type = upb_msgdef_wellknowntype(submsgdef);
is_wrapper = is_wrapper_msg(submsgdef);
if (is_wrapper) {
PHP_PROTO_HASHTABLE_VALUE subdesc_php = get_def_obj(submsgdef);
Descriptor* subdesc = UNBOX_HASHTABLE_VALUE(Descriptor, subdesc_php);
subklass = subdesc->klass;
}
}
for (zend_hash_internal_pointer_reset_ex(subtable, &subpointer);
php_proto_zend_hash_get_current_data_ex(subtable, (void**)&memory,
&subpointer) == SUCCESS;
zend_hash_move_forward_ex(subtable, &subpointer)) {
zend_hash_get_current_key_zval_ex(subtable, &subkey, &subpointer);
map_field_handlers->write_dimension(
submap, &subkey,
CACHED_PTR_TO_ZVAL_PTR((CACHED_VALUE*)memory) TSRMLS_CC);
if (is_wrapper &&
Z_TYPE_P(CACHED_PTR_TO_ZVAL_PTR((CACHED_VALUE*)memory)) != IS_OBJECT) {
set_wrapper_message_as_map_value(
subklass, submap, &subkey,
CACHED_PTR_TO_ZVAL_PTR((CACHED_VALUE*)memory) TSRMLS_CC);
} else {
map_field_handlers->write_dimension(
submap, &subkey,
CACHED_PTR_TO_ZVAL_PTR((CACHED_VALUE*)memory) TSRMLS_CC);
}
zval_dtor(&subkey);
}
} else if (upb_fielddef_isseq(field)) {
@ -354,13 +429,36 @@ void Message_construct(zval* msg, zval* array_wrapper) {
CACHED_PTR_TO_ZVAL_PTR((CACHED_VALUE*)value));
HashPosition subpointer;
void* memory;
bool is_wrapper = false;
zend_class_entry* subklass = NULL;
if (upb_fielddef_issubmsg(field)) {
const upb_msgdef* submsgdef = upb_fielddef_msgsubdef(field);
upb_wellknowntype_t type = upb_msgdef_wellknowntype(submsgdef);
is_wrapper = is_wrapper_msg(submsgdef);
if (is_wrapper) {
PHP_PROTO_HASHTABLE_VALUE subdesc_php = get_def_obj(submsgdef);
Descriptor* subdesc = UNBOX_HASHTABLE_VALUE(Descriptor, subdesc_php);
subklass = subdesc->klass;
}
}
for (zend_hash_internal_pointer_reset_ex(subtable, &subpointer);
php_proto_zend_hash_get_current_data_ex(subtable, (void**)&memory,
&subpointer) == SUCCESS;
zend_hash_move_forward_ex(subtable, &subpointer)) {
repeated_field_handlers->write_dimension(
subarray, NULL,
CACHED_PTR_TO_ZVAL_PTR((CACHED_VALUE*)memory) TSRMLS_CC);
if (is_wrapper &&
Z_TYPE_P(CACHED_PTR_TO_ZVAL_PTR((CACHED_VALUE*)memory)) != IS_OBJECT) {
RepeatedField* intern = UNBOX(RepeatedField, subarray);
append_wrapper_message(
subklass, intern,
CACHED_PTR_TO_ZVAL_PTR((CACHED_VALUE*)memory) TSRMLS_CC);
} else {
repeated_field_handlers->write_dimension(
subarray, NULL,
CACHED_PTR_TO_ZVAL_PTR((CACHED_VALUE*)memory) TSRMLS_CC);
}
}
} else if (upb_fielddef_issubmsg(field)) {
const upb_msgdef* submsgdef = upb_fielddef_msgsubdef(field);

@ -973,9 +973,12 @@ class Message
* ]);
* ```
*
* This method will trigger an error if it is passed data that cannot
* be converted to the correct type. For example, a StringValue field
* must receive data that is either a string or a StringValue object.
*
* @param array $array An array containing message properties and values.
* @return null.
* @throws \Exception Invalid data.
*/
protected function mergeFromArray(array $array)
{
@ -987,22 +990,61 @@ class Message
'Invalid message property: ' . $key);
}
$setter = $field->getSetter();
if ($field->isWrapperType()) {
self::normalizeToMessageType($value, $field->getMessageType()->getClass());
if ($field->isMap()) {
$valueField = $field->getMessageType()->getFieldByName('value');
if (!is_null($valueField) && $valueField->isWrapperType()) {
self::normalizeArrayElementsToMessageType($value, $valueField->getMessageType()->getClass());
}
} elseif ($field->isWrapperType()) {
$class = $field->getMessageType()->getClass();
if ($field->isRepeated()) {
self::normalizeArrayElementsToMessageType($value, $class);
} else {
self::normalizeToMessageType($value, $class);
}
}
$this->$setter($value);
}
}
/**
* Tries to normalize the elements in $value into a provided protobuf
* wrapper type $class. If $value is any type other than array, we do
* not do any conversion, and instead rely on the existing protobuf
* type checking. If $value is an array, we process each element and
* try to convert it to an instance of $class.
*
* @param mixed $value The array of values to normalize.
* @param string $class The expected wrapper class name
*/
private static function normalizeArrayElementsToMessageType(&$value, $class)
{
if (!is_array($value)) {
// In the case that $value is not an array, we do not want to
// attempt any conversion. Note that this includes the cases
// when $value is a RepeatedField of MapField. In those cases,
// we do not need to convert the elements, as they should
// already be the correct types.
return;
} else {
// Normalize each element in the array.
foreach ($value as $key => &$elementValue) {
self::normalizeToMessageType($elementValue, $class);
}
}
}
/**
* Tries to normalize $value into a provided protobuf wrapper type $class.
* If $value is any type other than an object, we attempt to construct an
* instance of $class and assign $value to it using the setValue method
* shared by all wrapper types.
*
* This method will raise an error if it receives a type that cannot be
* assigned to the wrapper type via setValue.
*
* @param mixed $value The value to normalize.
* @param string $class The expected wrapper class name
* @throws \Exception If $value cannot be converted to a wrapper type
*/
private static function normalizeToMessageType(&$value, $class)
{
@ -1019,10 +1061,9 @@ class Message
$value = $msg;
return;
} catch (\Exception $exception) {
throw new \Exception(
trigger_error(
"Error normalizing value to type '$class': " . $exception->getMessage(),
$exception->getCode(),
$exception
E_USER_ERROR
);
}
}

@ -19,4 +19,8 @@ message TestWrapperSetters {
google.protobuf.DoubleValue double_value_oneof = 10;
google.protobuf.StringValue string_value_oneof = 11;
}
repeated google.protobuf.StringValue repeated_string_value = 12;
map<string, google.protobuf.StringValue> map_string_value = 13;
}

@ -225,4 +225,88 @@ class WrapperTypeSettersTest extends TestBase
[TestWrapperSetters::class, BytesValue::class, 'bytes_value', 'getBytesValue', "nine"],
];
}
/**
* @dataProvider constructorWithRepeatedWrapperTypeDataProvider
*/
public function testConstructorWithRepeatedWrapperType($wrapperField, $getter, $value)
{
$actualInstance = new TestWrapperSetters([$wrapperField => $value]);
foreach ($actualInstance->$getter() as $key => $actualWrapperValue) {
$actualInnerValue = $actualWrapperValue->getValue();
$expectedElement = $value[$key];
if (is_object($expectedElement) && is_a($expectedElement, '\Google\Protobuf\StringValue')) {
$expectedInnerValue = $expectedElement->getValue();
} else {
$expectedInnerValue = $expectedElement;
}
$this->assertEquals($expectedInnerValue, $actualInnerValue);
}
}
public function constructorWithRepeatedWrapperTypeDataProvider()
{
$sv7 = new StringValue(['value' => 'seven']);
$sv8 = new StringValue(['value' => 'eight']);
$testWrapperSetters = new TestWrapperSetters();
$testWrapperSetters->setRepeatedStringValue([$sv7, $sv8]);
$repeatedField = $testWrapperSetters->getRepeatedStringValue();
return [
['repeated_string_value', 'getRepeatedStringValue', []],
['repeated_string_value', 'getRepeatedStringValue', [$sv7]],
['repeated_string_value', 'getRepeatedStringValue', [$sv7, $sv8]],
['repeated_string_value', 'getRepeatedStringValue', ['seven']],
['repeated_string_value', 'getRepeatedStringValue', [7]],
['repeated_string_value', 'getRepeatedStringValue', [7.7]],
['repeated_string_value', 'getRepeatedStringValue', ['seven', 'eight']],
['repeated_string_value', 'getRepeatedStringValue', [$sv7, 'eight']],
['repeated_string_value', 'getRepeatedStringValue', ['seven', $sv8]],
['repeated_string_value', 'getRepeatedStringValue', $repeatedField],
];
}
/**
* @dataProvider constructorWithMapWrapperTypeDataProvider
*/
public function testConstructorWithMapWrapperType($wrapperField, $getter, $value)
{
$actualInstance = new TestWrapperSetters([$wrapperField => $value]);
foreach ($actualInstance->$getter() as $key => $actualWrapperValue) {
$actualInnerValue = $actualWrapperValue->getValue();
$expectedElement = $value[$key];
if (is_object($expectedElement) && is_a($expectedElement, '\Google\Protobuf\StringValue')) {
$expectedInnerValue = $expectedElement->getValue();
} elseif (is_object($expectedElement) && is_a($expectedElement, '\Google\Protobuf\Internal\MapEntry')) {
$expectedInnerValue = $expectedElement->getValue()->getValue();
} else {
$expectedInnerValue = $expectedElement;
}
$this->assertEquals($expectedInnerValue, $actualInnerValue);
}
}
public function constructorWithMapWrapperTypeDataProvider()
{
$sv7 = new StringValue(['value' => 'seven']);
$sv8 = new StringValue(['value' => 'eight']);
$testWrapperSetters = new TestWrapperSetters();
$testWrapperSetters->setMapStringValue(['key' => $sv7, 'key2' => $sv8]);
$mapField = $testWrapperSetters->getMapStringValue();
return [
['map_string_value', 'getMapStringValue', []],
['map_string_value', 'getMapStringValue', ['key' => $sv7]],
['map_string_value', 'getMapStringValue', ['key' => $sv7, 'key2' => $sv8]],
['map_string_value', 'getMapStringValue', ['key' => 'seven']],
['map_string_value', 'getMapStringValue', ['key' => 7]],
['map_string_value', 'getMapStringValue', ['key' => 7.7]],
['map_string_value', 'getMapStringValue', ['key' => 'seven', 'key2' => 'eight']],
['map_string_value', 'getMapStringValue', ['key' => $sv7, 'key2' => 'eight']],
['map_string_value', 'getMapStringValue', ['key' => 'seven', 'key2' => $sv8]],
['map_string_value', 'getMapStringValue', $mapField],
];
}
}

@ -6,6 +6,6 @@ includedir=@includedir@
Name: Protocol Buffers
Description: Google's Data Interchange Format
Version: @VERSION@
Libs: -L${libdir} -lprotobuf-lite @PTHREAD_CFLAGS@ @PTHREAD_LIBS@
Libs: -L${libdir} -lprotobuf-lite @PTHREAD_LIBS@
Cflags: -I${includedir} @PTHREAD_CFLAGS@
Conflicts: protobuf

@ -6,7 +6,7 @@ includedir=@includedir@
Name: Protocol Buffers
Description: Google's Data Interchange Format
Version: @VERSION@
Libs: -L${libdir} -lprotobuf @PTHREAD_CFLAGS@ @PTHREAD_LIBS@
Libs: -L${libdir} -lprotobuf @PTHREAD_LIBS@
Libs.private: @LIBS@
Cflags: -I${includedir} @PTHREAD_CFLAGS@
Cflags: -I${includedir} @PTHREAD_CFLAGS@ @CXXFLAGS@
Conflicts: protobuf-lite

@ -82,7 +82,7 @@ static VALUE table_key(Map* self, VALUE key,
case UPB_TYPE_INT64:
case UPB_TYPE_UINT32:
case UPB_TYPE_UINT64:
native_slot_set(self->key_type, Qnil, buf, key);
native_slot_set("", self->key_type, Qnil, buf, key);
*out_key = buf;
*out_length = native_slot_size(self->key_type);
break;
@ -396,7 +396,7 @@ VALUE Map_index_set(VALUE _self, VALUE key, VALUE value) {
key = table_key(self, key, keybuf, &keyval, &length);
mem = value_memory(&v);
native_slot_set(self->value_type, self->value_type_class, mem, value);
native_slot_set("", self->value_type, self->value_type_class, mem, value);
// Replace any existing value by issuing a 'remove' operation first.
upb_strtable_remove2(&self->table, keyval, length, NULL);

@ -315,7 +315,8 @@ int Message_initialize_kwarg(VALUE key, VALUE val, VALUE _self) {
if (TYPE(val) != T_HASH) {
rb_raise(rb_eArgError,
"Expected Hash object as initializer value for map field '%s'.", name);
"Expected Hash object as initializer value for map field '%s' (given %s).",
name, rb_class2name(CLASS_OF(val)));
}
map = layout_get(self->descriptor->layout, Message_data(self), f);
Map_merge_into_self(map, val);
@ -324,7 +325,8 @@ int Message_initialize_kwarg(VALUE key, VALUE val, VALUE _self) {
if (TYPE(val) != T_ARRAY) {
rb_raise(rb_eArgError,
"Expected array as initializer value for repeated field '%s'.", name);
"Expected array as initializer value for repeated field '%s' (given %s).",
name, rb_class2name(CLASS_OF(val)));
}
ary = layout_get(self->descriptor->layout, Message_data(self), f);
for (int i = 0; i < RARRAY_LEN(val); i++) {
@ -620,10 +622,12 @@ VALUE build_class_from_descriptor(Descriptor* desc) {
// Also define #clone so that we don't inherit Object#clone.
rb_define_method(klass, "clone", Message_dup, 0);
rb_define_method(klass, "==", Message_eq, 1);
rb_define_method(klass, "eql?", Message_eq, 1);
rb_define_method(klass, "hash", Message_hash, 0);
rb_define_method(klass, "to_h", Message_to_h, 0);
rb_define_method(klass, "to_hash", Message_to_h, 0);
rb_define_method(klass, "inspect", Message_inspect, 0);
rb_define_method(klass, "to_s", Message_inspect, 0);
rb_define_method(klass, "[]", Message_index, 1);
rb_define_method(klass, "[]=", Message_index_set, 2);
rb_define_singleton_method(klass, "decode", Message_decode, 1);

@ -337,14 +337,16 @@ VALUE Builder_finalize_to_pool(VALUE _self, VALUE pool_rb);
#define NATIVE_SLOT_MAX_SIZE sizeof(uint64_t)
size_t native_slot_size(upb_fieldtype_t type);
void native_slot_set(upb_fieldtype_t type,
void native_slot_set(const char* name,
upb_fieldtype_t type,
VALUE type_class,
void* memory,
VALUE value);
// Atomically (with respect to Ruby VM calls) either update the value and set a
// oneof case, or do neither. If |case_memory| is null, then no case value is
// set.
void native_slot_set_value_and_case(upb_fieldtype_t type,
void native_slot_set_value_and_case(const char* name,
upb_fieldtype_t type,
VALUE type_class,
void* memory,
VALUE value,
@ -360,7 +362,7 @@ void native_slot_deep_copy(upb_fieldtype_t type, void* to, void* from);
bool native_slot_eq(upb_fieldtype_t type, void* mem1, void* mem2);
VALUE native_slot_encode_and_freeze_string(upb_fieldtype_t type, VALUE value);
void native_slot_check_int_range_precision(upb_fieldtype_t type, VALUE value);
void native_slot_check_int_range_precision(const char* name, upb_fieldtype_t type, VALUE value);
extern rb_encoding* kRubyStringUtf8Encoding;
extern rb_encoding* kRubyStringASCIIEncoding;

@ -178,7 +178,7 @@ VALUE RepeatedField_index_set(VALUE _self, VALUE _index, VALUE val) {
}
memory = RepeatedField_memoryat(self, index, element_size);
native_slot_set(field_type, field_type_class, memory, val);
native_slot_set("", field_type, field_type_class, memory, val);
return Qnil;
}
@ -217,7 +217,7 @@ VALUE RepeatedField_push(VALUE _self, VALUE val) {
RepeatedField_reserve(self, self->size + 1);
memory = (void *) (((uint8_t *)self->elements) + self->size * element_size);
native_slot_set(field_type, self->field_type_class, memory, val);
native_slot_set("", field_type, self->field_type_class, memory, val);
// native_slot_set may raise an error; bump size only after set.
self->size++;
return _self;

@ -65,9 +65,10 @@ static bool is_ruby_num(VALUE value) {
TYPE(value) == T_BIGNUM);
}
void native_slot_check_int_range_precision(upb_fieldtype_t type, VALUE val) {
void native_slot_check_int_range_precision(const char* name, upb_fieldtype_t type, VALUE val) {
if (!is_ruby_num(val)) {
rb_raise(cTypeError, "Expected number type for integral field.");
rb_raise(cTypeError, "Expected number type for integral field '%s' (given %s).",
name, rb_class2name(CLASS_OF(val)));
}
// NUM2{INT,UINT,LL,ULL} macros do the appropriate range checks on upper
@ -77,13 +78,15 @@ void native_slot_check_int_range_precision(upb_fieldtype_t type, VALUE val) {
double dbl_val = NUM2DBL(val);
if (floor(dbl_val) != dbl_val) {
rb_raise(rb_eRangeError,
"Non-integral floating point value assigned to integer field.");
"Non-integral floating point value assigned to integer field '%s' (given %s).",
name, rb_class2name(CLASS_OF(val)));
}
}
if (type == UPB_TYPE_UINT32 || type == UPB_TYPE_UINT64) {
if (NUM2DBL(val) < 0) {
rb_raise(rb_eRangeError,
"Assigning negative value to unsigned integer field.");
"Assigning negative value to unsigned integer field '%s' (given %s).",
name, rb_class2name(CLASS_OF(val)));
}
}
}
@ -108,12 +111,14 @@ VALUE native_slot_encode_and_freeze_string(upb_fieldtype_t type, VALUE value) {
return value;
}
void native_slot_set(upb_fieldtype_t type, VALUE type_class,
void native_slot_set(const char* name,
upb_fieldtype_t type, VALUE type_class,
void* memory, VALUE value) {
native_slot_set_value_and_case(type, type_class, memory, value, NULL, 0);
native_slot_set_value_and_case(name, type, type_class, memory, value, NULL, 0);
}
void native_slot_set_value_and_case(upb_fieldtype_t type, VALUE type_class,
void native_slot_set_value_and_case(const char* name,
upb_fieldtype_t type, VALUE type_class,
void* memory, VALUE value,
uint32_t* case_memory,
uint32_t case_number) {
@ -124,13 +129,15 @@ void native_slot_set_value_and_case(upb_fieldtype_t type, VALUE type_class,
switch (type) {
case UPB_TYPE_FLOAT:
if (!is_ruby_num(value)) {
rb_raise(cTypeError, "Expected number type for float field.");
rb_raise(cTypeError, "Expected number type for float field '%s' (given %s).",
name, rb_class2name(CLASS_OF(value)));
}
DEREF(memory, float) = NUM2DBL(value);
break;
case UPB_TYPE_DOUBLE:
if (!is_ruby_num(value)) {
rb_raise(cTypeError, "Expected number type for double field.");
rb_raise(cTypeError, "Expected number type for double field '%s' (given %s).",
name, rb_class2name(CLASS_OF(value)));
}
DEREF(memory, double) = NUM2DBL(value);
break;
@ -141,7 +148,8 @@ void native_slot_set_value_and_case(upb_fieldtype_t type, VALUE type_class,
} else if (value == Qfalse) {
val = 0;
} else {
rb_raise(cTypeError, "Invalid argument for boolean field.");
rb_raise(cTypeError, "Invalid argument for boolean field '%s' (given %s).",
name, rb_class2name(CLASS_OF(value)));
}
DEREF(memory, int8_t) = val;
break;
@ -150,7 +158,8 @@ void native_slot_set_value_and_case(upb_fieldtype_t type, VALUE type_class,
if (CLASS_OF(value) == rb_cSymbol) {
value = rb_funcall(value, rb_intern("to_s"), 0);
} else if (CLASS_OF(value) != rb_cString) {
rb_raise(cTypeError, "Invalid argument for string field.");
rb_raise(cTypeError, "Invalid argument for string field '%s' (given %s).",
name, rb_class2name(CLASS_OF(value)));
}
DEREF(memory, VALUE) = native_slot_encode_and_freeze_string(type, value);
@ -158,7 +167,8 @@ void native_slot_set_value_and_case(upb_fieldtype_t type, VALUE type_class,
case UPB_TYPE_BYTES: {
if (CLASS_OF(value) != rb_cString) {
rb_raise(cTypeError, "Invalid argument for string field.");
rb_raise(cTypeError, "Invalid argument for bytes field '%s' (given %s).",
name, rb_class2name(CLASS_OF(value)));
}
DEREF(memory, VALUE) = native_slot_encode_and_freeze_string(type, value);
@ -169,8 +179,8 @@ void native_slot_set_value_and_case(upb_fieldtype_t type, VALUE type_class,
value = Qnil;
} else if (CLASS_OF(value) != type_class) {
rb_raise(cTypeError,
"Invalid type %s to assign to submessage field.",
rb_class2name(CLASS_OF(value)));
"Invalid type %s to assign to submessage field '%s'.",
rb_class2name(CLASS_OF(value)), name);
}
DEREF(memory, VALUE) = value;
break;
@ -181,18 +191,18 @@ void native_slot_set_value_and_case(upb_fieldtype_t type, VALUE type_class,
value = rb_funcall(value, rb_intern("to_sym"), 0);
} else if (!is_ruby_num(value) && TYPE(value) != T_SYMBOL) {
rb_raise(cTypeError,
"Expected number or symbol type for enum field.");
"Expected number or symbol type for enum field '%s'.", name);
}
if (TYPE(value) == T_SYMBOL) {
// Ensure that the given symbol exists in the enum module.
VALUE lookup = rb_funcall(type_class, rb_intern("resolve"), 1, value);
if (lookup == Qnil) {
rb_raise(rb_eRangeError, "Unknown symbol value for enum field.");
rb_raise(rb_eRangeError, "Unknown symbol value for enum field '%s'.", name);
} else {
int_val = NUM2INT(lookup);
}
} else {
native_slot_check_int_range_precision(UPB_TYPE_INT32, value);
native_slot_check_int_range_precision(name, UPB_TYPE_INT32, value);
int_val = NUM2INT(value);
}
DEREF(memory, int32_t) = int_val;
@ -202,7 +212,7 @@ void native_slot_set_value_and_case(upb_fieldtype_t type, VALUE type_class,
case UPB_TYPE_INT64:
case UPB_TYPE_UINT32:
case UPB_TYPE_UINT64:
native_slot_check_int_range_precision(type, value);
native_slot_check_int_range_precision(name, type, value);
switch (type) {
case UPB_TYPE_INT32:
DEREF(memory, int32_t) = NUM2INT(value);
@ -658,8 +668,9 @@ void layout_clear(MessageLayout* layout,
DEREF(memory, VALUE) = ary;
} else {
native_slot_set(upb_fielddef_type(field), field_type_class(field),
memory, layout_get_default(field));
native_slot_set(upb_fielddef_name(field),
upb_fielddef_type(field), field_type_class(field),
memory, layout_get_default(field));
}
}
@ -816,6 +827,7 @@ void layout_set(MessageLayout* layout,
// use native_slot_set_value_and_case(), which ensures that both the value
// and case number are altered atomically (w.r.t. the Ruby VM).
native_slot_set_value_and_case(
upb_fielddef_name(field),
upb_fielddef_type(field), field_type_class(field),
memory, val,
oneof_case, upb_fielddef_number(field));
@ -827,8 +839,9 @@ void layout_set(MessageLayout* layout,
check_repeated_field_type(val, field);
DEREF(memory, VALUE) = val;
} else {
native_slot_set(upb_fielddef_type(field), field_type_class(field), memory,
val);
native_slot_set(upb_fielddef_name(field),
upb_fielddef_type(field), field_type_class(field),
memory, val);
}
if (layout->fields[upb_fielddef_index(field)].hasbit !=

@ -154,12 +154,12 @@ module BasicTest
e = assert_raise ArgumentError do
MapMessage.new(:map_string_int32 => "hello")
end
assert_equal e.message, "Expected Hash object as initializer value for map field 'map_string_int32'."
assert_equal e.message, "Expected Hash object as initializer value for map field 'map_string_int32' (given String)."
e = assert_raise ArgumentError do
TestMessage.new(:repeated_uint32 => "hello")
end
assert_equal e.message, "Expected array as initializer value for repeated field 'repeated_uint32'."
assert_equal e.message, "Expected array as initializer value for repeated field 'repeated_uint32' (given String)."
end
def test_map_field

@ -207,7 +207,7 @@ module BasicTestProto2
e = assert_raise ArgumentError do
TestMessage.new(:repeated_uint32 => "hello")
end
assert_equal e.message, "Expected array as initializer value for repeated field 'repeated_uint32'."
assert_equal e.message, "Expected array as initializer value for repeated field 'repeated_uint32' (given String)."
end

@ -103,7 +103,7 @@ module CommonTests
assert_equal 3, m.repeated_msg.first.sub_child.optional_int32
end
def test_inspect
def test_inspect_eq_to_s
m = proto_module::TestMessage.new(
:optional_int32 => -42,
:optional_enum => :A,
@ -111,10 +111,12 @@ module CommonTests
:repeated_string => ["hello", "there", "world"])
expected = "<#{proto_module}::TestMessage: optional_int32: -42, optional_int64: 0, optional_uint32: 0, optional_uint64: 0, optional_bool: false, optional_float: 0.0, optional_double: 0.0, optional_string: \"\", optional_bytes: \"\", optional_msg: <#{proto_module}::TestMessage2: foo: 0>, optional_enum: :A, repeated_int32: [], repeated_int64: [], repeated_uint32: [], repeated_uint64: [], repeated_bool: [], repeated_float: [], repeated_double: [], repeated_string: [\"hello\", \"there\", \"world\"], repeated_bytes: [], repeated_msg: [], repeated_enum: []>"
assert_equal expected, m.inspect
assert_equal expected, m.to_s
m = proto_module::OneofMessage.new(:b => -42)
expected = "<#{proto_module}::OneofMessage: a: \"\", b: -42, c: nil, d: :Default>"
assert_equal expected, m.inspect
assert_equal expected, m.to_s
end
def test_hash
@ -1117,4 +1119,25 @@ module CommonTests
def test_comparison_with_arbitrary_object
assert proto_module::TestMessage.new != nil
end
def test_eq
m1 = proto_module::TestMessage.new(:optional_string => 'foo', :repeated_string => ['bar1', 'bar2'])
m2 = proto_module::TestMessage.new(:optional_string => 'foo', :repeated_string => ['bar1', 'bar2'])
h = {}
h[m1] = :yes
assert m1 == m2
assert m1.eql?(m2)
assert m1.hash == m2.hash
assert h[m1] == :yes
assert h[m2] == :yes
m1.optional_int32 = 2
assert m1 != m2
assert !m1.eql?(m2)
assert m1.hash != m2.hash
assert_nil h[m2]
end
end

@ -0,0 +1,173 @@
#!/usr/bin/ruby
# generated_code.rb is in the same directory as this test.
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__)))
require 'test/unit'
require 'google/protobuf/well_known_types'
require 'generated_code_pb'
class TestTypeErrors < Test::Unit::TestCase
def test_bad_string
check_error Google::Protobuf::TypeError,
"Invalid argument for string field 'optional_string' (given Integer)." do
A::B::C::TestMessage.new(optional_string: 4)
end
check_error Google::Protobuf::TypeError,
"Invalid argument for string field 'oneof_string' (given Integer)." do
A::B::C::TestMessage.new(oneof_string: 4)
end
check_error ArgumentError,
"Expected array as initializer value for repeated field 'repeated_string' (given String)." do
A::B::C::TestMessage.new(repeated_string: '4')
end
end
def test_bad_float
check_error Google::Protobuf::TypeError,
"Expected number type for float field 'optional_float' (given TrueClass)." do
A::B::C::TestMessage.new(optional_float: true)
end
check_error Google::Protobuf::TypeError,
"Expected number type for float field 'oneof_float' (given TrueClass)." do
A::B::C::TestMessage.new(oneof_float: true)
end
check_error ArgumentError,
"Expected array as initializer value for repeated field 'repeated_float' (given String)." do
A::B::C::TestMessage.new(repeated_float: 'true')
end
end
def test_bad_double
check_error Google::Protobuf::TypeError,
"Expected number type for double field 'optional_double' (given Symbol)." do
A::B::C::TestMessage.new(optional_double: :double)
end
check_error Google::Protobuf::TypeError,
"Expected number type for double field 'oneof_double' (given Symbol)." do
A::B::C::TestMessage.new(oneof_double: :double)
end
check_error ArgumentError,
"Expected array as initializer value for repeated field 'repeated_double' (given FalseClass)." do
A::B::C::TestMessage.new(repeated_double: false)
end
end
def test_bad_bool
check_error Google::Protobuf::TypeError,
"Invalid argument for boolean field 'optional_bool' (given Float)." do
A::B::C::TestMessage.new(optional_bool: 4.4)
end
check_error Google::Protobuf::TypeError,
"Invalid argument for boolean field 'oneof_bool' (given Float)." do
A::B::C::TestMessage.new(oneof_bool: 4.4)
end
check_error ArgumentError,
"Expected array as initializer value for repeated field 'repeated_bool' (given String)." do
A::B::C::TestMessage.new(repeated_bool: 'hi')
end
end
def test_bad_int
check_error Google::Protobuf::TypeError,
"Expected number type for integral field 'optional_int32' (given String)." do
A::B::C::TestMessage.new(optional_int32: 'hi')
end
check_error RangeError,
"Non-integral floating point value assigned to integer field 'optional_int64' (given Float)." do
A::B::C::TestMessage.new(optional_int64: 2.4)
end
check_error Google::Protobuf::TypeError,
"Expected number type for integral field 'optional_uint32' (given Symbol)." do
A::B::C::TestMessage.new(optional_uint32: :thing)
end
check_error Google::Protobuf::TypeError,
"Expected number type for integral field 'optional_uint64' (given FalseClass)." do
A::B::C::TestMessage.new(optional_uint64: false)
end
check_error Google::Protobuf::TypeError,
"Expected number type for integral field 'oneof_int32' (given Symbol)." do
A::B::C::TestMessage.new(oneof_int32: :hi)
end
check_error RangeError,
"Non-integral floating point value assigned to integer field 'oneof_int64' (given Float)." do
A::B::C::TestMessage.new(oneof_int64: 2.4)
end
check_error Google::Protobuf::TypeError,
"Expected number type for integral field 'oneof_uint32' (given String)." do
A::B::C::TestMessage.new(oneof_uint32: 'x')
end
check_error RangeError,
"Non-integral floating point value assigned to integer field 'oneof_uint64' (given Float)." do
A::B::C::TestMessage.new(oneof_uint64: 1.1)
end
check_error ArgumentError,
"Expected array as initializer value for repeated field 'repeated_int32' (given Symbol)." do
A::B::C::TestMessage.new(repeated_int32: :hi)
end
check_error ArgumentError,
"Expected array as initializer value for repeated field 'repeated_int64' (given Float)." do
A::B::C::TestMessage.new(repeated_int64: 2.4)
end
check_error ArgumentError,
"Expected array as initializer value for repeated field 'repeated_uint32' (given String)." do
A::B::C::TestMessage.new(repeated_uint32: 'x')
end
check_error ArgumentError,
"Expected array as initializer value for repeated field 'repeated_uint64' (given Float)." do
A::B::C::TestMessage.new(repeated_uint64: 1.1)
end
end
def test_bad_enum
check_error RangeError,
"Unknown symbol value for enum field 'optional_enum'." do
A::B::C::TestMessage.new(optional_enum: 'enum')
end
check_error RangeError,
"Unknown symbol value for enum field 'oneof_enum'." do
A::B::C::TestMessage.new(oneof_enum: '')
end
check_error ArgumentError,
"Expected array as initializer value for repeated field 'repeated_enum' (given String)." do
A::B::C::TestMessage.new(repeated_enum: '')
end
end
def test_bad_bytes
check_error Google::Protobuf::TypeError,
"Invalid argument for bytes field 'optional_bytes' (given Float)." do
A::B::C::TestMessage.new(optional_bytes: 22.22)
end
check_error Google::Protobuf::TypeError,
"Invalid argument for bytes field 'oneof_bytes' (given Symbol)." do
A::B::C::TestMessage.new(oneof_bytes: :T22)
end
check_error ArgumentError,
"Expected array as initializer value for repeated field 'repeated_bytes' (given Symbol)." do
A::B::C::TestMessage.new(repeated_bytes: :T22)
end
end
def test_bad_msg
check_error Google::Protobuf::TypeError,
"Invalid type Integer to assign to submessage field 'optional_msg'." do
A::B::C::TestMessage.new(optional_msg: 2)
end
check_error Google::Protobuf::TypeError,
"Invalid type String to assign to submessage field 'oneof_msg'." do
A::B::C::TestMessage.new(oneof_msg: '2')
end
check_error ArgumentError,
"Expected array as initializer value for repeated field 'repeated_msg' (given String)." do
A::B::C::TestMessage.new(repeated_msg: '2')
end
end
def check_error(type, message)
err = assert_raises type do
yield
end
assert_equal message, err.message
end
end

@ -278,6 +278,19 @@ std::string GetEnumValueName(const std::string& enum_name, const std::string& en
return result;
}
uint GetGroupEndTag(const Descriptor* descriptor) {
const Descriptor* containing_type = descriptor->containing_type();
if (containing_type == NULL) {
return 0;
}
const FieldDescriptor* field = containing_type->FindFieldByName(descriptor->name());
if (field != NULL && field->type() == FieldDescriptor::Type::TYPE_GROUP) {
return internal::WireFormatLite::MakeTag(field->number(), internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED);
} else {
return 0;
}
}
std::string ToCSharpName(const std::string& name, const FileDescriptor* file) {
std::string result = GetFileNamespace(file);
if (result != "") {

@ -118,6 +118,9 @@ inline bool IsMapEntryMessage(const Descriptor* descriptor) {
return descriptor->options().map_entry();
}
// Checks if this descriptor is for a group and gets its end tag or 0 if it's not a group
uint GetGroupEndTag(const Descriptor* descriptor);
// Determines whether we're generating code for the proto representation of
// descriptors etc, for use in the runtime. This is the only type which is
// allowed to use proto2 syntax, and it generates internal classes.

@ -63,7 +63,8 @@ MessageGenerator::MessageGenerator(const Descriptor* descriptor,
const Options* options)
: SourceGeneratorBase(descriptor->file(), options),
descriptor_(descriptor),
has_bit_field_count_(0) {
has_bit_field_count_(0),
end_tag_(GetGroupEndTag(descriptor)) {
// fields by number
for (int i = 0; i < descriptor_->field_count(); i++) {
fields_by_number_.push_back(descriptor_->field(i));
@ -539,10 +540,14 @@ void MessageGenerator::GenerateMergingMethods(io::Printer* printer) {
} else {
printer->Print(
"default:\n"
" if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {\n"
" return;\n"
" }\n"
" _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);\n"
" break;\n");
if (end_tag_ != 0) {
printer->Print(
"$end_tag$:\n"
" return;\n",
"end_tag", SimpleItoa(end_tag_));
}
}
for (int i = 0; i < fields_by_number().size(); i++) {
const FieldDescriptor* field = fields_by_number()[i];

@ -59,6 +59,7 @@ class MessageGenerator : public SourceGeneratorBase {
const Descriptor* descriptor_;
std::vector<const FieldDescriptor*> fields_by_number_;
int has_bit_field_count_;
uint end_tag_;
void GenerateMessageSerializationMethods(io::Printer* printer);
void GenerateMergingMethods(io::Printer* printer);

@ -1439,13 +1439,17 @@ void ImmutableMessageGenerator::GenerateAnyMethods(io::Printer* printer) {
"public <T extends com.google.protobuf.Message> T unpack(\n"
" java.lang.Class<T> clazz)\n"
" throws com.google.protobuf.InvalidProtocolBufferException {\n"
" if (!is(clazz)) {\n"
" boolean invalidClazz = false;\n"
" if (cachedUnpackValue != null) {\n"
" if (cachedUnpackValue.getClass() == clazz) {\n"
" return (T) cachedUnpackValue;\n"
" }\n"
" invalidClazz = true;\n"
" }\n"
" if (invalidClazz || !is(clazz)) {\n"
" throw new com.google.protobuf.InvalidProtocolBufferException(\n"
" \"Type of the Any message does not match the given class.\");\n"
" }\n"
" if (cachedUnpackValue != null) {\n"
" return (T) cachedUnpackValue;\n"
" }\n"
" T defaultInstance =\n"
" com.google.protobuf.Internal.getDefaultInstance(clazz);\n"
" T result = (T) defaultInstance.getParserForType()\n"

@ -92,6 +92,20 @@ void EnumGenerator::GenerateHeader(io::Printer* printer) {
"\n",
"name", name_);
// Swift 5 included SE0192 "Handling Future Enum Cases"
// https://github.com/apple/swift-evolution/blob/master/proposals/0192-non-exhaustive-enums.md
// Since a .proto file can get new values added to an enum at any time, they
// are effectively "non-frozen". Even in a proto3 syntax file where there is
// support for the unknown value, an edit to the file can always add a new
// value moving something from unknown to known. Since Swift is now ABI
// stable, it also means a binary could contain Swift compiled against one
// version of the .pbobjc.h file, but finally linked against an enum with
// more cases. So the Swift code will always have to treat ObjC Proto Enums
// as "non-frozen". The default behavior in SE0192 is for all objc enums to
// be "non-frozen" unless marked as otherwise, so this means this generation
// doesn't have to bother with the `enum_extensibility` attribute, as the
// default will be what is needed.
printer->Print("$comments$typedef$deprecated_attribute$ GPB_ENUM($name$) {\n",
"comments", enum_comments,
"deprecated_attribute", GetOptionalDeprecatedAttribute(descriptor_, descriptor_->file()),

@ -1 +1 @@
Subproject commit c3bb0ee2a63279a803aaad956b9b26d74bf9e6e2
Subproject commit 5ec7f0c4a113e2f18ac2c6cc7df51ad6afc24081

@ -1,16 +1,25 @@
#!/usr/bin/env python
# Usage: ./update_version.py <MAJOR>.<MINOR>.<MICRO> [<RC version>]
#
# Example:
# ./update_version.py 3.7.1 2
# => Version will become 3.7.1-rc-2 (beta)
# ./update_version.py 3.7.1
# => Version will become 3.7.1 (stable)
import datetime
import re
import sys
from xml.dom import minidom
if len(sys.argv) < 2:
if len(sys.argv) < 2 or len(sys.argv) > 3:
print """
[ERROR] Please specify a version.
./update_version.py <MAJOR>.<MINOR>.<MICRO> [<RC version>]
Example:
./update_version.py 2.1.3
./update_version.py 3.7.1 2
"""
exit(1)
@ -21,10 +30,14 @@ if len(NEW_VERSION_INFO) != 3:
[ERROR] Version must be in the format <MAJOR>.<MINOR>.<MICRO>
Example:
./update_version.py 2.1.3
./update_version.py 3.7.3
"""
exit(1)
RC_VERSION = 0
if len(sys.argv) > 2:
RC_VERSION = int(sys.argv[2])
def Find(elem, tagname):
for child in elem.childNodes:
@ -41,6 +54,13 @@ def ReplaceText(elem, text):
elem.firstChild.replaceWholeText(text)
def GetFullVersion(rc_suffix = '-rc-'):
if RC_VERSION == 0:
return NEW_VERSION
else:
return '%s%s%s' % (NEW_VERSION, rc_suffix, RC_VERSION)
def RewriteXml(filename, rewriter, add_xml_prefix=True):
document = minidom.parse(filename)
rewriter(document)
@ -74,7 +94,7 @@ def UpdateConfigure():
lambda line : re.sub(
r'^AC_INIT\(\[Protocol Buffers\],\[.*\],\[protobuf@googlegroups.com\],\[protobuf\]\)$',
('AC_INIT([Protocol Buffers],[%s],[protobuf@googlegroups.com],[protobuf])'
% NEW_VERSION),
% GetFullVersion()),
line))
@ -120,44 +140,44 @@ def UpdateCsharp():
RewriteXml('csharp/src/Google.Protobuf/Google.Protobuf.csproj',
lambda document : ReplaceText(
Find(Find(document.documentElement, 'PropertyGroup'), 'VersionPrefix'),
NEW_VERSION),
GetFullVersion(rc_suffix = '-rc.')),
add_xml_prefix=False)
RewriteXml('csharp/Google.Protobuf.Tools.nuspec',
lambda document : ReplaceText(
Find(Find(document.documentElement, 'metadata'), 'version'),
NEW_VERSION))
GetFullVersion(rc_suffix = '-rc.')))
def UpdateJava():
RewriteXml('java/pom.xml',
lambda document : ReplaceText(
Find(document.documentElement, 'version'), NEW_VERSION))
Find(document.documentElement, 'version'), GetFullVersion()))
RewriteXml('java/bom/pom.xml',
lambda document : ReplaceText(
Find(document.documentElement, 'version'), NEW_VERSION))
Find(document.documentElement, 'version'), GetFullVersion()))
RewriteXml('java/core/pom.xml',
lambda document : ReplaceText(
Find(Find(document.documentElement, 'parent'), 'version'),
NEW_VERSION))
GetFullVersion()))
RewriteXml('java/util/pom.xml',
lambda document : ReplaceText(
Find(Find(document.documentElement, 'parent'), 'version'),
NEW_VERSION))
GetFullVersion()))
RewriteXml('protoc-artifacts/pom.xml',
lambda document : ReplaceText(
Find(document.documentElement, 'version'), NEW_VERSION))
Find(document.documentElement, 'version'), GetFullVersion()))
def UpdateJavaScript():
RewriteTextFile('js/package.json',
lambda line : re.sub(
r'^ "version": ".*",$',
' "version": "%s",' % NEW_VERSION,
' "version": "%s",' % GetFullVersion(rc_suffix = '-rc.'),
line))
@ -185,7 +205,7 @@ def UpdateObjectiveC():
RewriteTextFile('Protobuf.podspec',
lambda line : re.sub(
r"^ s.version = '.*'$",
" s.version = '%s'" % NEW_VERSION,
" s.version = '%s'" % GetFullVersion(rc_suffix = '-rc.'),
line))
@ -203,8 +223,12 @@ def UpdatePhp():
root = document.documentElement
version = Find(root, 'version')
ReplaceText(Find(version, 'release'), NEW_VERSION)
ReplaceText(Find(version, 'release'), GetFullVersion(rc_suffix = 'RC'))
ReplaceText(Find(version, 'api'), NEW_VERSION)
stability = Find(root, 'stability')
ReplaceText(Find(version, 'release'),
'stable' if RC_VERSION == 0 else 'beta')
ReplaceText(Find(version, 'api'), 'stable' if RC_VERSION == 0 else 'beta')
now = datetime.datetime.now()
ReplaceText(Find(root, 'date'), now.strftime('%Y-%m-%d'))
ReplaceText(Find(root, 'time'), now.strftime('%H:%M:%S'))
@ -215,7 +239,6 @@ def UpdatePhp():
% NEW_VERSION)
return
changelog.appendChild(document.createTextNode(' '))
stability = Find(root, 'stability')
release = CreateNode('release', 2, [
CreateNode('version', 3, [
FindAndClone(version, 'release'),
@ -234,18 +257,24 @@ def UpdatePhp():
changelog.appendChild(document.createTextNode('\n '))
RewriteXml('php/ext/google/protobuf/package.xml', Callback)
RewriteTextFile('php/ext/google/protobuf/protobuf.h',
lambda line : re.sub(
r"^#define PHP_PROTOBUF_VERSION .*$",
"#define PHP_PROTOBUF_VERSION \"%s\"" % GetFullVersion(rc_suffix = 'RC'),
line))
def UpdatePython():
RewriteTextFile('python/google/protobuf/__init__.py',
lambda line : re.sub(
r"^__version__ = '.*'$",
"__version__ = '%s'" % NEW_VERSION,
"__version__ = '%s'" % GetFullVersion(rc_suffix = 'rc'),
line))
def UpdateRuby():
RewriteTextFile('ruby/google-protobuf.gemspec',
lambda line : re.sub(
r'^ s.version = ".*"$',
' s.version = "%s"' % NEW_VERSION,
' s.version = "%s"' % GetFullVersion(rc_suffix = '.rc.'),
line))

Loading…
Cancel
Save